aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlexander Gramiak2019-05-09 18:12:22 -0600
committerAlexander Gramiak2019-05-19 19:50:32 -0600
commit462b1fd7185ab8866c8db15b6e7a9b865e4d2389 (patch)
treeb1fd61f503943b3ab7da24877033a3170cdfbef0 /src
parent44d577925e0f5679d417028799db47a1f5d0fd03 (diff)
downloademacs-462b1fd7185ab8866c8db15b6e7a9b865e4d2389.tar.gz
emacs-462b1fd7185ab8866c8db15b6e7a9b865e4d2389.zip
Introduce Emacs_Rectangle struct and typedef
* src/dispextern.h [HAVE_X_WINDOWS]: Alias Emacs_Rectangle to XRectangle. [!HAVE_X_WINDOWS]: Define Emacs_Rectangle struct. Use Emacs_Rectangle over XRectangle. * src/frame.h (MonitorInfo): * src/msdos.h: * src/w32term.c: * src/xdisp.c: Use Emacs_Rectangle over XRectangle. * src/nsgui.h: * src/w32gui.h: Remove old XRectangle structs. * src/xdisp.c: * src/nsgui.h: * src/w32gui.h: Rename CONVERT_FROM_XRECT and CONVERT_TO_XRECT to CONVERT_FROM_EMACS_RECT and CONVERT_TO_EMACS_RECT respectively.
Diffstat (limited to 'src')
-rw-r--r--src/dispextern.h15
-rw-r--r--src/frame.h2
-rw-r--r--src/msdos.h1
-rw-r--r--src/nsgui.h12
-rw-r--r--src/w32gui.h9
-rw-r--r--src/w32term.c6
-rw-r--r--src/xdisp.c45
7 files changed, 43 insertions, 47 deletions
diff --git a/src/dispextern.h b/src/dispextern.h
index eecf95b54fb..2077f891d10 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -39,7 +39,7 @@ typedef XColor Emacs_Color;
39typedef Cursor Emacs_Cursor; 39typedef Cursor Emacs_Cursor;
40#define No_Cursor (None) 40#define No_Cursor (None)
41typedef Pixmap Emacs_Pixmap; 41typedef Pixmap Emacs_Pixmap;
42 42typedef XRectangle Emacs_Rectangle;
43#else /* !HAVE_X_WINDOWS */ 43#else /* !HAVE_X_WINDOWS */
44 44
45/* XColor-like struct used by non-X code. */ 45/* XColor-like struct used by non-X code. */
@@ -52,6 +52,13 @@ typedef struct
52 52
53/* Accommodate X's usage of None as a null resource ID. */ 53/* Accommodate X's usage of None as a null resource ID. */
54#define No_Cursor (NULL) 54#define No_Cursor (NULL)
55
56/* XRectangle-like struct used by non-X GUI code. */
57typedef struct
58{
59 int x, y;
60 unsigned width, height;
61} Emacs_Rectangle;
55#endif /* HAVE_X_WINDOWS */ 62#endif /* HAVE_X_WINDOWS */
56 63
57#ifdef MSDOS 64#ifdef MSDOS
@@ -1046,7 +1053,7 @@ struct glyph_row
1046#ifdef HAVE_WINDOW_SYSTEM 1053#ifdef HAVE_WINDOW_SYSTEM
1047 /* Non-NULL means the current clipping area. This is temporarily 1054 /* Non-NULL means the current clipping area. This is temporarily
1048 set while exposing a region. Coordinates are frame-relative. */ 1055 set while exposing a region. Coordinates are frame-relative. */
1049 XRectangle *clip; 1056 const Emacs_Rectangle *clip;
1050#endif 1057#endif
1051}; 1058};
1052 1059
@@ -3317,7 +3324,9 @@ extern void handle_tool_bar_click (struct frame *,
3317 int, int, bool, int); 3324 int, int, bool, int);
3318 3325
3319extern void expose_frame (struct frame *, int, int, int, int); 3326extern void expose_frame (struct frame *, int, int, int, int);
3320extern bool gui_intersect_rectangles (XRectangle *, XRectangle *, XRectangle *); 3327extern bool gui_intersect_rectangles (const Emacs_Rectangle *,
3328 const Emacs_Rectangle *,
3329 Emacs_Rectangle *);
3321#endif /* HAVE_WINDOW_SYSTEM */ 3330#endif /* HAVE_WINDOW_SYSTEM */
3322 3331
3323extern void note_mouse_highlight (struct frame *, int, int); 3332extern void note_mouse_highlight (struct frame *, int, int);
diff --git a/src/frame.h b/src/frame.h
index b8aed823afb..781063340d8 100644
--- a/src/frame.h
+++ b/src/frame.h
@@ -1626,7 +1626,7 @@ flush_frame (struct frame *f)
1626#ifdef HAVE_WINDOW_SYSTEM 1626#ifdef HAVE_WINDOW_SYSTEM
1627 1627
1628struct MonitorInfo { 1628struct MonitorInfo {
1629 XRectangle geom, work; 1629 Emacs_Rectangle geom, work;
1630 int mm_width, mm_height; 1630 int mm_width, mm_height;
1631 char *name; 1631 char *name;
1632}; 1632};
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;
86typedef int Pixmap; 86typedef int Pixmap;
87typedef int Display; 87typedef int Display;
88typedef int Window; 88typedef int Window;
89typedef int XRectangle;
90#define PIX_TYPE unsigned long 89#define PIX_TYPE unsigned long
91#define XDISPLAY 90#define XDISPLAY
92 91
diff --git a/src/nsgui.h b/src/nsgui.h
index c6f0f4b0eae..592e21f60af 100644
--- a/src/nsgui.h
+++ b/src/nsgui.h
@@ -109,14 +109,6 @@ typedef void *Emacs_Cursor;
109 109
110typedef int Window; 110typedef int Window;
111 111
112
113/* Some sort of attempt to normalize rectangle handling. Seems a bit
114 much for what is accomplished. */
115typedef struct {
116 int x, y;
117 unsigned width, height;
118} XRectangle;
119
120#ifndef __OBJC__ 112#ifndef __OBJC__
121#if defined (__LP64__) && __LP64__ 113#if defined (__LP64__) && __LP64__
122typedef double CGFloat; 114typedef double CGFloat;
@@ -130,13 +122,13 @@ typedef struct _NSRect { NSPoint origin; NSSize size; } NSRect;
130 122
131#define NativeRectangle NSRect 123#define NativeRectangle NSRect
132 124
133#define CONVERT_TO_XRECT(xr, nr) \ 125#define CONVERT_TO_EMACS_RECT(xr, nr) \
134 ((xr).x = (nr).origin.x, \ 126 ((xr).x = (nr).origin.x, \
135 (xr).y = (nr).origin.y, \ 127 (xr).y = (nr).origin.y, \
136 (xr).width = (nr).size.width, \ 128 (xr).width = (nr).size.width, \
137 (xr).height = (nr).size.height) 129 (xr).height = (nr).size.height)
138 130
139#define CONVERT_FROM_XRECT(xr, nr) \ 131#define CONVERT_FROM_EMACS_RECT(xr, nr) \
140 ((nr).origin.x = (xr).x, \ 132 ((nr).origin.x = (xr).x, \
141 (nr).origin.y = (xr).y, \ 133 (nr).origin.y = (xr).y, \
142 (nr).size.width = (xr).width, \ 134 (nr).size.width = (xr).width, \
diff --git a/src/w32gui.h b/src/w32gui.h
index c8df7128a76..69b6a556ff0 100644
--- a/src/w32gui.h
+++ b/src/w32gui.h
@@ -106,20 +106,15 @@ extern HINSTANCE hinst;
106#define PBaseSize (1L << 8) /* program specified base for incrementing */ 106#define PBaseSize (1L << 8) /* program specified base for incrementing */
107#define PWinGravity (1L << 9) /* program specified window gravity */ 107#define PWinGravity (1L << 9) /* program specified window gravity */
108 108
109typedef struct {
110 int x, y;
111 unsigned width, height;
112} XRectangle;
113
114#define NativeRectangle RECT 109#define NativeRectangle RECT
115 110
116#define CONVERT_TO_XRECT(xr,nr) \ 111#define CONVERT_TO_EMACS_RECT(xr,nr) \
117 ((xr).x = (nr).left, \ 112 ((xr).x = (nr).left, \
118 (xr).y = (nr).top, \ 113 (xr).y = (nr).top, \
119 (xr).width = ((nr).right - (nr).left), \ 114 (xr).width = ((nr).right - (nr).left), \
120 (xr).height = ((nr).bottom - (nr).top)) 115 (xr).height = ((nr).bottom - (nr).top))
121 116
122#define CONVERT_FROM_XRECT(xr,nr) \ 117#define CONVERT_FROM_EMACS_RECT(xr,nr) \
123 ((nr).left = (xr).x, \ 118 ((nr).left = (xr).x, \
124 (nr).top = (xr).y, \ 119 (nr).top = (xr).y, \
125 (nr).right = ((xr).x + (xr).width), \ 120 (nr).right = ((xr).x + (xr).width), \
diff --git a/src/w32term.c b/src/w32term.c
index ed881ad3beb..5c492b3fa99 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -337,7 +337,7 @@ w32_draw_underwave (struct glyph_string *s, COLORREF color)
337 337
338 int wave_height = 3 * scale_y, wave_length = 2 * scale_x, thickness = scale_y; 338 int wave_height = 3 * scale_y, wave_length = 2 * scale_x, thickness = scale_y;
339 int dx, dy, x0, y0, width, x1, y1, x2, y2, odd, xmax; 339 int dx, dy, x0, y0, width, x1, y1, x2, y2, odd, xmax;
340 XRectangle wave_clip, string_clip, final_clip; 340 Emacs_Rectangle wave_clip, string_clip, final_clip;
341 RECT w32_final_clip, w32_string_clip; 341 RECT w32_final_clip, w32_string_clip;
342 HPEN hp, oldhp; 342 HPEN hp, oldhp;
343 343
@@ -356,14 +356,14 @@ w32_draw_underwave (struct glyph_string *s, COLORREF color)
356 wave_clip.height = wave_height; 356 wave_clip.height = wave_height;
357 357
358 get_glyph_string_clip_rect (s, &w32_string_clip); 358 get_glyph_string_clip_rect (s, &w32_string_clip);
359 CONVERT_TO_XRECT (string_clip, w32_string_clip); 359 CONVERT_TO_EMACS_RECT (string_clip, w32_string_clip);
360 360
361 if (!gui_intersect_rectangles (&wave_clip, &string_clip, &final_clip)) 361 if (!gui_intersect_rectangles (&wave_clip, &string_clip, &final_clip))
362 return; 362 return;
363 363
364 hp = CreatePen (PS_SOLID, thickness, color); 364 hp = CreatePen (PS_SOLID, thickness, color);
365 oldhp = SelectObject (s->hdc, hp); 365 oldhp = SelectObject (s->hdc, hp);
366 CONVERT_FROM_XRECT (final_clip, w32_final_clip); 366 CONVERT_FROM_EMACS_RECT (final_clip, w32_final_clip);
367 w32_set_clip_rectangle (s->hdc, &w32_final_clip); 367 w32_set_clip_rectangle (s->hdc, &w32_final_clip);
368 368
369 /* Draw the waves */ 369 /* Draw the waves */
diff --git a/src/xdisp.c b/src/xdisp.c
index 0c1d9660324..6929ca4b4bf 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -2080,7 +2080,7 @@ frame_to_window_pixel_xy (struct window *w, int *x, int *y)
2080int 2080int
2081get_glyph_string_clip_rects (struct glyph_string *s, NativeRectangle *rects, int n) 2081get_glyph_string_clip_rects (struct glyph_string *s, NativeRectangle *rects, int n)
2082{ 2082{
2083 XRectangle r; 2083 Emacs_Rectangle r;
2084 2084
2085 if (n <= 0) 2085 if (n <= 0)
2086 return 0; 2086 return 0;
@@ -2142,7 +2142,7 @@ get_glyph_string_clip_rects (struct glyph_string *s, NativeRectangle *rects, int
2142 take the intersection with the rectangle of the cursor. */ 2142 take the intersection with the rectangle of the cursor. */
2143 if (s->for_overlaps & OVERLAPS_ERASED_CURSOR) 2143 if (s->for_overlaps & OVERLAPS_ERASED_CURSOR)
2144 { 2144 {
2145 XRectangle rc, r_save = r; 2145 Emacs_Rectangle rc, r_save = r;
2146 2146
2147 rc.x = WINDOW_TEXT_TO_FRAME_PIXEL_X (s->w, s->w->phys_cursor.x); 2147 rc.x = WINDOW_TEXT_TO_FRAME_PIXEL_X (s->w, s->w->phys_cursor.x);
2148 rc.y = s->w->phys_cursor.y; 2148 rc.y = s->w->phys_cursor.y;
@@ -2208,7 +2208,7 @@ get_glyph_string_clip_rects (struct glyph_string *s, NativeRectangle *rects, int
2208 2208
2209 if (s->row->clip) 2209 if (s->row->clip)
2210 { 2210 {
2211 XRectangle r_save = r; 2211 Emacs_Rectangle r_save = r;
2212 2212
2213 if (! gui_intersect_rectangles (&r_save, s->row->clip, &r)) 2213 if (! gui_intersect_rectangles (&r_save, s->row->clip, &r))
2214 r.width = 0; 2214 r.width = 0;
@@ -2217,8 +2217,8 @@ get_glyph_string_clip_rects (struct glyph_string *s, NativeRectangle *rects, int
2217 if ((s->for_overlaps & OVERLAPS_BOTH) == 0 2217 if ((s->for_overlaps & OVERLAPS_BOTH) == 0
2218 || ((s->for_overlaps & OVERLAPS_BOTH) == OVERLAPS_BOTH && n == 1)) 2218 || ((s->for_overlaps & OVERLAPS_BOTH) == OVERLAPS_BOTH && n == 1))
2219 { 2219 {
2220#ifdef CONVERT_FROM_XRECT 2220#ifdef CONVERT_FROM_EMACS_RECT
2221 CONVERT_FROM_XRECT (r, *rects); 2221 CONVERT_FROM_EMACS_RECT (r, *rects);
2222#else 2222#else
2223 *rects = r; 2223 *rects = r;
2224#endif 2224#endif
@@ -2230,10 +2230,10 @@ get_glyph_string_clip_rects (struct glyph_string *s, NativeRectangle *rects, int
2230 multiple clipping rectangles, we exclude the row of the glyph 2230 multiple clipping rectangles, we exclude the row of the glyph
2231 string from the clipping rectangle. This is to avoid drawing 2231 string from the clipping rectangle. This is to avoid drawing
2232 the same text on the environment with anti-aliasing. */ 2232 the same text on the environment with anti-aliasing. */
2233#ifdef CONVERT_FROM_XRECT 2233#ifdef CONVERT_FROM_EMACS_RECT
2234 XRectangle rs[2]; 2234 Emacs_Rectangle rs[2];
2235#else 2235#else
2236 XRectangle *rs = rects; 2236 Emacs_Rectangle *rs = rects;
2237#endif 2237#endif
2238 int i = 0, row_y = WINDOW_TO_FRAME_PIXEL_Y (s->w, s->row->y); 2238 int i = 0, row_y = WINDOW_TO_FRAME_PIXEL_Y (s->w, s->row->y);
2239 2239
@@ -2266,9 +2266,9 @@ get_glyph_string_clip_rects (struct glyph_string *s, NativeRectangle *rects, int
2266 } 2266 }
2267 2267
2268 n = i; 2268 n = i;
2269#ifdef CONVERT_FROM_XRECT 2269#ifdef CONVERT_FROM_EMACS_RECT
2270 for (i = 0; i < n; i++) 2270 for (i = 0; i < n; i++)
2271 CONVERT_FROM_XRECT (rs[i], rects[i]); 2271 CONVERT_FROM_EMACS_RECT (rs[i], rects[i]);
2272#endif 2272#endif
2273 return n; 2273 return n;
2274 } 2274 }
@@ -32137,7 +32137,7 @@ cancel_mouse_face (struct frame *f)
32137 which intersects rectangle R. R is in window-relative coordinates. */ 32137 which intersects rectangle R. R is in window-relative coordinates. */
32138 32138
32139static void 32139static void
32140expose_area (struct window *w, struct glyph_row *row, XRectangle *r, 32140expose_area (struct window *w, struct glyph_row *row, const Emacs_Rectangle *r,
32141 enum glyph_row_area area) 32141 enum glyph_row_area area)
32142{ 32142{
32143 struct glyph *first = row->glyphs[area]; 32143 struct glyph *first = row->glyphs[area];
@@ -32195,7 +32195,7 @@ expose_area (struct window *w, struct glyph_row *row, XRectangle *r,
32195 true if mouse-face was overwritten. */ 32195 true if mouse-face was overwritten. */
32196 32196
32197static bool 32197static bool
32198expose_line (struct window *w, struct glyph_row *row, XRectangle *r) 32198expose_line (struct window *w, struct glyph_row *row, const Emacs_Rectangle *r)
32199{ 32199{
32200 eassert (row->enabled_p); 32200 eassert (row->enabled_p);
32201 32201
@@ -32230,7 +32230,7 @@ static void
32230expose_overlaps (struct window *w, 32230expose_overlaps (struct window *w,
32231 struct glyph_row *first_overlapping_row, 32231 struct glyph_row *first_overlapping_row,
32232 struct glyph_row *last_overlapping_row, 32232 struct glyph_row *last_overlapping_row,
32233 XRectangle *r) 32233 const Emacs_Rectangle *r)
32234{ 32234{
32235 struct glyph_row *row; 32235 struct glyph_row *row;
32236 32236
@@ -32256,9 +32256,9 @@ expose_overlaps (struct window *w,
32256/* Return true if W's cursor intersects rectangle R. */ 32256/* Return true if W's cursor intersects rectangle R. */
32257 32257
32258static bool 32258static bool
32259phys_cursor_in_rect_p (struct window *w, XRectangle *r) 32259phys_cursor_in_rect_p (struct window *w, const Emacs_Rectangle *r)
32260{ 32260{
32261 XRectangle cr, result; 32261 Emacs_Rectangle cr, result;
32262 struct glyph *cursor_glyph; 32262 struct glyph *cursor_glyph;
32263 struct glyph_row *row; 32263 struct glyph_row *row;
32264 32264
@@ -32416,10 +32416,10 @@ gui_draw_bottom_divider (struct window *w)
32416 mouse-face. */ 32416 mouse-face. */
32417 32417
32418static bool 32418static bool
32419expose_window (struct window *w, XRectangle *fr) 32419expose_window (struct window *w, const Emacs_Rectangle *fr)
32420{ 32420{
32421 struct frame *f = XFRAME (w->frame); 32421 struct frame *f = XFRAME (w->frame);
32422 XRectangle wr, r; 32422 Emacs_Rectangle wr, r;
32423 bool mouse_face_overwritten_p = false; 32423 bool mouse_face_overwritten_p = false;
32424 32424
32425 /* If window is not yet fully initialized, do nothing. This can 32425 /* If window is not yet fully initialized, do nothing. This can
@@ -32578,7 +32578,7 @@ expose_window (struct window *w, XRectangle *fr)
32578 true if the exposure overwrites mouse-face. */ 32578 true if the exposure overwrites mouse-face. */
32579 32579
32580static bool 32580static bool
32581expose_window_tree (struct window *w, XRectangle *r) 32581expose_window_tree (struct window *w, const Emacs_Rectangle *r)
32582{ 32582{
32583 struct frame *f = XFRAME (w->frame); 32583 struct frame *f = XFRAME (w->frame);
32584 bool mouse_face_overwritten_p = false; 32584 bool mouse_face_overwritten_p = false;
@@ -32606,7 +32606,7 @@ expose_window_tree (struct window *w, XRectangle *r)
32606void 32606void
32607expose_frame (struct frame *f, int x, int y, int w, int h) 32607expose_frame (struct frame *f, int x, int y, int w, int h)
32608{ 32608{
32609 XRectangle r; 32609 Emacs_Rectangle r;
32610 bool mouse_face_overwritten_p = false; 32610 bool mouse_face_overwritten_p = false;
32611 32611
32612 TRACE ((stderr, "expose_frame ")); 32612 TRACE ((stderr, "expose_frame "));
@@ -32693,10 +32693,11 @@ expose_frame (struct frame *f, int x, int y, int w, int h)
32693 empty. */ 32693 empty. */
32694 32694
32695bool 32695bool
32696gui_intersect_rectangles (XRectangle *r1, XRectangle *r2, XRectangle *result) 32696gui_intersect_rectangles (const Emacs_Rectangle *r1, const Emacs_Rectangle *r2,
32697 Emacs_Rectangle *result)
32697{ 32698{
32698 XRectangle *left, *right; 32699 const Emacs_Rectangle *left, *right;
32699 XRectangle *upper, *lower; 32700 const Emacs_Rectangle *upper, *lower;
32700 bool intersection_p = false; 32701 bool intersection_p = false;
32701 32702
32702 /* Rearrange so that R1 is the left-most rectangle. */ 32703 /* Rearrange so that R1 is the left-most rectangle. */