summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDmitry Gutov <dgutov@yandex.ru>2019-05-24 04:53:39 +0300
committerDmitry Gutov <dgutov@yandex.ru>2019-05-24 04:53:39 +0300
commit8cdb9d9d24be0894ec3adc79f7f4af61e131850e (patch)
tree05cfdc9237eaf1abe30911caca26e95e2c68f4bd /src
parent62349fe82ad42d7d2a7fb19e40860ee5d6ebd017 (diff)
parent5b6401b001c770f5426597175a90ba78ddca79ef (diff)
downloademacs-8cdb9d9d24be0894ec3adc79f7f4af61e131850e.tar.gz
Merge branch 'master' of git.sv.gnu.org:/srv/git/emacs
Diffstat (limited to 'src')
-rw-r--r--src/alloc.c4
-rw-r--r--src/buffer.c22
-rw-r--r--src/character.h9
-rw-r--r--src/data.c23
-rw-r--r--src/dispextern.h85
-rw-r--r--src/eval.c4
-rw-r--r--src/fileio.c9
-rw-r--r--src/fns.c6
-rw-r--r--src/font.h4
-rw-r--r--src/frame.h4
-rw-r--r--src/ftcrfont.c381
-rw-r--r--src/ftfont.c224
-rw-r--r--src/ftfont.h18
-rw-r--r--src/ftxfont.c8
-rw-r--r--src/gtkutil.c2
-rw-r--r--src/gtkutil.h2
-rw-r--r--src/image.c325
-rw-r--r--src/keyboard.c4
-rw-r--r--src/lisp.h2
-rw-r--r--src/macfont.m17
-rw-r--r--src/msdos.h1
-rw-r--r--src/nsfont.m2
-rw-r--r--src/nsgui.h61
-rw-r--r--src/nsimage.m4
-rw-r--r--src/nsmenu.m7
-rw-r--r--src/nsselect.m14
-rw-r--r--src/nsterm.h54
-rw-r--r--src/nsterm.m101
-rw-r--r--src/regex-emacs.c2
-rw-r--r--src/search.c7
-rw-r--r--src/termhooks.h8
-rw-r--r--src/w32fns.c27
-rw-r--r--src/w32font.c20
-rw-r--r--src/w32font.h2
-rw-r--r--src/w32gui.h43
-rw-r--r--src/w32term.c119
-rw-r--r--src/w32term.h50
-rw-r--r--src/window.c6
-rw-r--r--src/window.h10
-rw-r--r--src/xdisp.c250
-rw-r--r--src/xfaces.c68
-rw-r--r--src/xfns.c2
-rw-r--r--src/xfont.c111
-rw-r--r--src/xftfont.c156
-rw-r--r--src/xterm.c21
-rw-r--r--src/xterm.h14
46 files changed, 1162 insertions, 1151 deletions
diff --git a/src/alloc.c b/src/alloc.c
index af4adb3856e..5c5b56d02e9 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -6384,7 +6384,7 @@ mark_object (Lisp_Object arg)
do { \
CHECK_ALLOCATED (); \
CHECK_LIVE (LIVEP); \
- } while (0) \
+ } while (false)
/* Check both of the above conditions, for symbols. */
#define CHECK_ALLOCATED_AND_LIVE_SYMBOL() \
@@ -6394,7 +6394,7 @@ mark_object (Lisp_Object arg)
CHECK_ALLOCATED (); \
CHECK_LIVE (live_symbol_p); \
} \
- } while (0) \
+ } while (false)
#else /* not GC_CHECK_MARKED_OBJECTS */
diff --git a/src/buffer.c b/src/buffer.c
index 3b5078a175b..209e29f0f19 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -5603,17 +5603,17 @@ Use the command `abbrev-mode' to change this variable. */);
doc: /* Non-nil if searches and matches should ignore case. */);
DEFVAR_PER_BUFFER ("fill-column", &BVAR (current_buffer, fill_column),
- Qfixnump,
+ Qintegerp,
doc: /* Column beyond which automatic line-wrapping should happen.
Interactively, you can set the buffer local value using \\[set-fill-column]. */);
DEFVAR_PER_BUFFER ("left-margin", &BVAR (current_buffer, left_margin),
- Qfixnump,
+ Qintegerp,
doc: /* Column for the default `indent-line-function' to indent to.
Linefeed indents to this column in Fundamental mode. */);
DEFVAR_PER_BUFFER ("tab-width", &BVAR (current_buffer, tab_width),
- Qfixnump,
+ Qintegerp,
doc: /* Distance between tab stops (for display of tab characters), in columns.
NOTE: This controls the display width of a TAB character, and not
the size of an indentation step.
@@ -5784,7 +5784,7 @@ If it is nil, that means don't auto-save this buffer. */);
Backing up is done before the first time the file is saved. */);
DEFVAR_PER_BUFFER ("buffer-saved-size", &BVAR (current_buffer, save_length),
- Qfixnump,
+ Qintegerp,
doc: /* Length of current buffer when last read in, saved or auto-saved.
0 initially.
-1 means auto-saving turned off until next real save.
@@ -5858,7 +5858,7 @@ In addition, a char-table has six extra slots to control the display of:
See also the functions `display-table-slot' and `set-display-table-slot'. */);
DEFVAR_PER_BUFFER ("left-margin-width", &BVAR (current_buffer, left_margin_cols),
- Qfixnump,
+ Qintegerp,
doc: /* Width in columns of left marginal area for display of a buffer.
A value of nil means no marginal area.
@@ -5866,7 +5866,7 @@ Setting this variable does not take effect until a new buffer is displayed
in a window. To make the change take effect, call `set-window-buffer'. */);
DEFVAR_PER_BUFFER ("right-margin-width", &BVAR (current_buffer, right_margin_cols),
- Qfixnump,
+ Qintegerp,
doc: /* Width in columns of right marginal area for display of a buffer.
A value of nil means no marginal area.
@@ -5874,7 +5874,7 @@ Setting this variable does not take effect until a new buffer is displayed
in a window. To make the change take effect, call `set-window-buffer'. */);
DEFVAR_PER_BUFFER ("left-fringe-width", &BVAR (current_buffer, left_fringe_width),
- Qfixnump,
+ Qintegerp,
doc: /* Width of this buffer's left fringe (in pixels).
A value of 0 means no left fringe is shown in this buffer's window.
A value of nil means to use the left fringe width from the window's frame.
@@ -5883,7 +5883,7 @@ Setting this variable does not take effect until a new buffer is displayed
in a window. To make the change take effect, call `set-window-buffer'. */);
DEFVAR_PER_BUFFER ("right-fringe-width", &BVAR (current_buffer, right_fringe_width),
- Qfixnump,
+ Qintegerp,
doc: /* Width of this buffer's right fringe (in pixels).
A value of 0 means no right fringe is shown in this buffer's window.
A value of nil means to use the right fringe width from the window's frame.
@@ -5900,12 +5900,12 @@ Setting this variable does not take effect until a new buffer is displayed
in a window. To make the change take effect, call `set-window-buffer'. */);
DEFVAR_PER_BUFFER ("scroll-bar-width", &BVAR (current_buffer, scroll_bar_width),
- Qfixnump,
+ Qintegerp,
doc: /* Width of this buffer's vertical scroll bars in pixels.
A value of nil means to use the scroll bar width from the window's frame. */);
DEFVAR_PER_BUFFER ("scroll-bar-height", &BVAR (current_buffer, scroll_bar_height),
- Qfixnump,
+ Qintegerp,
doc: /* Height of this buffer's horizontal scroll bars in pixels.
A value of nil means to use the scroll bar height from the window's frame. */);
@@ -6175,7 +6175,7 @@ Setting this variable is very fast, much faster than scanning all the text in
the buffer looking for properties to change. */);
DEFVAR_PER_BUFFER ("buffer-display-count",
- &BVAR (current_buffer, display_count), Qfixnump,
+ &BVAR (current_buffer, display_count), Qintegerp,
doc: /* A number incremented each time this buffer is displayed in a window.
The function `set-window-buffer' increments it. */);
diff --git a/src/character.h b/src/character.h
index 5dff85aed47..cc57a2a7d5c 100644
--- a/src/character.h
+++ b/src/character.h
@@ -558,12 +558,13 @@ enum
/* Return a non-outlandish value for the tab width. */
-#define SANE_TAB_WIDTH(buf) \
- sanitize_tab_width (XFIXNAT (BVAR (buf, tab_width)))
+#define SANE_TAB_WIDTH(buf) sanitize_tab_width (BVAR (buf, tab_width))
+
INLINE int
-sanitize_tab_width (EMACS_INT width)
+sanitize_tab_width (Lisp_Object width)
{
- return 0 < width && width <= 1000 ? width : 8;
+ return (FIXNUMP (width) && 0 < XFIXNUM (width) && XFIXNUM (width) <= 1000
+ ? XFIXNUM (width) : 8);
}
/* Return the width of ASCII character C. The width is measured by
diff --git a/src/data.c b/src/data.c
index 476d28eadbc..c1699aeae73 100644
--- a/src/data.c
+++ b/src/data.c
@@ -1122,20 +1122,21 @@ store_symval_forwarding (lispfwd valcontents, Lisp_Object newval,
int offset = XBUFFER_OBJFWD (valcontents)->offset;
Lisp_Object predicate = XBUFFER_OBJFWD (valcontents)->predicate;
- if (!NILP (newval))
+ if (!NILP (newval) && !NILP (predicate))
{
- if (SYMBOLP (predicate))
+ eassert (SYMBOLP (predicate));
+ Lisp_Object choiceprop = Fget (predicate, Qchoice);
+ if (!NILP (choiceprop))
{
- Lisp_Object prop;
-
- if ((prop = Fget (predicate, Qchoice), !NILP (prop)))
- {
- if (NILP (Fmemq (newval, prop)))
- wrong_choice (prop, newval);
- }
- else if ((prop = Fget (predicate, Qrange), !NILP (prop)))
+ if (NILP (Fmemq (newval, choiceprop)))
+ wrong_choice (choiceprop, newval);
+ }
+ else
+ {
+ Lisp_Object rangeprop = Fget (predicate, Qrange);
+ if (CONSP (rangeprop))
{
- Lisp_Object min = XCAR (prop), max = XCDR (prop);
+ Lisp_Object min = XCAR (rangeprop), max = XCDR (rangeprop);
if (! NUMBERP (newval)
|| NILP (CALLN (Fleq, min, newval, max)))
wrong_range (min, max, newval);
diff --git a/src/dispextern.h b/src/dispextern.h
index e86ea6a02ae..aa80fa653db 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -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 *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);
@@ -3363,10 +3396,10 @@ extern void image_destroy_bitmap (struct frame *, ptrdiff_t);
extern void image_destroy_all_bitmaps (Display_Info *);
#ifdef HAVE_X_WINDOWS
extern void x_create_bitmap_mask (struct frame *, ptrdiff_t);
+extern void x_kill_gs_process (Pixmap, struct frame *);
#endif
extern Lisp_Object image_find_image_file (Lisp_Object);
-void x_kill_gs_process (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);
diff --git a/src/eval.c b/src/eval.c
index 567c32e0d75..5bba8766373 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -544,8 +544,8 @@ usage: (quote ARG) */)
DEFUN ("function", Ffunction, Sfunction, 1, UNEVALLED, 0,
doc: /* Like `quote', but preferred for objects which are functions.
-In byte compilation, `function' causes its argument to be compiled.
-`quote' cannot do that.
+In byte compilation, `function' causes its argument to be handled by
+the byte compiler. `quote' cannot do that.
usage: (function ARG) */)
(Lisp_Object args)
{
diff --git a/src/fileio.c b/src/fileio.c
index 4ee125d7de2..9e9779967dd 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -5802,6 +5802,7 @@ A non-nil CURRENT-ONLY argument means save only current buffer. */)
&& BUF_SAVE_MODIFF (b) < BUF_MODIFF (b)
&& BUF_AUTOSAVE_MODIFF (b) < BUF_MODIFF (b)
/* -1 means we've turned off autosaving for a while--see below. */
+ && FIXNUMP (BVAR (b, save_length))
&& XFIXNUM (BVAR (b, save_length)) >= 0
&& (do_handled_files
|| NILP (Ffind_file_name_handler (BVAR (b, auto_save_file_name),
@@ -5815,13 +5816,17 @@ A non-nil CURRENT-ONLY argument means save only current buffer. */)
&& before_time.tv_sec - b->auto_save_failure_time < 1200)
continue;
+ enum { growth_factor = 4 };
+ verify (BUF_BYTES_MAX <= EMACS_INT_MAX / growth_factor);
+
set_buffer_internal (b);
if (NILP (Vauto_save_include_big_deletions)
- && (XFIXNAT (BVAR (b, save_length)) * 10
- > (BUF_Z (b) - BUF_BEG (b)) * 13)
+ && FIXNUMP (BVAR (b, save_length))
/* A short file is likely to change a large fraction;
spare the user annoying messages. */
&& XFIXNAT (BVAR (b, save_length)) > 5000
+ && (growth_factor * (BUF_Z (b) - BUF_BEG (b))
+ < (growth_factor - 1) * XFIXNAT (BVAR (b, save_length)))
/* These messages are frequent and annoying for `*mail*'. */
&& !NILP (BVAR (b, filename))
&& NILP (no_message))
diff --git a/src/fns.c b/src/fns.c
index c3202495daf..6b1f7331f55 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -1131,10 +1131,8 @@ string the same way whether it is unibyte or multibyte.) */)
DEFUN ("string-make-unibyte", Fstring_make_unibyte, Sstring_make_unibyte,
1, 1, 0,
doc: /* Return the unibyte equivalent of STRING.
-Multibyte character codes are converted to unibyte according to
-`nonascii-translation-table' or, if that is nil, `nonascii-insert-offset'.
-If the lookup in the translation table fails, this function takes just
-the low 8 bits of each character. */)
+Multibyte character codes above 255 are converted to unibyte
+by taking just the low 8 bits of each character's code. */)
(Lisp_Object string)
{
CHECK_STRING (string);
diff --git a/src/font.h b/src/font.h
index 3720650a2e1..9ca0c97dc52 100644
--- a/src/font.h
+++ b/src/font.h
@@ -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 */
diff --git a/src/frame.h b/src/frame.h
index b8aed823afb..fa45a32d6b6 100644
--- a/src/frame.h
+++ b/src/frame.h
@@ -1480,7 +1480,7 @@ FRAME_BOTTOM_DIVIDER_WIDTH (struct frame *f)
- FRAME_TOTAL_FRINGE_WIDTH (f) \
- FRAME_SCROLL_BAR_AREA_WIDTH (f) \
- 2 * FRAME_INTERNAL_BORDER_WIDTH (f)) \
- / FRAME_COLUMN_WIDTH (f)) \
+ / FRAME_COLUMN_WIDTH (f))
#define FRAME_PIXEL_HEIGHT_TO_TEXT_LINES(f, height) \
(((height) \
@@ -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;
};
diff --git a/src/ftcrfont.c b/src/ftcrfont.c
index e7c73eac4d3..9686cec0e8c 100644
--- a/src/ftcrfont.c
+++ b/src/ftcrfont.c
@@ -79,7 +79,6 @@ ftcrfont_glyph_extents (struct font *font,
cairo_glyph_t cr_glyph = {.index = glyph};
cairo_text_extents_t extents;
- FT_Activate_Size (ftcrfont_info->ft_size_draw);
cairo_scaled_font_glyph_extents (ftcrfont_info->cr_scaled_font,
&cr_glyph, 1, &extents);
cache->lbearing = floor (extents.x_bearing);
@@ -118,103 +117,159 @@ ftcrfont_match (struct frame *f, Lisp_Object spec)
static Lisp_Object
ftcrfont_open (struct frame *f, Lisp_Object entity, int pixel_size)
{
- Lisp_Object font_object;
-
- FT_UInt size = XFIXNUM (AREF (entity, FONT_SIZE_INDEX));
+ FcResult result;
+ Lisp_Object val, filename, font_object;
+ FcPattern *pat, *match;
+ struct font_info *ftcrfont_info;
+ struct font *font;
+ double size = 0;
+ cairo_font_face_t *font_face;
+ cairo_font_extents_t extents;
+ FT_Face ft_face;
+ FcMatrix *matrix;
+
+ val = assq_no_quit (QCfont_entity, AREF (entity, FONT_EXTRA_INDEX));
+ if (! CONSP (val))
+ return Qnil;
+ val = XCDR (val);
+ filename = XCAR (val);
+ size = XFIXNUM (AREF (entity, FONT_SIZE_INDEX));
if (size == 0)
size = pixel_size;
+
+ block_input ();
+
+ pat = ftfont_entity_pattern (entity, pixel_size);
+ FcConfigSubstitute (NULL, pat, FcMatchPattern);
+ FcDefaultSubstitute (pat);
+ match = FcFontMatch (NULL, pat, &result);
+ ftfont_fix_match (pat, match);
+
+ FcPatternDestroy (pat);
+ font_face = cairo_ft_font_face_create_for_pattern (match);
+ if (!font_face)
+ {
+ unblock_input ();
+ FcPatternDestroy (match);
+ return Qnil;
+ }
+ cairo_matrix_t font_matrix, ctm;
+ cairo_matrix_init_scale (&font_matrix, pixel_size, pixel_size);
+ cairo_matrix_init_identity (&ctm);
+ cairo_font_options_t *options = cairo_font_options_create ();
+ cairo_scaled_font_t *scaled_font
+ = cairo_scaled_font_create (font_face, &font_matrix, &ctm, options);
+ cairo_font_face_destroy (font_face);
+ cairo_font_options_destroy (options);
+ unblock_input ();
+
font_object = font_build_object (VECSIZE (struct font_info),
Qftcr, entity, size);
+ ASET (font_object, FONT_FILE_INDEX, filename);
+ font = XFONT_OBJECT (font_object);
+ font->pixel_size = size;
+ font->driver = &ftcrfont_driver;
+ font->encoding_charset = font->repertory_charset = -1;
+
+ ftcrfont_info = (struct font_info *) font;
+ ftcrfont_info->cr_scaled_font = scaled_font;
+
+ /* This means that there's no need of transformation. */
+ ftcrfont_info->matrix.xx = 0;
+ if (FcPatternGetMatrix (match, FC_MATRIX, 0, &matrix) == FcResultMatch)
+ {
+ ftcrfont_info->matrix.xx = 0x10000L * matrix->xx;
+ ftcrfont_info->matrix.yy = 0x10000L * matrix->yy;
+ ftcrfont_info->matrix.xy = 0x10000L * matrix->xy;
+ ftcrfont_info->matrix.yx = 0x10000L * matrix->yx;
+ }
+
+ ftcrfont_info->metrics = NULL;
+ ftcrfont_info->metrics_nrows = 0;
+
block_input ();
- font_object = ftfont_open2 (f, entity, pixel_size, font_object);
- if (FONT_OBJECT_P (font_object))
+ cairo_glyph_t stack_glyph;
+ int n = 0;
+ font->min_width = font->average_width = font->space_width = 0;
+ for (char c = 32; c < 127; c++)
{
- struct font *font = XFONT_OBJECT (font_object);
- struct font_info *ftcrfont_info = (struct font_info *) font;
- FT_Face ft_face = ftcrfont_info->ft_size->face;
-
- font->driver = &ftcrfont_driver;
- FT_New_Size (ft_face, &ftcrfont_info->ft_size_draw);
- FT_Activate_Size (ftcrfont_info->ft_size_draw);
- if (ftcrfont_info->bitmap_strike_index < 0)
- FT_Set_Pixel_Sizes (ft_face, 0, font->pixel_size);
- else
- FT_Select_Size (ft_face, ftcrfont_info->bitmap_strike_index);
- cairo_font_face_t *font_face =
- cairo_ft_font_face_create_for_ft_face (ft_face, 0);
- cairo_matrix_t font_matrix, ctm;
- cairo_matrix_init_scale (&font_matrix, pixel_size, pixel_size);
- cairo_matrix_init_identity (&ctm);
- cairo_font_options_t *options = cairo_font_options_create ();
- ftcrfont_info->cr_scaled_font =
- cairo_scaled_font_create (font_face, &font_matrix, &ctm, options);
- cairo_font_face_destroy (font_face);
- cairo_font_options_destroy (options);
- ftcrfont_info->metrics = NULL;
- ftcrfont_info->metrics_nrows = 0;
- if (ftcrfont_info->bitmap_strike_index >= 0)
+ cairo_glyph_t *glyphs = &stack_glyph;
+ int num_glyphs = 1;
+ cairo_status_t status =
+ cairo_scaled_font_text_to_glyphs (ftcrfont_info->cr_scaled_font,
+ 0, 0, &c, 1, &glyphs, &num_glyphs,
+ NULL, NULL, NULL);
+
+ if (status == CAIRO_STATUS_SUCCESS)
{
- /* Several members of struct font/font_info set by
- ftfont_open2 are bogus. Recalculate them with cairo
- scaled font functions. */
- cairo_font_extents_t extents;
- cairo_scaled_font_extents (ftcrfont_info->cr_scaled_font, &extents);
- font->ascent = lround (extents.ascent);
- Lisp_Object val = assq_no_quit (QCminspace,
- AREF (entity, FONT_EXTRA_INDEX));
- if (!(CONSP (val) && NILP (XCDR (val))))
- {
- font->descent = lround (extents.descent);
- font->height = font->ascent + font->descent;
- }
- else
+ if (glyphs != &stack_glyph)
+ cairo_glyph_free (glyphs);
+ else if (stack_glyph.index)
{
- font->height = lround (extents.height);
- font->descent = font->height - font->ascent;
+ int this_width = ftcrfont_glyph_extents (font, stack_glyph.index,
+ NULL);
+
+ if (this_width > 0
+ && (! font->min_width
+ || font->min_width > this_width))
+ font->min_width = this_width;
+ if (c == 32)
+ font->space_width = this_width;
+ font->average_width += this_width;
+ n++;
}
+ }
+ }
+ if (n > 0)
+ font->average_width /= n;
- cairo_glyph_t stack_glyph;
- int n = 0;
- font->min_width = font->average_width = font->space_width = 0;
- for (char c = 32; c < 127; c++)
- {
- cairo_glyph_t *glyphs = &stack_glyph;
- int num_glyphs = 1;
- cairo_status_t status =
- cairo_scaled_font_text_to_glyphs (ftcrfont_info->cr_scaled_font,
- 0, 0, &c, 1,
- &glyphs, &num_glyphs,
- NULL, NULL, NULL);
-
- if (status == CAIRO_STATUS_SUCCESS)
- {
- if (glyphs != &stack_glyph)
- cairo_glyph_free (glyphs);
- else
- {
- int this_width =
- ftcrfont_glyph_extents (font, stack_glyph.index, NULL);
-
- if (this_width > 0
- && (! font->min_width
- || font->min_width > this_width))
- font->min_width = this_width;
- if (c == 32)
- font->space_width = this_width;
- font->average_width += this_width;
- n++;
- }
- }
- }
- if (n > 0)
- font->average_width /= n;
+ cairo_scaled_font_extents (ftcrfont_info->cr_scaled_font, &extents);
+ font->ascent = lround (extents.ascent);
+ val = assq_no_quit (QCminspace, AREF (entity, FONT_EXTRA_INDEX));
+ if (!(CONSP (val) && NILP (XCDR (val))))
+ {
+ font->descent = lround (extents.descent);
+ font->height = font->ascent + font->descent;
+ }
+ else
+ {
+ font->height = lround (extents.height);
+ font->descent = font->height - font->ascent;
+ }
- font->underline_position = -1;
- font->underline_thickness = 0;
- }
+ ft_face = cairo_ft_scaled_font_lock_face (scaled_font);
+ if (XFIXNUM (AREF (entity, FONT_SIZE_INDEX)) == 0)
+ {
+ int upEM = ft_face->units_per_EM;
+
+ font->underline_position = -ft_face->underline_position * size / upEM;
+ font->underline_thickness = ft_face->underline_thickness * size / upEM;
+ if (font->underline_thickness > 2)
+ font->underline_position -= font->underline_thickness / 2;
+ }
+ else
+ {
+ font->underline_position = -1;
+ font->underline_thickness = 0;
}
+#ifdef HAVE_LIBOTF
+ ftcrfont_info->maybe_otf = (ft_face->face_flags & FT_FACE_FLAG_SFNT) != 0;
+ ftcrfont_info->otf = NULL;
+#endif /* HAVE_LIBOTF */
+ if (ft_face->units_per_EM)
+ ftcrfont_info->bitmap_position_unit = 0;
+ else
+ ftcrfont_info->bitmap_position_unit = (extents.height
+ / ft_face->size->metrics.height);
+ cairo_ft_scaled_font_unlock_face (scaled_font);
+ ftcrfont_info->ft_size = NULL;
unblock_input ();
+ font->baseline_offset = 0;
+ font->relative_compose = 0;
+ font->default_ascent = 0;
+ font->vertical_centering = false;
+
return font_object;
}
@@ -225,24 +280,63 @@ ftcrfont_close (struct font *font)
return;
struct font_info *ftcrfont_info = (struct font_info *) font;
- int i;
block_input ();
- for (i = 0; i < ftcrfont_info->metrics_nrows; i++)
+#ifdef HAVE_LIBOTF
+ if (ftcrfont_info->otf)
+ {
+ OTF_close (ftcrfont_info->otf);
+ ftcrfont_info->otf = NULL;
+ }
+#endif
+ for (int i = 0; i < ftcrfont_info->metrics_nrows; i++)
if (ftcrfont_info->metrics[i])
xfree (ftcrfont_info->metrics[i]);
if (ftcrfont_info->metrics)
xfree (ftcrfont_info->metrics);
- FT_Done_Size (ftcrfont_info->ft_size_draw);
cairo_scaled_font_destroy (ftcrfont_info->cr_scaled_font);
unblock_input ();
+}
+
+static int
+ftcrfont_has_char (Lisp_Object font, int c)
+{
+ if (FONT_ENTITY_P (font))
+ return ftfont_has_char (font, c);
- ftfont_close (font);
+ return -1;
+}
+
+static unsigned
+ftcrfont_encode_char (struct font *font, int c)
+{
+ struct font_info *ftcrfont_info = (struct font_info *) font;
+ unsigned code = FONT_INVALID_CODE;
+ unsigned char utf8[MAX_MULTIBYTE_LENGTH];
+ unsigned char *p = utf8;
+ cairo_glyph_t stack_glyph;
+ cairo_glyph_t *glyphs = &stack_glyph;
+ int num_glyphs = 1;
+
+ CHAR_STRING_ADVANCE (c, p);
+ if (cairo_scaled_font_text_to_glyphs (ftcrfont_info->cr_scaled_font, 0, 0,
+ (char *) utf8, p - utf8,
+ &glyphs, &num_glyphs,
+ NULL, NULL, NULL)
+ == CAIRO_STATUS_SUCCESS)
+ {
+ if (glyphs != &stack_glyph)
+ cairo_glyph_free (glyphs);
+ else if (stack_glyph.index)
+ code = stack_glyph.index;
+ }
+
+ return code;
}
static void
ftcrfont_text_extents (struct font *font,
- unsigned *code,
+ const unsigned *code,
int nglyphs,
struct font_metrics *metrics)
{
@@ -280,10 +374,18 @@ ftcrfont_get_bitmap (struct font *font, unsigned int code,
{
struct font_info *ftcrfont_info = (struct font_info *) font;
- if (ftcrfont_info->bitmap_strike_index < 0)
- return ftfont_get_bitmap (font, code, bitmap, bits_per_pixel);
+ if (ftcrfont_info->bitmap_position_unit)
+ return -1;
- return -1;
+ cairo_scaled_font_t *scaled_font = ftcrfont_info->cr_scaled_font;
+ FT_Face ft_face = cairo_ft_scaled_font_lock_face (scaled_font);
+
+ ftcrfont_info->ft_size = ft_face->size;
+ int result = ftfont_get_bitmap (font, code, bitmap, bits_per_pixel);
+ cairo_ft_scaled_font_unlock_face (scaled_font);
+ ftcrfont_info->ft_size = NULL;
+
+ return result;
}
static int
@@ -292,25 +394,75 @@ ftcrfont_anchor_point (struct font *font, unsigned int code, int idx,
{
struct font_info *ftcrfont_info = (struct font_info *) font;
- if (ftcrfont_info->bitmap_strike_index < 0)
- return ftfont_anchor_point (font, code, idx, x, y);
+ if (ftcrfont_info->bitmap_position_unit)
+ return -1;
- return -1;
+ cairo_scaled_font_t *scaled_font = ftcrfont_info->cr_scaled_font;
+ FT_Face ft_face = cairo_ft_scaled_font_lock_face (scaled_font);
+
+ ftcrfont_info->ft_size = ft_face->size;
+ int result = ftfont_anchor_point (font, code, idx, x, y);
+ cairo_ft_scaled_font_unlock_face (scaled_font);
+ ftcrfont_info->ft_size = NULL;
+
+ return result;
}
+#ifdef HAVE_LIBOTF
static Lisp_Object
-ftcrfont_shape (Lisp_Object lgstring)
+ftcrfont_otf_capability (struct font *font)
{
+ struct font_info *ftcrfont_info = (struct font_info *) font;
+ cairo_scaled_font_t *scaled_font = ftcrfont_info->cr_scaled_font;
+ FT_Face ft_face = cairo_ft_scaled_font_lock_face (scaled_font);
+
+ ftcrfont_info->ft_size = ft_face->size;
+ Lisp_Object result = ftfont_otf_capability (font);
+ cairo_ft_scaled_font_unlock_face (scaled_font);
+ ftcrfont_info->ft_size = NULL;
+
+ return result;
+}
+#endif
+
#if defined HAVE_M17N_FLT && defined HAVE_LIBOTF
+static Lisp_Object
+ftcrfont_shape (Lisp_Object lgstring)
+{
struct font *font = CHECK_FONT_GET_OBJECT (LGSTRING_FONT (lgstring));
struct font_info *ftcrfont_info = (struct font_info *) font;
- if (ftcrfont_info->bitmap_strike_index < 0)
- return ftfont_shape (lgstring);
+ if (ftcrfont_info->bitmap_position_unit)
+ return make_fixnum (0);
+
+ cairo_scaled_font_t *scaled_font = ftcrfont_info->cr_scaled_font;
+ FT_Face ft_face = cairo_ft_scaled_font_lock_face (scaled_font);
+
+ ftcrfont_info->ft_size = ft_face->size;
+ Lisp_Object result = ftfont_shape (lgstring);
+ cairo_ft_scaled_font_unlock_face (scaled_font);
+ ftcrfont_info->ft_size = NULL;
+
+ return result;
+}
#endif
- return make_fixnum (0);
+#ifdef HAVE_OTF_GET_VARIATION_GLYPHS
+static int
+ftcrfont_variation_glyphs (struct font *font, int c, unsigned variations[256])
+{
+ struct font_info *ftcrfont_info = (struct font_info *) font;
+ cairo_scaled_font_t *scaled_font = ftcrfont_info->cr_scaled_font;
+ FT_Face ft_face = cairo_ft_scaled_font_lock_face (scaled_font);
+
+ ftcrfont_info->ft_size = ft_face->size;
+ int result = ftfont_variation_glyphs (font, c, variations);
+ cairo_ft_scaled_font_unlock_face (scaled_font);
+ ftcrfont_info->ft_size = NULL;
+
+ return result;
}
+#endif /* HAVE_OTF_GET_VARIATION_GLYPHS */
static int
ftcrfont_draw (struct glyph_string *s,
@@ -321,8 +473,6 @@ ftcrfont_draw (struct glyph_string *s,
struct font_info *ftcrfont_info = (struct font_info *) s->font;
cairo_t *cr;
cairo_glyph_t *glyphs;
- cairo_surface_t *surface;
- cairo_surface_type_t surface_type;
int len = to - from;
int i;
@@ -341,28 +491,17 @@ 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);
cairo_set_scaled_font (cr, ftcrfont_info->cr_scaled_font);
-
- FT_Activate_Size (ftcrfont_info->ft_size_draw);
cairo_show_glyphs (cr, glyphs, len);
- surface = cairo_get_target (cr);
- /* XXX: It used to be necessary to flush when exporting. It might
- be the case that this is no longer necessary. */
- surface_type = cairo_surface_get_type (surface);
- if (surface_type != CAIRO_SURFACE_TYPE_XLIB
- && (surface_type != CAIRO_SURFACE_TYPE_IMAGE
- || cairo_image_surface_get_format (surface) != CAIRO_FORMAT_ARGB32))
- cairo_surface_flush (surface);
x_end_cr_clip (f);
@@ -384,18 +523,20 @@ struct font_driver const ftcrfont_driver =
.list_family = ftfont_list_family,
.open = ftcrfont_open,
.close = ftcrfont_close,
- .has_char = ftfont_has_char,
- .encode_char = ftfont_encode_char,
+ .has_char = ftcrfont_has_char,
+ .encode_char = ftcrfont_encode_char,
.text_extents = ftcrfont_text_extents,
.draw = ftcrfont_draw,
.get_bitmap = ftcrfont_get_bitmap,
.anchor_point = ftcrfont_anchor_point,
#ifdef HAVE_LIBOTF
- .otf_capability = ftfont_otf_capability,
+ .otf_capability = ftcrfont_otf_capability,
#endif
+#if defined HAVE_M17N_FLT && defined HAVE_LIBOTF
.shape = ftcrfont_shape,
+#endif
#ifdef HAVE_OTF_GET_VARIATION_GLYPHS
- .get_variation_glyphs = ftfont_variation_glyphs,
+ .get_variation_glyphs = ftcrfont_variation_glyphs,
#endif
.filter_properties = ftfont_filter_properties,
.combining_capability = ftfont_combining_capability,
diff --git a/src/ftfont.c b/src/ftfont.c
index 4770c3c40b3..d8b510d7032 100644
--- a/src/ftfont.c
+++ b/src/ftfont.c
@@ -1079,12 +1079,159 @@ ftfont_list_family (struct frame *f)
return list;
}
+void
+ftfont_fix_match (FcPattern *pat, FcPattern *match)
+{
+ /* These values are not used for matching (except antialias), but for
+ rendering, so make sure they are carried over to the match.
+ We also put antialias here because most fonts are antialiased, so
+ the match will have antialias true. */
+
+ FcBool b = FcTrue;
+ int i;
+ double dpi;
+
+ FcPatternGetBool (pat, FC_ANTIALIAS, 0, &b);
+ if (! b)
+ {
+ FcPatternDel (match, FC_ANTIALIAS);
+ FcPatternAddBool (match, FC_ANTIALIAS, FcFalse);
+ }
+ FcPatternGetBool (pat, FC_HINTING, 0, &b);
+ if (! b)
+ {
+ FcPatternDel (match, FC_HINTING);
+ FcPatternAddBool (match, FC_HINTING, FcFalse);
+ }
+#ifndef FC_HINT_STYLE
+# define FC_HINT_STYLE "hintstyle"
+#endif
+ if (FcResultMatch == FcPatternGetInteger (pat, FC_HINT_STYLE, 0, &i))
+ {
+ FcPatternDel (match, FC_HINT_STYLE);
+ FcPatternAddInteger (match, FC_HINT_STYLE, i);
+ }
+#ifndef FC_LCD_FILTER
+ /* Older fontconfig versions don't have FC_LCD_FILTER. */
+#define FC_LCD_FILTER "lcdfilter"
+#endif
+ if (FcResultMatch == FcPatternGetInteger (pat, FC_LCD_FILTER, 0, &i))
+ {
+ FcPatternDel (match, FC_LCD_FILTER);
+ FcPatternAddInteger (match, FC_LCD_FILTER, i);
+ }
+ if (FcResultMatch == FcPatternGetInteger (pat, FC_RGBA, 0, &i))
+ {
+ FcPatternDel (match, FC_RGBA);
+ FcPatternAddInteger (match, FC_RGBA, i);
+ }
+ if (FcResultMatch == FcPatternGetDouble (pat, FC_DPI, 0, &dpi))
+ {
+ FcPatternDel (match, FC_DPI);
+ FcPatternAddDouble (match, FC_DPI, dpi);
+ }
+}
+
+void
+ftfont_add_rendering_parameters (FcPattern *pat, Lisp_Object entity)
+{
+ Lisp_Object tail;
+ int ival;
+
+ for (tail = AREF (entity, FONT_EXTRA_INDEX); CONSP (tail); tail = XCDR (tail))
+ {
+ Lisp_Object key = XCAR (XCAR (tail));
+ Lisp_Object val = XCDR (XCAR (tail));
+
+ if (EQ (key, QCantialias))
+ FcPatternAddBool (pat, FC_ANTIALIAS, NILP (val) ? FcFalse : FcTrue);
+ else if (EQ (key, QChinting))
+ FcPatternAddBool (pat, FC_HINTING, NILP (val) ? FcFalse : FcTrue);
+ else if (EQ (key, QCautohint))
+ FcPatternAddBool (pat, FC_AUTOHINT, NILP (val) ? FcFalse : FcTrue);
+ else if (EQ (key, QChintstyle))
+ {
+ if (FIXNUMP (val))
+ FcPatternAddInteger (pat, FC_HINT_STYLE, XFIXNUM (val));
+ else if (SYMBOLP (val)
+ && FcNameConstant (SDATA (SYMBOL_NAME (val)), &ival))
+ FcPatternAddInteger (pat, FC_HINT_STYLE, ival);
+ }
+ else if (EQ (key, QCrgba))
+ {
+ if (FIXNUMP (val))
+ FcPatternAddInteger (pat, FC_RGBA, XFIXNUM (val));
+ else if (SYMBOLP (val)
+ && FcNameConstant (SDATA (SYMBOL_NAME (val)), &ival))
+ FcPatternAddInteger (pat, FC_RGBA, ival);
+ }
+ else if (EQ (key, QClcdfilter))
+ {
+ if (FIXNUMP (val))
+ FcPatternAddInteger (pat, FC_LCD_FILTER, ival = XFIXNUM (val));
+ else if (SYMBOLP (val)
+ && FcNameConstant (SDATA (SYMBOL_NAME (val)), &ival))
+ FcPatternAddInteger (pat, FC_LCD_FILTER, ival);
+ }
+#ifdef FC_EMBOLDEN
+ else if (EQ (key, QCembolden))
+ FcPatternAddBool (pat, FC_EMBOLDEN, NILP (val) ? FcFalse : FcTrue);
+#endif
+ }
+}
+
+FcPattern *
+ftfont_entity_pattern (Lisp_Object entity, int pixel_size)
+{
+ Lisp_Object val, filename, idx;
+ FcPattern *pat;
+ int i;
+
+ val = assq_no_quit (QCfont_entity, AREF (entity, FONT_EXTRA_INDEX));
+ eassert (CONSP (val));
+ val = XCDR (val);
+ filename = XCAR (val);
+ idx = XCDR (val);
+ pat = FcPatternCreate ();
+ FcPatternAddInteger (pat, FC_WEIGHT, FONT_WEIGHT_NUMERIC (entity));
+ i = FONT_SLANT_NUMERIC (entity) - 100;
+ if (i < 0) i = 0;
+ FcPatternAddInteger (pat, FC_SLANT, i);
+ FcPatternAddInteger (pat, FC_WIDTH, FONT_WIDTH_NUMERIC (entity));
+ FcPatternAddDouble (pat, FC_PIXEL_SIZE, pixel_size);
+ val = AREF (entity, FONT_FAMILY_INDEX);
+ if (! NILP (val))
+ FcPatternAddString (pat, FC_FAMILY, (FcChar8 *) SDATA (SYMBOL_NAME (val)));
+ val = AREF (entity, FONT_FOUNDRY_INDEX);
+ if (! NILP (val))
+ FcPatternAddString (pat, FC_FOUNDRY, (FcChar8 *) SDATA (SYMBOL_NAME (val)));
+ val = AREF (entity, FONT_SPACING_INDEX);
+ if (! NILP (val))
+ FcPatternAddInteger (pat, FC_SPACING, XFIXNUM (val));
+ val = AREF (entity, FONT_DPI_INDEX);
+ if (! NILP (val))
+ {
+ double dbl = XFIXNUM (val);
+
+ FcPatternAddDouble (pat, FC_DPI, dbl);
+ }
+ val = AREF (entity, FONT_AVGWIDTH_INDEX);
+ if (FIXNUMP (val) && XFIXNUM (val) == 0)
+ FcPatternAddBool (pat, FC_SCALABLE, FcTrue);
+ /* This is necessary to identify the exact font (e.g. 10x20.pcf.gz
+ over 10x20-ISO8859-1.pcf.gz). */
+ FcPatternAddCharSet (pat, FC_CHARSET, ftfont_get_fc_charset (entity));
+
+ ftfont_add_rendering_parameters (pat, entity);
+
+ FcPatternAddString (pat, FC_FILE, (FcChar8 *) SDATA (filename));
+ FcPatternAddInteger (pat, FC_INDEX, XFIXNUM (idx));
+
+ return pat;
+}
Lisp_Object
-ftfont_open2 (struct frame *f,
- Lisp_Object entity,
- int pixel_size,
- Lisp_Object font_object)
+ftfont_open (struct frame *f, Lisp_Object entity, int pixel_size)
{
struct font_info *ftfont_info;
struct font *font;
@@ -1092,12 +1239,11 @@ ftfont_open2 (struct frame *f,
FT_Face ft_face;
FT_Size ft_size;
FT_UInt size;
- Lisp_Object val, filename, idx, cache;
+ Lisp_Object val, filename, idx, cache, font_object;
bool scalable;
int spacing;
int i;
double upEM;
- FT_Int strike_index = -1;
val = assq_no_quit (QCfont_entity, AREF (entity, FONT_EXTRA_INDEX));
if (! CONSP (val))
@@ -1126,35 +1272,17 @@ ftfont_open2 (struct frame *f,
size = pixel_size;
if (FT_Set_Pixel_Sizes (ft_face, size, size) != 0)
{
- int min_distance = INT_MAX;
- bool magnify = true;
-
- for (FT_Int i = 0; i < ft_face->num_fixed_sizes; i++)
- {
- int distance = ft_face->available_sizes[i].height - (int) size;
-
- /* Prefer down-scaling to upscaling. */
- if (magnify == (distance < 0) ? abs (distance) <= min_distance
- : magnify)
- {
- magnify = distance < 0;
- min_distance = abs (distance);
- strike_index = i;
- }
- }
-
- if (strike_index < 0 || FT_Select_Size (ft_face, strike_index) != 0)
+ if (cache_data->face_refcount == 0)
{
- if (cache_data->face_refcount == 0)
- {
- FT_Done_Face (ft_face);
- cache_data->ft_face = NULL;
- }
- return Qnil;
+ FT_Done_Face (ft_face);
+ cache_data->ft_face = NULL;
}
+ return Qnil;
}
cache_data->face_refcount++;
+ font_object = font_build_object (VECSIZE (struct font_info),
+ Qfreetype, entity, size);
ASET (font_object, FONT_FILE_INDEX, filename);
font = XFONT_OBJECT (font_object);
ftfont_info = (struct font_info *) font;
@@ -1164,7 +1292,6 @@ ftfont_open2 (struct frame *f,
ftfont_info->maybe_otf = (ft_face->face_flags & FT_FACE_FLAG_SFNT) != 0;
ftfont_info->otf = NULL;
#endif /* HAVE_LIBOTF */
- ftfont_info->bitmap_strike_index = strike_index;
/* This means that there's no need of transformation. */
ftfont_info->matrix.xx = 0;
font->pixel_size = size;
@@ -1258,31 +1385,6 @@ ftfont_open2 (struct frame *f,
return font_object;
}
-Lisp_Object
-ftfont_open (struct frame *f, Lisp_Object entity, int pixel_size)
-{
- Lisp_Object font_object;
- FT_UInt size;
- size = XFIXNUM (AREF (entity, FONT_SIZE_INDEX));
- if (size == 0)
- size = pixel_size;
- font_object = font_build_object (VECSIZE (struct font_info),
- Qfreetype, entity, size);
- font_object = ftfont_open2 (f, entity, pixel_size, font_object);
- if (FONT_OBJECT_P (font_object))
- {
- struct font *font = XFONT_OBJECT (font_object);
- struct font_info *ftfont_info = (struct font_info *) font;
-
- if (ftfont_info->bitmap_strike_index >= 0)
- {
- ftfont_close (font);
- font_object = Qnil;
- }
- }
- return font_object;
-}
-
void
ftfont_close (struct font *font)
{
@@ -1353,7 +1455,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;
@@ -2789,6 +2891,14 @@ syms_of_ftfont (void)
/* The boolean-valued font property key specifying the use of leading. */
DEFSYM (QCminspace, ":minspace");
+ /* Fontconfig's rendering parameters. */
+ DEFSYM (QChinting, ":hinting");
+ DEFSYM (QCautohint, ":autohint");
+ DEFSYM (QChintstyle, ":hintstyle");
+ DEFSYM (QCrgba, ":rgba");
+ DEFSYM (QCembolden, ":embolden");
+ DEFSYM (QClcdfilter, ":lcdfilter");
+
staticpro (&freetype_font_cache);
freetype_font_cache = list1 (Qt);
diff --git a/src/ftfont.h b/src/ftfont.h
index adbda49ff1c..7860469491f 100644
--- a/src/ftfont.h
+++ b/src/ftfont.h
@@ -37,10 +37,9 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
#endif /* HAVE_LIBOTF */
extern FcCharSet *ftfont_get_fc_charset (Lisp_Object);
-extern Lisp_Object ftfont_open2 (struct frame *f,
- Lisp_Object entity,
- int pixel_size,
- Lisp_Object font_object);
+extern void ftfont_fix_match (FcPattern *, FcPattern *);
+extern void ftfont_add_rendering_parameters (FcPattern *, Lisp_Object);
+extern FcPattern *ftfont_entity_pattern (Lisp_Object, int);
/* This struct is shared by the XFT, Freetype, and Cairo font
backends. Members up to and including 'matrix' are common, the
@@ -54,17 +53,14 @@ struct font_info
#endif /* HAVE_LIBOTF */
FT_Size ft_size;
int index;
- /* Index of the bitmap strike used as a fallback for
- FT_Set_Pixel_Sizes failure. If the value is non-negative, then
- ft_size is not of the requested size. Otherwise it is -1. */
- FT_Int bitmap_strike_index;
FT_Matrix matrix;
#ifdef USE_CAIRO
cairo_scaled_font_t *cr_scaled_font;
- /* To prevent cairo from cluttering the activated FT_Size maintained
- in ftfont.c, we activate this special FT_Size before drawing. */
- FT_Size ft_size_draw;
+ /* Scale factor from the bitmap strike metrics in 1/64 pixels, used
+ as the hb_position_t value in HarfBuzz, to those in (scaled)
+ pixels. The value is 0 for scalable fonts. */
+ double bitmap_position_unit;
/* Font metrics cache. */
struct font_metrics **metrics;
short metrics_nrows;
diff --git a/src/ftxfont.c b/src/ftxfont.c
index f9a69c35151..8bce7f10f1e 100644
--- a/src/ftxfont.c
+++ b/src/ftxfont.c
@@ -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 *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;
}
diff --git a/src/gtkutil.c b/src/gtkutil.c
index 48233576531..43918dd3da5 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -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;
diff --git a/src/gtkutil.h b/src/gtkutil.h
index ec899781ca8..229aa08f817 100644
--- a/src/gtkutil.h
+++ b/src/gtkutil.h
@@ -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,
diff --git a/src/image.c b/src/image.c
index 071b92a741e..699bdfd4fa1 100644
--- a/src/image.c
+++ b/src/image.c
@@ -132,17 +132,17 @@ static unsigned long *colors_in_color_table (int *n);
#ifdef HAVE_NS
/* Use with images created by ns_image_for_XPM. */
static unsigned long
-XGetPixel (XImagePtr ximage, int x, int y)
+XGetPixel (Emacs_Pix_Container image, int x, int y)
{
- return ns_get_pixel (ximage, x, y);
+ return ns_get_pixel (image, x, y);
}
/* Use with images created by ns_image_for_XPM; alpha set to 1;
pixel is assumed to be in RGB form. */
static void
-XPutPixel (XImagePtr ximage, int x, int y, unsigned long pixel)
+XPutPixel (Emacs_Pix_Container image, int x, int y, unsigned long pixel)
{
- ns_put_pixel (ximage, x, y, pixel);
+ ns_put_pixel (image, x, y, pixel);
}
#endif /* HAVE_NS */
@@ -228,7 +228,7 @@ image_create_bitmap_from_data (struct frame *f, char *bits,
#ifdef HAVE_NTGUI
Lisp_Object frame UNINIT; /* The value is not used. */
- Pixmap bitmap;
+ Emacs_Pixmap bitmap;
bitmap = CreateBitmap (width, height,
FRAME_DISPLAY_INFO (XFRAME (frame))->n_planes,
FRAME_DISPLAY_INFO (XFRAME (frame))->n_cbits,
@@ -412,17 +412,19 @@ typedef void Picture;
#endif
static bool image_create_x_image_and_pixmap_1 (struct frame *, int, int, int,
- XImagePtr *, Pixmap *, Picture *);
-static void image_destroy_x_image (XImagePtr ximg);
+ Emacs_Pix_Container *,
+ Emacs_Pixmap *, Picture *);
+static void image_destroy_x_image (Emacs_Pix_Container);
#ifdef HAVE_NTGUI
-static XImagePtr_or_DC image_get_x_image_or_dc (struct frame *, struct image *,
- bool, HGDIOBJ *);
-static void image_unget_x_image_or_dc (struct image *, bool, XImagePtr_or_DC,
- HGDIOBJ);
+static HDC image_get_x_image_or_dc (struct frame *, struct image *,
+ bool, HGDIOBJ *);
+static void image_unget_x_image_or_dc (struct image *, bool,
+ HDC, HGDIOBJ);
#else
-static XImagePtr image_get_x_image (struct frame *, struct image *, bool);
-static void image_unget_x_image (struct image *, bool, XImagePtr);
+static Emacs_Pix_Container image_get_x_image (struct frame *, struct image *,
+ bool);
+static void image_unget_x_image (struct image *, bool, Emacs_Pix_Container);
#define image_get_x_image_or_dc(f, img, mask_p, dummy) \
image_get_x_image (f, img, mask_p)
#define image_unget_x_image_or_dc(img, mask_p, ximg, dummy) \
@@ -436,7 +438,7 @@ static void image_sync_to_pixmaps (struct frame *, struct image *);
/* Useful functions defined in the section
`Image type independent image structures' below. */
-static unsigned long four_corners_best (XImagePtr ximg,
+static unsigned long four_corners_best (XImage *ximg,
int *corners,
unsigned long width,
unsigned long height);
@@ -449,7 +451,7 @@ void
x_create_bitmap_mask (struct frame *f, ptrdiff_t id)
{
Pixmap pixmap, mask;
- XImagePtr ximg, mask_img;
+ XImage *ximg, *mask_img;
unsigned long width, height;
bool result;
unsigned long bg;
@@ -1076,10 +1078,10 @@ image_ascent (struct image *img, struct face *face, struct glyph_slice *slice)
#ifdef USE_CAIRO
static uint32_t
-xcolor_to_argb32 (XColor xc)
+emacs_color_to_argb32 (Emacs_Color *ec)
{
- return ((0xffu << 24) | ((xc.red / 256) << 16)
- | ((xc.green / 256) << 8) | (xc.blue / 256));
+ return ((0xffu << 24) | ((ec->red / 256) << 16)
+ | ((ec->green / 256) << 8) | (ec->blue / 256));
}
static uint32_t
@@ -1087,11 +1089,11 @@ get_spec_bg_or_alpha_as_argb (struct image *img,
struct frame *f)
{
uint32_t bgcolor = 0;
- XColor xbgcolor;
+ Emacs_Color xbgcolor;
Lisp_Object bg = image_spec_value (img->spec, QCbackground, NULL);
if (STRINGP (bg) && x_parse_color (f, SSDATA (bg), &xbgcolor))
- bgcolor = xcolor_to_argb32 (xbgcolor);
+ bgcolor = emacs_color_to_argb32 (&xbgcolor);
return bgcolor;
}
@@ -1121,10 +1123,10 @@ set_cairo_image_surface (struct image *img, cairo_surface_t *surface)
/* Image background colors. */
/* Find the "best" corner color of a bitmap.
- On W32, XIMG is assumed to a device context with the bitmap selected. */
+ On W32, PIMG is assumed to a device context with the bitmap selected. */
static RGB_PIXEL_COLOR
-four_corners_best (XImagePtr_or_DC ximg, int *corners,
+four_corners_best (Emacs_Pix_Context pimg, int *corners,
unsigned long width, unsigned long height)
{
RGB_PIXEL_COLOR corner_pixels[4];
@@ -1133,19 +1135,19 @@ four_corners_best (XImagePtr_or_DC ximg, int *corners,
if (corners && corners[BOT_CORNER] >= 0)
{
- /* Get the colors at the corner_pixels of ximg. */
- corner_pixels[0] = GET_PIXEL (ximg, corners[LEFT_CORNER], corners[TOP_CORNER]);
- corner_pixels[1] = GET_PIXEL (ximg, corners[RIGHT_CORNER] - 1, corners[TOP_CORNER]);
- corner_pixels[2] = GET_PIXEL (ximg, corners[RIGHT_CORNER] - 1, corners[BOT_CORNER] - 1);
- corner_pixels[3] = GET_PIXEL (ximg, corners[LEFT_CORNER], corners[BOT_CORNER] - 1);
+ /* Get the colors at the corner_pixels of pimg. */
+ corner_pixels[0] = GET_PIXEL (pimg, corners[LEFT_CORNER], corners[TOP_CORNER]);
+ corner_pixels[1] = GET_PIXEL (pimg, corners[RIGHT_CORNER] - 1, corners[TOP_CORNER]);
+ corner_pixels[2] = GET_PIXEL (pimg, corners[RIGHT_CORNER] - 1, corners[BOT_CORNER] - 1);
+ corner_pixels[3] = GET_PIXEL (pimg, corners[LEFT_CORNER], corners[BOT_CORNER] - 1);
}
else
{
- /* Get the colors at the corner_pixels of ximg. */
- corner_pixels[0] = GET_PIXEL (ximg, 0, 0);
- corner_pixels[1] = GET_PIXEL (ximg, width - 1, 0);
- corner_pixels[2] = GET_PIXEL (ximg, width - 1, height - 1);
- corner_pixels[3] = GET_PIXEL (ximg, 0, height - 1);
+ /* Get the colors at the corner_pixels of pimg. */
+ corner_pixels[0] = GET_PIXEL (pimg, 0, 0);
+ corner_pixels[1] = GET_PIXEL (pimg, width - 1, 0);
+ corner_pixels[2] = GET_PIXEL (pimg, width - 1, height - 1);
+ corner_pixels[3] = GET_PIXEL (pimg, 0, height - 1);
}
/* Choose the most frequently found color as background. */
for (i = best_count = 0; i < 4; ++i)
@@ -1165,27 +1167,27 @@ four_corners_best (XImagePtr_or_DC ximg, int *corners,
/* Return the `background' field of IMG. If IMG doesn't have one yet,
it is guessed heuristically. If non-zero, XIMG is an existing
- XImage object (or device context with the image selected on W32) to
- use for the heuristic. */
+ Emacs_Pix_Context object (device context with the image selected on
+ W32) to use for the heuristic. */
RGB_PIXEL_COLOR
-image_background (struct image *img, struct frame *f, XImagePtr_or_DC ximg)
+image_background (struct image *img, struct frame *f, Emacs_Pix_Context pimg)
{
if (! img->background_valid)
/* IMG doesn't have a background yet, try to guess a reasonable value. */
{
- bool free_ximg = !ximg;
+ bool free_pimg = !pimg;
#ifdef HAVE_NTGUI
HGDIOBJ prev;
#endif /* HAVE_NTGUI */
- if (free_ximg)
- ximg = image_get_x_image_or_dc (f, img, 0, &prev);
+ if (free_pimg)
+ pimg = image_get_x_image_or_dc (f, img, 0, &prev);
- img->background = four_corners_best (ximg, img->corners, img->width, img->height);
+ img->background = four_corners_best (pimg, img->corners, img->width, img->height);
- if (free_ximg)
- image_unget_x_image_or_dc (img, 0, ximg, prev);
+ if (free_pimg)
+ image_unget_x_image_or_dc (img, 0, pimg, prev);
img->background_valid = 1;
}
@@ -1195,10 +1197,12 @@ image_background (struct image *img, struct frame *f, XImagePtr_or_DC ximg)
/* Return the `background_transparent' field of IMG. If IMG doesn't
have one yet, it is guessed heuristically. If non-zero, MASK is an
- existing XImage object to use for the heuristic. */
+ existing Emacs_Pix_Context (XImage* on X) object to use for the
+ heuristic. */
int
-image_background_transparent (struct image *img, struct frame *f, XImagePtr_or_DC mask)
+image_background_transparent (struct image *img, struct frame *f,
+ Emacs_Pix_Context mask)
{
if (! img->background_transparent_valid)
/* IMG doesn't have a background yet, try to guess a reasonable value. */
@@ -1321,7 +1325,7 @@ static unsigned long
image_alloc_image_color (struct frame *f, struct image *img,
Lisp_Object color_name, unsigned long dflt)
{
- XColor color;
+ Emacs_Color color;
unsigned long result;
eassert (STRINGP (color_name));
@@ -2001,7 +2005,7 @@ mark_image_cache (struct image_cache *c)
WIDTH and HEIGHT must both be positive.
If XIMG is null, assume it is a bitmap. */
static bool
-image_check_image_size (XImagePtr ximg, int width, int height)
+image_check_image_size (Emacs_Pix_Container ximg, int width, int height)
{
#ifdef HAVE_X_WINDOWS
/* Respect Xlib's limits: it cannot deal with images that have more
@@ -2035,18 +2039,20 @@ image_check_image_size (XImagePtr ximg, int width, int height)
#endif
}
-/* Create an XImage and a pixmap of size WIDTH x HEIGHT for use on
- frame F. Set *XIMG and *PIXMAP to the XImage and Pixmap created.
- Set (*XIMG)->data to a raster of WIDTH x HEIGHT pixels allocated
- via xmalloc. Print error messages via image_error if an error
- occurs. Value is true if successful.
+/* Create an Emacs_Pix_Container and a pixmap of size WIDTH x
+ HEIGHT for use on frame F. Set *PIMG and *PIXMAP to the
+ Emacs_Pix_Container and Emacs_Pixmap created. Set (*PIMG)->data
+ to a raster of WIDTH x HEIGHT pixels allocated via xmalloc. Print
+ error messages via image_error if an error occurs. Value is true
+ if successful.
On W32, a DEPTH of zero signifies a 24 bit image, otherwise DEPTH
should indicate the bit depth of the image. */
static bool
image_create_x_image_and_pixmap_1 (struct frame *f, int width, int height, int depth,
- XImagePtr *ximg, Pixmap *pixmap, Picture *picture)
+ Emacs_Pix_Container *pimg,
+ Emacs_Pixmap *pixmap, Picture *picture)
{
#ifdef HAVE_X_WINDOWS
Display *display = FRAME_X_DISPLAY (f);
@@ -2057,33 +2063,33 @@ image_create_x_image_and_pixmap_1 (struct frame *f, int width, int height, int d
if (depth <= 0)
depth = DefaultDepthOfScreen (screen);
- *ximg = XCreateImage (display, DefaultVisualOfScreen (screen),
+ *pimg = XCreateImage (display, DefaultVisualOfScreen (screen),
depth, ZPixmap, 0, NULL, width, height,
depth > 16 ? 32 : depth > 8 ? 16 : 8, 0);
- if (*ximg == NULL)
+ if (*pimg == NULL)
{
image_error ("Unable to allocate X image");
return 0;
}
- if (! image_check_image_size (*ximg, width, height))
+ if (! image_check_image_size (*pimg, width, height))
{
- image_destroy_x_image (*ximg);
- *ximg = NULL;
+ image_destroy_x_image (*pimg);
+ *pimg = NULL;
image_error ("Image too large (%dx%d)",
make_fixnum (width), make_fixnum (height));
return 0;
}
/* Allocate image raster. */
- (*ximg)->data = xmalloc ((*ximg)->bytes_per_line * height);
+ (*pimg)->data = xmalloc ((*pimg)->bytes_per_line * height);
/* Allocate a pixmap of the same size. */
*pixmap = XCreatePixmap (display, drawable, width, height, depth);
if (*pixmap == NO_PIXMAP)
{
- image_destroy_x_image (*ximg);
- *ximg = NULL;
+ image_destroy_x_image (*pimg);
+ *pimg = NULL;
image_error ("Unable to create X pixmap");
return 0;
}
@@ -2150,10 +2156,10 @@ image_create_x_image_and_pixmap_1 (struct frame *f, int width, int height, int d
if (depth < 16)
palette_colors = 1 << (depth - 1);
- *ximg = xmalloc (sizeof (XImage) + palette_colors * sizeof (RGBQUAD));
+ *pimg = xmalloc (sizeof (XImage) + palette_colors * sizeof (RGBQUAD));
- header = &(*ximg)->info.bmiHeader;
- memset (&(*ximg)->info, 0, sizeof (BITMAPINFO));
+ header = &(*pimg)->info.bmiHeader;
+ memset (&(*pimg)->info, 0, sizeof (BITMAPINFO));
header->biSize = sizeof (*header);
header->biWidth = width;
header->biHeight = -height; /* negative indicates a top-down bitmap. */
@@ -2165,10 +2171,10 @@ image_create_x_image_and_pixmap_1 (struct frame *f, int width, int height, int d
/* TODO: fill in palette. */
if (depth == 1)
{
- (*ximg)->info.bmiColors[0].rgbBlue = 0;
- (*ximg)->info.bmiColors[0].rgbGreen = 0;
- (*ximg)->info.bmiColors[0].rgbRed = 0;
- (*ximg)->info.bmiColors[0].rgbReserved = 0;
+ (*pimg)->info.bmiColors[0].rgbBlue = 0;
+ (*pimg)->info.bmiColors[0].rgbGreen = 0;
+ (*pimg)->info.bmiColors[0].rgbRed = 0;
+ (*pimg)->info.bmiColors[0].rgbReserved = 0;
/* bmiColors is a variable-length array declared by w32api
headers as bmiColors[1], which triggers a warning under
-Warray-bounds; shut that up. */
@@ -2176,10 +2182,10 @@ image_create_x_image_and_pixmap_1 (struct frame *f, int width, int height, int d
# pragma GCC push_options
# pragma GCC diagnostic ignored "-Warray-bounds"
# endif
- (*ximg)->info.bmiColors[1].rgbBlue = 255;
- (*ximg)->info.bmiColors[1].rgbGreen = 255;
- (*ximg)->info.bmiColors[1].rgbRed = 255;
- (*ximg)->info.bmiColors[1].rgbReserved = 0;
+ (*pimg)->info.bmiColors[1].rgbBlue = 255;
+ (*pimg)->info.bmiColors[1].rgbGreen = 255;
+ (*pimg)->info.bmiColors[1].rgbRed = 255;
+ (*pimg)->info.bmiColors[1].rgbReserved = 0;
# if GNUC_PREREQ (4, 4, 0)
# pragma GCC pop_options
# endif
@@ -2189,10 +2195,10 @@ image_create_x_image_and_pixmap_1 (struct frame *f, int width, int height, int d
/* Create a DIBSection and raster array for the bitmap,
and store its handle in *pixmap. */
- *pixmap = CreateDIBSection (hdc, &((*ximg)->info),
+ *pixmap = CreateDIBSection (hdc, &((*pimg)->info),
(depth < 16) ? DIB_PAL_COLORS : DIB_RGB_COLORS,
/* casting avoids a GCC warning */
- (void **)&((*ximg)->data), NULL, 0);
+ (void **)&((*pimg)->data), NULL, 0);
/* Realize display palette and garbage all frames. */
release_frame_dc (f, hdc);
@@ -2204,8 +2210,8 @@ image_create_x_image_and_pixmap_1 (struct frame *f, int width, int height, int d
/* All system errors are < 10000, so the following is safe. */
XSETINT (errcode, err);
image_error ("Unable to create bitmap, error code %d", errcode);
- image_destroy_x_image (*ximg);
- *ximg = NULL;
+ image_destroy_x_image (*pimg);
+ *pimg = NULL;
return 0;
}
@@ -2217,69 +2223,70 @@ image_create_x_image_and_pixmap_1 (struct frame *f, int width, int height, int d
*pixmap = ns_image_for_XPM (width, height, depth);
if (*pixmap == 0)
{
- *ximg = NULL;
+ *pimg = NULL;
image_error ("Unable to allocate NSImage for XPM pixmap");
return 0;
}
- *ximg = *pixmap;
+ *pimg = *pixmap;
return 1;
#endif
}
-/* Destroy XImage XIMG. Free XIMG->data. */
+/* Destroy Emacs_Pix_Container PIMG. Free data associated with PIMG. */
static void
-image_destroy_x_image (XImagePtr ximg)
+image_destroy_x_image (Emacs_Pix_Container pimg)
{
eassert (input_blocked_p ());
- if (ximg)
+ if (pimg)
{
#ifdef HAVE_X_WINDOWS
- xfree (ximg->data);
- ximg->data = NULL;
- XDestroyImage (ximg);
+ xfree (pimg->data);
+ pimg->data = NULL;
+ XDestroyImage (pimg);
#endif /* HAVE_X_WINDOWS */
#ifdef HAVE_NTGUI
/* Data will be freed by DestroyObject. */
- ximg->data = NULL;
- xfree (ximg);
+ pimg->data = NULL;
+ xfree (pimg);
#endif /* HAVE_NTGUI */
#ifdef HAVE_NS
- ns_release_object (ximg);
+ ns_release_object (pimg);
#endif /* HAVE_NS */
}
}
-/* Put XImage XIMG into pixmap PIXMAP on frame F. WIDTH and HEIGHT
- are width and height of both the image and pixmap. */
+/* Put Emacs_Pix_Container PIMG into pixmap PIXMAP on frame F.
+ WIDTH and HEIGHT are width and height of both the image and
+ pixmap. */
static void
-gui_put_x_image (struct frame *f, XImagePtr ximg, Pixmap pixmap,
- int width, int height)
+gui_put_x_image (struct frame *f, Emacs_Pix_Container pimg,
+ Emacs_Pixmap pixmap, int width, int height)
{
#ifdef HAVE_X_WINDOWS
GC gc;
eassert (input_blocked_p ());
gc = XCreateGC (FRAME_X_DISPLAY (f), pixmap, 0, NULL);
- XPutImage (FRAME_X_DISPLAY (f), pixmap, gc, ximg, 0, 0, 0, 0,
- ximg->width, ximg->height);
+ XPutImage (FRAME_X_DISPLAY (f), pixmap, gc, pimg, 0, 0, 0, 0,
+ pimg->width, pimg->height);
XFreeGC (FRAME_X_DISPLAY (f), gc);
#endif /* HAVE_X_WINDOWS */
#ifdef HAVE_NTGUI
#if 0 /* I don't think this is necessary looking at where it is used. */
HDC hdc = get_frame_dc (f);
- SetDIBits (hdc, pixmap, 0, height, ximg->data, &(ximg->info), DIB_RGB_COLORS);
+ SetDIBits (hdc, pixmap, 0, height, pimg->data, &(pimg->info), DIB_RGB_COLORS);
release_frame_dc (f, hdc);
#endif
#endif /* HAVE_NTGUI */
#ifdef HAVE_NS
- eassert (ximg == pixmap);
- ns_retain_object (ximg);
+ eassert (pimg == pixmap);
+ ns_retain_object (pimg);
#endif
}
@@ -2289,7 +2296,7 @@ gui_put_x_image (struct frame *f, XImagePtr ximg, Pixmap pixmap,
static bool
image_create_x_image_and_pixmap (struct frame *f, struct image *img,
int width, int height, int depth,
- XImagePtr *ximg, bool mask_p)
+ Emacs_Pix_Container *ximg, bool mask_p)
{
eassert ((!mask_p ? img->pixmap : img->mask) == NO_PIXMAP);
@@ -2302,14 +2309,14 @@ image_create_x_image_and_pixmap (struct frame *f, struct image *img,
picture);
}
-/* Put X image XIMG into image IMG on frame F, as a mask if and only
- if MASK_P. On X, this simply records XIMG on a member of IMG, so
+/* Put pixel image PIMG into image IMG on frame F, as a mask if and only
+ if MASK_P. On X, this simply records PIMG on a member of IMG, so
it can be put into the pixmap afterwards via image_sync_to_pixmaps.
- On the other platforms, it puts XIMG into the pixmap, then frees
- the X image and its buffer. */
+ On the other platforms, it puts PIMG into the pixmap, then frees
+ the pixel image and its buffer. */
static void
-image_put_x_image (struct frame *f, struct image *img, XImagePtr ximg,
+image_put_x_image (struct frame *f, struct image *img, Emacs_Pix_Container ximg,
bool mask_p)
{
#ifdef HAVE_X_WINDOWS
@@ -2357,12 +2364,12 @@ image_sync_to_pixmaps (struct frame *f, struct image *img)
currently selected GDI object into *PREV for future restoration by
image_unget_x_image_or_dc. */
-static XImagePtr_or_DC
+static HDC
image_get_x_image_or_dc (struct frame *f, struct image *img, bool mask_p,
HGDIOBJ *prev)
{
HDC frame_dc = get_frame_dc (f);
- XImagePtr_or_DC ximg = CreateCompatibleDC (frame_dc);
+ HDC ximg = CreateCompatibleDC (frame_dc);
release_frame_dc (f, frame_dc);
*prev = SelectObject (ximg, !mask_p ? img->pixmap : img->mask);
@@ -2372,7 +2379,7 @@ image_get_x_image_or_dc (struct frame *f, struct image *img, bool mask_p,
static void
image_unget_x_image_or_dc (struct image *img, bool mask_p,
- XImagePtr_or_DC ximg, HGDIOBJ prev)
+ HDC ximg, HGDIOBJ prev)
{
SelectObject (ximg, prev);
DeleteDC (ximg);
@@ -2381,11 +2388,11 @@ image_unget_x_image_or_dc (struct image *img, bool mask_p,
/* Get the X image for IMG on frame F. The resulting X image data
should be treated as read-only at least on X. */
-static XImagePtr
+static Emacs_Pix_Container
image_get_x_image (struct frame *f, struct image *img, bool mask_p)
{
#ifdef HAVE_X_WINDOWS
- XImagePtr ximg_in_img = !mask_p ? img->ximg : img->mask_img;
+ XImage *ximg_in_img = !mask_p ? img->ximg : img->mask_img;
if (ximg_in_img)
return ximg_in_img;
@@ -2393,7 +2400,7 @@ image_get_x_image (struct frame *f, struct image *img, bool mask_p)
return XGetImage (FRAME_X_DISPLAY (f), !mask_p ? img->pixmap : img->mask,
0, 0, img->width, img->height, ~0, ZPixmap);
#elif defined (HAVE_NS)
- XImagePtr pixmap = !mask_p ? img->pixmap : img->mask;
+ Emacs_Pix_Container pixmap = !mask_p ? img->pixmap : img->mask;
ns_retain_object (pixmap);
return pixmap;
@@ -2401,10 +2408,10 @@ image_get_x_image (struct frame *f, struct image *img, bool mask_p)
}
static void
-image_unget_x_image (struct image *img, bool mask_p, XImagePtr ximg)
+image_unget_x_image (struct image *img, bool mask_p, Emacs_Pix_Container ximg)
{
#ifdef HAVE_X_WINDOWS
- XImagePtr ximg_in_img = !mask_p ? img->ximg : img->mask_img;
+ XImage *ximg_in_img = !mask_p ? img->ximg : img->mask_img;
if (ximg_in_img)
eassert (ximg == ximg_in_img);
@@ -4201,7 +4208,7 @@ xpm_load_image (struct frame *f,
#ifndef HAVE_NS
bool have_mask = false;
#endif
- XImagePtr ximg = NULL, mask_img = NULL;
+ Emacs_Pix_Container ximg = NULL, mask_img = NULL;
#define match() \
LA1 = xpm_scan (&s, end, &beg, &len)
@@ -4286,7 +4293,7 @@ xpm_load_image (struct frame *f,
char *color, *max_color;
int key, next_key, max_key = 0;
Lisp_Object symbol_color = Qnil, color_val;
- XColor cdef;
+ Emacs_Color cdef;
expect (XPM_TK_STRING);
if (len <= chars_per_pixel || len >= BUFSIZ + chars_per_pixel)
@@ -4772,18 +4779,18 @@ static int laplace_matrix[9] = {
#define COLOR_INTENSITY(R, G, B) ((2 * (R) + 3 * (G) + (B)) / 6)
-/* On frame F, return an array of XColor structures describing image
- IMG->pixmap. Each XColor structure has its pixel color set. RGB_P
- means also fill the red/green/blue members of the XColor
- structures. Value is a pointer to the array of XColors structures,
+/* On frame F, return an array of Emacs_Color structures describing image
+ IMG->pixmap. Each Emacs_Color structure has its pixel color set. RGB_P
+ means also fill the red/green/blue members of the Emacs_Color
+ structures. Value is a pointer to the array of Emacs_Color structures,
allocated with xmalloc; it must be freed by the caller. */
-static XColor *
-image_to_xcolors (struct frame *f, struct image *img, bool rgb_p)
+static Emacs_Color *
+image_to_emacs_colors (struct frame *f, struct image *img, bool rgb_p)
{
int x, y;
- XColor *colors, *p;
- XImagePtr_or_DC ximg;
+ Emacs_Color *colors, *p;
+ Emacs_Pix_Context ximg;
ptrdiff_t nbytes;
#ifdef HAVE_NTGUI
HGDIOBJ prev;
@@ -4798,13 +4805,13 @@ image_to_xcolors (struct frame *f, struct image *img, bool rgb_p)
/* Get the X image or create a memory device context for IMG. */
ximg = image_get_x_image_or_dc (f, img, 0, &prev);
- /* Fill the `pixel' members of the XColor array. I wished there
+ /* Fill the `pixel' members of the Emacs_Color array. I wished there
were an easy and portable way to circumvent XGetPixel. */
p = colors;
for (y = 0; y < img->height; ++y)
{
#if defined (HAVE_X_WINDOWS) || defined (HAVE_NTGUI)
- XColor *row = p;
+ Emacs_Color *row = p;
for (x = 0; x < img->width; ++x, ++p)
p->pixel = GET_PIXEL (ximg, x, y);
if (rgb_p)
@@ -4839,7 +4846,7 @@ image_to_xcolors (struct frame *f, struct image *img, bool rgb_p)
stored in ximg->data. */
static void
-XPutPixel (XImagePtr ximg, int x, int y, COLORREF color)
+XPutPixel (XImage *ximg, int x, int y, COLORREF color)
{
int width = ximg->info.bmiHeader.biWidth;
unsigned char * pixel;
@@ -4878,16 +4885,16 @@ XPutPixel (XImagePtr ximg, int x, int y, COLORREF color)
#endif /* HAVE_NTGUI */
-/* Create IMG->pixmap from an array COLORS of XColor structures, whose
+/* Create IMG->pixmap from an array COLORS of Emacs_Color structures, whose
RGB members are set. F is the frame on which this all happens.
COLORS will be freed; an existing IMG->pixmap will be freed, too. */
static void
-image_from_xcolors (struct frame *f, struct image *img, XColor *colors)
+image_from_emacs_colors (struct frame *f, struct image *img, Emacs_Color *colors)
{
int x, y;
- XImagePtr oimg = NULL;
- XColor *p;
+ Emacs_Pix_Container oimg = NULL;
+ Emacs_Color *p;
init_color_table ();
@@ -4925,8 +4932,8 @@ static void
image_detect_edges (struct frame *f, struct image *img,
int *matrix, int color_adjust)
{
- XColor *colors = image_to_xcolors (f, img, 1);
- XColor *new, *p;
+ Emacs_Color *colors = image_to_emacs_colors (f, img, 1);
+ Emacs_Color *new, *p;
int x, y, i, sum;
ptrdiff_t nbytes;
@@ -4969,7 +4976,7 @@ image_detect_edges (struct frame *f, struct image *img,
for (xx = x - 1; xx < x + 2; ++xx, ++i)
if (matrix[i])
{
- XColor *t = COLOR (colors, xx, yy);
+ Emacs_Color *t = COLOR (colors, xx, yy);
r += matrix[i] * t->red;
g += matrix[i] * t->green;
b += matrix[i] * t->blue;
@@ -4983,7 +4990,7 @@ image_detect_edges (struct frame *f, struct image *img,
}
xfree (colors);
- image_from_xcolors (f, img, new);
+ image_from_emacs_colors (f, img, new);
#undef COLOR
}
@@ -5066,8 +5073,8 @@ image_disable_image (struct frame *f, struct image *img)
/* Color (or grayscale). Convert to gray, and equalize. Just
drawing such images with a stipple can look very odd, so
we're using this method instead. */
- XColor *colors = image_to_xcolors (f, img, 1);
- XColor *p, *end;
+ Emacs_Color *colors = image_to_emacs_colors (f, img, 1);
+ Emacs_Color *p, *end;
const int h = 15000;
const int l = 30000;
@@ -5080,7 +5087,7 @@ image_disable_image (struct frame *f, struct image *img)
p->red = p->green = p->blue = i2;
}
- image_from_xcolors (f, img, colors);
+ image_from_emacs_colors (f, img, colors);
}
/* Draw a cross over the disabled image, if we must or if we
@@ -5158,13 +5165,13 @@ static void
image_build_heuristic_mask (struct frame *f, struct image *img,
Lisp_Object how)
{
- XImagePtr_or_DC ximg;
+ Emacs_Pix_Context ximg;
#ifdef HAVE_NTGUI
HGDIOBJ prev;
char *mask_img;
int row_width;
#elif !defined HAVE_NS
- XImagePtr mask_img;
+ Emacs_Pix_Container mask_img;
#endif
int x, y;
bool use_img_background;
@@ -5400,7 +5407,7 @@ pbm_load (struct frame *f, struct image *img)
char *contents = NULL;
char *end, *p;
#ifndef USE_CAIRO
- XImagePtr ximg;
+ Emacs_Pix_Container ximg;
#endif
specified_file = image_spec_value (img->spec, QCfile, NULL);
@@ -5522,7 +5529,7 @@ pbm_load (struct frame *f, struct image *img)
unsigned long fg = FRAME_FOREGROUND_PIXEL (f);
unsigned long bg = FRAME_BACKGROUND_PIXEL (f);
#ifdef USE_CAIRO
- XColor xfg, xbg;
+ Emacs_Color xfg, xbg;
int fga32, bga32;
#endif
/* Parse the image specification. */
@@ -5542,7 +5549,7 @@ pbm_load (struct frame *f, struct image *img)
xfg.pixel = fg;
x_query_colors (f, &xfg, 1);
}
- fga32 = xcolor_to_argb32 (xfg);
+ fga32 = emacs_color_to_argb32 (&xfg);
if (! fmt[PBM_BACKGROUND].count
|| ! STRINGP (fmt[PBM_BACKGROUND].value)
@@ -5555,7 +5562,7 @@ pbm_load (struct frame *f, struct image *img)
xbg.pixel = bg;
x_query_colors (f, &xbg, 1);
}
- bga32 = xcolor_to_argb32 (xbg);
+ bga32 = emacs_color_to_argb32 (&xbg);
#else
if (fmt[PBM_FOREGROUND].count
&& STRINGP (fmt[PBM_FOREGROUND].value))
@@ -5700,7 +5707,7 @@ pbm_load (struct frame *f, struct image *img)
#else
if (NILP (image_spec_value (img->spec, QCbackground, NULL)))
/* Casting avoids a GCC warning. */
- IMAGE_BACKGROUND (img, f, (XImagePtr_or_DC)ximg);
+ IMAGE_BACKGROUND (img, f, (Emacs_Pix_Context)ximg);
/* Put ximg into the image. */
image_put_x_image (f, img, ximg, 0);
@@ -5795,6 +5802,7 @@ DEF_DLL_FN (png_uint_32, png_get_valid, (png_structp, png_infop, png_uint_32));
DEF_DLL_FN (void, png_set_strip_16, (png_structp));
DEF_DLL_FN (void, png_set_expand, (png_structp));
DEF_DLL_FN (void, png_set_gray_to_rgb, (png_structp));
+DEF_DLL_FN (int, png_set_interlace_handling, (png_structp));
DEF_DLL_FN (void, png_set_background,
(png_structp, png_color_16p, int, int, double));
DEF_DLL_FN (png_uint_32, png_get_bKGD,
@@ -5833,6 +5841,7 @@ init_png_functions (void)
LOAD_DLL_FN (library, png_set_strip_16);
LOAD_DLL_FN (library, png_set_expand);
LOAD_DLL_FN (library, png_set_gray_to_rgb);
+ LOAD_DLL_FN (library, png_set_interlace_handling);
LOAD_DLL_FN (library, png_set_background);
LOAD_DLL_FN (library, png_get_bKGD);
LOAD_DLL_FN (library, png_read_update_info);
@@ -5868,6 +5877,7 @@ init_png_functions (void)
# undef png_set_background
# undef png_set_expand
# undef png_set_gray_to_rgb
+# undef png_set_interlace_handling
# undef png_set_longjmp_fn
# undef png_set_read_fn
# undef png_set_sig_bytes
@@ -5892,6 +5902,7 @@ init_png_functions (void)
# define png_set_background fn_png_set_background
# define png_set_expand fn_png_set_expand
# define png_set_gray_to_rgb fn_png_set_gray_to_rgb
+# define png_set_interlace_handling fn_png_set_interlace_handling
# define png_set_longjmp_fn fn_png_set_longjmp_fn
# define png_set_read_fn fn_png_set_read_fn
# define png_set_sig_bytes fn_png_set_sig_bytes
@@ -6022,7 +6033,7 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c)
cairo_surface_t *surface;
uint32_t *dataptr;
#else
- XImagePtr ximg, mask_img = NULL;
+ Emacs_Pix_Container ximg, mask_img = NULL;
#endif
/* Find out what file to load. */
@@ -6180,7 +6191,7 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c)
/* png_color_16 *image_bg; */
Lisp_Object specified_bg
= image_spec_value (img->spec, QCbackground, NULL);
- XColor color;
+ Emacs_Color color;
/* If the user specified a color, try to use it; if not, use the
current frame background, ignoring any default background
@@ -6206,7 +6217,7 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c)
}
}
- /* Update info structure. */
+ png_set_interlace_handling (png_ptr);
png_read_update_info (png_ptr, info_ptr);
/* Get number of channels. Valid values are 1 for grayscale images
@@ -6335,7 +6346,7 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c)
#else
/* Maybe fill in the background field while we have ximg handy.
Casting avoids a GCC warning. */
- IMAGE_BACKGROUND (img, f, (XImagePtr_or_DC)ximg);
+ IMAGE_BACKGROUND (img, f, (Emacs_Pix_Context)ximg);
/* Put ximg into the image. */
image_put_x_image (f, img, ximg, 0);
@@ -6345,7 +6356,7 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c)
{
/* Fill in the background_transparent field while we have the
mask handy. Casting avoids a GCC warning. */
- image_background_transparent (img, f, (XImagePtr_or_DC)mask_img);
+ image_background_transparent (img, f, (Emacs_Pix_Context)mask_img);
image_put_x_image (f, img, mask_img, 1);
}
@@ -6765,7 +6776,7 @@ jpeg_load_body (struct frame *f, struct image *img,
int i, ir, ig, ib;
#ifndef USE_CAIRO
unsigned long *colors;
- XImagePtr ximg = NULL;
+ Emacs_Pix_Container ximg = NULL;
#endif
/* Open the JPEG file. */
@@ -6955,7 +6966,7 @@ jpeg_load_body (struct frame *f, struct image *img,
/* Maybe fill in the background field while we have ximg handy. */
if (NILP (image_spec_value (img->spec, QCbackground, NULL)))
/* Casting avoids a GCC warning. */
- IMAGE_BACKGROUND (img, f, (XImagePtr_or_DC)ximg);
+ IMAGE_BACKGROUND (img, f, (Emacs_Pix_Context)ximg);
/* Put ximg into the image. */
image_put_x_image (f, img, ximg, 0);
@@ -7255,7 +7266,7 @@ tiff_load (struct frame *f, struct image *img)
int width, height, x, y, count;
uint32 *buf;
int rc;
- XImagePtr ximg;
+ Emacs_Pix_Container ximg;
tiff_memory_source memsrc;
Lisp_Object image;
@@ -7425,7 +7436,7 @@ tiff_load (struct frame *f, struct image *img)
/* Maybe fill in the background field while we have ximg handy. */
if (NILP (image_spec_value (img->spec, QCbackground, NULL)))
/* Casting avoids a GCC warning on W32. */
- IMAGE_BACKGROUND (img, f, (XImagePtr_or_DC)ximg);
+ IMAGE_BACKGROUND (img, f, (Emacs_Pix_Context)ximg);
/* Put ximg into the image. */
image_put_x_image (f, img, ximg, 0);
@@ -7813,7 +7824,7 @@ gif_load (struct frame *f, struct image *img)
uint32_t *data32 = (uint32_t *) cairo_image_surface_get_data (surface);
if (STRINGP (specified_bg))
{
- XColor color;
+ Emacs_Color color;
if (FRAME_TERMINAL (f)->defined_color_hook
(f, SSDATA (specified_bg), &color, false, false))
{
@@ -7829,7 +7840,7 @@ gif_load (struct frame *f, struct image *img)
}
#else
/* Create the X image and pixmap. */
- XImagePtr ximg;
+ Emacs_Pix_Container ximg;
if (!image_create_x_image_and_pixmap (f, img, width, height, 0, &ximg, 0))
{
gif_close (gif, NULL);
@@ -8059,7 +8070,7 @@ gif_load (struct frame *f, struct image *img)
/* Maybe fill in the background field while we have ximg handy. */
if (NILP (image_spec_value (img->spec, QCbackground, NULL)))
/* Casting avoids a GCC warning. */
- IMAGE_BACKGROUND (img, f, (XImagePtr_or_DC)ximg);
+ IMAGE_BACKGROUND (img, f, (Emacs_Pix_Context)ximg);
/* Put ximg into the image. */
image_put_x_image (f, img, ximg, 0);
@@ -8443,7 +8454,7 @@ imagemagick_load_image (struct frame *f, struct image *img,
size_t image_width, image_height;
MagickBooleanType status;
#ifndef USE_CAIRO
- XImagePtr ximg;
+ Emacs_Pix_Container ximg;
#endif
int x, y;
MagickWand *image_wand;
@@ -8548,7 +8559,7 @@ imagemagick_load_image (struct frame *f, struct image *img,
/* Retrieve the frame's background color, for use later. */
{
- XColor bgcolor;
+ Emacs_Color bgcolor;
Lisp_Object specified_bg;
specified_bg = image_spec_value (img->spec, QCbackground, NULL);
@@ -9274,7 +9285,7 @@ svg_load_image (struct frame *f, struct image *img, char *contents,
g_object_unref (pixbuf);
#else
/* Try to create a x pixmap to hold the svg pixmap. */
- XImagePtr ximg;
+ Emacs_Pix_Container ximg;
if (!image_create_x_image_and_pixmap (f, img, width, height, 0, &ximg, 0))
{
g_object_unref (pixbuf);
@@ -9285,7 +9296,7 @@ svg_load_image (struct frame *f, struct image *img, char *contents,
/* Handle alpha channel by combining the image with a background
color. */
- XColor background;
+ Emacs_Color background;
Lisp_Object specified_bg = image_spec_value (img->spec, QCbackground, NULL);
if (!STRINGP (specified_bg)
|| !FRAME_TERMINAL (f)->defined_color_hook (f,
@@ -9341,7 +9352,7 @@ svg_load_image (struct frame *f, struct image *img, char *contents,
/* Maybe fill in the background field while we have ximg handy.
Casting avoids a GCC warning. */
- IMAGE_BACKGROUND (img, f, (XImagePtr_or_DC)ximg);
+ IMAGE_BACKGROUND (img, f, (Emacs_Pix_Context)ximg);
/* Put ximg into the image. */
image_put_x_image (f, img, ximg, 0);
@@ -9569,7 +9580,7 @@ x_kill_gs_process (Pixmap pixmap, struct frame *f)
img->pixmap. */
if (x_mutable_colormap (FRAME_X_VISUAL (f)))
{
- XImagePtr ximg;
+ XImage *ximg;
block_input ();
diff --git a/src/keyboard.c b/src/keyboard.c
index 5f2b7afe6d1..bb4d185c914 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -3909,7 +3909,7 @@ kbd_buffer_get_event (KBOARD **kbp,
case END_SESSION_EVENT:
case LANGUAGE_CHANGE_EVENT:
#endif
-#if defined (HAVE_X11) || defined (HAVE_NTGUI) || defined (HAVE_NS)
+#ifdef HAVE_WINDOW_SYSTEM
case DELETE_WINDOW_EVENT:
case ICONIFY_EVENT:
case DEICONIFY_EVENT:
@@ -5283,7 +5283,7 @@ make_lispy_event (struct input_event *event)
switch (event->kind)
{
-#if defined (HAVE_X11) || defined (HAVE_NTGUI) || defined (HAVE_NS)
+#ifdef HAVE_WINDOW_SYSTEM
case DELETE_WINDOW_EVENT:
/* Make an event (delete-frame (FRAME)). */
return list2 (Qdelete_frame, list1 (event->frame_or_window));
diff --git a/src/lisp.h b/src/lisp.h
index 876b757bf3f..6db90596899 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -2679,7 +2679,7 @@ struct Lisp_Buffer_Objfwd
{
enum Lisp_Fwd_Type type; /* = Lisp_Fwd_Buffer_Obj */
int offset;
- /* One of Qnil, Qfixnump, Qsymbolp, Qstringp, Qfloatp or Qnumberp. */
+ /* One of Qnil, Qintegerp, Qsymbolp, Qstringp, Qfloatp or Qnumberp. */
Lisp_Object predicate;
};
diff --git a/src/macfont.m b/src/macfont.m
index 0ade77e7337..f825e6291d3 100644
--- a/src/macfont.m
+++ b/src/macfont.m
@@ -1639,7 +1639,7 @@ static Lisp_Object macfont_open (struct frame *, Lisp_Object, int);
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 @@ macfont_encode_char (struct font *font, int c)
}
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;
@@ -2818,7 +2818,18 @@ macfont_draw (struct glyph_string *s, int from, int to, int x, int y,
}
}
- context = [[NSGraphicsContext currentContext] graphicsPort];
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101000
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 101000
+ if ([[NSGraphicsContext currentContext] respondsToSelector:@selector(CGContext)])
+#endif
+ context = [[NSGraphicsContext currentContext] CGContext];
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 101000
+ else
+#endif
+#endif
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 101000
+ context = [[NSGraphicsContext currentContext] graphicsPort];
+#endif
CGContextSaveGState (context);
if (!CGRectIsNull (background_rect))
diff --git a/src/msdos.h b/src/msdos.h
index 90ceea8e3d2..3614c94dd0e 100644
--- a/src/msdos.h
+++ b/src/msdos.h
@@ -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
diff --git a/src/nsfont.m b/src/nsfont.m
index 9721e489357..eca97ab86cc 100644
--- a/src/nsfont.m
+++ b/src/nsfont.m
@@ -945,7 +945,7 @@ nsfont_encode_char (struct font *font, int c)
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;
diff --git a/src/nsgui.h b/src/nsgui.h
index ab6cdff1e5c..c21953593ad 100644
--- a/src/nsgui.h
+++ b/src/nsgui.h
@@ -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, \
diff --git a/src/nsimage.m b/src/nsimage.m
index 33236c48d42..0249d22acae 100644
--- a/src/nsimage.m
+++ b/src/nsimage.m
@@ -313,8 +313,8 @@ ns_set_alpha (void *img, int x, int y, unsigned char a)
if (bmRep == nil || color == nil)
return self;
- if ([color colorSpaceName] != NSCalibratedRGBColorSpace)
- rgbColor = [color colorUsingColorSpaceName: NSCalibratedRGBColorSpace];
+ if ([color colorSpace] != [NSColorSpace deviceRGBColorSpace])
+ rgbColor = [color colorUsingColorSpace:[NSColorSpace deviceRGBColorSpace]];
else
rgbColor = color;
diff --git a/src/nsmenu.m b/src/nsmenu.m
index fd1323344b3..3fe06cda02a 100644
--- a/src/nsmenu.m
+++ b/src/nsmenu.m
@@ -668,9 +668,9 @@ ns_activate_menubar (struct frame *f)
/* Draw radio buttons and tickboxes. */
if (wv->selected && (wv->button_type == BUTTON_TYPE_TOGGLE ||
wv->button_type == BUTTON_TYPE_RADIO))
- [item setState: NSOnState];
+ [item setState: NSControlStateValueOn];
else
- [item setState: NSOffState];
+ [item setState: NSControlStateValueOff];
[item setTag: (NSInteger)wv->call_data];
}
@@ -1594,7 +1594,7 @@ ns_popup_dialog (struct frame *f, Lisp_Object header, Lisp_Object contents)
[cell setBordered: NO];
[cell setEnabled: NO];
[cell setCellAttribute: NSCellIsInsetButton to: 8];
- [cell setBezelStyle: NSRoundedBezelStyle];
+ [cell setBezelStyle: NSBezelStyleRounded];
matrix = [[NSMatrix alloc] initWithFrame: contentRect
mode: NSHighlightModeMatrix
@@ -1607,7 +1607,6 @@ ns_popup_dialog (struct frame *f, Lisp_Object header, Lisp_Object contents)
[matrix autorelease];
[[self contentView] addSubview: matrix];
- [self setOneShot: YES];
[self setReleasedWhenClosed: YES];
[self setHidesOnDeactivate: YES];
return self;
diff --git a/src/nsselect.m b/src/nsselect.m
index cf36c869eb1..b044fe6f32d 100644
--- a/src/nsselect.m
+++ b/src/nsselect.m
@@ -57,7 +57,7 @@ symbol_to_nsstring (Lisp_Object sym)
if (EQ (sym, QCLIPBOARD)) return NSPasteboardNameGeneral;
if (EQ (sym, QPRIMARY)) return NXPrimaryPboard;
if (EQ (sym, QSECONDARY)) return NXSecondaryPboard;
- if (EQ (sym, QTEXT)) return NSStringPboardType;
+ if (EQ (sym, QTEXT)) return NSPasteboardTypeString;
return [NSString stringWithUTF8String: SSDATA (SYMBOL_NAME (sym))];
}
@@ -76,11 +76,11 @@ ns_string_to_symbol (NSString *t)
return QPRIMARY;
if ([t isEqualToString: NXSecondaryPboard])
return QSECONDARY;
- if ([t isEqualToString: NSStringPboardType])
+ if ([t isEqualToString: NSPasteboardTypeString])
return QTEXT;
if ([t isEqualToString: NSFilenamesPboardType])
return QFILE_NAME;
- if ([t isEqualToString: NSTabularTextPboardType])
+ if ([t isEqualToString: NSPasteboardTypeTabularText])
return QTEXT;
return intern ([t UTF8String]);
}
@@ -193,7 +193,7 @@ ns_string_to_pasteboard_internal (id pb, Lisp_Object str, NSString *gtype)
else
{
// Used for ns-own-selection-internal.
- eassert (gtype == NSStringPboardType);
+ eassert (gtype == NSPasteboardTypeString);
[pb setString: nsStr forType: gtype];
}
[nsStr release];
@@ -345,7 +345,7 @@ anything that the functions on `selection-converter-alist' know about. */)
}
/* We only support copy of text. */
- type = NSStringPboardType;
+ type = NSPasteboardTypeString;
target_symbol = ns_string_to_symbol (type);
if (STRINGP (value))
{
@@ -472,9 +472,9 @@ nxatoms_of_nsselect (void)
[NSNumber numberWithLong:0], NSPasteboardNameGeneral,
[NSNumber numberWithLong:0], NXPrimaryPboard,
[NSNumber numberWithLong:0], NXSecondaryPboard,
- [NSNumber numberWithLong:0], NSStringPboardType,
+ [NSNumber numberWithLong:0], NSPasteboardTypeString,
[NSNumber numberWithLong:0], NSFilenamesPboardType,
- [NSNumber numberWithLong:0], NSTabularTextPboardType,
+ [NSNumber numberWithLong:0], NSPasteboardTypeTabularText,
nil] retain];
}
diff --git a/src/nsterm.h b/src/nsterm.h
index ffaf809785e..1e56276ca3c 100644
--- a/src/nsterm.h
+++ b/src/nsterm.h
@@ -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);
@@ -1165,10 +1165,6 @@ extern void ns_release_autorelease_pool (void *);
extern const char *ns_get_defaults_value (const char *key);
extern void ns_init_locale (void);
-#ifdef NS_IMPL_COCOA
-extern void ns_enable_screen_updates (void);
-#endif
-
/* in nsmenu */
extern void update_frame_tool_bar (struct frame *f);
extern void free_frame_tool_bar (struct frame *f);
@@ -1336,4 +1332,14 @@ enum NSWindowTabbingMode
/* Deprecated in macOS 10.13. */
#define NSPasteboardNameGeneral NSGeneralPboard
#endif
+
+#if !defined (NS_IMPL_COCOA) || !defined (MAC_OS_X_VERSION_10_14)
+/* Deprecated in macOS 10.14. */
+#define NSPasteboardTypeString NSStringPboardType
+#define NSPasteboardTypeTabularText NSTabularTextPboardType
+#define NSPasteboardTypeURL NSURLPboardType
+#define NSControlStateValueOn NSOnState
+#define NSControlStateValueOff NSOffState
+#define NSBezelStyleRounded NSRoundedBezelStyle
+#endif
#endif /* HAVE_NS */
diff --git a/src/nsterm.m b/src/nsterm.m
index d688aceca53..0cae5e9d448 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -160,20 +160,28 @@ char const * nstrace_fullscreen_type_name (int fs_type)
- (NSColor *)colorUsingDefaultColorSpace
{
- /* FIXMES: We're checking for colorWithSRGBRed here so this will
- only work in the same place as in the method above. It should
- really be a check whether we're on macOS 10.7 or above. */
+ /* FIXME: We're checking for colorWithSRGBRed here so this will only
+ work in the same place as in the method above. It should really
+ be a check whether we're on macOS 10.7 or above. */
#if defined (NS_IMPL_COCOA) \
&& MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
- if (ns_use_srgb_colorspace
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
- && [NSColor respondsToSelector:
- @selector(colorWithSRGBRed:green:blue:alpha:)]
+ if ([NSColor respondsToSelector:
+ @selector(colorWithSRGBRed:green:blue:alpha:)])
#endif
- )
- return [self colorUsingColorSpace: [NSColorSpace sRGBColorSpace]];
+ {
+ if (ns_use_srgb_colorspace)
+ return [self colorUsingColorSpace: [NSColorSpace sRGBColorSpace]];
+ else
+ return [self colorUsingColorSpace: [NSColorSpace deviceRGBColorSpace]];
+ }
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
+ else
#endif
+#endif /* NS_IMPL_COCOA && MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 */
+#if defined (NS_IMPL_GNUSTEP) || MAC_OS_X_VERSION_MIN_REQUIRED < 1070
return [self colorUsingColorSpaceName: NSCalibratedRGBColorSpace];
+#endif
}
@end
@@ -283,9 +291,6 @@ static int ns_window_num = 0;
static BOOL ns_fake_keydown = NO;
#ifdef NS_IMPL_COCOA
static BOOL ns_menu_bar_is_hidden = NO;
-
-/* The number of times NSDisableScreenUpdates has been called. */
-static int disable_screen_updates_count = 0;
#endif
/* static int debug_lock = 0; */
@@ -688,40 +693,6 @@ ns_release_autorelease_pool (void *pool)
}
-#ifdef NS_IMPL_COCOA
-/* Disabling screen updates can be used to make several actions appear
- "atomic" to the end user. It seems some actions can still update
- the display, though.
-
- When we re-enable screen updates the number of calls to
- NSEnableScreenUpdates should match the number to
- NSDisableScreenUpdates.
-
- We use these functions to prevent the user seeing a blank frame
- after it has been resized. ns_set_window_size disables updates and
- when redisplay completes unwind_redisplay enables them again
- (bug#30699). */
-
-static void
-ns_disable_screen_updates (void)
-{
- NSDisableScreenUpdates ();
- disable_screen_updates_count++;
-}
-
-void
-ns_enable_screen_updates (void)
-/* Re-enable screen updates. Called from unwind_redisplay. */
-{
- while (disable_screen_updates_count > 0)
- {
- NSEnableScreenUpdates ();
- disable_screen_updates_count--;
- }
-}
-#endif
-
-
static BOOL
ns_menu_bar_should_be_hidden (void)
/* True, if the menu bar should be hidden. */
@@ -1779,15 +1750,6 @@ ns_set_window_size (struct frame *f,
block_input ();
-#ifdef NS_IMPL_COCOA
- /* To prevent showing the user a blank frame, stop updates being
- flushed to the screen until after redisplay has completed. This
- breaks live resize (resizing with a mouse), so don't do it if
- we're in a live resize loop. */
- if (![view inLiveResize])
- ns_disable_screen_updates ();
-#endif
-
if (pixelwise)
{
pixelwidth = FRAME_TEXT_TO_PIXEL_WIDTH (f, width);
@@ -2327,7 +2289,7 @@ ns_color_index_to_rgba(int idx, struct frame *f)
}
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 +2312,7 @@ ns_query_color(void *col, XColor *color_def, bool setPixel)
bool
ns_defined_color (struct frame *f,
const char *name,
- XColor *color_def,
+ Emacs_Color *color_def,
bool alloc,
bool makeIndex)
/* --------------------------------------------------------------------------
@@ -2378,7 +2340,7 @@ ns_defined_color (struct frame *f,
}
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 +2538,7 @@ ns_frame_up_to_date (struct frame *f)
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 +4934,7 @@ ns_judge_scroll_bars (struct frame *f)
========================================================================== */
static void
-ns_free_pixmap (struct frame *_f, Pixmap pixmap)
+ns_free_pixmap (struct frame *_f, Emacs_Pixmap pixmap)
{
ns_release_object (pixmap);
}
@@ -5459,14 +5421,14 @@ ns_term_init (Lisp_Object display_name)
NSTRACE_MSG ("Input/output types");
- ns_send_types = [[NSArray arrayWithObjects: NSStringPboardType, nil] retain];
- ns_return_types = [[NSArray arrayWithObjects: NSStringPboardType, nil]
+ ns_send_types = [[NSArray arrayWithObjects: NSPasteboardTypeString, nil] retain];
+ ns_return_types = [[NSArray arrayWithObjects: NSPasteboardTypeString, nil]
retain];
ns_drag_types = [[NSArray arrayWithObjects:
- NSStringPboardType,
- NSTabularTextPboardType,
+ NSPasteboardTypeString,
+ NSPasteboardTypeTabularText,
NSFilenamesPboardType,
- NSURLPboardType, nil] retain];
+ NSPasteboardTypeURL, nil] retain];
/* If fullscreen is in init/default-frame-alist, focus isn't set
right for fullscreen windows, so set this. */
@@ -8276,6 +8238,9 @@ not_in_argv (NSString *arg)
{
return NO;
}
+ /* FIXME: NSFilenamesPboardType is deprecated in 10.14, but the
+ NSURL method can only handle one file at a time. Stick with the
+ existing code at the moment. */
else if ([type isEqualToString: NSFilenamesPboardType])
{
NSArray *files;
@@ -8370,8 +8335,8 @@ not_in_argv (NSString *arg)
NSTRACE ("[EmacsView writeSelectionToPasteboard:types:]");
- /* We only support NSStringPboardType. */
- if ([types containsObject:NSStringPboardType] == NO) {
+ /* We only support NSPasteboardTypeString. */
+ if ([types containsObject:NSPasteboardTypeString] == NO) {
return NO;
}
@@ -8385,7 +8350,7 @@ not_in_argv (NSString *arg)
if (! STRINGP (val))
return NO;
- typesDeclared = [NSArray arrayWithObject:NSStringPboardType];
+ typesDeclared = [NSArray arrayWithObject:NSPasteboardTypeString];
[pb declareTypes:typesDeclared owner:nil];
ns_string_to_pasteboard (pb, val);
return YES;
@@ -9047,10 +9012,12 @@ not_in_argv (NSString *arg)
last_hit_part = horizontal ? scroll_bar_before_handle : scroll_bar_above_handle; break;
case NSScrollerIncrementPage:
last_hit_part = horizontal ? scroll_bar_after_handle : scroll_bar_below_handle; break;
+#if defined (NS_IMPL_GNUSTEP) || MAC_OS_X_VERSION_MIN_REQUIRED < 1070
case NSScrollerDecrementLine:
last_hit_part = horizontal ? scroll_bar_left_arrow : scroll_bar_up_arrow; break;
case NSScrollerIncrementLine:
last_hit_part = horizontal ? scroll_bar_right_arrow : scroll_bar_down_arrow; break;
+#endif
case NSScrollerKnob:
last_hit_part = horizontal ? scroll_bar_horizontal_handle : scroll_bar_handle; break;
case NSScrollerKnobSlot: /* GNUstep-only */
diff --git a/src/regex-emacs.c b/src/regex-emacs.c
index 8dc69805024..4cb17037c26 100644
--- a/src/regex-emacs.c
+++ b/src/regex-emacs.c
@@ -3432,7 +3432,7 @@ static bool bcmp_translate (re_char *, re_char *, ptrdiff_t,
{ \
d = string2; \
dend = end_match_2; \
- } \
+ }
/* Test if at very beginning or at very end of the virtual concatenation
of STRING1 and STRING2. If only one string, it's STRING2. */
diff --git a/src/search.c b/src/search.c
index dfbae5c9628..8a0f707b723 100644
--- a/src/search.c
+++ b/src/search.c
@@ -1324,12 +1324,7 @@ search_buffer_non_re (Lisp_Object string, ptrdiff_t pos,
}
else
{
- /* Converting multibyte to single-byte.
-
- ??? Perhaps this conversion should be done in a special way
- by subtracting nonascii-insert-offset from each non-ASCII char,
- so that only the multibyte chars which really correspond to
- the chosen single-byte character set can possibly match. */
+ /* Converting multibyte to single-byte. */
raw_pattern_size = SCHARS (string);
raw_pattern_size_byte = SCHARS (string);
raw_pattern = SAFE_ALLOCA (raw_pattern_size + 1);
diff --git a/src/termhooks.h b/src/termhooks.h
index 0962add0817..f1827128f19 100644
--- a/src/termhooks.h
+++ b/src/termhooks.h
@@ -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
diff --git a/src/w32fns.c b/src/w32fns.c
index 525642bfaab..bb74fcc1640 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -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);
diff --git a/src/w32font.c b/src/w32font.c
index 848016da1ca..47a33aec35f 100644
--- a/src/w32font.c
+++ b/src/w32font.c
@@ -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;
@@ -704,11 +704,23 @@ w32font_draw (struct glyph_string *s, int from, int to,
int i;
for (i = 0; i < len; i++)
- ExtTextOutW (s->hdc, x + i, y, options, NULL,
- s->char2b + from + i, 1, NULL);
+ {
+ WCHAR c = s->char2b[from + i] & 0xFFFF;
+ ExtTextOutW (s->hdc, x + i, y, options, NULL, &c, 1, NULL);
+ }
}
else
- ExtTextOutW (s->hdc, x, y, options, NULL, s->char2b + from, len, NULL);
+ {
+ /* The number of glyphs in a glyph_string cannot be larger than
+ the maximum value of the 'used' member of a glyph_row, so we
+ are OK using alloca here. */
+ eassert (len <= SHRT_MAX);
+ WCHAR *chars = alloca (len * sizeof (WCHAR));
+ int j;
+ for (j = 0; j < len; j++)
+ chars[j] = s->char2b[from + j] & 0xFFFF;
+ ExtTextOutW (s->hdc, x, y, options, NULL, chars, len, NULL);
+ }
/* Restore clip region. */
if (s->num_clips > 0)
diff --git a/src/w32font.h b/src/w32font.h
index 65f42a3178d..c7bb7f30570 100644
--- a/src/w32font.h
+++ b/src/w32font.h
@@ -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);
diff --git a/src/w32gui.h b/src/w32gui.h
index 5dcbbd95166..62bad33c19b 100644
--- a/src/w32gui.h
+++ b/src/w32gui.h
@@ -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), \
diff --git a/src/w32term.c b/src/w32term.c
index 435455e1a6d..5726124b0ed 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -85,7 +85,7 @@ static int any_help_event_p;
extern unsigned int msh_mousewheel;
extern int w32_codepage_for_font (char *fontname);
-extern Cursor w32_load_cursor (LPCTSTR name);
+extern HCURSOR w32_load_cursor (LPCTSTR name);
/* This is display since w32 does not support multiple ones. */
@@ -166,7 +166,7 @@ int w32_message_fd = -1;
static void w32_handle_tool_bar_click (struct frame *,
struct input_event *);
-static void w32_define_cursor (Window, Cursor);
+static void w32_define_cursor (Window, Emacs_Cursor);
static void w32_scroll_bar_clear (struct frame *);
static void w32_raise_frame (struct frame *);
@@ -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;
}
@@ -337,7 +335,7 @@ w32_draw_underwave (struct glyph_string *s, COLORREF color)
int wave_height = 3 * scale_y, wave_length = 2 * scale_x, thickness = scale_y;
int dx, dy, x0, y0, width, x1, y1, x2, y2, odd, xmax;
- XRectangle wave_clip, string_clip, final_clip;
+ Emacs_Rectangle wave_clip, string_clip, final_clip;
RECT w32_final_clip, w32_string_clip;
HPEN hp, oldhp;
@@ -356,14 +354,14 @@ w32_draw_underwave (struct glyph_string *s, COLORREF color)
wave_clip.height = wave_height;
get_glyph_string_clip_rect (s, &w32_string_clip);
- CONVERT_TO_XRECT (string_clip, w32_string_clip);
+ CONVERT_TO_EMACS_RECT (string_clip, w32_string_clip);
if (!gui_intersect_rectangles (&wave_clip, &string_clip, &final_clip))
return;
hp = CreatePen (PS_SOLID, thickness, color);
oldhp = SelectObject (s->hdc, hp);
- CONVERT_FROM_XRECT (final_clip, w32_final_clip);
+ CONVERT_FROM_EMACS_RECT (final_clip, w32_final_clip);
w32_set_clip_rectangle (s->hdc, &w32_final_clip);
/* Draw the waves */
@@ -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;
}
@@ -1101,14 +1097,10 @@ w32_compute_glyph_string_overhangs (struct glyph_string *s)
&& s->first_glyph->type == CHAR_GLYPH
&& !s->font_not_found_p)
{
- unsigned *code = alloca (sizeof (unsigned) * s->nchars);
struct font *font = s->font;
struct font_metrics metrics;
- int i;
- for (i = 0; i < s->nchars; i++)
- code[i] = s->char2b[i];
- font->driver->text_extents (font, code, s->nchars, &metrics);
+ font->driver->text_extents (font, s->char2b, s->nchars, &metrics);
s->right_overhang = (metrics.rbearing > metrics.width
? metrics.rbearing - metrics.width : 0);
s->left_overhang = metrics.lbearing < 0 ? -metrics.lbearing : 0;
@@ -1353,7 +1345,7 @@ static void
w32_draw_glyphless_glyph_string_foreground (struct glyph_string *s)
{
struct glyph *glyph = s->first_glyph;
- XChar2b char2b[8];
+ unsigned char2b[8];
int x, i, j;
bool with_background;
@@ -1410,16 +1402,12 @@ w32_draw_glyphless_glyph_string_foreground (struct glyph_string *s)
{
struct font *font = s->font;
int upper_len = (len + 1) / 2;
- unsigned code;
HFONT old_font;
old_font = SelectObject (s->hdc, FONT_HANDLE (font));
/* It is certain that all LEN characters in STR are ASCII. */
for (j = 0; j < len; j++)
- {
- code = font->driver->encode_char (font, str[j]);
- STORE_XCHAR2B (char2b + j, code >> 8, code & 0xFF);
- }
+ char2b[j] = font->driver->encode_char (font, str[j]) & 0xFFFF;
font->driver->draw (s, 0, upper_len,
x + glyph->slice.glyphless.upper_xoff,
s->ybase + glyph->slice.glyphless.upper_yoff,
@@ -1517,7 +1505,7 @@ w32_alloc_lighter_color (struct frame *f, COLORREF *color,
colors in COLORS. On W32, we no longer try to map colors to
a palette. */
static void
-w32_query_colors (struct frame *f, XColor *colors, int ncolors)
+w32_query_colors (struct frame *f, Emacs_Color *colors, int ncolors)
{
int i;
@@ -1534,7 +1522,7 @@ w32_query_colors (struct frame *f, XColor *colors, int ncolors)
/* Store F's background color into *BGCOLOR. */
static void
-w32_query_frame_background_color (struct frame *f, XColor *bgcolor)
+w32_query_frame_background_color (struct frame *f, Emacs_Color *bgcolor)
{
bgcolor->pixel = FRAME_BACKGROUND_PIXEL (f);
w32_query_colors (f, bgcolor, 1);
@@ -1551,7 +1539,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 +1551,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 +1614,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 +2273,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;
@@ -3429,7 +3416,7 @@ static void w32_horizontal_scroll_bar_report_motion (struct frame **, Lisp_Objec
Lisp_Object *, Lisp_Object *,
Time *);
static void
-w32_define_cursor (Window window, Cursor cursor)
+w32_define_cursor (Window window, Emacs_Cursor cursor)
{
PostMessage (window, WM_EMACS_SETCURSOR, (WPARAM) cursor, 0);
}
@@ -5806,7 +5793,7 @@ w32_draw_bar_cursor (struct window *w, struct glyph_row *row,
/* RIF: Define cursor CURSOR on frame F. */
static void
-w32_define_frame_cursor (struct frame *f, Cursor cursor)
+w32_define_frame_cursor (struct frame *f, Emacs_Cursor cursor)
{
w32_define_cursor (FRAME_W32_WINDOW (f), cursor);
}
@@ -6947,7 +6934,7 @@ w32_toggle_invisible_pointer (struct frame *f, bool invisible)
***********************************************************************/
static void
-w32_free_pixmap (struct frame *_f, Pixmap pixmap)
+w32_free_pixmap (struct frame *_f, Emacs_Pixmap pixmap)
{
DeleteObject (pixmap);
}
@@ -7208,7 +7195,7 @@ w32_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
/* initialize palette with white and black */
{
- XColor color;
+ Emacs_Color color;
w32_defined_color (0, "white", &color, true, false);
w32_defined_color (0, "black", &color, true, false);
}
diff --git a/src/w32term.h b/src/w32term.h
index a03b9fd3311..729e8d0fd49 100644
--- a/src/w32term.h
+++ b/src/w32term.h
@@ -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) (
diff --git a/src/window.c b/src/window.c
index 30ffad0e513..deeb4f63fe0 100644
--- a/src/window.c
+++ b/src/window.c
@@ -3947,8 +3947,8 @@ set_window_buffer (Lisp_Object window, Lisp_Object buffer,
b->display_error_modiff = 0;
/* Update time stamps of buffer display. */
- if (FIXNUMP (BVAR (b, display_count)))
- bset_display_count (b, make_fixnum (XFIXNUM (BVAR (b, display_count)) + 1));
+ if (INTEGERP (BVAR (b, display_count)))
+ bset_display_count (b, Fadd1 (BVAR (b, display_count)));
bset_display_time (b, Fcurrent_time ());
w->window_end_pos = 0;
@@ -4089,7 +4089,7 @@ displaying that buffer. */)
return Qt;
}
- if (WINDOWP (object))
+ if (WINDOW_LIVE_P (object))
{
struct window *w = XWINDOW (object);
mark_window_display_accurate (object, false);
diff --git a/src/window.h b/src/window.h
index fdef407041b..6b0f0e5d07c 100644
--- a/src/window.h
+++ b/src/window.h
@@ -595,7 +595,7 @@ wset_next_buffers (struct window *w, Lisp_Object val)
#define WINDOW_BUFFER(W) \
(WINDOW_LEAF_P(W) \
? (W)->contents \
- : Qnil) \
+ : Qnil)
/* Return the canonical column width of the frame of window W. */
#define WINDOW_FRAME_COLUMN_WIDTH(W) \
@@ -649,7 +649,7 @@ wset_next_buffers (struct window *w, Lisp_Object val)
#define WINDOW_RIGHTMOST_P(W) \
(WINDOW_RIGHT_PIXEL_EDGE (W) \
== (WINDOW_RIGHT_PIXEL_EDGE \
- (XWINDOW (FRAME_ROOT_WINDOW (WINDOW_XFRAME (W)))))) \
+ (XWINDOW (FRAME_ROOT_WINDOW (WINDOW_XFRAME (W))))))
/* True if window W has no other windows below it on its frame (the
minibuffer window is not counted in this respect unless W itself is a
@@ -657,13 +657,13 @@ wset_next_buffers (struct window *w, Lisp_Object val)
#define WINDOW_BOTTOMMOST_P(W) \
(WINDOW_BOTTOM_PIXEL_EDGE (W) \
== (WINDOW_BOTTOM_PIXEL_EDGE \
- (XWINDOW (FRAME_ROOT_WINDOW (WINDOW_XFRAME (W)))))) \
+ (XWINDOW (FRAME_ROOT_WINDOW (WINDOW_XFRAME (W))))))
/* True if window W takes up the full width of its frame. */
#define WINDOW_FULL_WIDTH_P(W) \
(WINDOW_PIXEL_WIDTH (W) \
== (WINDOW_PIXEL_WIDTH \
- (XWINDOW (FRAME_ROOT_WINDOW (WINDOW_XFRAME (W)))))) \
+ (XWINDOW (FRAME_ROOT_WINDOW (WINDOW_XFRAME (W))))))
/* Width of right divider of window W. */
#define WINDOW_RIGHT_DIVIDER_WIDTH(W) \
@@ -1122,7 +1122,7 @@ struct glyph *get_phys_cursor_glyph (struct window *w);
/* True if WINDOW is a valid window. */
#define WINDOW_VALID_P(WINDOW) \
- (WINDOWP (WINDOW) && !NILP (XWINDOW (WINDOW)->contents)) \
+ (WINDOWP (WINDOW) && !NILP (XWINDOW (WINDOW)->contents))
/* A window of any sort, leaf or interior, is "valid" if its
contents slot is non-nil. */
diff --git a/src/xdisp.c b/src/xdisp.c
index 1aa677fcc78..5f438152341 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -376,17 +376,26 @@ static Lisp_Object list_of_error;
|| it->s[IT_BYTEPOS (*it)] == '\t')) \
|| (IT_BYTEPOS (*it) < ZV_BYTE \
&& (*BYTE_POS_ADDR (IT_BYTEPOS (*it)) == ' ' \
- || *BYTE_POS_ADDR (IT_BYTEPOS (*it)) == '\t')))) \
-
-/* Test all the conditions needed to print the fill column indicator. */
-#define FILL_COLUMN_INDICATOR_NEEDED(it) \
- Vdisplay_fill_column_indicator \
- && (it->continuation_lines_width == 0) \
- && (!NILP (Vdisplay_fill_column_indicator_column)) \
- && FIXNATP (Vdisplay_fill_column_indicator_character) \
- && ((EQ (Vdisplay_fill_column_indicator_column, Qt) \
- && FIXNATP (BVAR (current_buffer, fill_column))) \
- || (FIXNATP (Vdisplay_fill_column_indicator_column)))
+ || *BYTE_POS_ADDR (IT_BYTEPOS (*it)) == '\t'))))
+
+/* If all the conditions needed to print the fill column indicator are
+ met, return the (nonnegative) column number, else return a negative
+ value. */
+static int
+fill_column_indicator_column (struct it *it)
+{
+ if (Vdisplay_fill_column_indicator
+ && it->continuation_lines_width == 0
+ && CHARACTERP (Vdisplay_fill_column_indicator_character))
+ {
+ Lisp_Object col = (EQ (Vdisplay_fill_column_indicator_column, Qt)
+ ? BVAR (current_buffer, fill_column)
+ : Vdisplay_fill_column_indicator_column);
+ if (RANGED_FIXNUMP (0, col, INT_MAX))
+ return XFIXNUM (col);
+ }
+ return -1;
+}
/* True means print newline to stdout before next mini-buffer message. */
@@ -2080,7 +2089,7 @@ frame_to_window_pixel_xy (struct window *w, int *x, int *y)
int
get_glyph_string_clip_rects (struct glyph_string *s, NativeRectangle *rects, int n)
{
- XRectangle r;
+ Emacs_Rectangle r;
if (n <= 0)
return 0;
@@ -2142,7 +2151,7 @@ get_glyph_string_clip_rects (struct glyph_string *s, NativeRectangle *rects, int
take the intersection with the rectangle of the cursor. */
if (s->for_overlaps & OVERLAPS_ERASED_CURSOR)
{
- XRectangle rc, r_save = r;
+ Emacs_Rectangle rc, r_save = r;
rc.x = WINDOW_TEXT_TO_FRAME_PIXEL_X (s->w, s->w->phys_cursor.x);
rc.y = s->w->phys_cursor.y;
@@ -2208,7 +2217,7 @@ get_glyph_string_clip_rects (struct glyph_string *s, NativeRectangle *rects, int
if (s->row->clip)
{
- XRectangle r_save = r;
+ Emacs_Rectangle r_save = r;
if (! gui_intersect_rectangles (&r_save, s->row->clip, &r))
r.width = 0;
@@ -2217,8 +2226,8 @@ get_glyph_string_clip_rects (struct glyph_string *s, NativeRectangle *rects, int
if ((s->for_overlaps & OVERLAPS_BOTH) == 0
|| ((s->for_overlaps & OVERLAPS_BOTH) == OVERLAPS_BOTH && n == 1))
{
-#ifdef CONVERT_FROM_XRECT
- CONVERT_FROM_XRECT (r, *rects);
+#ifdef CONVERT_FROM_EMACS_RECT
+ CONVERT_FROM_EMACS_RECT (r, *rects);
#else
*rects = r;
#endif
@@ -2230,10 +2239,10 @@ get_glyph_string_clip_rects (struct glyph_string *s, NativeRectangle *rects, int
multiple clipping rectangles, we exclude the row of the glyph
string from the clipping rectangle. This is to avoid drawing
the same text on the environment with anti-aliasing. */
-#ifdef CONVERT_FROM_XRECT
- XRectangle rs[2];
+#ifdef CONVERT_FROM_EMACS_RECT
+ Emacs_Rectangle rs[2];
#else
- XRectangle *rs = rects;
+ Emacs_Rectangle *rs = rects;
#endif
int i = 0, row_y = WINDOW_TO_FRAME_PIXEL_Y (s->w, s->row->y);
@@ -2266,9 +2275,9 @@ get_glyph_string_clip_rects (struct glyph_string *s, NativeRectangle *rects, int
}
n = i;
-#ifdef CONVERT_FROM_XRECT
+#ifdef CONVERT_FROM_EMACS_RECT
for (i = 0; i < n; i++)
- CONVERT_FROM_XRECT (rs[i], rects[i]);
+ CONVERT_FROM_EMACS_RECT (rs[i], rects[i]);
#endif
return n;
}
@@ -13986,12 +13995,6 @@ redisplay_internal (void)
#if defined (USE_X_TOOLKIT) || defined (USE_GTK) || defined (HAVE_NS)
if (popup_activated ())
{
-#ifdef NS_IMPL_COCOA
- /* On macOS we may have disabled screen updates due to window
- resizing. We should re-enable them so the popup can be
- displayed. */
- ns_enable_screen_updates ();
-#endif
return;
}
#endif
@@ -14794,12 +14797,6 @@ unwind_redisplay (void)
{
redisplaying_p = false;
unblock_buffer_flips ();
-#ifdef NS_IMPL_COCOA
- /* On macOS we may have disabled screen updates due to window
- resizing. When redisplay completes we want to re-enable
- them. */
- ns_enable_screen_updates ();
-#endif
}
@@ -20172,18 +20169,11 @@ append_space_for_newline (struct it *it, bool default_face_p)
/* Corner case for when display-fill-column-indicator-mode
is active and the extra character should be added in the
same place than the line. */
- if ((it->w->pseudo_window_p == 0)
- && FILL_COLUMN_INDICATOR_NEEDED(it))
+ int indicator_column = (it->w->pseudo_window_p == 0
+ ? fill_column_indicator_column (it)
+ : -1);
+ if (0 <= indicator_column)
{
- int fill_column_indicator_column = -1;
-
- if (EQ (Vdisplay_fill_column_indicator_column, Qt))
- fill_column_indicator_column =
- XFIXNAT (BVAR (current_buffer, fill_column));
- else
- fill_column_indicator_column =
- XFIXNAT (Vdisplay_fill_column_indicator_column);
-
struct font *font =
default_face->font ?
default_face->font : FRAME_FONT (it->f);
@@ -20191,18 +20181,19 @@ append_space_for_newline (struct it *it, bool default_face_p)
font->average_width ?
font->average_width : font->space_width;
- const int column_x =
- char_width * fill_column_indicator_column +
- it->lnum_pixel_width;
-
- if (it->current_x == column_x)
+ int column_x;
+ if (!INT_MULTIPLY_WRAPV (indicator_column, char_width,
+ &column_x)
+ && !INT_ADD_WRAPV (it->lnum_pixel_width, column_x,
+ &column_x)
+ && it->current_x == column_x)
{
it->c = it->char_to_display =
XFIXNAT (Vdisplay_fill_column_indicator_character);
it->face_id =
merge_faces (it->w, Qfill_column_indicator,
0, saved_face_id);
- face = FACE_FROM_ID(it->f, it->face_id);
+ face = FACE_FROM_ID (it->f, it->face_id);
goto produce_glyphs;
}
}
@@ -20434,30 +20425,22 @@ extend_face_to_end_of_line (struct it *it)
/* Display fill column indicator if not in modeline or
toolbar and display fill column indicator mode is
active. */
- if ((it->w->pseudo_window_p == 0)
- && FILL_COLUMN_INDICATOR_NEEDED(it))
+ int indicator_column = (it->w->pseudo_window_p == 0
+ ? fill_column_indicator_column (it)
+ : -1);
+ if (0 <= indicator_column)
{
- int fill_column_indicator_column = -1;
-
- if (EQ (Vdisplay_fill_column_indicator_column, Qt))
- fill_column_indicator_column =
- XFIXNAT (BVAR (current_buffer, fill_column));
- else
- fill_column_indicator_column =
- XFIXNAT (Vdisplay_fill_column_indicator_column);
-
struct font *font =
default_face->font ? default_face->font : FRAME_FONT (f);
const int char_width =
font->average_width ?
font->average_width : font->space_width;
- const int column_x =
- char_width * fill_column_indicator_column +
- it->lnum_pixel_width;
-
- if ((it->current_x <= column_x)
- && (column_x <= it->last_visible_x))
+ int column_x;
+ if (!INT_MULTIPLY_WRAPV (indicator_column, char_width, &column_x)
+ && !INT_ADD_WRAPV (it->lnum_pixel_width, column_x, &column_x)
+ && it->current_x <= column_x
+ && column_x <= it->last_visible_x)
{
const char saved_char = it->char_to_display;
const struct text_pos saved_pos = it->position;
@@ -20637,45 +20620,33 @@ extend_face_to_end_of_line (struct it *it)
it->face_id = face->id;
/* Display fill-column indicator if needed. */
- if (FILL_COLUMN_INDICATOR_NEEDED(it))
+ int indicator_column = fill_column_indicator_column (it);
+ if (0 <= indicator_column
+ && INT_ADD_WRAPV (it->lnum_pixel_width, indicator_column,
+ &indicator_column))
+ indicator_column = -1;
+ do
{
- int fill_column_indicator_column = -1;
+ int saved_face_id;
+ bool indicate = it->current_x == indicator_column;
+ if (indicate)
+ {
+ saved_face_id = it->face_id;
+ it->face_id =
+ merge_faces (it->w, Qfill_column_indicator, 0, saved_face_id);
+ it->c = it->char_to_display =
+ XFIXNAT (Vdisplay_fill_column_indicator_character);
+ }
- /* Vdisplay_fill_column_indicator_column accepts the special
- value t to use the default fill-column variable. The
- conditions are all defined in the macro
- FILL_COLUMN_INDICATOR_NEEDED. */
- if (EQ (Vdisplay_fill_column_indicator_column, Qt))
- fill_column_indicator_column =
- XFIXNAT (BVAR (current_buffer, fill_column)) + it->lnum_pixel_width;
- else
- fill_column_indicator_column =
- XFIXNAT (Vdisplay_fill_column_indicator_column) + it->lnum_pixel_width;
+ PRODUCE_GLYPHS (it);
- do
+ if (indicate)
{
- if (it->current_x == fill_column_indicator_column)
- {
- const int saved_face_id = it->face_id;
- it->face_id =
- merge_faces (it->w, Qfill_column_indicator, 0, saved_face_id);
- it->c = it->char_to_display =
- XFIXNAT (Vdisplay_fill_column_indicator_character);
- PRODUCE_GLYPHS (it);
- it->face_id = saved_face_id;
- it->c = it->char_to_display = ' ';
- }
- else
- PRODUCE_GLYPHS (it);
- } while (it->current_x <= it->last_visible_x);
+ it->face_id = saved_face_id;
+ it->c = it->char_to_display = ' ';
+ }
}
- else
- {
- do
- {
- PRODUCE_GLYPHS (it);
- } while (it->current_x <= it->last_visible_x);
- }
+ while (it->current_x <= it->last_visible_x);
if (WINDOW_RIGHT_MARGIN_WIDTH (it->w) > 0
&& (it->glyph_row->used[RIGHT_MARGIN_AREA]
@@ -25914,7 +25885,7 @@ dump_glyph_string (struct glyph_string *s)
#endif /* GLYPH_DEBUG */
/* Initialize glyph string S. CHAR2B is a suitably allocated vector
- of XChar2b structures for S; it can't be allocated in
+ of 2-byte unsigned integers for S; it can't be allocated in
init_glyph_string because it must be allocated via `alloca'. W
is the window on which S is drawn. ROW and AREA are the glyph row
and area within the row from which S is constructed. START is the
@@ -25944,7 +25915,7 @@ init_glyph_string (struct glyph_string *s,
#ifdef HAVE_NTGUI
HDC hdc,
#endif
- XChar2b *char2b, struct window *w, struct glyph_row *row,
+ unsigned *char2b, struct window *w, struct glyph_row *row,
enum glyph_row_area area, int start, enum draw_glyphs_face hl)
{
memset (s, 0, sizeof *s);
@@ -26023,7 +25994,7 @@ append_glyph_string (struct glyph_string **head, struct glyph_string **tail,
static struct face *
get_char_face_and_encoding (struct frame *f, int c, int face_id,
- XChar2b *char2b, bool display_p)
+ unsigned *char2b, bool display_p)
{
struct face *face = FACE_FROM_ID (f, face_id);
unsigned code = 0;
@@ -26035,7 +26006,8 @@ get_char_face_and_encoding (struct frame *f, int c, int face_id,
if (code == FONT_INVALID_CODE)
code = 0;
}
- STORE_XCHAR2B (char2b, (code >> 8), (code & 0xFF));
+ /* Ensure that the code is only 2 bytes wide. */
+ *char2b = code & 0xFFFF;
/* Make sure X resources of the face are allocated. */
#ifdef HAVE_X_WINDOWS
@@ -26056,7 +26028,7 @@ get_char_face_and_encoding (struct frame *f, int c, int face_id,
static struct face *
get_glyph_face_and_encoding (struct frame *f, struct glyph *glyph,
- XChar2b *char2b)
+ unsigned *char2b)
{
struct face *face;
unsigned code = 0;
@@ -26078,7 +26050,8 @@ get_glyph_face_and_encoding (struct frame *f, struct glyph *glyph,
code = 0;
}
- STORE_XCHAR2B (char2b, (code >> 8), (code & 0xFF));
+ /* Ensure that the code is only 2 bytes wide. */
+ *char2b = code & 0xFFFF;
return face;
}
@@ -26087,7 +26060,7 @@ get_glyph_face_and_encoding (struct frame *f, struct glyph *glyph,
Return true iff FONT has a glyph for C. */
static bool
-get_char_glyph_code (int c, struct font *font, XChar2b *char2b)
+get_char_glyph_code (int c, struct font *font, unsigned *char2b)
{
unsigned code;
@@ -26098,7 +26071,9 @@ get_char_glyph_code (int c, struct font *font, XChar2b *char2b)
if (code == FONT_INVALID_CODE)
return false;
- STORE_XCHAR2B (char2b, (code >> 8), (code & 0xFF));
+
+ /* Ensure that the code is only 2 bytes wide. */
+ *char2b = code & 0xFFFF;
return true;
}
@@ -26211,7 +26186,8 @@ fill_gstring_glyph_string (struct glyph_string *s, int face_id,
Lisp_Object lglyph = LGSTRING_GLYPH (lgstring, i);
unsigned code = LGLYPH_CODE (lglyph);
- STORE_XCHAR2B ((s->char2b + i), code >> 8, code & 0xFF);
+ /* Ensure that the code is only 2 bytes wide. */
+ s->char2b[i] = code & 0xFFFF;
}
s->width = composition_gstring_width (lgstring, s->cmp_from, s->cmp_to, NULL);
return glyph - s->row->glyphs[s->area];
@@ -26390,17 +26366,16 @@ fill_stretch_glyph_string (struct glyph_string *s, int start, int end)
}
static struct font_metrics *
-get_per_char_metric (struct font *font, XChar2b *char2b)
+get_per_char_metric (struct font *font, const unsigned *char2b)
{
static struct font_metrics metrics;
- unsigned code;
if (! font)
return NULL;
- code = (XCHAR2B_BYTE1 (char2b) << 8) | XCHAR2B_BYTE2 (char2b);
- if (code == FONT_INVALID_CODE)
+ if (*char2b == FONT_INVALID_CODE)
return NULL;
- font->driver->text_extents (font, &code, 1, &metrics);
+
+ font->driver->text_extents (font, char2b, 1, &metrics);
return &metrics;
}
@@ -26418,7 +26393,7 @@ normal_char_ascent_descent (struct font *font, int c, int *ascent, int *descent)
if (FONT_TOO_HIGH (font))
{
- XChar2b char2b;
+ unsigned char2b;
/* Get metrics of C, defaulting to a reasonably sized ASCII
character. */
@@ -26465,7 +26440,7 @@ gui_get_glyph_overhangs (struct glyph *glyph, struct frame *f, int *left, int *r
if (glyph->type == CHAR_GLYPH)
{
- XChar2b char2b;
+ unsigned char2b;
struct face *face = get_glyph_face_and_encoding (f, glyph, &char2b);
if (face->font)
{
@@ -26779,7 +26754,7 @@ compute_overhangs_and_x (struct glyph_string *s, int x, bool backward_p)
do \
{ \
int face_id; \
- XChar2b *char2b; \
+ unsigned *char2b; \
\
face_id = (row)->glyphs[area][START].face_id; \
\
@@ -26808,7 +26783,7 @@ compute_overhangs_and_x (struct glyph_string *s, int x, bool backward_p)
struct face *base_face = FACE_FROM_ID (f, face_id); \
ptrdiff_t cmp_id = (row)->glyphs[area][START].u.cmp.id; \
struct composition *cmp = composition_table[cmp_id]; \
- XChar2b *char2b; \
+ unsigned *char2b; \
struct glyph_string *first_s = NULL; \
int n; \
\
@@ -26840,7 +26815,7 @@ compute_overhangs_and_x (struct glyph_string *s, int x, bool backward_p)
#define BUILD_GSTRING_GLYPH_STRING(START, END, HEAD, TAIL, HL, X, LAST_X) \
do { \
int face_id; \
- XChar2b *char2b; \
+ unsigned *char2b; \
Lisp_Object gstring; \
\
face_id = (row)->glyphs[area][START].face_id; \
@@ -28433,7 +28408,7 @@ gui_produce_glyphs (struct it *it)
if (it->what == IT_CHARACTER)
{
- XChar2b char2b;
+ unsigned char2b;
struct face *face = FACE_FROM_ID (it->f, it->face_id);
struct font *font = face->font;
struct font_metrics *pcm = NULL;
@@ -28832,7 +28807,7 @@ gui_produce_glyphs (struct it *it)
int lbearing, rbearing;
int i, width, ascent, descent;
int c;
- XChar2b char2b;
+ unsigned char2b;
struct font_metrics *pcm;
ptrdiff_t pos;
@@ -31153,7 +31128,7 @@ Returns the alist element for the first matching AREA in MAP. */)
/* Display frame CURSOR, optionally using shape defined by POINTER. */
static void
-define_frame_cursor1 (struct frame *f, Cursor cursor, Lisp_Object pointer)
+define_frame_cursor1 (struct frame *f, Emacs_Cursor cursor, Lisp_Object pointer)
{
#ifdef HAVE_WINDOW_SYSTEM
if (!FRAME_WINDOW_P (f))
@@ -31205,7 +31180,7 @@ note_mode_line_or_margin_highlight (Lisp_Object window, int x, int y,
struct window *w = XWINDOW (window);
struct frame *f = XFRAME (w->frame);
Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
- Cursor cursor = No_Cursor;
+ Emacs_Cursor cursor = No_Cursor;
Lisp_Object pointer = Qnil;
int dx, dy, width, height;
ptrdiff_t charpos;
@@ -31518,7 +31493,7 @@ note_mouse_highlight (struct frame *f, int x, int y)
enum window_part part = ON_NOTHING;
Lisp_Object window;
struct window *w;
- Cursor cursor = No_Cursor;
+ Emacs_Cursor cursor = No_Cursor;
Lisp_Object pointer = Qnil; /* Takes precedence over cursor! */
struct buffer *b;
@@ -32137,7 +32112,7 @@ cancel_mouse_face (struct frame *f)
which intersects rectangle R. R is in window-relative coordinates. */
static void
-expose_area (struct window *w, struct glyph_row *row, XRectangle *r,
+expose_area (struct window *w, struct glyph_row *row, const Emacs_Rectangle *r,
enum glyph_row_area area)
{
struct glyph *first = row->glyphs[area];
@@ -32195,7 +32170,7 @@ expose_area (struct window *w, struct glyph_row *row, XRectangle *r,
true if mouse-face was overwritten. */
static bool
-expose_line (struct window *w, struct glyph_row *row, XRectangle *r)
+expose_line (struct window *w, struct glyph_row *row, const Emacs_Rectangle *r)
{
eassert (row->enabled_p);
@@ -32230,7 +32205,7 @@ static void
expose_overlaps (struct window *w,
struct glyph_row *first_overlapping_row,
struct glyph_row *last_overlapping_row,
- XRectangle *r)
+ const Emacs_Rectangle *r)
{
struct glyph_row *row;
@@ -32256,9 +32231,9 @@ expose_overlaps (struct window *w,
/* Return true if W's cursor intersects rectangle R. */
static bool
-phys_cursor_in_rect_p (struct window *w, XRectangle *r)
+phys_cursor_in_rect_p (struct window *w, const Emacs_Rectangle *r)
{
- XRectangle cr, result;
+ Emacs_Rectangle cr, result;
struct glyph *cursor_glyph;
struct glyph_row *row;
@@ -32416,10 +32391,10 @@ gui_draw_bottom_divider (struct window *w)
mouse-face. */
static bool
-expose_window (struct window *w, XRectangle *fr)
+expose_window (struct window *w, const Emacs_Rectangle *fr)
{
struct frame *f = XFRAME (w->frame);
- XRectangle wr, r;
+ Emacs_Rectangle wr, r;
bool mouse_face_overwritten_p = false;
/* If window is not yet fully initialized, do nothing. This can
@@ -32578,7 +32553,7 @@ expose_window (struct window *w, XRectangle *fr)
true if the exposure overwrites mouse-face. */
static bool
-expose_window_tree (struct window *w, XRectangle *r)
+expose_window_tree (struct window *w, const Emacs_Rectangle *r)
{
struct frame *f = XFRAME (w->frame);
bool mouse_face_overwritten_p = false;
@@ -32606,7 +32581,7 @@ expose_window_tree (struct window *w, XRectangle *r)
void
expose_frame (struct frame *f, int x, int y, int w, int h)
{
- XRectangle r;
+ Emacs_Rectangle r;
bool mouse_face_overwritten_p = false;
TRACE ((stderr, "expose_frame "));
@@ -32693,10 +32668,11 @@ expose_frame (struct frame *f, int x, int y, int w, int h)
empty. */
bool
-gui_intersect_rectangles (XRectangle *r1, XRectangle *r2, XRectangle *result)
+gui_intersect_rectangles (const Emacs_Rectangle *r1, const Emacs_Rectangle *r2,
+ Emacs_Rectangle *result)
{
- XRectangle *left, *right;
- XRectangle *upper, *lower;
+ const Emacs_Rectangle *left, *right;
+ const Emacs_Rectangle *upper, *lower;
bool intersection_p = false;
/* Rearrange so that R1 is the left-most rectangle. */
diff --git a/src/xfaces.c b/src/xfaces.c
index 5c2414b7b0e..d211ec8c460 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -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))
diff --git a/src/xfns.c b/src/xfns.c
index c8cc1704a47..4195980d33e 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -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);
diff --git a/src/xfont.c b/src/xfont.c
index ff80df407d7..81808e7a62e 100644
--- a/src/xfont.c
+++ b/src/xfont.c
@@ -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 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 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 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,51 @@ 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 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);
+ {
+ USE_SAFE_ALLOCA;
+ const unsigned *code = s->char2b + from;
+ XChar2b *char2b;
+ SAFE_NALLOCA (char2b, 1, len);
+ for (int i = 0; i < len; ++i)
+ char2b[i] = (XChar2b) { .byte1 = code[i] >> 8,
+ .byte2 = code[i] & 0xFF };
+ XDrawImageString16 (display, FRAME_X_DRAWABLE (s->f),
+ gc, x, y, char2b, len);
+ SAFE_FREE ();
+ }
}
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 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);
+ {
+ USE_SAFE_ALLOCA;
+ const unsigned *code = s->char2b + from;
+ XChar2b *char2b;
+ SAFE_NALLOCA (char2b, 1, len);
+ for (int i = 0; i < len; ++i)
+ char2b[i] = (XChar2b) { .byte1 = code[i] >> 8,
+ .byte2 = code[i] & 0xFF };
+ XDrawString16 (display, FRAME_X_DRAWABLE (s->f),
+ gc, x, y, char2b, len);
+ SAFE_FREE ();
+ }
}
unblock_input ();
diff --git a/src/xftfont.c b/src/xftfont.c
index 8a4516f7f91..4f0a0d81d85 100644
--- a/src/xftfont.c
+++ b/src/xftfont.c
@@ -127,120 +127,18 @@ xftfont_match (struct frame *f, Lisp_Object spec)
static FcChar8 ascii_printable[95];
-static void
-xftfont_fix_match (FcPattern *pat, FcPattern *match)
-{
- /* These values are not used for matching (except antialias), but for
- rendering, so make sure they are carried over to the match.
- We also put antialias here because most fonts are antialiased, so
- the match will have antialias true. */
-
- FcBool b = FcTrue;
- int i;
- double dpi;
-
- FcPatternGetBool (pat, FC_ANTIALIAS, 0, &b);
- if (! b)
- {
- FcPatternDel (match, FC_ANTIALIAS);
- FcPatternAddBool (match, FC_ANTIALIAS, FcFalse);
- }
- FcPatternGetBool (pat, FC_HINTING, 0, &b);
- if (! b)
- {
- FcPatternDel (match, FC_HINTING);
- FcPatternAddBool (match, FC_HINTING, FcFalse);
- }
-#ifndef FC_HINT_STYLE
-# define FC_HINT_STYLE "hintstyle"
-#endif
- if (FcResultMatch == FcPatternGetInteger (pat, FC_HINT_STYLE, 0, &i))
- {
- FcPatternDel (match, FC_HINT_STYLE);
- FcPatternAddInteger (match, FC_HINT_STYLE, i);
- }
-#ifndef FC_LCD_FILTER
- /* Older fontconfig versions don't have FC_LCD_FILTER. */
-#define FC_LCD_FILTER "lcdfilter"
-#endif
- if (FcResultMatch == FcPatternGetInteger (pat, FC_LCD_FILTER, 0, &i))
- {
- FcPatternDel (match, FC_LCD_FILTER);
- FcPatternAddInteger (match, FC_LCD_FILTER, i);
- }
- if (FcResultMatch == FcPatternGetInteger (pat, FC_RGBA, 0, &i))
- {
- FcPatternDel (match, FC_RGBA);
- FcPatternAddInteger (match, FC_RGBA, i);
- }
- if (FcResultMatch == FcPatternGetDouble (pat, FC_DPI, 0, &dpi))
- {
- FcPatternDel (match, FC_DPI);
- FcPatternAddDouble (match, FC_DPI, dpi);
- }
-}
-
-static void
-xftfont_add_rendering_parameters (FcPattern *pat, Lisp_Object entity)
-{
- Lisp_Object tail;
- int ival;
-
- for (tail = AREF (entity, FONT_EXTRA_INDEX); CONSP (tail); tail = XCDR (tail))
- {
- Lisp_Object key = XCAR (XCAR (tail));
- Lisp_Object val = XCDR (XCAR (tail));
-
- if (EQ (key, QCantialias))
- FcPatternAddBool (pat, FC_ANTIALIAS, NILP (val) ? FcFalse : FcTrue);
- else if (EQ (key, QChinting))
- FcPatternAddBool (pat, FC_HINTING, NILP (val) ? FcFalse : FcTrue);
- else if (EQ (key, QCautohint))
- FcPatternAddBool (pat, FC_AUTOHINT, NILP (val) ? FcFalse : FcTrue);
- else if (EQ (key, QChintstyle))
- {
- if (FIXNUMP (val))
- FcPatternAddInteger (pat, FC_HINT_STYLE, XFIXNUM (val));
- else if (SYMBOLP (val)
- && FcNameConstant (SDATA (SYMBOL_NAME (val)), &ival))
- FcPatternAddInteger (pat, FC_HINT_STYLE, ival);
- }
- else if (EQ (key, QCrgba))
- {
- if (FIXNUMP (val))
- FcPatternAddInteger (pat, FC_RGBA, XFIXNUM (val));
- else if (SYMBOLP (val)
- && FcNameConstant (SDATA (SYMBOL_NAME (val)), &ival))
- FcPatternAddInteger (pat, FC_RGBA, ival);
- }
- else if (EQ (key, QClcdfilter))
- {
- if (FIXNUMP (val))
- FcPatternAddInteger (pat, FC_LCD_FILTER, ival = XFIXNUM (val));
- else if (SYMBOLP (val)
- && FcNameConstant (SDATA (SYMBOL_NAME (val)), &ival))
- FcPatternAddInteger (pat, FC_LCD_FILTER, ival);
- }
-#ifdef FC_EMBOLDEN
- else if (EQ (key, QCembolden))
- FcPatternAddBool (pat, FC_EMBOLDEN, NILP (val) ? FcFalse : FcTrue);
-#endif
- }
-}
-
static Lisp_Object
xftfont_open (struct frame *f, Lisp_Object entity, int pixel_size)
{
FcResult result;
Display *display = FRAME_X_DISPLAY (f);
- Lisp_Object val, filename, idx, font_object;
+ Lisp_Object val, filename, font_object;
FcPattern *pat = NULL, *match;
struct font_info *xftfont_info = NULL;
struct font *font;
double size = 0;
XftFont *xftfont = NULL;
int spacing;
- int i;
XGlyphInfo extents;
FT_Face ft_face;
FcMatrix *matrix;
@@ -250,52 +148,17 @@ xftfont_open (struct frame *f, Lisp_Object entity, int pixel_size)
return Qnil;
val = XCDR (val);
filename = XCAR (val);
- idx = XCDR (val);
size = XFIXNUM (AREF (entity, FONT_SIZE_INDEX));
if (size == 0)
size = pixel_size;
- pat = FcPatternCreate ();
- FcPatternAddInteger (pat, FC_WEIGHT, FONT_WEIGHT_NUMERIC (entity));
- i = FONT_SLANT_NUMERIC (entity) - 100;
- if (i < 0) i = 0;
- FcPatternAddInteger (pat, FC_SLANT, i);
- FcPatternAddInteger (pat, FC_WIDTH, FONT_WIDTH_NUMERIC (entity));
- FcPatternAddDouble (pat, FC_PIXEL_SIZE, pixel_size);
- val = AREF (entity, FONT_FAMILY_INDEX);
- if (! NILP (val))
- FcPatternAddString (pat, FC_FAMILY, (FcChar8 *) SDATA (SYMBOL_NAME (val)));
- val = AREF (entity, FONT_FOUNDRY_INDEX);
- if (! NILP (val))
- FcPatternAddString (pat, FC_FOUNDRY, (FcChar8 *) SDATA (SYMBOL_NAME (val)));
- val = AREF (entity, FONT_SPACING_INDEX);
- if (! NILP (val))
- FcPatternAddInteger (pat, FC_SPACING, XFIXNUM (val));
- val = AREF (entity, FONT_DPI_INDEX);
- if (! NILP (val))
- {
- double dbl = XFIXNUM (val);
-
- FcPatternAddDouble (pat, FC_DPI, dbl);
- }
- val = AREF (entity, FONT_AVGWIDTH_INDEX);
- if (FIXNUMP (val) && XFIXNUM (val) == 0)
- FcPatternAddBool (pat, FC_SCALABLE, FcTrue);
- /* This is necessary to identify the exact font (e.g. 10x20.pcf.gz
- over 10x20-ISO8859-1.pcf.gz). */
- FcPatternAddCharSet (pat, FC_CHARSET, ftfont_get_fc_charset (entity));
-
- xftfont_add_rendering_parameters (pat, entity);
-
- FcPatternAddString (pat, FC_FILE, (FcChar8 *) SDATA (filename));
- FcPatternAddInteger (pat, FC_INDEX, XFIXNUM (idx));
-
block_input ();
+ pat = ftfont_entity_pattern (entity, pixel_size);
/* Substitute in values from X resources and XftDefaultSet. */
XftDefaultSubstitute (display, FRAME_X_SCREEN_NUMBER (f), pat);
match = XftFontMatch (display, FRAME_X_SCREEN_NUMBER (f), pat, &result);
- xftfont_fix_match (pat, match);
+ ftfont_fix_match (pat, match);
FcPatternDestroy (pat);
xftfont = XftFontOpenPattern (display, match);
@@ -536,7 +399,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 +484,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++)
@@ -696,7 +558,7 @@ xftfont_cached_font_ok (struct frame *f, Lisp_Object font_object,
bool ok = false;
int i1, i2, r1, r2;
- xftfont_add_rendering_parameters (pat, entity);
+ ftfont_add_rendering_parameters (pat, entity);
XftDefaultSubstitute (display, FRAME_X_SCREEN_NUMBER (f), pat);
r1 = FcPatternGetBool (pat, FC_ANTIALIAS, 0, &b1);
@@ -769,12 +631,6 @@ void
syms_of_xftfont (void)
{
DEFSYM (Qxft, "xft");
- DEFSYM (QChinting, ":hinting");
- DEFSYM (QCautohint, ":autohint");
- DEFSYM (QChintstyle, ":hintstyle");
- DEFSYM (QCrgba, ":rgba");
- DEFSYM (QCembolden, ":embolden");
- DEFSYM (QClcdfilter, ":lcdfilter");
DEFVAR_BOOL ("xft-font-ascent-descent-override",
xft_font_ascent_descent_override,
diff --git a/src/xterm.c b/src/xterm.c
index 4f4a1d6d02a..559d1b48924 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -1599,13 +1599,8 @@ x_compute_glyph_string_overhangs (struct glyph_string *s)
if (s->first_glyph->type == CHAR_GLYPH)
{
- unsigned *code = alloca (sizeof (unsigned) * s->nchars);
struct font *font = s->font;
- int i;
-
- for (i = 0; i < s->nchars; i++)
- code[i] = (s->char2b[i].byte1 << 8) | s->char2b[i].byte2;
- font->driver->text_extents (font, code, s->nchars, &metrics);
+ font->driver->text_extents (font, s->char2b, s->nchars, &metrics);
}
else
{
@@ -1831,7 +1826,7 @@ static void
x_draw_glyphless_glyph_string_foreground (struct glyph_string *s)
{
struct glyph *glyph = s->first_glyph;
- XChar2b char2b[8];
+ unsigned char2b[8];
int x, i, j;
/* If first glyph of S has a left box line, start drawing the text
@@ -1882,14 +1877,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,
@@ -8200,7 +8191,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
fit in 81 bytes. So, we must prepare sufficient
bytes for copy_buffer. 513 bytes (256 chars for
two-byte character set) seems to be a fairly good
- approximation. -- 2000.8.10 handa@etl.go.jp */
+ approximation. -- 2000.8.10 handa@gnu.org */
unsigned char copy_buffer[513];
unsigned char *copy_bufptr = copy_buffer;
int copy_bufsiz = sizeof (copy_buffer);
@@ -9356,7 +9347,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)
@@ -12161,7 +12152,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);
}
diff --git a/src/xterm.h b/src/xterm.h
index 84030d5c25e..ce1443c381c 100644
--- a/src/xterm.h
+++ b/src/xterm.h
@@ -731,8 +731,6 @@ struct x_output
#endif
};
-#define No_Cursor (None)
-
enum
{
/* Values for focus_state, used as bit mask.
@@ -1224,7 +1222,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
@@ -1263,15 +1262,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), \