...
 
Commits (11)
  • Alexander Gramiak's avatar
    Introduce Emacs_Color struct and typedef · 187bb8a2
    Alexander Gramiak authored
    This avoids clashing with the XColor struct from X.
    
    * src/dispextern [HAVE_X_WINDOWS]: Define Emacs_Color alias.
    [!HAVE_X_WINDOWS]: Rename XColor compatibility struct to
    Emacs_Color. Remove unused fields.
    
    * src/gtkutil.c:
    * src/gtkutil.h:
    * src/image.c:
    * src/nsterm.h:
    * src/nsterm.m:
    * src/termhooks.h:
    * src/w32fns.c:
    * src/w32term.c:
    * src/w32term.h:
    * src/xfaces.c:
    * src/xfns.c:
    * src/xterm.h: Use Emacs_Color over XColor outside of X-specific
    sections.
    187bb8a2
  • Alexander Gramiak's avatar
    Introduce Emacs_Cursor typedef · 8e8290d9
    Alexander Gramiak authored
    * src/dispextern.h [HAVE_X_WINDOWS]: Define Emacs_Cursor alias. Move
    the No_Cursor definition from xterm.h.
    (redisplay_interface): Use Emacs_Cursor over Cursor.
    
    * src/nsgui.h:
    * src/nsterm.h:
    * src/nsterm.m:
    * src/w32gui.h:
    * src/w32term.c:
    * src/xdisp.c:
    * src/xterm.c (x_define_frame_cursor): Use Emacs_Cursor over Cursor.
    8e8290d9
  • Alexander Gramiak's avatar
    Introduce Emacs_Pixmap typedef · 38a52171
    Alexander Gramiak authored
    * src/dispextern.h [HAVE_X_WINDOWS]: Alias Emacs_Pixmap to Pixmap.
    (image, x_kill_gs_process): Use Emacs_Pixmap over Pixmap.
    
    * src/image.c:
    
    * src/nsgui.h:
    * src/nsterm.m:
    * src/termhooks.h:
    * src/w32gui.h:
    * src/w32term.c:
    * src/w32term.h:
    * src/xterm.c (x_free_pixmap): Use Emacs_Pixmap over Pixmap.
    
    * src/w32gui.h: Remove unused typedef Bitmap.
    38a52171
  • Alexander Gramiak's avatar
    Introduce Emacs_Rectangle struct and typedef · 668ee430
    Alexander Gramiak authored
    * src/dispextern.h [HAVE_X_WINDOWS]: Alias Emacs_Rectangle to
    XRectangle.
    [!HAVE_X_WINDOWS]: Define Emacs_Rectangle struct.
    Use Emacs_Rectangle over XRectangle.
    
    * src/frame.h (MonitorInfo):
    * src/msdos.h:
    * src/w32term.c:
    * src/xdisp.c: Use Emacs_Rectangle over XRectangle.
    
    * src/nsgui.h:
    * src/w32gui.h: Remove old XRectangle structs.
    
    * src/xdisp.c:
    * src/nsgui.h:
    * src/w32gui.h: Rename CONVERT_FROM_XRECT and CONVERT_TO_XRECT to
    CONVERT_FROM_EMACS_RECT and CONVERT_TO_EMACS_RECT respectively.
    668ee430
  • Alexander Gramiak's avatar
    Introduce Emacs_GC struct and typedef · 09c65d6c
    Alexander Gramiak authored
    * 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.
    09c65d6c
  • Alexander Gramiak's avatar
    Replace XChar2b with unsigned short in all font backends · c0f62cb9
    Alexander Gramiak authored
    The xfont backend using XChar2b in its API doesn't mean that we should
    use it everywhere else.
    
    * src/dispextern.h (glyph_string):
    * src/ftcrfont.c (ftcrfont_draw):
    * src/ftxfont.c (ftxfont_draw):
    * src/w32term.c (w32_draw_glyphless_glyph_string_foreground):
    * src/xdisp.c (init_glyph_string, get_char_face_and_encoding)
    (get_glyph_face_and_encoding, get_char_glyph_code)
    (fill_gstring_glyph_string, fill_stretch_glyph_string)
    (normal_char_ascent_descent, gui_get_glyph_overhangs)
    (compute_overhangs_and_x, gui_produce_glyphs):
    * src/xfont.c (xfont_get_pcm, xfont_chars_supported, xfont_open)
    (xfont_encode_char, xfont_text_extents, xfont_draw)
    * src/xftfont.c (xftfont_draw):
    * src/xterm.c (x_compute_glyph_string_overhangs)
    (x_draw_glyphless_glyph_string_foreground): Use unsigned short over XChar2b.
    
    * src/nsgui.h:
    * src/w32gui.h:
    * src/xterm.h: Remove XChar2b, STORE_XCHAR2B, XCHAR2B_BYTE1, and
    XCHAR2B_BYTE2 typedefs and macros.
    
    * src/font.h (font_driver):
    (ftfont_text_extents)
    * src/ftcrfont.c (ftcrfont_text_extents):
    * src/ftfont.c (ftfont_text_extents):
    * src/macfont.m (macfont_text_extents):
    * src/nsfont.m (nsfont_text_extents):
    * src/w32font.h (w32_font_text_extents):
    * src/font.c (xfont_text_extents):
    * src/xftfont.c (xftfont_text_extents): Make code parameter const.
    c0f62cb9
  • Alexander Gramiak's avatar
    Introduce Emacs_Pix_Container and Emacs_Pix_Context typedefs · 94b5d24a
    Alexander Gramiak authored
    Emacs_Pix_Container is a pointer to a struct representing pixmap data
    on the backend.  Emacs_Pix_Context is the context for the
    bitmap/pixmap on the backend.  Only w32 currently makes this
    distinction; they are otherwise the same type.
    
    * src/dispextern.h: Remove XImagePtr in favor of
    using XImage* directly. Rename XImagePtr_or_DC to Emacs_Pix_Context.
    [HAVE_X_WINDOWS] Alias Emacs_Pix_Container and
    Emacs_Pix_Context to XImage*.
    [HAVE_NS] Alias Emacs_Pix_Container and Emacs_Pix_Context to trivial
    Emacs_Pixmap definition.
    [HAVE_NTGUI]: Alias Emacs_Pix_Container to XImage* and
    Emacs_Pix_Context to HDC.
    
    * src/dispextern.h:
    * src/image.c: Use Emacs_Pix_Container over XImagePtr and
    Emacs_Pix_Context over XImagePtr_or_DC.
    94b5d24a
  • Alexander Gramiak's avatar
    19b55275
  • Alexander Gramiak's avatar
    33354a3a
  • Alexander Gramiak's avatar
  • Alexander Gramiak's avatar
    fixup! Introduce Emacs_Cursor typedef · 81981fd2
    Alexander Gramiak authored
    81981fd2
......@@ -34,16 +34,45 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
#ifdef HAVE_XRENDER
# include <X11/extensions/Xrender.h>
#endif
typedef XColor Emacs_Color;
typedef Cursor Emacs_Cursor;
#define No_Cursor (None)
typedef Pixmap Emacs_Pixmap;
typedef XRectangle Emacs_Rectangle;
typedef XGCValues Emacs_GC;
#else /* !HAVE_X_WINDOWS */
/* X-related stuff used by non-X gui code. */
/* XColor-like struct used by non-X code. */
typedef struct {
typedef struct
{
unsigned long pixel;
unsigned short red, green, blue;
char flags;
char pad;
} XColor;
} Emacs_Color;
/* Accommodate X's usage of None as a null resource ID. */
#define No_Cursor (NULL)
/* XRectangle-like struct used by non-X GUI code. */
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 */
......@@ -63,16 +92,16 @@ xstrcasecmp (char const *a, char const *b)
#ifdef HAVE_X_WINDOWS
#include <X11/Xresource.h> /* for XrmDatabase */
typedef struct x_display_info Display_Info;
typedef XImage * XImagePtr;
typedef XImagePtr XImagePtr_or_DC;
typedef XImage *Emacs_Pix_Container;
typedef XImage *Emacs_Pix_Context;
#define NativeRectangle XRectangle
#endif
#ifdef HAVE_NTGUI
#include "w32gui.h"
typedef struct w32_display_info Display_Info;
typedef XImage *XImagePtr;
typedef HDC XImagePtr_or_DC;
typedef XImage *Emacs_Pix_Container;
typedef HDC Emacs_Pix_Context;
#endif
#ifdef HAVE_NS
......@@ -80,8 +109,8 @@ typedef HDC XImagePtr_or_DC;
#define FACE_COLOR_TO_PIXEL(face_color, frame) ns_color_index_to_rgba(face_color, frame)
/* Following typedef needed to accommodate the MSDOS port, believe it or not. */
typedef struct ns_display_info Display_Info;
typedef Pixmap XImagePtr;
typedef XImagePtr XImagePtr_or_DC;
typedef Emacs_Pixmap Emacs_Pix_Container;
typedef Emacs_Pixmap Emacs_Pix_Context;
#else
#define FACE_COLOR_TO_PIXEL(face_color, frame) face_color
#endif
......@@ -92,8 +121,7 @@ typedef XImagePtr XImagePtr_or_DC;
#endif
#ifndef HAVE_WINDOW_SYSTEM
typedef int Cursor;
#define No_Cursor (0)
typedef void *Emacs_Cursor;
#endif
#ifndef NativeRectangle
......@@ -1040,7 +1068,7 @@ struct glyph_row
#ifdef HAVE_WINDOW_SYSTEM
/* Non-NULL means the current clipping area. This is temporarily
set while exposing a region. Coordinates are frame-relative. */
XRectangle *clip;
const Emacs_Rectangle *clip;
#endif
};
......@@ -1289,7 +1317,7 @@ struct glyph_string
enum glyph_row_area area;
/* Characters to be drawn, and number of characters. */
XChar2b *char2b;
unsigned short *char2b;
int nchars;
/* A face-override for drawing cursors, mouse face and similar. */
......@@ -1350,7 +1378,7 @@ struct glyph_string
GC gc;
#endif
#if defined (HAVE_NTGUI)
XGCValues *gc;
Emacs_GC *gc;
HDC hdc;
#endif
......@@ -1592,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;
......@@ -2888,7 +2919,7 @@ struct redisplay_interface
void (*draw_glyph_string) (struct glyph_string *s);
/* Define cursor CURSOR on frame F. */
void (*define_frame_cursor) (struct frame *f, Cursor cursor);
void (*define_frame_cursor) (struct frame *f, Emacs_Cursor cursor);
/* Clear the area at (X,Y,WIDTH,HEIGHT) of frame F. */
void (*clear_frame_area) (struct frame *f, int x, int y,
......@@ -2955,7 +2986,7 @@ struct image
struct timespec timestamp;
/* Pixmaps of the image. */
Pixmap pixmap, mask;
Emacs_Pixmap pixmap, mask;
#ifdef USE_CAIRO
void *cr_data;
......@@ -2965,7 +2996,7 @@ struct image
Non-NULL means it and its Pixmap counterpart may be out of sync
and the latter is outdated. NULL means the X image has been
synchronized to Pixmap. */
XImagePtr ximg, mask_img;
XImage* ximg, *mask_img;
# ifdef HAVE_NATIVE_SCALING
/* Picture versions of pixmap and mask for compositing. */
......@@ -3311,7 +3342,9 @@ extern void handle_tool_bar_click (struct frame *,
int, int, bool, int);
extern void expose_frame (struct frame *, int, int, int, int);
extern bool gui_intersect_rectangles (XRectangle *, XRectangle *, XRectangle *);
extern bool gui_intersect_rectangles (const Emacs_Rectangle *,
const Emacs_Rectangle *,
Emacs_Rectangle *);
#endif /* HAVE_WINDOW_SYSTEM */
extern void note_mouse_highlight (struct frame *, int, int);
......@@ -3366,7 +3399,7 @@ extern void x_create_bitmap_mask (struct frame *, ptrdiff_t);
#endif
extern Lisp_Object image_find_image_file (Lisp_Object);
void x_kill_gs_process (Pixmap, struct frame *);
void x_kill_gs_process (Emacs_Pixmap, struct frame *);
struct image_cache *make_image_cache (void);
void free_image_cache (struct frame *);
void clear_image_caches (Lisp_Object);
......@@ -3384,9 +3417,9 @@ ptrdiff_t lookup_image (struct frame *, Lisp_Object);
#endif
RGB_PIXEL_COLOR image_background (struct image *, struct frame *,
XImagePtr_or_DC ximg);
Emacs_Pix_Context img);
int image_background_transparent (struct image *, struct frame *,
XImagePtr_or_DC mask);
Emacs_Pix_Context mask);
int image_ascent (struct image *, struct face *, struct glyph_slice *);
......@@ -3410,8 +3443,8 @@ void x_free_colors (struct frame *, unsigned long *, int);
void update_face_from_frame_parameter (struct frame *, Lisp_Object,
Lisp_Object);
extern bool tty_defined_color (struct frame *f, const char *, XColor *, bool,
bool);
extern bool tty_defined_color (struct frame *, const char *, Emacs_Color *,
bool, bool);
Lisp_Object tty_color_name (struct frame *, int);
void clear_face_cache (bool);
......
......@@ -647,7 +647,7 @@ struct font_driver
the font FONT and the sequence of glyph codes CODE, and store the
result in METRICS. */
void (*text_extents) (struct font *font,
unsigned *code, int nglyphs,
const unsigned *code, int nglyphs,
struct font_metrics *metrics);
#ifdef HAVE_WINDOW_SYSTEM
......@@ -894,7 +894,7 @@ extern Lisp_Object ftfont_shape (Lisp_Object);
extern unsigned ftfont_encode_char (struct font *, int);
extern void ftfont_close (struct font *);
extern void ftfont_filter_properties (Lisp_Object, Lisp_Object);
extern void ftfont_text_extents (struct font *, unsigned *, int,
extern void ftfont_text_extents (struct font *, const unsigned *, int,
struct font_metrics *);
extern void syms_of_ftfont (void);
#endif /* HAVE_FREETYPE */
......
......@@ -1626,7 +1626,7 @@ flush_frame (struct frame *f)
#ifdef HAVE_WINDOW_SYSTEM
struct MonitorInfo {
XRectangle geom, work;
Emacs_Rectangle geom, work;
int mm_width, mm_height;
char *name;
};
......
......@@ -232,7 +232,7 @@ ftcrfont_close (struct font *font)
static void
ftcrfont_text_extents (struct font *font,
unsigned *code,
const unsigned *code,
int nglyphs,
struct font_metrics *metrics)
{
......@@ -331,13 +331,12 @@ ftcrfont_draw (struct glyph_string *s,
glyphs = alloca (sizeof (cairo_glyph_t) * len);
for (i = 0; i < len; i++)
{
unsigned code = ((XCHAR2B_BYTE1 (s->char2b + from + i) << 8)
| XCHAR2B_BYTE2 (s->char2b + from + i));
glyphs[i].index = code;
glyphs[i].index = s->char2b[from + i];
glyphs[i].x = x;
glyphs[i].y = y;
x += (s->padding_p ? 1 : ftcrfont_glyph_extents (s->font, code, NULL));
x += (s->padding_p ? 1 : ftcrfont_glyph_extents (s->font,
glyphs[i].index,
NULL));
}
x_set_cr_source_with_gc_foreground (f, s->gc);
......
......@@ -1336,7 +1336,7 @@ ftfont_encode_char (struct font *font, int c)
}
void
ftfont_text_extents (struct font *font, unsigned int *code,
ftfont_text_extents (struct font *font, const unsigned int *code,
int nglyphs, struct font_metrics *metrics)
{
struct font_info *ftfont_info = (struct font_info *) font;
......
......@@ -252,7 +252,7 @@ ftxfont_draw (struct glyph_string *s, int from, int to, int x, int y,
struct font *font = s->font;
XPoint p[0x700];
int n[7];
unsigned *code;
unsigned short *code = s->char2b + from;
int len = to - from;
int i;
GC *gcs;
......@@ -260,14 +260,9 @@ ftxfont_draw (struct glyph_string *s, int from, int to, int x, int y,
n[0] = n[1] = n[2] = n[3] = n[4] = n[5] = n[6] = 0;
USE_SAFE_ALLOCA;
SAFE_NALLOCA (code, 1, len);
block_input ();
if (with_background)
ftxfont_draw_background (f, font, s->gc, x, y, s->width);
for (i = 0; i < len; i++)
code[i] = ((XCHAR2B_BYTE1 (s->char2b + from + i) << 8)
| XCHAR2B_BYTE2 (s->char2b + from + i));
if (face->gc == s->gc)
{
......@@ -312,7 +307,6 @@ ftxfont_draw (struct glyph_string *s, int from, int to, int x, int y,
}
unblock_input ();
SAFE_FREE ();
return len;
}
......
......@@ -520,7 +520,7 @@ get_utf8_string (const char *str)
bool
xg_check_special_colors (struct frame *f,
const char *color_name,
XColor *color)
Emacs_Color *color)
{
bool success_p = 0;
bool get_bg = strcmp ("gtk_selection_bg_color", color_name) == 0;
......
......@@ -166,7 +166,7 @@ extern void xg_free_frame_widgets (struct frame *f);
extern void xg_set_background_color (struct frame *f, unsigned long bg);
extern bool xg_check_special_colors (struct frame *f,
const char *color_name,
XColor *color);
Emacs_Color *color);
extern void xg_set_frame_icon (struct frame *f,
Pixmap icon_pixmap,
......
This diff is collapsed.
......@@ -1639,7 +1639,7 @@ static CGGlyph macfont_get_glyph_for_cid (struct font *font,
static void macfont_close (struct font *);
static int macfont_has_char (Lisp_Object, int);
static unsigned macfont_encode_char (struct font *, int);
static void macfont_text_extents (struct font *, unsigned int *, int,
static void macfont_text_extents (struct font *, const unsigned int *, int,
struct font_metrics *);
static int macfont_draw (struct glyph_string *, int, int, int, int, bool);
static Lisp_Object macfont_shape (Lisp_Object);
......@@ -2735,7 +2735,7 @@ So we use CTFontDescriptorCreateMatchingFontDescriptor (no
}
static void
macfont_text_extents (struct font *font, unsigned int *code, int nglyphs,
macfont_text_extents (struct font *font, const unsigned int *code, int nglyphs,
struct font_metrics *metrics)
{
int width, i;
......
......@@ -86,7 +86,6 @@ typedef int GC;
typedef int Pixmap;
typedef int Display;
typedef int Window;
typedef int XRectangle;
#define PIX_TYPE unsigned long
#define XDISPLAY
......
......@@ -945,7 +945,7 @@ when setting family in ns_spec_to_descriptor(). */
of METRICS. The glyphs are specified by their glyph codes in
CODE (length NGLYPHS). */
static void
nsfont_text_extents (struct font *font, unsigned int *code,
nsfont_text_extents (struct font *font, const unsigned int *code,
int nglyphs, struct font_metrics *metrics)
{
struct nsfont_info *font_info = (struct nsfont_info *)font;
......
......@@ -58,72 +58,23 @@ typedef struct _XCharStruct
int descent;
} XCharStruct;
/* Fake structure from Xlib.h to represent two-byte characters. */
#ifndef __OBJC__
typedef unsigned short unichar;
#endif
typedef unichar XChar2b;
#define STORE_XCHAR2B(chp, b1, b2) \
(*(chp) = ((XChar2b)((((b1) & 0x00ff) << 8) | ((b2) & 0x00ff))))
#define XCHAR2B_BYTE1(chp) \
((*(chp) & 0xff00) >> 8)
#define XCHAR2B_BYTE2(chp) \
(*(chp) & 0x00ff)
/* 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;
typedef id Emacs_Pixmap;
#else
void *font;
typedef void *Emacs_Pixmap;
#endif
} XGCValues;
typedef XGCValues * GC;
#define GCForeground 0x01
#define GCBackground 0x02
#define GCFont 0x03
#ifdef __OBJC__
typedef id Pixmap;
typedef NSCursor *Emacs_Cursor;
#else
typedef void *Pixmap;
typedef void *Emacs_Cursor;
#endif
#ifdef __OBJC__
typedef NSCursor * Cursor;
#else
typedef void *Cursor;
#endif
#define No_Cursor (0)
#ifdef __OBJC__
typedef NSColor * Color;
#else
typedef void * Color;
#endif
typedef int Window;
/* Some sort of attempt to normalize rectangle handling. Seems a bit
much for what is accomplished. */
typedef struct {
int x, y;
unsigned width, height;
} XRectangle;
#ifndef __OBJC__
#if defined (__LP64__) && __LP64__
typedef double CGFloat;
......@@ -137,13 +88,13 @@ typedef struct _NSRect { NSPoint origin; NSSize size; } NSRect;
#define NativeRectangle NSRect
#define CONVERT_TO_XRECT(xr, nr) \
#define CONVERT_TO_EMACS_RECT(xr, nr) \
((xr).x = (nr).origin.x, \
(xr).y = (nr).origin.y, \
(xr).width = (nr).size.width, \
(xr).height = (nr).size.height)
#define CONVERT_FROM_XRECT(xr, nr) \
#define CONVERT_FROM_EMACS_RECT(xr, nr) \
((nr).origin.x = (xr).x, \
(nr).origin.y = (xr).y, \
(nr).size.width = (xr).width, \
......
......@@ -872,10 +872,10 @@ struct ns_display_info
Lisp_Object rdb;
/* The cursor to use for vertical scroll bars. */
Cursor vertical_scroll_bar_cursor;
Emacs_Cursor vertical_scroll_bar_cursor;
/* The cursor to use for horizontal scroll bars. */
Cursor horizontal_scroll_bar_cursor;
Emacs_Cursor horizontal_scroll_bar_cursor;
/* Information about the range of text currently shown in
mouse-face. */
......@@ -931,24 +931,24 @@ struct ns_output
#endif
/* NSCursors are initialized in initFrameFromEmacs. */
Cursor text_cursor;
Cursor nontext_cursor;
Cursor modeline_cursor;
Cursor hand_cursor;
Cursor hourglass_cursor;
Cursor horizontal_drag_cursor;
Cursor vertical_drag_cursor;
Cursor left_edge_cursor;
Cursor top_left_corner_cursor;
Cursor top_edge_cursor;
Cursor top_right_corner_cursor;
Cursor right_edge_cursor;
Cursor bottom_right_corner_cursor;
Cursor bottom_edge_cursor;
Cursor bottom_left_corner_cursor;
Emacs_Cursor text_cursor;
Emacs_Cursor nontext_cursor;
Emacs_Cursor modeline_cursor;
Emacs_Cursor hand_cursor;
Emacs_Cursor hourglass_cursor;
Emacs_Cursor horizontal_drag_cursor;
Emacs_Cursor vertical_drag_cursor;
Emacs_Cursor left_edge_cursor;
Emacs_Cursor top_left_corner_cursor;
Emacs_Cursor top_edge_cursor;
Emacs_Cursor top_right_corner_cursor;
Emacs_Cursor right_edge_cursor;
Emacs_Cursor bottom_right_corner_cursor;
Emacs_Cursor bottom_edge_cursor;
Emacs_Cursor bottom_left_corner_cursor;
/* NS-specific */
Cursor current_pointer;
Emacs_Cursor current_pointer;
/* lord knows why Emacs needs to know about our Window ids.. */
Window window_desc, parent_desc;
......@@ -1134,10 +1134,10 @@ extern void ns_set_doc_edited (void);
extern bool
ns_defined_color (struct frame *f,
const char *name,
XColor *color_def, bool alloc,
Emacs_Color *color_def, bool alloc,
bool makeIndex);
extern void
ns_query_color (void *col, XColor *color_def, bool setPixel);
ns_query_color (void *col, Emacs_Color *color_def, bool setPixel);
#ifdef __OBJC__
extern int ns_lisp_to_color (Lisp_Object color, NSColor **col);
......
......@@ -2327,7 +2327,7 @@ so some key presses (TAB) are swallowed by the system. */
}
void
ns_query_color(void *col, XColor *color_def, bool setPixel)
ns_query_color(void *col, Emacs_Color *color_def, bool setPixel)
/* --------------------------------------------------------------------------
Get ARGB values out of NSColor col and put them into color_def.
If setPixel, set the pixel to a concatenated version.
......@@ -2350,7 +2350,7 @@ so some key presses (TAB) are swallowed by the system. */
bool
ns_defined_color (struct frame *f,
const char *name,
XColor *color_def,
Emacs_Color *color_def,
bool alloc,
bool makeIndex)
/* --------------------------------------------------------------------------
......@@ -2378,7 +2378,7 @@ so some key presses (TAB) are swallowed by the system. */
}
static void
ns_query_frame_background_color (struct frame *f, XColor *bgcolor)
ns_query_frame_background_color (struct frame *f, Emacs_Color *bgcolor)
/* --------------------------------------------------------------------------
External (hook): Store F's background color into *BGCOLOR
-------------------------------------------------------------------------- */
......@@ -2576,7 +2576,7 @@ so some key presses (TAB) are swallowed by the system. */
static void
ns_define_frame_cursor (struct frame *f, Cursor cursor)
ns_define_frame_cursor (struct frame *f, Emacs_Cursor cursor)
/* --------------------------------------------------------------------------
External (RIF): set frame mouse pointer type.
-------------------------------------------------------------------------- */
......@@ -4972,7 +4972,7 @@ in certain situations (rapid incoming events).
========================================================================== */
static void
ns_free_pixmap (struct frame *_f, Pixmap pixmap)
ns_free_pixmap (struct frame *_f, Emacs_Pixmap pixmap)
{
ns_release_object (pixmap);
}
......
......@@ -496,7 +496,7 @@ struct terminal
If MAKEINDEX (on NS), set COLOR_DEF pixel to ARGB. */
bool (*defined_color_hook) (struct frame *f, const char *color_name,
XColor *color_def,
Emacs_Color *color_def,
bool alloc,
bool makeIndex);
......@@ -515,13 +515,13 @@ struct terminal
/* This hook is called to store the frame's background color into
BGCOLOR. */
void (*query_frame_background_color) (struct frame *f, XColor *bgcolor);
void (*query_frame_background_color) (struct frame *f, Emacs_Color *bgcolor);
#if defined (HAVE_X_WINDOWS) || defined (HAVE_NTGUI)
/* On frame F, translate pixel colors to RGB values for the NCOLORS
colors in COLORS. Use cached information, if available. */
void (*query_colors) (struct frame *f, XColor *colors, int ncolors);
void (*query_colors) (struct frame *f, Emacs_Color *colors, int ncolors);
#endif
/* Return the current position of the mouse.
......@@ -744,7 +744,7 @@ struct terminal
/* Image hooks */
#ifdef HAVE_WINDOW_SYSTEM
/* Free the pixmap PIXMAP on F. */
void (*free_pixmap) (struct frame *f, Pixmap pixmap);
void (*free_pixmap) (struct frame *f, Emacs_Pixmap pixmap);
#endif
......
......@@ -1174,7 +1174,7 @@ gamma_correct (struct frame *f, COLORREF *color)
If ALLOC is nonzero, allocate a new colormap cell. */
bool
w32_defined_color (struct frame *f, const char *color, XColor *color_def,
w32_defined_color (struct frame *f, const char *color, Emacs_Color *color_def,
bool alloc_p, bool _makeIndex)
{
register Lisp_Object tem;
......@@ -1248,7 +1248,7 @@ w32_defined_color (struct frame *f, const char *color, XColor *color_def,
static int
w32_decode_color (struct frame *f, Lisp_Object arg, int def)
{
XColor cdef;
Emacs_Color cdef;
CHECK_STRING (arg);
......@@ -2247,15 +2247,15 @@ w32_set_z_group (struct frame *f, Lisp_Object new_value, Lisp_Object old_value)
/* Subroutines for creating a frame. */
Cursor w32_load_cursor (LPCTSTR);
HCURSOR w32_load_cursor (LPCTSTR);
Cursor
HCURSOR
w32_load_cursor (LPCTSTR name)
{
/* Try first to load cursor from application resource. */
Cursor cursor = LoadImage ((HINSTANCE) GetModuleHandle (NULL),
name, IMAGE_CURSOR, 0, 0,
LR_DEFAULTCOLOR | LR_DEFAULTSIZE | LR_SHARED);
HCURSOR cursor = LoadImage ((HINSTANCE) GetModuleHandle (NULL),
name, IMAGE_CURSOR, 0, 0,
LR_DEFAULTCOLOR | LR_DEFAULTSIZE | LR_SHARED);
if (!cursor)
{
/* Then try to load a shared predefined cursor. */
......@@ -5217,7 +5217,7 @@ w32_wnd_proc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
case WM_EMACS_SETCURSOR:
{
Cursor cursor = (Cursor) wParam;
HCURSOR cursor = (HCURSOR) wParam;
f = w32_window_to_frame (dpyinfo, hwnd);
if (f && cursor)
{
......@@ -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. */
......@@ -6100,7 +6097,7 @@ DEFUN ("xw-color-defined-p", Fxw_color_defined_p, Sxw_color_defined_p, 1, 2, 0,
doc: /* SKIP: real doc in xfns.c. */)
(Lisp_Object color, Lisp_Object frame)
{
XColor foo;
Emacs_Color foo;
struct frame *f = decode_window_system_frame (frame);
CHECK_STRING (color);
......@@ -6115,7 +6112,7 @@ DEFUN ("xw-color-values", Fxw_color_values, Sxw_color_values, 1, 2, 0,
doc: /* SKIP: real doc in xfns.c. */)
(Lisp_Object color, Lisp_Object frame)
{
XColor foo;
Emacs_Color foo;
struct frame *f = decode_window_system_frame (frame);
CHECK_STRING (color);
......
......@@ -433,7 +433,7 @@ w32font_encode_char (struct font *font, int c)
CODE (length NGLYPHS). Apparently metrics can be NULL, in this
case just return the overall width. */
void
w32font_text_extents (struct font *font, unsigned *code,
w32font_text_extents (struct font *font, const unsigned *code,
int nglyphs, struct font_metrics *metrics)
{
int i;
......
......@@ -74,7 +74,7 @@ int w32font_open_internal (struct frame *f, Lisp_Object font_entity,
int pixel_size, Lisp_Object font_object);
void w32font_close (struct font *font);
int w32font_has_char (Lisp_Object entity, int c);
void w32font_text_extents (struct font *font, unsigned *code, int nglyphs,
void w32font_text_extents (struct font *font, const unsigned *code, int nglyphs,
struct font_metrics *metrics);
int w32font_draw (struct glyph_string *s, int from, int to,
int x, int y, bool with_background);
......
......@@ -27,41 +27,11 @@ 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 Pixmap;
typedef HBITMAP Bitmap;
typedef HBITMAP Emacs_Pixmap;
typedef XGCValues * GC;
typedef COLORREF Color;
typedef HWND Window;
typedef HDC Display; /* HDC so it doesn't conflict with xpm lib. */
typedef HCURSOR Cursor;
#define No_Cursor (0)
#define XChar2b wchar_t
/* Dealing with bits of wchar_t as if they were an XChar2b. */
#define STORE_XCHAR2B(chp, byte1, byte2) \
((*(chp)) = ((XChar2b)((((byte1) & 0x00ff) << 8) | ((byte2) & 0x00ff))))
#define XCHAR2B_BYTE1(chp) \
(((*(chp)) & 0xff00) >> 8)
#define XCHAR2B_BYTE2(chp) \
((*(chp)) & 0x00ff)
typedef HCURSOR Emacs_Cursor;
/* Windows equivalent of XImage. */
typedef struct _XImage
......@@ -110,20 +80,15 @@ extern HINSTANCE hinst;
#define PBaseSize (1L << 8) /* program specified base for incrementing */
#define PWinGravity (1L << 9) /* program specified window gravity */
typedef struct {
int x, y;
unsigned width, height;
} XRectangle;
#define NativeRectangle RECT
#define CONVERT_TO_XRECT(xr,nr) \
#define CONVERT_TO_EMACS_RECT(xr,nr) \
((xr).x = (nr).left, \
(xr).y = (nr).top, \
(xr).width = ((nr).right - (nr).left), \
(xr).height = ((nr).bottom - (nr).top))
#define CONVERT_FROM_XRECT(xr,nr) \
#define CONVERT_FROM_EMACS_RECT(xr,nr) \
((nr).left = (xr).x, \
(nr).top = (xr).y, \
(nr).right = ((xr).x + (xr).width), \
......
This diff is collapsed.
......@@ -56,7 +56,7 @@ extern BOOL bUseDflt;
struct w32_bitmap_record
{
Pixmap pixmap;
Emacs_Pixmap pixmap;
char *file;
HINSTANCE hinst; /* Used to load the file */
int refcount;
......@@ -114,10 +114,10 @@ struct w32_display_info
Window root_window;
/* The cursor to use for vertical scroll bars. */
Cursor vertical_scroll_bar_cursor;
HCURSOR vertical_scroll_bar_cursor;
/* The cursor to use for horizontal scroll bars. */
Cursor horizontal_scroll_bar_cursor;
HCURSOR horizontal_scroll_bar_cursor;
/* Resource data base */
const char *rdb;
......@@ -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. */
......@@ -241,7 +241,7 @@ extern void w32_set_scroll_bar_default_height (struct frame *);
extern struct w32_display_info *w32_term_init (Lisp_Object,
char *, char *);
extern bool w32_defined_color (struct frame *, const char *, XColor *,
extern bool w32_defined_color (struct frame *, const char *, Emacs_Color *,
bool, bool);
extern int w32_display_pixel_height (struct w32_display_info *);
extern int w32_display_pixel_width (struct w32_display_info *);
......@@ -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
......@@ -348,27 +348,27 @@ struct w32_output
COLORREF scroll_bar_background_pixel;
/* Descriptor for the cursor in use for this window. */
Cursor text_cursor;
Cursor nontext_cursor;
Cursor modeline_cursor;
Cursor hand_cursor;
Cursor hourglass_cursor;
Cursor horizontal_drag_cursor;
Cursor vertical_drag_cursor;
Cursor left_edge_cursor;
Cursor top_left_corner_cursor;
Cursor top_edge_cursor;
Cursor top_right_corner_cursor;
Cursor right_edge_cursor;
Cursor bottom_right_corner_cursor;
Cursor bottom_edge_cursor;
Cursor bottom_left_corner_cursor;
HCURSOR text_cursor;
HCURSOR nontext_cursor;
HCURSOR modeline_cursor;
HCURSOR hand_cursor;
HCURSOR hourglass_cursor;
HCURSOR horizontal_drag_cursor;
HCURSOR vertical_drag_cursor;
HCURSOR left_edge_cursor;
HCURSOR top_left_corner_cursor;
HCURSOR top_edge_cursor;
HCURSOR top_right_corner_cursor;
HCURSOR right_edge_cursor;
HCURSOR bottom_right_corner_cursor;
HCURSOR bottom_edge_cursor;
HCURSOR bottom_left_corner_cursor;
/* Non-zero means hourglass cursor is currently displayed. */
unsigned hourglass_p : 1;
/* Non-hourglass cursor that is currently active. */
Cursor current_cursor;
HCURSOR current_cursor;
DWORD dwStyle;
......@@ -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;
......@@ -721,7 +721,7 @@ extern void complete_deferred_msg (HWND hwnd, UINT msg, LRESULT result);
extern BOOL parse_button (int, int, int *, int *);
extern void w32_sys_ring_bell (struct frame *f);
extern void w32_query_color (struct frame *, XColor *);
extern void w32_query_color (struct frame *, Emacs_Color *);
extern void w32_delete_display (struct w32_display_info *dpyinfo);
#define FILE_NOTIFICATIONS_SIZE 16384
......@@ -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) (
......
This diff is collapsed.
......@@ -348,7 +348,7 @@ static void free_face_cache (struct face_cache *);
static bool merge_face_ref (struct window *w,
struct frame *, Lisp_Object, Lisp_Object *,
bool, struct named_merge_point *);
static int color_distance (XColor *x, XColor *y);
static int color_distance (Emacs_Color *x, Emacs_Color *y);
#ifdef HAVE_WINDOW_SYSTEM
static void set_font_frame_param (Lisp_Object, Lisp_Object);
......@@ -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);
}
......@@ -802,7 +802,7 @@ load_pixmap (struct frame *f, Lisp_Object name)
/***********************************************************************
X Colors
Color Handling
***********************************************************************/
/* Parse RGB_LIST, and fill in the RGB fields of COLOR.
......@@ -810,7 +810,7 @@ load_pixmap (struct frame *f, Lisp_Object name)
Return true iff RGB_LIST is OK. */
static bool
parse_rgb_list (Lisp_Object rgb_list, XColor *color)
parse_rgb_list (Lisp_Object rgb_list, Emacs_Color *color)
{
#define PARSE_RGB_LIST_FIELD(field) \
if (CONSP (rgb_list) && FIXNUMP (XCAR (rgb_list))) \
......@@ -835,8 +835,8 @@ parse_rgb_list (Lisp_Object rgb_list, XColor *color)
returned in it. */
static bool
tty_lookup_color (struct frame *f, Lisp_Object color, XColor *tty_color,
XColor *std_color)
tty_lookup_color (struct frame *f, Lisp_Object color, Emacs_Color *tty_color,
Emacs_Color *std_color)
{
Lisp_Object frame, color_desc;
......@@ -897,7 +897,7 @@ tty_lookup_color (struct frame *f, Lisp_Object color, XColor *tty_color,
bool
tty_defined_color (struct frame *f, const char *color_name,
XColor *color_def, bool alloc, bool _makeIndex)
Emacs_Color *color_def, bool alloc, bool _makeIndex)
{
bool status = true;
......@@ -965,7 +965,7 @@ tty_color_name (struct frame *f, int idx)
static bool
face_color_gray_p (struct frame *f, const char *color_name)
{
XColor color;
Emacs_Color color;
bool gray_p;
if (FRAME_TERMINAL (f)->defined_color_hook
......@@ -994,7 +994,7 @@ face_color_supported_p (struct frame *f, const char *color_name,
bool background_p)
{
Lisp_Object frame;
XColor not_used;
Emacs_Color not_used;
XSETFRAME (frame, f);
return
......@@ -1043,7 +1043,7 @@ COLOR must be a valid color name. */)
static unsigned long
load_color2 (struct frame *f, struct face *face, Lisp_Object name,
enum lface_attribute_index target_index, XColor *color)
enum lface_attribute_index target_index, Emacs_Color *color)
{
eassert (STRINGP (name));
eassert (target_index == LFACE_FOREGROUND_INDEX
......@@ -1117,7 +1117,7 @@ unsigned long
load_color (struct frame *f, struct face *face, Lisp_Object name,
enum lface_attribute_index target_index)
{
XColor color;
Emacs_Color color;
return load_color2 (f, face, name, target_index, &color);
}
......@@ -1134,7 +1134,7 @@ load_face_colors (struct frame *f, struct face *face,
Lisp_Object attrs[LFACE_VECTOR_SIZE])
{
Lisp_Object fg, bg, dfg;
XColor xfg, xbg;
Emacs_Color xfg, xbg;
bg = attrs[LFACE_BACKGROUND_INDEX];
fg = attrs[LFACE_FOREGROUND_INDEX];
......@@ -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 ();
......@@ -4170,7 +4170,7 @@ prepare_face_for_display (struct frame *f, struct face *face)
/* Returns the `distance' between the colors X and Y. */
static int
color_distance (XColor *x, XColor *y)
color_distance (Emacs_Color *x, Emacs_Color *y)
{
/* This formula is from a paper titled `Colour metric' by Thiadmer Riemersma.
Quoting from that paper:
......@@ -4205,7 +4205,7 @@ two lists of the form (RED GREEN BLUE) aforementioned. */)
Lisp_Object metric)
{
struct frame *f = decode_live_frame (frame);
XColor cdef1, cdef2;
Emacs_Color cdef1, cdef2;
if (!(CONSP (color1) && parse_rgb_list (color1, &cdef1))
&& !(STRINGP (color1)
......@@ -4885,8 +4885,8 @@ tty_supports_face_attributes_p (struct frame *f,
{
int weight, slant;
Lisp_Object val, fg, bg;
XColor fg_tty_color, fg_std_color;
XColor bg_tty_color, bg_std_color;
Emacs_Color fg_tty_color, fg_std_color;
Emacs_Color bg_tty_color, bg_std_color;
unsigned test_caps = 0;
Lisp_Object *def_attrs = def_face->lface;
......@@ -4988,7 +4988,7 @@ tty_supports_face_attributes_p (struct frame *f,
else
/* Make sure the color is really different than the default. */
{
XColor def_fg_color;
Emacs_Color def_fg_color;
if (tty_lookup_color (f, def_fg, &def_fg_color, 0)
&& (color_distance (&fg_tty_color, &def_fg_color)
<= TTY_SAME_COLOR_THRESHOLD))
......@@ -5012,7 +5012,7 @@ tty_supports_face_attributes_p (struct frame *f,
else
/* Make sure the color is really different than the default. */
{
XColor def_bg_color;
Emacs_Color def_bg_color;
if (tty_lookup_color (f, def_bg, &def_bg_color, 0)
&& (color_distance (&bg_tty_color, &def_bg_color)
<= TTY_SAME_COLOR_THRESHOLD))
......
......@@ -653,7 +653,7 @@ gamma_correct (struct frame *f, XColor *color)
bool
x_defined_color (struct frame *f, const char *color_name,
XColor *color, bool alloc_p, bool _makeIndex)
Emacs_Color *color, bool alloc_p, bool _makeIndex)
{
bool success_p = false;
Colormap cmap = FRAME_X_COLORMAP (f);
......
......@@ -46,18 +46,20 @@ struct xfont_info
/* Prototypes of support functions. */
static XCharStruct *xfont_get_pcm (XFontStruct *, XChar2b *);
static XCharStruct *xfont_get_pcm (XFontStruct *, unsigned short char2b);
/* Get metrics of character CHAR2B in XFONT. Value is null if CHAR2B
is not contained in the font. */
static XCharStruct *
xfont_get_pcm (XFontStruct *xfont, XChar2b *char2b)
xfont_get_pcm (XFontStruct *xfont, unsigned short char2b)
{
/* The result metric information. */
XCharStruct *pcm = NULL;
const unsigned char byte1 = char2b >> 8;
const unsigned char byte2 = char2b & 0xFF;
eassert (xfont && char2b);
eassert (xfont);
if (xfont->per_char != NULL)
{
......@@ -66,13 +68,13 @@ xfont_get_pcm (XFontStruct *xfont, XChar2b *char2b)
/* min_char_or_byte2 specifies the linear character index
corresponding to the first element of the per_char array,
max_char_or_byte2 is the index of the last character. A
character with non-zero CHAR2B->byte1 is not in the font.
character with non-zero byte1 is not in the font.
A character with byte2 less than min_char_or_byte2 or
greater max_char_or_byte2 is not in the font. */
if (char2b->byte1 == 0
&& char2b->byte2 >= xfont->min_char_or_byte2
&& char2b->byte2 <= xfont->max_char_or_byte2)
pcm = xfont->per_char + char2b->byte2 - xfont->min_char_or_byte2;
if (byte1 == 0
&& byte2 >= xfont->min_char_or_byte2
&& byte2 <= xfont->max_char_or_byte2)
pcm = xfont->per_char + byte2 - xfont->min_char_or_byte2;
}
else
{
......@@ -89,14 +91,14 @@ xfont_get_pcm (XFontStruct *xfont, XChar2b *char2b)
D = max_char_or_byte2 - min_char_or_byte2 + 1
/ = integer division
\ = integer modulus */
if (char2b->byte1 >= xfont->min_byte1
&& char2b->byte1 <= xfont->max_byte1
&& char2b->byte2 >= xfont->min_char_or_byte2
&& char2b->byte2 <= xfont->max_char_or_byte2)
if (byte1 >= xfont->min_byte1
&& byte1 <= xfont->max_byte1
&& byte2 >= xfont->min_char_or_byte2
&& byte2 <= xfont->max_char_or_byte2)
pcm = (xfont->per_char
+ ((xfont->max_char_or_byte2 - xfont->min_char_or_byte2 + 1)
* (char2b->byte1 - xfont->min_byte1))
+ (char2b->byte2 - xfont->min_char_or_byte2));
* (byte1 - xfont->min_byte1))
+ (byte2 - xfont->min_char_or_byte2));
}
}
else
......@@ -104,8 +106,8 @@ xfont_get_pcm (XFontStruct *xfont, XChar2b *char2b)
/* If the per_char pointer is null, all glyphs between the first
and last character indexes inclusive have the same
information, as given by both min_bounds and max_bounds. */
if (char2b->byte2 >= xfont->min_char_or_byte2
&& char2b->byte2 <= xfont->max_char_or_byte2)
if (byte2 >= xfont->min_char_or_byte2
&& byte2 <= xfont->max_char_or_byte2)
pcm = &xfont->max_bounds;
}
......@@ -193,7 +195,6 @@ xfont_chars_supported (Lisp_Object chars, XFontStruct *xfont,
{
int c = XFIXNUM (XCAR (chars));
unsigned code = ENCODE_CHAR (charset, c);
XChar2b char2b;
if (code == CHARSET_INVALID_CODE (charset))
break;
......@@ -201,9 +202,7 @@ xfont_chars_supported (Lisp_Object chars, XFontStruct *xfont,
continue;
if (code >= 0x10000)
break;
char2b.byte1 = code >> 8;
char2b.byte2 = code & 0xFF;
if (! xfont_get_pcm (xfont, &char2b))
if (! xfont_get_pcm (xfont, code))
break;
}
return (NILP (chars));
......@@ -216,7 +215,6 @@ xfont_chars_supported (Lisp_Object chars, XFontStruct *xfont,
{
int c = XFIXNUM (AREF (chars, i));
unsigned code = ENCODE_CHAR (charset, c);
XChar2b char2b;
if (code == CHARSET_INVALID_CODE (charset))
continue;
......@@ -224,9 +222,7 @@ xfont_chars_supported (Lisp_Object chars, XFontStruct *xfont,
break;
if (code >= 0x10000)
continue;
char2b.byte1 = code >> 8;
char2b.byte2 = code & 0xFF;
if (xfont_get_pcm (xfont, &char2b))
if (xfont_get_pcm (xfont, code))
break;
}
return (i >= 0);
......@@ -801,11 +797,9 @@ xfont_open (struct frame *f, Lisp_Object entity, int pixel_size)
else
{
XCharStruct *pcm;
XChar2b char2b;
Lisp_Object val;
char2b.byte1 = 0x00, char2b.byte2 = 0x20;
pcm = xfont_get_pcm (xfont, &char2b);
pcm = xfont_get_pcm (xfont, 0x20);
if (pcm)
font->space_width = pcm->width;
else
......@@ -823,8 +817,8 @@ xfont_open (struct frame *f, Lisp_Object entity, int pixel_size)
{
int width = font->space_width, n = pcm != NULL;
for (char2b.byte2 = 33; char2b.byte2 <= 126; char2b.byte2++)
if ((pcm = xfont_get_pcm (xfont, &char2b)) != NULL)
for (unsigned short char2b = 33; char2b <= 126; ++char2b)
if ((pcm = xfont_get_pcm (xfont, char2b)) != NULL)
width += pcm->width, n++;
if (n > 0)
font->average_width = width / n;
......@@ -934,7 +928,6 @@ xfont_encode_char (struct font *font, int c)
XFontStruct *xfont = ((struct xfont_info *) font)->xfont;
struct charset *charset;
unsigned code;
XChar2b char2b;
charset = CHARSET_FROM_ID (font->encoding_charset);
code = ENCODE_CHAR (charset, c);
......@@ -946,13 +939,11 @@ xfont_encode_char (struct font *font, int c)
return (ENCODE_CHAR (charset, c) != CHARSET_INVALID_CODE (charset)
? code : FONT_INVALID_CODE);
}
char2b.byte1 = code >> 8;
char2b.byte2 = code & 0xFF;
return (xfont_get_pcm (xfont, &char2b) ? code : FONT_INVALID_CODE);
return (xfont_get_pcm (xfont, code) ? code : FONT_INVALID_CODE);
}
static void
xfont_text_extents (struct font *font, unsigned int *code,
xfont_text_extents (struct font *font, const unsigned int *code,
int nglyphs, struct font_metrics *metrics)
{
XFontStruct *xfont = ((struct xfont_info *) font)->xfont;
......@@ -961,13 +952,11 @@ xfont_text_extents (struct font *font, unsigned int *code,
for (i = 0, first = true; i < nglyphs; i++)
{
XChar2b char2b;
static XCharStruct *pcm;
if (code[i] >= 0x10000)
continue;
char2b.byte1 = code[i] >> 8, char2b.byte2 = code[i] & 0xFF;
pcm = xfont_get_pcm (xfont, &char2b);
pcm = xfont_get_pcm (xfont, code[i]);
if (! pcm)
continue;
if (first)
......@@ -1017,7 +1006,7 @@ xfont_draw (struct glyph_string *s, int from, int to, int x, int y,
USE_SAFE_ALLOCA;
char *str = SAFE_ALLOCA (len);
for (i = 0; i < len ; i++)
str[i] = XCHAR2B_BYTE2 (s->char2b + from + i);
str[i] = s->char2b[from + i] & 0xFF;
block_input ();
if (with_background)
{
......@@ -1049,21 +1038,41 @@ xfont_draw (struct glyph_string *s, int from, int to, int x, int y,
{
if (s->padding_p)
for (i = 0; i < len; i++)
XDrawImageString16 (display, FRAME_X_DRAWABLE (s->f),
gc, x + i, y, s->char2b + from + i, 1);
{
const unsigned short code = s->char2b[from + i];
const XChar2b char2b = { .byte1 = code >> 8,
.byte2 = code & 0xFF };
XDrawImageString16 (display, FRAME_X_DRAWABLE (s->f),
gc, x + i, y, &char2b, 1);
}
else
XDrawImageString16 (display, FRAME_X_DRAWABLE (s->f),
gc, x, y, s->char2b + from, len);
{
const unsigned short code = s->char2b[from];
const XChar2b char2b = { .byte1 = code >> 8,
.byte2 = code & 0xFF };
XDrawImageString16 (display, FRAME_X_DRAWABLE (s->f),
gc, x, y, &char2b, len);
}
}
else
{
if (s->padding_p)
for (i = 0; i < len; i++)
XDrawString16 (display, FRAME_X_DRAWABLE (s->f),
gc, x + i, y, s->char2b + from + i, 1);
{
const unsigned short code = s->char2b[from + i];
const XChar2b char2b = { .byte1 = code >> 8,
.byte2 = code & 0xFF };
XDrawString16 (display, FRAME_X_DRAWABLE (s->f),
gc, x + i, y, &char2b, 1);
}
else
XDrawString16 (display, FRAME_X_DRAWABLE (s->f),
gc, x, y, s->char2b + from, len);
{
const unsigned short code = s->char2b[from];
const XChar2b char2b = { .byte1 = code >> 8,
.byte2 = code & 0xFF };
XDrawString16 (display, FRAME_X_DRAWABLE (s->f),
gc, x, y, &char2b, len);
}
}
unblock_input ();
......
......@@ -536,7 +536,7 @@ xftfont_encode_char (struct font *font, int c)
}
static void
xftfont_text_extents (struct font *font, unsigned int *code,
xftfont_text_extents (struct font *font, const unsigned int *code,
int nglyphs, struct font_metrics *metrics)
{
struct font_info *xftfont_info = (struct font_info *) font;
......@@ -621,8 +621,7 @@ xftfont_draw (struct glyph_string *s, int from, int to, int x, int y,
}
code = alloca (sizeof (FT_UInt) * len);
for (i = 0; i < len; i++)
code[i] = ((XCHAR2B_BYTE1 (s->char2b + from + i) << 8)
| XCHAR2B_BYTE2 (s->char2b + from + i));
code[i] = s->char2b[from + i];
if (s->padding_p)
for (i = 0; i < len; i++)
......
......@@ -1648,7 +1648,7 @@ x_compute_glyph_string_overhangs (struct glyph_string *s)
int i;
for (i = 0; i < s->nchars; i++)
code[i] = (s->char2b[i].byte1 << 8) | s->char2b[i].byte2;
code[i] = s->char2b[i];
font->driver->text_extents (font, code, s->nchars, &metrics);
}
else
......@@ -1875,7 +1875,7 @@ static void
x_draw_glyphless_glyph_string_foreground (struct glyph_string *s)
{
struct glyph *glyph = s->first_glyph;
XChar2b char2b[8];
unsigned short char2b[8];
int x, i, j;
/* If first glyph of S has a left box line, start drawing the text
......@@ -1926,14 +1926,10 @@ x_draw_glyphless_glyph_string_foreground (struct glyph_string *s)
if (str)
{
int upper_len = (len + 1) / 2;
unsigned code;
/* It is assured that all LEN characters in STR is ASCII. */
for (j = 0; j < len; j++)
{
code = s->font->driver->encode_char (s->font, str[j]);
STORE_XCHAR2B (char2b + j, code >> 8, code & 0xFF);
}
char2b[j] = s->font->driver->encode_char (s->font, str[j]) & 0xFFFF;
s->font->driver->draw (s, 0, upper_len,
x + glyph->slice.glyphless.upper_xoff,
s->ybase + glyph->slice.glyphless.upper_yoff,
......@@ -9383,7 +9379,7 @@ x_draw_bar_cursor (struct window *w, struct glyph_row *row, int width, enum text
/* RIF: Define cursor CURSOR on frame F. */
static void
x_define_frame_cursor (struct frame *f, Cursor cursor)
x_define_frame_cursor (struct frame *f, Emacs_Cursor cursor)
{
if (!f->pointer_invisible
&& f->output_data.x->current_cursor != cursor)
......@@ -12186,7 +12182,7 @@ x_check_font (struct frame *f, struct font *font)
***********************************************************************/
static void
x_free_pixmap (struct frame *f, Pixmap pixmap)
x_free_pixmap (struct frame *f, Emacs_Pixmap pixmap)
{
XFreePixmap (FRAME_X_DISPLAY (f), pixmap);
}
......
......@@ -730,8 +730,6 @@ struct x_output
#endif
};
#define No_Cursor (None)
enum
{
/* Values for focus_state, used as bit mask.
......@@ -1222,7 +1220,8 @@ extern void destroy_frame_xic (struct frame *);
extern void xic_set_preeditarea (struct window *, int, int);
extern void xic_set_statusarea (struct frame *);
extern void xic_set_xfontset (struct frame *, const char *);
extern bool x_defined_color (struct frame *, const char *, XColor *, bool, bool);
extern bool x_defined_color (struct frame *, const char *, Emacs_Color *,
bool, bool);
#ifdef HAVE_X_I18N
extern void free_frame_xic (struct frame *);
# if defined HAVE_X_WINDOWS && defined USE_X_TOOLKIT
......@@ -1261,15 +1260,6 @@ extern void x_session_close (void);
#define FRAME_X_EMBEDDED_P(f) (FRAME_X_OUTPUT(f)->explicit_parent != 0)
#define STORE_XCHAR2B(chp, b1, b2) \
((chp)->byte1 = (b1), (chp)->byte2 = (b2))
#define XCHAR2B_BYTE1(chp) \
((chp)->byte1)
#define XCHAR2B_BYTE2(chp) \
((chp)->byte2)
#define STORE_NATIVE_RECT(nr,rx,ry,rwidth,rheight) \
((nr).x = (rx), \
(nr).y = (ry), \
......