summaryrefslogtreecommitdiff
path: root/src/xfaces.c
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>1995-11-10 16:19:51 +0000
committerRichard M. Stallman <rms@gnu.org>1995-11-10 16:19:51 +0000
commit868ea237c26e1feec37ac9956f70aa2b1c17bf87 (patch)
treecb7a77a18417f49ce05c9b33b5e6fe6584e7effa /src/xfaces.c
parentdda9343061d37a058e9ca42b37c31f401f0faf3a (diff)
downloademacs-868ea237c26e1feec37ac9956f70aa2b1c17bf87.tar.gz
(unload_font): Invalidate computed faces.
(unload_color): Likewise. (new_computed_face): Reuse invalidated computed faces.
Diffstat (limited to 'src/xfaces.c')
-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. */
This is done from time to time so that we don't hold on to
lots of GCs that are no longer needed.
+ If a computed face has 0 as its font,
+ it is unused, and can be reused by new_computed_face.
+
Constraints:
Symbols naming faces must have associations on all frames; for any
@@ -327,10 +330,28 @@ unload_font (f, font)
struct frame *f;
XFontStruct *font;
{
+ int len = FRAME_N_COMPUTED_FACES (f);
+ int i;
+
if (!font || font == ((XFontStruct *) FACE_DEFAULT))
return;
BLOCK_INPUT;
+ /* Invalidate any computed faces which use this font,
+ and free their GC's if they have any. */
+ for (i = 0; i < len; i++)
+ {
+ struct face *face = FRAME_COMPUTED_FACES (f)[i];
+ if (face->font == font)
+ {
+ Display *dpy = FRAME_X_DISPLAY (f);
+ if (face->gc)
+ XFreeGC (dpy, face->gc);
+ face->gc = 0;
+ face->font = 0;
+ }
+ }
+
XFreeFont (FRAME_X_DISPLAY (f), font);
UNBLOCK_INPUT;
}
@@ -375,7 +396,26 @@ unload_color (f, pixel)
necessary and some servers don't allow it. So don't do it. */
if (! (class == StaticColor || class == StaticGray || class == TrueColor))
{
+ int len = FRAME_N_COMPUTED_FACES (f);
+ int i;
+
BLOCK_INPUT;
+ /* Invalidate any computed faces which use this color,
+ and free their GC's if they have any. */
+ for (i = 0; i < len; i++)
+ {
+ struct face *face = FRAME_COMPUTED_FACES (f)[i];
+ if (face->foreground == pixel
+ || face->background == pixel)
+ {
+ Display *dpy = FRAME_X_DISPLAY (f);
+ if (face->gc)
+ XFreeGC (dpy, face->gc);
+ face->gc = 0;
+ face->font = 0;
+ }
+ }
+
XFreeColors (dpy, cmap, &pixel, 1, (unsigned long)0);
UNBLOCK_INPUT;
}
@@ -604,7 +644,19 @@ new_computed_face (f, new_face)
struct frame *f;
struct face *new_face;
{
- int i = FRAME_N_COMPUTED_FACES (f);
+ int len = FRAME_N_COMPUTED_FACES (f);
+ int i;
+
+ /* Search for an unused computed face in the middle of the table. */
+ for (i = 0; i < len; i++)
+ {
+ struct face *face = FRAME_COMPUTED_FACES (f)[i];
+ if (face->font == 0)
+ {
+ FRAME_COMPUTED_FACES (f)[i] = copy_face (new_face);
+ return i;
+ }
+ }
if (i >= FRAME_SIZE_COMPUTED_FACES (f))
{