Commit 11dd3d61 authored by Richard M. Stallman's avatar Richard M. Stallman
Browse files

(scratch_cursor_gc): New variable.

(dumpglyphs): Rework handling of GCs for cursor display
to use scratch_cursor_gc, and reuse the GC more.
parent a3d358c6
...@@ -239,6 +239,9 @@ static int highlight; ...@@ -239,6 +239,9 @@ static int highlight;
static int curs_x; static int curs_x;
static int curs_y; static int curs_y;
/* Reusable Graphics Context for drawing a cursor in a non-default face. */
static GC scratch_cursor_gc;
/* Mouse movement. /* Mouse movement.
In order to avoid asking for motion events and then throwing most In order to avoid asking for motion events and then throwing most
...@@ -630,7 +633,6 @@ dumpglyphs (f, left, top, gp, n, hl, just_foreground) ...@@ -630,7 +633,6 @@ dumpglyphs (f, left, top, gp, n, hl, just_foreground)
struct face *face = FRAME_DEFAULT_FACE (f); struct face *face = FRAME_DEFAULT_FACE (f);
FONT_TYPE *font = FACE_FONT (face); FONT_TYPE *font = FACE_FONT (face);
GC gc = FACE_GC (face); GC gc = FACE_GC (face);
int gc_temporary = 0;
/* HL = 3 means use a mouse face previously chosen. */ /* HL = 3 means use a mouse face previously chosen. */
if (hl == 3) if (hl == 3)
...@@ -668,8 +670,11 @@ dumpglyphs (f, left, top, gp, n, hl, just_foreground) ...@@ -668,8 +670,11 @@ dumpglyphs (f, left, top, gp, n, hl, just_foreground)
/* Now override that if the cursor's on this character. */ /* Now override that if the cursor's on this character. */
if (hl == 2) if (hl == 2)
{ {
if (!face->font if ((!face->font
|| (int) face->font == FACE_DEFAULT) || (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; gc = f->display.x->cursor_gc;
} }
...@@ -680,9 +685,6 @@ dumpglyphs (f, left, top, gp, n, hl, just_foreground) ...@@ -680,9 +685,6 @@ dumpglyphs (f, left, top, gp, n, hl, just_foreground)
unsigned long mask; unsigned long mask;
xgcv.background = f->display.x->cursor_pixel; 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, /* If the glyph would be invisible,
try a different foreground. */ try a different foreground. */
...@@ -702,13 +704,18 @@ dumpglyphs (f, left, top, gp, n, hl, just_foreground) ...@@ -702,13 +704,18 @@ dumpglyphs (f, left, top, gp, n, hl, just_foreground)
xgcv.font = face->font->fid; xgcv.font = face->font->fid;
xgcv.graphics_exposures = 0; xgcv.graphics_exposures = 0;
mask = GCForeground | GCBackground | GCFont | GCGraphicsExposures; mask = GCForeground | GCBackground | GCFont | GCGraphicsExposures;
gc = XCreateGC (x_current_display, FRAME_X_WINDOW (f), if (scratch_cursor_gc)
mask, &xgcv); 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 0
/* If this code is restored, it must also reset to the default stipple
if necessary. */
if (face->stipple && face->stipple != FACE_DEFAULT) if (face->stipple && face->stipple != FACE_DEFAULT)
XSetStipple (x_current_display, gc, face->stipple); XSetStipple (x_current_display, gc, face->stipple);
#endif #endif
gc_temporary = 1;
} }
} }
...@@ -746,9 +753,6 @@ dumpglyphs (f, left, top, gp, n, hl, just_foreground) ...@@ -746,9 +753,6 @@ dumpglyphs (f, left, top, gp, n, hl, just_foreground)
} }
#endif #endif
if (gc_temporary)
XFreeGC (x_current_display, gc);
/* We should probably check for XA_UNDERLINE_POSITION and /* We should probably check for XA_UNDERLINE_POSITION and
XA_UNDERLINE_THICKNESS properties on the font, but let's XA_UNDERLINE_THICKNESS properties on the font, but let's
just get the thing working, and come back to that. */ just get the thing working, and come back to that. */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment