aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard M. Stallman1994-09-23 05:31:24 +0000
committerRichard M. Stallman1994-09-23 05:31:24 +0000
commitf1c16f36b3cdae08e9d2fd75026479151517cfcc (patch)
treec08a27680204742d35909eb926e31363326a51d2 /src
parentb242af8897aadc312b2d44ef9df6c253abac2bf0 (diff)
downloademacs-f1c16f36b3cdae08e9d2fd75026479151517cfcc.tar.gz
emacs-f1c16f36b3cdae08e9d2fd75026479151517cfcc.zip
(Fx_list_fonts): Use a cache stored in FRAME_X_SCREEN.
(the_x_screen): New variable. (syms_of_xfns): Staticpro parts of it. (Fx_open_connection): Initialize it. (Fx_create_frame): Make frame point to it.
Diffstat (limited to 'src')
-rw-r--r--src/xfns.c77
1 files changed, 70 insertions, 7 deletions
diff --git a/src/xfns.c b/src/xfns.c
index bb551f307c5..4770023fa4d 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -135,6 +135,10 @@ Lisp_Object Vx_no_window_manager;
135 135
136Lisp_Object Vmouse_depressed; 136Lisp_Object Vmouse_depressed;
137 137
138/* For now, we have just one x_display structure since we only support
139 one X display. */
140static struct x_screen the_x_screen;
141
138extern unsigned int x_mouse_x, x_mouse_y, x_mouse_grabbed; 142extern unsigned int x_mouse_x, x_mouse_y, x_mouse_grabbed;
139 143
140/* Atom for indicating window state to the window manager. */ 144/* Atom for indicating window state to the window manager. */
@@ -2367,6 +2371,10 @@ be shared by the new frame.")
2367 tem = x_get_arg (parms, Qunsplittable, 0, 0, boolean); 2371 tem = x_get_arg (parms, Qunsplittable, 0, 0, boolean);
2368 f->no_split = minibuffer_only || EQ (tem, Qt); 2372 f->no_split = minibuffer_only || EQ (tem, Qt);
2369 2373
2374 FRAME_X_SCREEN (f) = &the_x_screen;
2375 FRAME_X_SCREEN (f)->reference_count++;
2376 the_x_screen.x_display_value = x_current_display;
2377
2370 UNGCPRO; 2378 UNGCPRO;
2371 2379
2372 /* It is now ok to make the frame official 2380 /* It is now ok to make the frame official
@@ -2463,6 +2471,7 @@ even if they match PATTERN and FACE.")
2463 XFontStruct *info; 2471 XFontStruct *info;
2464 XFontStruct *size_ref; 2472 XFontStruct *size_ref;
2465 Lisp_Object list; 2473 Lisp_Object list;
2474 FRAME_PTR f;
2466 2475
2467 check_x (); 2476 check_x ();
2468 CHECK_STRING (pattern, 0); 2477 CHECK_STRING (pattern, 0);
@@ -2471,11 +2480,14 @@ even if they match PATTERN and FACE.")
2471 if (!NILP (frame)) 2480 if (!NILP (frame))
2472 CHECK_LIVE_FRAME (frame, 2); 2481 CHECK_LIVE_FRAME (frame, 2);
2473 2482
2483 f = NILP (frame) ? selected_frame : XFRAME (frame);
2484
2485 /* Determine the width standard for comparison with the fonts we find. */
2486
2474 if (NILP (face)) 2487 if (NILP (face))
2475 size_ref = 0; 2488 size_ref = 0;
2476 else 2489 else
2477 { 2490 {
2478 FRAME_PTR f = NILP (frame) ? selected_frame : XFRAME (frame);
2479 int face_id; 2491 int face_id;
2480 2492
2481 /* Don't die if we get called with a terminal frame. */ 2493 /* Don't die if we get called with a terminal frame. */
@@ -2495,6 +2507,42 @@ even if they match PATTERN and FACE.")
2495 } 2507 }
2496 } 2508 }
2497 2509
2510 /* See if we cached the result for this particular query. */
2511 list = Fassoc (pattern, FRAME_X_SCREEN (f)->font_list_cache);
2512
2513 /* We have info in the cache for this PATTERN. */
2514 if (!NILP (list))
2515 {
2516 Lisp_Object tem, newlist;
2517
2518 /* We have info about this pattern. */
2519 list = XCONS (list)->cdr;
2520
2521 if (size_ref == 0)
2522 return list;
2523
2524 BLOCK_INPUT;
2525
2526 /* Filter the cached info and return just the fonts that match FACE. */
2527 newlist = Qnil;
2528 for (tem = list; CONSP (tem); tem = XCONS (tem)->cdr)
2529 {
2530 XFontStruct *thisinfo;
2531
2532 thisinfo = XLoadQueryFont (x_current_display,
2533 XSTRING (XCONS (tem)->car)->data);
2534
2535 if (thisinfo && same_size_fonts (thisinfo, size_ref))
2536 newlist = Fcons (XCONS (tem)->car, newlist);
2537
2538 XFreeFont (x_current_display, thisinfo);
2539 }
2540
2541 UNBLOCK_INPUT;
2542
2543 return newlist;
2544 }
2545
2498 BLOCK_INPUT; 2546 BLOCK_INPUT;
2499 2547
2500 /* Solaris 2.3 has a bug in XListFontsWithInfo. */ 2548 /* Solaris 2.3 has a bug in XListFontsWithInfo. */
@@ -2516,10 +2564,20 @@ even if they match PATTERN and FACE.")
2516 2564
2517 if (names) 2565 if (names)
2518 { 2566 {
2519 Lisp_Object *tail;
2520 int i; 2567 int i;
2568 Lisp_Object full_list;
2569
2570 /* Make a list of all the fonts we got back.
2571 Store that in the font cache for the display. */
2572 full_list = Qnil;
2573 for (i = 0; i < num_fonts; i++)
2574 full_list = Fcons (build_string (names[i]), full_list);
2575 FRAME_X_SCREEN (f)->font_list_cache
2576 = Fcons (Fcons (pattern, full_list),
2577 FRAME_X_SCREEN (f)->font_list_cache);
2521 2578
2522 tail = &list; 2579 /* Make a list of the fonts that have the right width. */
2580 list = Qnil;
2523 for (i = 0; i < num_fonts; i++) 2581 for (i = 0; i < num_fonts; i++)
2524 { 2582 {
2525 XFontStruct *thisinfo; 2583 XFontStruct *thisinfo;
@@ -2533,11 +2591,9 @@ even if they match PATTERN and FACE.")
2533#endif 2591#endif
2534 if (thisinfo && (! size_ref 2592 if (thisinfo && (! size_ref
2535 || same_size_fonts (thisinfo, size_ref))) 2593 || same_size_fonts (thisinfo, size_ref)))
2536 { 2594 list = Fcons (build_string (names[i]), list);
2537 *tail = Fcons (build_string (names[i]), Qnil);
2538 tail = &XCONS (*tail)->cdr;
2539 }
2540 } 2595 }
2596 list = Fnreverse (list);
2541 2597
2542 BLOCK_INPUT; 2598 BLOCK_INPUT;
2543#ifdef BROKEN_XLISTFONTSWITHINFO 2599#ifdef BROKEN_XLISTFONTSWITHINFO
@@ -3831,6 +3887,8 @@ Optional second arg XRM_STRING is a string of resources in xrdb format.")
3831 x_current_display->db = xrdb; 3887 x_current_display->db = xrdb;
3832#endif 3888#endif
3833 3889
3890 the_x_screen.name = display;
3891
3834 x_screen = DefaultScreenOfDisplay (x_current_display); 3892 x_screen = DefaultScreenOfDisplay (x_current_display);
3835 3893
3836 screen_visual = select_visual (x_screen, &n_planes); 3894 screen_visual = select_visual (x_screen, &n_planes);
@@ -3920,6 +3978,11 @@ syms_of_xfns ()
3920 /* This is zero if not using X windows. */ 3978 /* This is zero if not using X windows. */
3921 x_current_display = 0; 3979 x_current_display = 0;
3922 3980
3981 the_x_screen.font_list_cache = Qnil;
3982 the_x_screen.name = Qnil;
3983 staticpro (&the_x_screen.font_list_cache);
3984 staticpro (&the_x_screen.name);
3985
3923 /* The section below is built by the lisp expression at the top of the file, 3986 /* The section below is built by the lisp expression at the top of the file,
3924 just above where these variables are declared. */ 3987 just above where these variables are declared. */
3925 /*&&& init symbols here &&&*/ 3988 /*&&& init symbols here &&&*/