Commit 462b1fd7 authored by Alexander Gramiak's avatar Alexander Gramiak

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.
parent 44d57792
......@@ -39,7 +39,7 @@ typedef XColor Emacs_Color;
typedef Cursor Emacs_Cursor;
#define No_Cursor (None)
typedef Pixmap Emacs_Pixmap;
typedef XRectangle Emacs_Rectangle;
#else /* !HAVE_X_WINDOWS */
/* XColor-like struct used by non-X code. */
......@@ -52,6 +52,13 @@ typedef struct
/* 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;
#endif /* HAVE_X_WINDOWS */
#ifdef MSDOS
......@@ -1046,7 +1053,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
};
......@@ -3317,7 +3324,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);
......
......@@ -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;
};
......
......@@ -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
......
......@@ -109,14 +109,6 @@ typedef void *Emacs_Cursor;
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;
......@@ -130,13 +122,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, \
......
......@@ -106,20 +106,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), \
......
......@@ -337,7 +337,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 +356,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 */
......
......@@ -2080,7 +2080,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 +2142,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 +2208,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 +2217,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 +2230,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 +2266,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;
}
......@@ -32137,7 +32137,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 +32195,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 +32230,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 +32256,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 +32416,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 +32578,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 +32606,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 +32693,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. */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment