Mercurial > emacs
comparison src/xfaces.c @ 13460:5513606156bc
(unload_font): Invalidate computed faces.
(unload_color): Likewise.
(new_computed_face): Reuse invalidated computed faces.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Fri, 10 Nov 1995 16:19:51 +0000 |
parents | 941c37982f37 |
children | 67c2ba47a729 |
comparison
equal
deleted
inserted
replaced
13459:96fdfde22e87 | 13460:5513606156bc |
---|---|
119 if it doesn't have one already. | 119 if it doesn't have one already. |
120 clear_face_cache clears out the GCs of all computed faces. | 120 clear_face_cache clears out the GCs of all computed faces. |
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 |
127 FRAME, for all FACE-NAME, if (assq FACE-NAME (frame-face-alist | 130 FRAME, for all FACE-NAME, if (assq FACE-NAME (frame-face-alist |
128 FRAME)) is non-nil, it must be non-nil for all frames. | 131 FRAME)) is non-nil, it must be non-nil for all frames. |
325 static void | 328 static void |
326 unload_font (f, font) | 329 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 } |
337 | 358 |
338 static unsigned long | 359 static unsigned long |
373 | 394 |
374 /* If display has an immutable color map, freeing colors is not | 395 /* If display has an immutable color map, freeing colors is not |
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 } |
382 } | 422 } |
383 | 423 |
602 static int | 642 static int |
603 new_computed_face (f, new_face) | 643 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 { |
611 int new_size = i + 32; | 663 int new_size = i + 32; |
612 | 664 |