aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard M. Stallman1995-11-10 16:19:51 +0000
committerRichard M. Stallman1995-11-10 16:19:51 +0000
commit195f798edb7664c1e04e5a115e14e94e5565b1d6 (patch)
treec5cebc37b257ee6eac496e016f5abd41a683c31b /src
parentd3413a53d1d04413c0bccf991ed9bcc0829c7508 (diff)
downloademacs-195f798edb7664c1e04e5a115e14e94e5565b1d6.tar.gz
emacs-195f798edb7664c1e04e5a115e14e94e5565b1d6.zip
(unload_font): Invalidate computed faces.
(unload_color): Likewise. (new_computed_face): Reuse invalidated computed faces.
Diffstat (limited to 'src')
-rw-r--r--src/xfaces.c54
1 files changed, 53 insertions, 1 deletions
diff --git a/src/xfaces.c b/src/xfaces.c
index dc7f4188863..254aaf275f1 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -121,6 +121,9 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
121 This is done from time to time so that we don't hold on to 121 This is done from time to time so that we don't hold on to
122 lots of GCs that are no longer needed. 122 lots of GCs that are no longer needed.
123 123
124 If a computed face has 0 as its font,
125 it is unused, and can be reused by new_computed_face.
126
124 Constraints: 127 Constraints:
125 128
126 Symbols naming faces must have associations on all frames; for any 129 Symbols naming faces must have associations on all frames; for any
@@ -327,10 +330,28 @@ unload_font (f, font)
327 struct frame *f; 330 struct frame *f;
328 XFontStruct *font; 331 XFontStruct *font;
329{ 332{
333 int len = FRAME_N_COMPUTED_FACES (f);
334 int i;
335
330 if (!font || font == ((XFontStruct *) FACE_DEFAULT)) 336 if (!font || font == ((XFontStruct *) FACE_DEFAULT))
331 return; 337 return;
332 338
333 BLOCK_INPUT; 339 BLOCK_INPUT;
340 /* Invalidate any computed faces which use this font,
341 and free their GC's if they have any. */
342 for (i = 0; i < len; i++)
343 {
344 struct face *face = FRAME_COMPUTED_FACES (f)[i];
345 if (face->font == font)
346 {
347 Display *dpy = FRAME_X_DISPLAY (f);
348 if (face->gc)
349 XFreeGC (dpy, face->gc);
350 face->gc = 0;
351 face->font = 0;
352 }
353 }
354
334 XFreeFont (FRAME_X_DISPLAY (f), font); 355 XFreeFont (FRAME_X_DISPLAY (f), font);
335 UNBLOCK_INPUT; 356 UNBLOCK_INPUT;
336} 357}
@@ -375,7 +396,26 @@ unload_color (f, pixel)
375 necessary and some servers don't allow it. So don't do it. */ 396 necessary and some servers don't allow it. So don't do it. */
376 if (! (class == StaticColor || class == StaticGray || class == TrueColor)) 397 if (! (class == StaticColor || class == StaticGray || class == TrueColor))
377 { 398 {
399 int len = FRAME_N_COMPUTED_FACES (f);
400 int i;
401
378 BLOCK_INPUT; 402 BLOCK_INPUT;
403 /* Invalidate any computed faces which use this color,
404 and free their GC's if they have any. */
405 for (i = 0; i < len; i++)
406 {
407 struct face *face = FRAME_COMPUTED_FACES (f)[i];
408 if (face->foreground == pixel
409 || face->background == pixel)
410 {
411 Display *dpy = FRAME_X_DISPLAY (f);
412 if (face->gc)
413 XFreeGC (dpy, face->gc);
414 face->gc = 0;
415 face->font = 0;
416 }
417 }
418
379 XFreeColors (dpy, cmap, &pixel, 1, (unsigned long)0); 419 XFreeColors (dpy, cmap, &pixel, 1, (unsigned long)0);
380 UNBLOCK_INPUT; 420 UNBLOCK_INPUT;
381 } 421 }
@@ -604,7 +644,19 @@ new_computed_face (f, new_face)
604 struct frame *f; 644 struct frame *f;
605 struct face *new_face; 645 struct face *new_face;
606{ 646{
607 int i = FRAME_N_COMPUTED_FACES (f); 647 int len = FRAME_N_COMPUTED_FACES (f);
648 int i;
649
650 /* Search for an unused computed face in the middle of the table. */
651 for (i = 0; i < len; i++)
652 {
653 struct face *face = FRAME_COMPUTED_FACES (f)[i];
654 if (face->font == 0)
655 {
656 FRAME_COMPUTED_FACES (f)[i] = copy_face (new_face);
657 return i;
658 }
659 }
608 660
609 if (i >= FRAME_SIZE_COMPUTED_FACES (f)) 661 if (i >= FRAME_SIZE_COMPUTED_FACES (f))
610 { 662 {