Mercurial > emacs
changeset 7935:f15e1a058e93
(scratch_cursor_gc): New variable.
(dumpglyphs): Rework handling of GCs for cursor display
to use scratch_cursor_gc, and reuse the GC more.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Fri, 17 Jun 1994 13:35:53 +0000 |
parents | b5e9b6a00f5d |
children | a64f4117dc04 |
files | src/xterm.c |
diffstat | 1 files changed, 17 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/src/xterm.c Fri Jun 17 04:05:56 1994 +0000 +++ b/src/xterm.c Fri Jun 17 13:35:53 1994 +0000 @@ -239,6 +239,9 @@ static int curs_x; static int curs_y; +/* Reusable Graphics Context for drawing a cursor in a non-default face. */ +static GC scratch_cursor_gc; + /* Mouse movement. In order to avoid asking for motion events and then throwing most @@ -630,7 +633,6 @@ struct face *face = FRAME_DEFAULT_FACE (f); FONT_TYPE *font = FACE_FONT (face); GC gc = FACE_GC (face); - int gc_temporary = 0; /* HL = 3 means use a mouse face previously chosen. */ if (hl == 3) @@ -668,8 +670,11 @@ /* Now override that if the cursor's on this character. */ if (hl == 2) { - if (!face->font - || (int) face->font == FACE_DEFAULT) + if ((!face->font + || (int) face->font == FACE_DEFAULT + || face->font == f->display.x->font) + && face->background == f->display.x->background_pixel + && face->foreground == f->display.x->foreground_pixel) { gc = f->display.x->cursor_gc; } @@ -680,10 +685,7 @@ unsigned long mask; xgcv.background = f->display.x->cursor_pixel; - if (face == FRAME_DEFAULT_FACE (f)) - xgcv.foreground = f->display.x->cursor_foreground_pixel; - else - xgcv.foreground = face->background; + xgcv.foreground = face->background; /* If the glyph would be invisible, try a different foreground. */ if (xgcv.foreground == xgcv.background) @@ -702,13 +704,18 @@ xgcv.font = face->font->fid; xgcv.graphics_exposures = 0; mask = GCForeground | GCBackground | GCFont | GCGraphicsExposures; - gc = XCreateGC (x_current_display, FRAME_X_WINDOW (f), - mask, &xgcv); + if (scratch_cursor_gc) + XChangeGC (x_current_display, scratch_cursor_gc, mask, &xgcv); + else + scratch_cursor_gc = + XCreateGC (x_current_display, window, mask, &xgcv); + gc = scratch_cursor_gc; #if 0 +/* If this code is restored, it must also reset to the default stipple + if necessary. */ if (face->stipple && face->stipple != FACE_DEFAULT) XSetStipple (x_current_display, gc, face->stipple); #endif - gc_temporary = 1; } } @@ -746,9 +753,6 @@ } #endif - if (gc_temporary) - XFreeGC (x_current_display, gc); - /* We should probably check for XA_UNDERLINE_POSITION and XA_UNDERLINE_THICKNESS properties on the font, but let's just get the thing working, and come back to that. */