mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-02-16 17:24:23 +00:00
Introduce Emacs_GC struct and typedef
* src/dispextern.h [HAVE_X_WINDOWS]: Alias Emacs_GC to XGCValues. [!HAVE_X_WINDOWS]: Define Emacs_GC, GCForeground, and GCBackground. * src/nsgui.h: * src/w32gui.h:Remove obsolete XGCValues, GC, GCForeground, GCBackground, and GCFont definitions. * src/w32fns.c (w32_make_gc): Do not set unused font field. * src/w32term.c: Use Emacs_GC over XGCValues. Do not set unused font field. * src/xfaces.c: Use Emacs_GC over XGCValues and GC.
This commit is contained in:
parent
462b1fd718
commit
b3d3c0daa4
7 changed files with 82 additions and 104 deletions
|
|
@ -40,6 +40,7 @@ typedef Cursor Emacs_Cursor;
|
|||
#define No_Cursor (None)
|
||||
typedef Pixmap Emacs_Pixmap;
|
||||
typedef XRectangle Emacs_Rectangle;
|
||||
typedef XGCValues Emacs_GC;
|
||||
#else /* !HAVE_X_WINDOWS */
|
||||
|
||||
/* XColor-like struct used by non-X code. */
|
||||
|
|
@ -59,6 +60,20 @@ typedef struct
|
|||
int x, y;
|
||||
unsigned width, height;
|
||||
} Emacs_Rectangle;
|
||||
|
||||
/* XGCValues-like struct used by non-X GUI code. */
|
||||
typedef struct
|
||||
{
|
||||
unsigned long foreground;
|
||||
unsigned long background;
|
||||
} Emacs_GC;
|
||||
|
||||
/* Mask values to select foreground/background. */
|
||||
/* FIXME: The GC handling in w32 really should be redesigned as to not
|
||||
need these. */
|
||||
#define GCForeground 0x01
|
||||
#define GCBackground 0x02
|
||||
|
||||
#endif /* HAVE_X_WINDOWS */
|
||||
|
||||
#ifdef MSDOS
|
||||
|
|
@ -1363,7 +1378,7 @@ struct glyph_string
|
|||
GC gc;
|
||||
#endif
|
||||
#if defined (HAVE_NTGUI)
|
||||
XGCValues *gc;
|
||||
Emacs_GC *gc;
|
||||
HDC hdc;
|
||||
#endif
|
||||
|
||||
|
|
@ -1605,8 +1620,11 @@ struct face
|
|||
|
||||
/* If non-zero, this is a GC that we can use without modification for
|
||||
drawing the characters in this face. */
|
||||
# ifdef HAVE_X_WINDOWS
|
||||
GC gc;
|
||||
|
||||
# else
|
||||
Emacs_GC *gc;
|
||||
# endif
|
||||
/* Background stipple or bitmap used for this face. This is
|
||||
an id as returned from load_pixmap. */
|
||||
ptrdiff_t stipple;
|
||||
|
|
|
|||
19
src/nsgui.h
19
src/nsgui.h
|
|
@ -76,25 +76,6 @@ typedef unichar XChar2b;
|
|||
/* Used in xdisp.c when comparing faces and frame colors. */
|
||||
extern unsigned long ns_color_index_to_rgba(int idx, struct frame *f);
|
||||
|
||||
/* XXX: xfaces requires these structures, but the question is are we
|
||||
forced to use them? */
|
||||
typedef struct _XGCValues
|
||||
{
|
||||
unsigned long foreground;
|
||||
unsigned long background;
|
||||
#ifdef __OBJC__
|
||||
struct ns_font *font;
|
||||
#else
|
||||
void *font;
|
||||
#endif
|
||||
} XGCValues;
|
||||
|
||||
typedef XGCValues * GC;
|
||||
|
||||
#define GCForeground 0x01
|
||||
#define GCBackground 0x02
|
||||
#define GCFont 0x03
|
||||
|
||||
#ifdef __OBJC__
|
||||
typedef id Emacs_Pixmap;
|
||||
#else
|
||||
|
|
|
|||
|
|
@ -5559,22 +5559,19 @@ w32_icon (struct frame *f, Lisp_Object parms)
|
|||
static void
|
||||
w32_make_gc (struct frame *f)
|
||||
{
|
||||
XGCValues gc_values;
|
||||
Emacs_GC gc_values;
|
||||
|
||||
block_input ();
|
||||
|
||||
/* Create the GC's of this frame.
|
||||
Note that many default values are used. */
|
||||
|
||||
/* Normal video */
|
||||
gc_values.font = FRAME_FONT (f);
|
||||
|
||||
/* Cursor has cursor-color background, background-color foreground. */
|
||||
gc_values.foreground = FRAME_BACKGROUND_PIXEL (f);
|
||||
gc_values.background = f->output_data.w32->cursor_pixel;
|
||||
f->output_data.w32->cursor_gc
|
||||
= XCreateGC (NULL, FRAME_W32_WINDOW (f),
|
||||
(GCFont | GCForeground | GCBackground),
|
||||
(GCForeground | GCBackground),
|
||||
&gc_values);
|
||||
|
||||
/* Reliefs. */
|
||||
|
|
|
|||
13
src/w32gui.h
13
src/w32gui.h
|
|
@ -27,21 +27,8 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
|
|||
#define local_alloc(n) (HeapAlloc (local_heap, HEAP_ZERO_MEMORY, (n)))
|
||||
#define local_free(p) (HeapFree (local_heap, 0, ((LPVOID) (p))))
|
||||
|
||||
/* Emulate X GC's by keeping color and font info in a structure. */
|
||||
typedef struct _XGCValues
|
||||
{
|
||||
COLORREF foreground;
|
||||
COLORREF background;
|
||||
struct font *font;
|
||||
} XGCValues;
|
||||
|
||||
#define GCForeground 0x01
|
||||
#define GCBackground 0x02
|
||||
#define GCFont 0x03
|
||||
|
||||
typedef HBITMAP Emacs_Pixmap;
|
||||
|
||||
typedef XGCValues * GC;
|
||||
typedef HWND Window;
|
||||
typedef HDC Display; /* HDC so it doesn't conflict with xpm lib. */
|
||||
typedef HCURSOR Emacs_Cursor;
|
||||
|
|
|
|||
|
|
@ -237,23 +237,21 @@ record_event (char *locus, int type)
|
|||
|
||||
|
||||
static void
|
||||
XChangeGC (void *ignore, XGCValues *gc, unsigned long mask,
|
||||
XGCValues *xgcv)
|
||||
XChangeGC (void *ignore, Emacs_GC *gc, unsigned long mask,
|
||||
Emacs_GC *egc)
|
||||
{
|
||||
if (mask & GCForeground)
|
||||
gc->foreground = xgcv->foreground;
|
||||
gc->foreground = egc->foreground;
|
||||
if (mask & GCBackground)
|
||||
gc->background = xgcv->background;
|
||||
if (mask & GCFont)
|
||||
gc->font = xgcv->font;
|
||||
gc->background = egc->background;
|
||||
}
|
||||
|
||||
XGCValues *
|
||||
XCreateGC (void *ignore, HWND wignore, unsigned long mask, XGCValues *xgcv)
|
||||
Emacs_GC *
|
||||
XCreateGC (void *ignore, HWND wignore, unsigned long mask, Emacs_GC *egc)
|
||||
{
|
||||
XGCValues *gc = xzalloc (sizeof (XGCValues));
|
||||
Emacs_GC *gc = xzalloc (sizeof (*gc));
|
||||
|
||||
XChangeGC (ignore, gc, mask, xgcv);
|
||||
XChangeGC (ignore, gc, mask, egc);
|
||||
|
||||
return gc;
|
||||
}
|
||||
|
|
@ -396,7 +394,7 @@ w32_draw_underwave (struct glyph_string *s, COLORREF color)
|
|||
|
||||
/* Draw a hollow rectangle at the specified position. */
|
||||
static void
|
||||
w32_draw_rectangle (HDC hdc, XGCValues *gc, int x, int y,
|
||||
w32_draw_rectangle (HDC hdc, Emacs_GC *gc, int x, int y,
|
||||
int width, int height)
|
||||
{
|
||||
HBRUSH hb, oldhb;
|
||||
|
|
@ -906,38 +904,37 @@ w32_set_cursor_gc (struct glyph_string *s)
|
|||
else
|
||||
{
|
||||
/* Cursor on non-default face: must merge. */
|
||||
XGCValues xgcv;
|
||||
Emacs_GC egc;
|
||||
unsigned long mask;
|
||||
|
||||
xgcv.background = s->f->output_data.w32->cursor_pixel;
|
||||
xgcv.foreground = s->face->background;
|
||||
egc.background = s->f->output_data.w32->cursor_pixel;
|
||||
egc.foreground = s->face->background;
|
||||
|
||||
/* If the glyph would be invisible, try a different foreground. */
|
||||
if (xgcv.foreground == xgcv.background)
|
||||
xgcv.foreground = s->face->foreground;
|
||||
if (xgcv.foreground == xgcv.background)
|
||||
xgcv.foreground = s->f->output_data.w32->cursor_foreground_pixel;
|
||||
if (xgcv.foreground == xgcv.background)
|
||||
xgcv.foreground = s->face->foreground;
|
||||
if (egc.foreground == egc.background)
|
||||
egc.foreground = s->face->foreground;
|
||||
if (egc.foreground == egc.background)
|
||||
egc.foreground = s->f->output_data.w32->cursor_foreground_pixel;
|
||||
if (egc.foreground == egc.background)
|
||||
egc.foreground = s->face->foreground;
|
||||
|
||||
/* Make sure the cursor is distinct from text in this face. */
|
||||
if (xgcv.background == s->face->background
|
||||
&& xgcv.foreground == s->face->foreground)
|
||||
if (egc.background == s->face->background
|
||||
&& egc.foreground == s->face->foreground)
|
||||
{
|
||||
xgcv.background = s->face->foreground;
|
||||
xgcv.foreground = s->face->background;
|
||||
egc.background = s->face->foreground;
|
||||
egc.foreground = s->face->background;
|
||||
}
|
||||
|
||||
IF_DEBUG (w32_check_font (s->f, s->font));
|
||||
xgcv.font = s->font;
|
||||
mask = GCForeground | GCBackground | GCFont;
|
||||
mask = GCForeground | GCBackground;
|
||||
|
||||
if (FRAME_DISPLAY_INFO (s->f)->scratch_cursor_gc)
|
||||
XChangeGC (NULL, FRAME_DISPLAY_INFO (s->f)->scratch_cursor_gc,
|
||||
mask, &xgcv);
|
||||
mask, &egc);
|
||||
else
|
||||
FRAME_DISPLAY_INFO (s->f)->scratch_cursor_gc
|
||||
= XCreateGC (NULL, FRAME_W32_WINDOW (s->f), mask, &xgcv);
|
||||
= XCreateGC (NULL, FRAME_W32_WINDOW (s->f), mask, &egc);
|
||||
|
||||
s->gc = FRAME_DISPLAY_INFO (s->f)->scratch_cursor_gc;
|
||||
}
|
||||
|
|
@ -972,21 +969,20 @@ w32_set_mouse_face_gc (struct glyph_string *s)
|
|||
{
|
||||
/* Otherwise construct scratch_cursor_gc with values from FACE
|
||||
but font FONT. */
|
||||
XGCValues xgcv;
|
||||
Emacs_GC egc;
|
||||
unsigned long mask;
|
||||
|
||||
xgcv.background = s->face->background;
|
||||
xgcv.foreground = s->face->foreground;
|
||||
egc.background = s->face->background;
|
||||
egc.foreground = s->face->foreground;
|
||||
IF_DEBUG (w32_check_font (s->f, s->font));
|
||||
xgcv.font = s->font;
|
||||
mask = GCForeground | GCBackground | GCFont;
|
||||
mask = GCForeground | GCBackground;
|
||||
|
||||
if (FRAME_DISPLAY_INFO (s->f)->scratch_cursor_gc)
|
||||
XChangeGC (NULL, FRAME_DISPLAY_INFO (s->f)->scratch_cursor_gc,
|
||||
mask, &xgcv);
|
||||
mask, &egc);
|
||||
else
|
||||
FRAME_DISPLAY_INFO (s->f)->scratch_cursor_gc
|
||||
= XCreateGC (NULL, FRAME_W32_WINDOW (s->f), mask, &xgcv);
|
||||
= XCreateGC (NULL, FRAME_W32_WINDOW (s->f), mask, &egc);
|
||||
|
||||
s->gc = FRAME_DISPLAY_INFO (s->f)->scratch_cursor_gc;
|
||||
}
|
||||
|
|
@ -1551,7 +1547,7 @@ static void
|
|||
w32_setup_relief_color (struct frame *f, struct relief *relief, double factor,
|
||||
int delta, COLORREF default_pixel)
|
||||
{
|
||||
XGCValues xgcv;
|
||||
Emacs_GC egc;
|
||||
struct w32_output *di = f->output_data.w32;
|
||||
unsigned long mask = GCForeground;
|
||||
COLORREF pixel;
|
||||
|
|
@ -1563,22 +1559,21 @@ w32_setup_relief_color (struct frame *f, struct relief *relief, double factor,
|
|||
/* TODO: Free colors (if using palette)? */
|
||||
|
||||
/* Allocate new color. */
|
||||
xgcv.foreground = default_pixel;
|
||||
egc.foreground = default_pixel;
|
||||
pixel = background;
|
||||
if (w32_alloc_lighter_color (f, &pixel, factor, delta))
|
||||
xgcv.foreground = relief->pixel = pixel;
|
||||
egc.foreground = relief->pixel = pixel;
|
||||
|
||||
xgcv.font = NULL; /* avoid compiler warnings */
|
||||
if (relief->gc == 0)
|
||||
{
|
||||
#if 0 /* TODO: stipple */
|
||||
xgcv.stipple = dpyinfo->gray;
|
||||
egc.stipple = dpyinfo->gray;
|
||||
mask |= GCStipple;
|
||||
#endif
|
||||
relief->gc = XCreateGC (NULL, FRAME_W32_WINDOW (f), mask, &xgcv);
|
||||
relief->gc = XCreateGC (NULL, FRAME_W32_WINDOW (f), mask, &egc);
|
||||
}
|
||||
else
|
||||
XChangeGC (NULL, relief->gc, mask, &xgcv);
|
||||
XChangeGC (NULL, relief->gc, mask, &egc);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1627,7 +1622,7 @@ w32_draw_relief_rect (struct frame *f,
|
|||
RECT *clip_rect)
|
||||
{
|
||||
int i;
|
||||
XGCValues gc;
|
||||
Emacs_GC gc;
|
||||
HDC hdc = get_frame_dc (f);
|
||||
|
||||
if (raised_p)
|
||||
|
|
@ -2286,7 +2281,7 @@ w32_draw_stretch_glyph_string (struct glyph_string *s)
|
|||
/* Clear rest using the GC of the original non-cursor face. */
|
||||
if (width < background_width)
|
||||
{
|
||||
XGCValues *gc = s->face->gc;
|
||||
Emacs_GC *gc = s->face->gc;
|
||||
int y = s->y;
|
||||
int w = background_width - width, h = s->height;
|
||||
RECT r;
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@ struct w32_display_info
|
|||
int smallest_font_height;
|
||||
|
||||
/* Reusable Graphics Context for drawing a cursor in a non-default face. */
|
||||
XGCValues *scratch_cursor_gc;
|
||||
Emacs_GC *scratch_cursor_gc;
|
||||
|
||||
/* Information about the range of text currently shown in
|
||||
mouse-face. */
|
||||
|
|
@ -308,7 +308,7 @@ struct w32_output
|
|||
HPALETTE old_palette;
|
||||
|
||||
/* Here are the Graphics Contexts for the default font. */
|
||||
XGCValues *cursor_gc; /* cursor drawing */
|
||||
Emacs_GC *cursor_gc; /* cursor drawing */
|
||||
|
||||
/* The window used for this frame.
|
||||
May be zero while the frame object is being created
|
||||
|
|
@ -388,7 +388,7 @@ struct w32_output
|
|||
/* Relief GCs, colors etc. */
|
||||
struct relief
|
||||
{
|
||||
XGCValues *gc;
|
||||
Emacs_GC *gc;
|
||||
unsigned long pixel;
|
||||
}
|
||||
black_relief, white_relief;
|
||||
|
|
@ -805,7 +805,7 @@ typedef struct tagTRACKMOUSEEVENT
|
|||
struct image;
|
||||
struct face;
|
||||
|
||||
XGCValues *XCreateGC (void *, HWND, unsigned long, XGCValues *);
|
||||
Emacs_GC *XCreateGC (void *, HWND, unsigned long, Emacs_GC *);
|
||||
|
||||
typedef DWORD (WINAPI * ClipboardSequence_Proc) (void);
|
||||
typedef BOOL (WINAPI * AppendMenuW_Proc) (
|
||||
|
|
|
|||
34
src/xfaces.c
34
src/xfaces.c
|
|
@ -513,12 +513,12 @@ x_free_gc (struct frame *f, GC gc)
|
|||
#ifdef HAVE_NTGUI
|
||||
/* W32 emulation of GCs */
|
||||
|
||||
static GC
|
||||
x_create_gc (struct frame *f, unsigned long mask, XGCValues *xgcv)
|
||||
static Emacs_GC *
|
||||
x_create_gc (struct frame *f, unsigned long mask, Emacs_GC *egc)
|
||||
{
|
||||
GC gc;
|
||||
Emacs_GC *gc;
|
||||
block_input ();
|
||||
gc = XCreateGC (NULL, FRAME_W32_WINDOW (f), mask, xgcv);
|
||||
gc = XCreateGC (NULL, FRAME_W32_WINDOW (f), mask, egc);
|
||||
unblock_input ();
|
||||
IF_DEBUG (++ngcs);
|
||||
return gc;
|
||||
|
|
@ -528,7 +528,7 @@ x_create_gc (struct frame *f, unsigned long mask, XGCValues *xgcv)
|
|||
/* Free GC which was used on frame F. */
|
||||
|
||||
static void
|
||||
x_free_gc (struct frame *f, GC gc)
|
||||
x_free_gc (struct frame *f, Emacs_GC *gc)
|
||||
{
|
||||
IF_DEBUG ((--ngcs, eassert (ngcs >= 0)));
|
||||
xfree (gc);
|
||||
|
|
@ -539,18 +539,18 @@ x_free_gc (struct frame *f, GC gc)
|
|||
#ifdef HAVE_NS
|
||||
/* NS emulation of GCs */
|
||||
|
||||
static GC
|
||||
static Emacs_GC *
|
||||
x_create_gc (struct frame *f,
|
||||
unsigned long mask,
|
||||
XGCValues *xgcv)
|
||||
Emacs_GC *egc)
|
||||
{
|
||||
GC gc = xmalloc (sizeof *gc);
|
||||
*gc = *xgcv;
|
||||
Emacs_GC *gc = xmalloc (sizeof *gc);
|
||||
*gc = *egc;
|
||||
return gc;
|
||||
}
|
||||
|
||||
static void
|
||||
x_free_gc (struct frame *f, GC gc)
|
||||
x_free_gc (struct frame *f, Emacs_GC *gc)
|
||||
{
|
||||
xfree (gc);
|
||||
}
|
||||
|
|
@ -4140,25 +4140,25 @@ prepare_face_for_display (struct frame *f, struct face *face)
|
|||
|
||||
if (face->gc == 0)
|
||||
{
|
||||
XGCValues xgcv;
|
||||
Emacs_GC egc;
|
||||
unsigned long mask = GCForeground | GCBackground | GCGraphicsExposures;
|
||||
|
||||
xgcv.foreground = face->foreground;
|
||||
xgcv.background = face->background;
|
||||
egc.foreground = face->foreground;
|
||||
egc.background = face->background;
|
||||
#ifdef HAVE_X_WINDOWS
|
||||
xgcv.graphics_exposures = False;
|
||||
egc.graphics_exposures = False;
|
||||
#endif
|
||||
|
||||
block_input ();
|
||||
#ifdef HAVE_X_WINDOWS
|
||||
if (face->stipple)
|
||||
{
|
||||
xgcv.fill_style = FillOpaqueStippled;
|
||||
xgcv.stipple = image_bitmap_pixmap (f, face->stipple);
|
||||
egc.fill_style = FillOpaqueStippled;
|
||||
egc.stipple = image_bitmap_pixmap (f, face->stipple);
|
||||
mask |= GCFillStyle | GCStipple;
|
||||
}
|
||||
#endif
|
||||
face->gc = x_create_gc (f, mask, &xgcv);
|
||||
face->gc = x_create_gc (f, mask, &egc);
|
||||
if (face->font)
|
||||
font_prepare_for_face (f, face);
|
||||
unblock_input ();
|
||||
|
|
|
|||
Loading…
Reference in a new issue