Lisp_Object *, Lisp_Object *,
unsigned long *));
-static int is_emacs_window (WindowPtr);
+static int is_emacs_window P_ ((WindowPtr));
-int x_bitmap_icon (struct frame *, Lisp_Object);
-void x_make_frame_visible (struct frame *);
+static void XSetFont P_ ((Display *, GC, XFontStruct *));
/* Defined in macmenu.h. */
extern void menubar_selection_callback (FRAME_PTR, int);
+#define GC_FORE_COLOR(gc) (&(gc)->fore_color)
+#define GC_BACK_COLOR(gc) (&(gc)->back_color)
+#define GC_FONT(gc) ((gc)->xgcv.font)
+#define MAC_WINDOW_NORMAL_GC(w) (((mac_output *) GetWRefCon (w))->normal_gc)
+
+
/* X display function emulation */
void
}
-/* Set foreground color for subsequent QuickDraw commands. Assume
- graphic port has already been set. */
-
-static void
-mac_set_forecolor (unsigned long color)
-{
- RGBColor fg_color;
-
- fg_color.red = RED16_FROM_ULONG (color);
- fg_color.green = GREEN16_FROM_ULONG (color);
- fg_color.blue = BLUE16_FROM_ULONG (color);
-
- RGBForeColor (&fg_color);
-}
-
-
-/* Set background color for subsequent QuickDraw commands. Assume
- graphic port has already been set. */
-
-static void
-mac_set_backcolor (unsigned long color)
-{
- RGBColor bg_color;
-
- bg_color.red = RED16_FROM_ULONG (color);
- bg_color.green = GREEN16_FROM_ULONG (color);
- bg_color.blue = BLUE16_FROM_ULONG (color);
-
- RGBBackColor (&bg_color);
-}
-
-/* Set foreground and background color for subsequent QuickDraw
- commands. Assume that the graphic port has already been set. */
-
-static void
-mac_set_colors (gc, bg_save)
- GC gc;
- RGBColor *bg_save;
-{
- if (bg_save)
- GetBackColor (bg_save);
- mac_set_forecolor (gc->foreground);
- mac_set_backcolor (gc->background);
-}
-
/* Mac version of XDrawLine. */
static void
GC gc;
int x1, y1, x2, y2;
{
- RGBColor old_bg;
-
SetPortWindowPort (w);
- mac_set_colors (gc, &old_bg);
+ RGBForeColor (GC_FORE_COLOR (gc));
MoveTo (x1, y1);
LineTo (x2, y2);
-
- RGBBackColor (&old_bg);
}
void
GetGWorld (&old_port, &old_gdh);
SetGWorld (p, NULL);
- mac_set_colors (gc, NULL);
+ RGBForeColor (GC_FORE_COLOR (gc));
LockPixels (GetGWorldPixMap (p));
MoveTo (x1, y1);
SetGWorld (old_port, old_gdh);
}
-/* Mac version of XClearArea. */
-void
-XClearArea (display, w, x, y, width, height, exposures)
- Display *display;
+static void
+mac_erase_rectangle (w, gc, x, y, width, height)
WindowPtr w;
+ GC gc;
int x, y;
unsigned int width, height;
- int exposures;
{
- struct mac_output *mwp = (mac_output *) GetWRefCon (w);
Rect r;
- XGCValues xgc;
- RGBColor old_bg;
-
- xgc.foreground = mwp->x_compatible.foreground_pixel;
- xgc.background = mwp->x_compatible.background_pixel;
SetPortWindowPort (w);
- mac_set_colors (&xgc, &old_bg);
+ RGBBackColor (GC_BACK_COLOR (gc));
SetRect (&r, x, y, x + width, y + height);
EraseRect (&r);
- RGBBackColor (&old_bg);
+ RGBBackColor (GC_BACK_COLOR (MAC_WINDOW_NORMAL_GC (w)));
+}
+
+
+/* Mac version of XClearArea. */
+
+void
+XClearArea (display, w, x, y, width, height, exposures)
+ Display *display;
+ WindowPtr w;
+ int x, y;
+ unsigned int width, height;
+ int exposures;
+{
+ mac_erase_rectangle (w, MAC_WINDOW_NORMAL_GC (w), x, y, width, height);
}
/* Mac version of XClearWindow. */
Display *display;
WindowPtr w;
{
- struct mac_output *mwp = (mac_output *) GetWRefCon (w);
- XGCValues xgc;
-
- xgc.foreground = mwp->x_compatible.foreground_pixel;
- xgc.background = mwp->x_compatible.background_pixel;
-
SetPortWindowPort (w);
- mac_set_colors (&xgc, NULL);
+ RGBBackColor (GC_BACK_COLOR (MAC_WINDOW_NORMAL_GC (w)));
#if TARGET_API_MAC_CARBON
{
{
BitMap bitmap;
Rect r;
- RGBColor old_bg;
bitmap.rowBytes = sizeof(unsigned short);
bitmap.baseAddr = (char *)bits;
SetPortWindowPort (w);
- mac_set_colors (gc, &old_bg);
+ RGBForeColor (GC_FORE_COLOR (gc));
+ RGBBackColor (GC_BACK_COLOR (gc));
SetRect (&r, x, y, x + width, y + height);
#if TARGET_API_MAC_CARBON
overlay_p ? srcOr : srcCopy, 0);
#endif /* not TARGET_API_MAC_CARBON */
- RGBBackColor (&old_bg);
+ RGBBackColor (GC_BACK_COLOR (MAC_WINDOW_NORMAL_GC (w)));
}
char *data;
unsigned int width, height;
unsigned long fg, bg;
- unsigned int depth; /* not used */
+ unsigned int depth;
{
Pixmap pixmap;
BitMap bitmap;
CGrafPtr old_port;
GDHandle old_gdh;
+ static GC gc = NULL; /* not reentrant */
+
+ if (gc == NULL)
+ gc = XCreateGC (display, w, 0, NULL);
pixmap = XCreatePixmap (display, w, width, height, depth);
if (pixmap == NULL)
GetGWorld (&old_port, &old_gdh);
SetGWorld (pixmap, NULL);
mac_create_bitmap_from_bitmap_data (&bitmap, data, width, height);
- mac_set_forecolor (fg);
- mac_set_backcolor (bg);
+ XSetForeground (display, gc, fg);
+ XSetBackground (display, gc, bg);
+ RGBForeColor (GC_FORE_COLOR (gc));
+ RGBBackColor (GC_BACK_COLOR (gc));
LockPixels (GetGWorldPixMap (pixmap));
#if TARGET_API_MAC_CARBON
CopyBits (&bitmap, GetPortBitMapForCopyBits (pixmap),
unsigned int width, height;
{
Rect r;
- RGBColor old_bg;
SetPortWindowPort (w);
- mac_set_colors (gc, &old_bg);
+ RGBForeColor (GC_FORE_COLOR (gc));
SetRect (&r, x, y, x + width, y + height);
PaintRect (&r); /* using foreground color of gc */
-
- RGBBackColor (&old_bg);
}
GetGWorld (&old_port, &old_gdh);
SetGWorld (p, NULL);
- mac_set_colors (gc, NULL);
+ RGBForeColor (GC_FORE_COLOR (gc));
SetRect (&r, x, y, x + width, y + height);
LockPixels (GetGWorldPixMap (p));
unsigned int width, height;
{
Rect r;
- RGBColor old_bg;
SetPortWindowPort (w);
- mac_set_colors (gc, &old_bg);
+ RGBForeColor (GC_FORE_COLOR (gc));
SetRect (&r, x, y, x + width + 1, y + height + 1);
FrameRect (&r); /* using foreground color of gc */
-
- RGBBackColor (&old_bg);
}
GetGWorld (&old_port, &old_gdh);
SetGWorld (p, NULL);
- mac_set_colors (gc, NULL);
+ RGBForeColor (GC_FORE_COLOR (gc));
SetRect (&r, x, y, x + width + 1, y + height + 1);
LockPixels (GetGWorldPixMap (p));
char *buf;
int nchars, mode, bytes_per_char;
{
- RGBColor old_bg;
-
- SetPortWindowPort (w);
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020
UInt32 textFlags, savedFlags;
if (!NILP(Vmac_use_core_graphics)) {
}
#endif
- mac_set_colors (gc, &old_bg);
+ SetPortWindowPort (w);
+
+ RGBForeColor (GC_FORE_COLOR (gc));
+ if (mode != srcOr)
+ RGBBackColor (GC_BACK_COLOR (gc));
- TextFont (gc->font->mac_fontnum);
- TextSize (gc->font->mac_fontsize);
- TextFace (gc->font->mac_fontface);
+ TextFont (GC_FONT (gc)->mac_fontnum);
+ TextSize (GC_FONT (gc)->mac_fontsize);
+ TextFace (GC_FONT (gc)->mac_fontface);
TextMode (mode);
MoveTo (x, y);
DrawText (buf, 0, nchars * bytes_per_char);
- RGBBackColor (&old_bg);
+ if (mode != srcOr)
+ RGBBackColor (GC_BACK_COLOR (MAC_WINDOW_NORMAL_GC (w)));
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020
if (!NILP(Vmac_use_core_graphics))
SwapQDTextFlags(savedFlags);
BackColor (whiteColor);
CopyBits (&(w->portBits), &(w->portBits), &src_r, &dest_r, srcCopy, 0);
- mac_set_colors (gc, NULL);
+ RGBBackColor (GC_BACK_COLOR (MAC_WINDOW_NORMAL_GC (w)));
#endif /* not TARGET_API_MAC_CARBON */
}
/* Mac replacement for XChangeGC. */
static void
-XChangeGC (void * ignore, XGCValues* gc, unsigned long mask,
- XGCValues *xgcv)
+XChangeGC (display, gc, mask, xgcv)
+ Display *display;
+ GC gc;
+ unsigned long mask;
+ XGCValues *xgcv;
{
if (mask & GCForeground)
- gc->foreground = xgcv->foreground;
+ XSetForeground (display, gc, xgcv->foreground);
if (mask & GCBackground)
- gc->background = xgcv->background;
+ XSetBackground (display, gc, xgcv->background);
if (mask & GCFont)
- gc->font = xgcv->font;
+ XSetFont (display, gc, xgcv->font);
}
/* Mac replacement for XCreateGC. */
-XGCValues *
-XCreateGC (void * ignore, Window window, unsigned long mask,
- XGCValues *xgcv)
+GC
+XCreateGC (display, window, mask, xgcv)
+ Display *display;
+ Window window;
+ unsigned long mask;
+ XGCValues *xgcv;
{
- XGCValues *gc = (XGCValues *) xmalloc (sizeof (XGCValues));
- bzero (gc, sizeof (XGCValues));
+ GC gc = xmalloc (sizeof (*gc));
- XChangeGC (ignore, gc, mask, xgcv);
+ if (gc)
+ {
+ bzero (gc, sizeof (*gc));
+ XChangeGC (display, gc, mask, xgcv);
+ }
return gc;
}
/* Mac replacement for XGetGCValues. */
static void
-XGetGCValues (void* ignore, XGCValues *gc,
- unsigned long mask, XGCValues *xgcv)
+XGetGCValues (display, gc, mask, xgcv)
+ Display *display;
+ GC gc;
+ unsigned long mask;
+ XGCValues *xgcv;
{
- XChangeGC (ignore, xgcv, mask, gc);
+ if (mask & GCForeground)
+ xgcv->foreground = gc->xgcv.foreground;
+ if (mask & GCBackground)
+ xgcv->background = gc->xgcv.background;
+ if (mask & GCFont)
+ xgcv->font = gc->xgcv.font;
}
GC gc;
unsigned long color;
{
- gc->foreground = color;
+ if (gc->xgcv.foreground != color)
+ {
+ gc->xgcv.foreground = color;
+ gc->fore_color.red = RED16_FROM_ULONG (color);
+ gc->fore_color.green = GREEN16_FROM_ULONG (color);
+ gc->fore_color.blue = BLUE16_FROM_ULONG (color);
+ }
}
GC gc;
unsigned long color;
{
- gc->background = color;
+ if (gc->xgcv.background != color)
+ {
+ gc->xgcv.background = color;
+ gc->back_color.red = RED16_FROM_ULONG (color);
+ gc->back_color.green = GREEN16_FROM_ULONG (color);
+ gc->back_color.blue = BLUE16_FROM_ULONG (color);
+ }
+}
+
+
+/* Mac replacement for XSetFont. */
+
+static void
+XSetFont (display, gc, font)
+ Display *display;
+ GC gc;
+ XFontStruct *font;
+{
+ gc->xgcv.font = font;
}
#endif
}
-
-/* Mac replacement for XSetFont. */
-
-static void
-XSetFont (display, gc, font)
- Display *display;
- GC gc;
- XFontStruct *font;
-{
- gc->font = font;
-}
-
-
/* x_sync is a no-op on Mac. */
void
x_sync (f)
struct frame *f = XFRAME (WINDOW_FRAME (w));
Display *display = FRAME_MAC_DISPLAY (f);
WindowPtr window = FRAME_MAC_WINDOW (f);
- XGCValues gcv;
GC gc = f->output_data.mac->normal_gc;
struct face *face = p->face;
int rowY;
if (p->bx >= 0 && !p->overlay_p)
{
- XGCValues gcv;
- gcv.foreground = face->background;
-
#if 0 /* MAC_TODO: stipple */
/* In case the same realized face is used for fringes and
for something displayed in the text (e.g. face `region' on
XSetForeground (FRAME_X_DISPLAY (f), face->gc, face->background);
#endif
- XFillRectangle (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f),
- &gcv,
- p->bx, p->by, p->nx, p->ny);
+ mac_erase_rectangle (window, face->gc, p->bx, p->by, p->nx, p->ny);
#if 0 /* MAC_TODO: stipple */
if (!face->stipple)
if (p->which)
{
unsigned short *bits = p->bits + p->dh;
+ XGCValues gcv;
- gcv.foreground = (p->cursor_p
- ? (p->overlay_p ? face->background
- : f->output_data.mac->cursor_pixel)
- : face->foreground);
- gcv.background = face->background;
-
- mac_draw_bitmap (display, window, &gcv, p->x, p->y,
+ XGetGCValues (display, face->gc, GCForeground, &gcv);
+ XSetForeground (display, face->gc,
+ (p->cursor_p
+ ? (p->overlay_p ? face->background
+ : f->output_data.mac->cursor_pixel)
+ : face->foreground));
+ mac_draw_bitmap (display, window, face->gc, p->x, p->y,
p->wd, p->h, bits, p->overlay_p);
+ XSetForeground (display, face->gc, gcv.foreground);
}
mac_reset_clipping (display, window);
struct glyph_string *s;
int x, y, w, h;
{
- XGCValues xgcv;
-
- xgcv.foreground = s->gc->background;
- XFillRectangle (s->display, s->window, &xgcv, x, y, w, h);
+ mac_erase_rectangle (s->window, s->gc, x, y, w, h);
}
{
XGCValues xgcv;
- xgcv.foreground = s->face->box_color;
+ XGetGCValues (s->display, s->gc, GCForeground, &xgcv);
+ XSetForeground (s->display, s->gc, s->face->box_color);
mac_set_clip_rectangle (s->display, s->window, clip_rect);
/* Top. */
- XFillRectangle (s->display, s->window, &xgcv,
+ XFillRectangle (s->display, s->window, s->gc,
left_x, top_y, right_x - left_x + 1, width);
/* Left. */
if (left_p)
- XFillRectangle (s->display, s->window, &xgcv,
+ XFillRectangle (s->display, s->window, s->gc,
left_x, top_y, width, bottom_y - top_y + 1);
/* Bottom. */
- XFillRectangle (s->display, s->window, &xgcv,
+ XFillRectangle (s->display, s->window, s->gc,
left_x, bottom_y - width + 1, right_x - left_x + 1, width);
/* Right. */
if (right_p)
- XFillRectangle (s->display, s->window, &xgcv,
+ XFillRectangle (s->display, s->window, s->gc,
right_x - width + 1, top_y, width, bottom_y - top_y + 1);
+ XSetForeground (s->display, s->gc, xgcv.foreground);
mac_reset_clipping (s->display, s->window);
}
}
else
#endif /* MAC_TODO */
- {
- XGCValues xgcv;
- XGetGCValues (s->display, gc, GCForeground | GCBackground, &xgcv);
- XSetForeground (s->display, gc, xgcv.background);
- XFillRectangle (s->display, s->window, gc, x, y, w, h);
- XSetForeground (s->display, gc, xgcv.foreground);
- }
+ mac_erase_rectangle (s->window, gc, x, y, w, h);
mac_reset_clipping (s->display, s->window);
}
&& XINT (bar->width) == sb_width
&& XINT (bar->height) == height))
{
- /* Clear areas not covered by the scroll bar because it's not as
- wide as the area reserved for it . This makes sure a
- previous mode line display is cleared after C-x 2 C-x 1, for
- example. */
- int area_width = WINDOW_SCROLL_BAR_AREA_WIDTH (w);
+ /* Since toolkit scroll bars are smaller than the space reserved
+ for them on the frame, we have to clear "under" them. */
XClearArea (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f),
- left, top, area_width, height, 0);
+ left, top, width, height, 0);
#if 0
if (sb_left + sb_width >= FRAME_PIXEL_WIDTH (f))