[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] Changes to emacs/src/macterm.c
From: |
YAMAMOTO Mitsuharu |
Subject: |
[Emacs-diffs] Changes to emacs/src/macterm.c |
Date: |
Mon, 18 Jul 2005 01:40:31 -0400 |
Index: emacs/src/macterm.c
diff -c emacs/src/macterm.c:1.123 emacs/src/macterm.c:1.124
*** emacs/src/macterm.c:1.123 Thu Jul 14 09:23:24 2005
--- emacs/src/macterm.c Mon Jul 18 05:40:30 2005
***************
*** 259,272 ****
Lisp_Object *, Lisp_Object *,
unsigned long *));
! static int is_emacs_window (WindowPtr);
! int x_bitmap_icon (struct frame *, Lisp_Object);
! void x_make_frame_visible (struct frame *);
/* Defined in macmenu.h. */
extern void menubar_selection_callback (FRAME_PTR, int);
/* X display function emulation */
void
--- 259,277 ----
Lisp_Object *, Lisp_Object *,
unsigned long *));
! static int is_emacs_window P_ ((WindowPtr));
! 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
***************
*** 278,328 ****
}
- /* 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
--- 283,288 ----
***************
*** 332,347 ****
GC gc;
int x1, y1, x2, y2;
{
- RGBColor old_bg;
-
SetPortWindowPort (w);
! mac_set_colors (gc, &old_bg);
MoveTo (x1, y1);
LineTo (x2, y2);
-
- RGBBackColor (&old_bg);
}
void
--- 292,303 ----
GC gc;
int x1, y1, x2, y2;
{
SetPortWindowPort (w);
! RGBForeColor (GC_FORE_COLOR (gc));
MoveTo (x1, y1);
LineTo (x2, y2);
}
void
***************
*** 357,363 ****
GetGWorld (&old_port, &old_gdh);
SetGWorld (p, NULL);
! mac_set_colors (gc, NULL);
LockPixels (GetGWorldPixMap (p));
MoveTo (x1, y1);
--- 313,319 ----
GetGWorld (&old_port, &old_gdh);
SetGWorld (p, NULL);
! RGBForeColor (GC_FORE_COLOR (gc));
LockPixels (GetGWorldPixMap (p));
MoveTo (x1, y1);
***************
*** 367,398 ****
SetGWorld (old_port, old_gdh);
}
- /* 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;
{
- 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);
SetRect (&r, x, y, x + width, y + height);
EraseRect (&r);
! RGBBackColor (&old_bg);
}
/* Mac version of XClearWindow. */
--- 323,360 ----
SetGWorld (old_port, old_gdh);
}
! static void
! mac_erase_rectangle (w, gc, x, y, width, height)
WindowPtr w;
+ GC gc;
int x, y;
unsigned int width, height;
{
Rect r;
SetPortWindowPort (w);
! RGBBackColor (GC_BACK_COLOR (gc));
SetRect (&r, x, y, x + width, y + height);
EraseRect (&r);
! 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. */
***************
*** 402,416 ****
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);
#if TARGET_API_MAC_CARBON
{
--- 364,372 ----
Display *display;
WindowPtr w;
{
SetPortWindowPort (w);
! RGBBackColor (GC_BACK_COLOR (MAC_WINDOW_NORMAL_GC (w)));
#if TARGET_API_MAC_CARBON
{
***************
*** 438,444 ****
{
BitMap bitmap;
Rect r;
- RGBColor old_bg;
bitmap.rowBytes = sizeof(unsigned short);
bitmap.baseAddr = (char *)bits;
--- 394,399 ----
***************
*** 446,452 ****
SetPortWindowPort (w);
! mac_set_colors (gc, &old_bg);
SetRect (&r, x, y, x + width, y + height);
#if TARGET_API_MAC_CARBON
--- 401,408 ----
SetPortWindowPort (w);
! RGBForeColor (GC_FORE_COLOR (gc));
! RGBBackColor (GC_BACK_COLOR (gc));
SetRect (&r, x, y, x + width, y + height);
#if TARGET_API_MAC_CARBON
***************
*** 459,465 ****
overlay_p ? srcOr : srcCopy, 0);
#endif /* not TARGET_API_MAC_CARBON */
! RGBBackColor (&old_bg);
}
--- 415,421 ----
overlay_p ? srcOr : srcCopy, 0);
#endif /* not TARGET_API_MAC_CARBON */
! RGBBackColor (GC_BACK_COLOR (MAC_WINDOW_NORMAL_GC (w)));
}
***************
*** 565,576 ****
char *data;
unsigned int width, height;
unsigned long fg, bg;
! unsigned int depth; /* not used */
{
Pixmap pixmap;
BitMap bitmap;
CGrafPtr old_port;
GDHandle old_gdh;
pixmap = XCreatePixmap (display, w, width, height, depth);
if (pixmap == NULL)
--- 521,536 ----
char *data;
unsigned int width, height;
unsigned long fg, bg;
! 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)
***************
*** 579,586 ****
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);
LockPixels (GetGWorldPixMap (pixmap));
#if TARGET_API_MAC_CARBON
CopyBits (&bitmap, GetPortBitMapForCopyBits (pixmap),
--- 539,548 ----
GetGWorld (&old_port, &old_gdh);
SetGWorld (pixmap, NULL);
mac_create_bitmap_from_bitmap_data (&bitmap, data, width, height);
! 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),
***************
*** 608,623 ****
unsigned int width, height;
{
Rect r;
- RGBColor old_bg;
SetPortWindowPort (w);
! mac_set_colors (gc, &old_bg);
SetRect (&r, x, y, x + width, y + height);
PaintRect (&r); /* using foreground color of gc */
-
- RGBBackColor (&old_bg);
}
--- 570,582 ----
unsigned int width, height;
{
Rect r;
SetPortWindowPort (w);
! RGBForeColor (GC_FORE_COLOR (gc));
SetRect (&r, x, y, x + width, y + height);
PaintRect (&r); /* using foreground color of gc */
}
***************
*** 636,642 ****
GetGWorld (&old_port, &old_gdh);
SetGWorld (p, NULL);
! mac_set_colors (gc, NULL);
SetRect (&r, x, y, x + width, y + height);
LockPixels (GetGWorldPixMap (p));
--- 595,601 ----
GetGWorld (&old_port, &old_gdh);
SetGWorld (p, NULL);
! RGBForeColor (GC_FORE_COLOR (gc));
SetRect (&r, x, y, x + width, y + height);
LockPixels (GetGWorldPixMap (p));
***************
*** 659,674 ****
unsigned int width, height;
{
Rect r;
- RGBColor old_bg;
SetPortWindowPort (w);
! mac_set_colors (gc, &old_bg);
SetRect (&r, x, y, x + width + 1, y + height + 1);
FrameRect (&r); /* using foreground color of gc */
-
- RGBBackColor (&old_bg);
}
--- 618,630 ----
unsigned int width, height;
{
Rect r;
SetPortWindowPort (w);
! RGBForeColor (GC_FORE_COLOR (gc));
SetRect (&r, x, y, x + width + 1, y + height + 1);
FrameRect (&r); /* using foreground color of gc */
}
***************
*** 689,695 ****
GetGWorld (&old_port, &old_gdh);
SetGWorld (p, NULL);
! mac_set_colors (gc, NULL);
SetRect (&r, x, y, x + width + 1, y + height + 1);
LockPixels (GetGWorldPixMap (p));
--- 645,651 ----
GetGWorld (&old_port, &old_gdh);
SetGWorld (p, NULL);
! RGBForeColor (GC_FORE_COLOR (gc));
SetRect (&r, x, y, x + width + 1, y + height + 1);
LockPixels (GetGWorldPixMap (p));
***************
*** 711,719 ****
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)) {
--- 667,672 ----
***************
*** 722,738 ****
}
#endif
! mac_set_colors (gc, &old_bg);
! TextFont (gc->font->mac_fontnum);
! TextSize (gc->font->mac_fontsize);
! TextFace (gc->font->mac_fontface);
TextMode (mode);
MoveTo (x, y);
DrawText (buf, 0, nchars * bytes_per_char);
! RGBBackColor (&old_bg);
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020
if (!NILP(Vmac_use_core_graphics))
SwapQDTextFlags(savedFlags);
--- 675,696 ----
}
#endif
! SetPortWindowPort (w);
! RGBForeColor (GC_FORE_COLOR (gc));
! if (mode != srcOr)
! RGBBackColor (GC_BACK_COLOR (gc));
!
! 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);
! 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);
***************
*** 911,917 ****
BackColor (whiteColor);
CopyBits (&(w->portBits), &(w->portBits), &src_r, &dest_r, srcCopy, 0);
! mac_set_colors (gc, NULL);
#endif /* not TARGET_API_MAC_CARBON */
}
--- 869,875 ----
BackColor (whiteColor);
CopyBits (&(w->portBits), &(w->portBits), &src_r, &dest_r, srcCopy, 0);
! RGBBackColor (GC_BACK_COLOR (MAC_WINDOW_NORMAL_GC (w)));
#endif /* not TARGET_API_MAC_CARBON */
}
***************
*** 1001,1028 ****
/* Mac replacement for XChangeGC. */
static void
! XChangeGC (void * ignore, XGCValues* gc, unsigned long mask,
! XGCValues *xgcv)
{
if (mask & GCForeground)
! gc->foreground = xgcv->foreground;
if (mask & GCBackground)
! gc->background = xgcv->background;
if (mask & GCFont)
! gc->font = xgcv->font;
}
/* Mac replacement for XCreateGC. */
! XGCValues *
! XCreateGC (void * ignore, Window window, unsigned long mask,
! XGCValues *xgcv)
{
! XGCValues *gc = (XGCValues *) xmalloc (sizeof (XGCValues));
! bzero (gc, sizeof (XGCValues));
! XChangeGC (ignore, gc, mask, xgcv);
return gc;
}
--- 959,995 ----
/* Mac replacement for XChangeGC. */
static void
! XChangeGC (display, gc, mask, xgcv)
! Display *display;
! GC gc;
! unsigned long mask;
! XGCValues *xgcv;
{
if (mask & GCForeground)
! XSetForeground (display, gc, xgcv->foreground);
if (mask & GCBackground)
! XSetBackground (display, gc, xgcv->background);
if (mask & GCFont)
! XSetFont (display, gc, xgcv->font);
}
/* Mac replacement for XCreateGC. */
! GC
! XCreateGC (display, window, mask, xgcv)
! Display *display;
! Window window;
! unsigned long mask;
! XGCValues *xgcv;
{
! GC gc = xmalloc (sizeof (*gc));
! if (gc)
! {
! bzero (gc, sizeof (*gc));
! XChangeGC (display, gc, mask, xgcv);
! }
return gc;
}
***************
*** 1042,1051 ****
/* Mac replacement for XGetGCValues. */
static void
! XGetGCValues (void* ignore, XGCValues *gc,
! unsigned long mask, XGCValues *xgcv)
{
! XChangeGC (ignore, xgcv, mask, gc);
}
--- 1009,1026 ----
/* Mac replacement for XGetGCValues. */
static void
! XGetGCValues (display, gc, mask, xgcv)
! Display *display;
! GC gc;
! unsigned long mask;
! XGCValues *xgcv;
{
! if (mask & GCForeground)
! xgcv->foreground = gc->xgcv.foreground;
! if (mask & GCBackground)
! xgcv->background = gc->xgcv.background;
! if (mask & GCFont)
! xgcv->font = gc->xgcv.font;
}
***************
*** 1057,1063 ****
GC gc;
unsigned long color;
{
! gc->foreground = color;
}
--- 1032,1044 ----
GC gc;
unsigned long 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);
! }
}
***************
*** 1069,1075 ****
GC gc;
unsigned long color;
{
! gc->background = color;
}
--- 1050,1074 ----
GC gc;
unsigned long 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;
}
***************
*** 1116,1134 ****
#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)
--- 1115,1120 ----
***************
*** 1439,1445 ****
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;
--- 1425,1430 ----
***************
*** 1463,1471 ****
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
--- 1448,1453 ----
***************
*** 1477,1485 ****
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);
#if 0 /* MAC_TODO: stipple */
if (!face->stipple)
--- 1459,1465 ----
XSetForeground (FRAME_X_DISPLAY (f), face->gc, face->background);
#endif
! mac_erase_rectangle (window, face->gc, p->bx, p->by, p->nx, p->ny);
#if 0 /* MAC_TODO: stipple */
if (!face->stipple)
***************
*** 1490,1504 ****
if (p->which)
{
unsigned short *bits = p->bits + p->dh;
! 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,
p->wd, p->h, bits, p->overlay_p);
}
mac_reset_clipping (display, window);
--- 1470,1486 ----
if (p->which)
{
unsigned short *bits = p->bits + p->dh;
+ XGCValues gcv;
! 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);
***************
*** 1973,1982 ****
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);
}
--- 1955,1961 ----
struct glyph_string *s;
int x, y, w, h;
{
! mac_erase_rectangle (s->window, s->gc, x, y, w, h);
}
***************
*** 2564,2590 ****
{
XGCValues xgcv;
! xgcv.foreground = s->face->box_color;
mac_set_clip_rectangle (s->display, s->window, clip_rect);
/* Top. */
! XFillRectangle (s->display, s->window, &xgcv,
left_x, top_y, right_x - left_x + 1, width);
/* Left. */
if (left_p)
! XFillRectangle (s->display, s->window, &xgcv,
left_x, top_y, width, bottom_y - top_y + 1);
/* Bottom. */
! XFillRectangle (s->display, s->window, &xgcv,
left_x, bottom_y - width + 1, right_x - left_x + 1, width);
/* Right. */
if (right_p)
! XFillRectangle (s->display, s->window, &xgcv,
right_x - width + 1, top_y, width, bottom_y - top_y + 1);
mac_reset_clipping (s->display, s->window);
}
--- 2543,2571 ----
{
XGCValues xgcv;
! 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, s->gc,
left_x, top_y, right_x - left_x + 1, width);
/* Left. */
if (left_p)
! XFillRectangle (s->display, s->window, s->gc,
left_x, top_y, width, bottom_y - top_y + 1);
/* Bottom. */
! 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, 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);
}
***************
*** 3003,3015 ****
}
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_reset_clipping (s->display, s->window);
}
--- 2984,2990 ----
}
else
#endif /* MAC_TODO */
! mac_erase_rectangle (s->window, gc, x, y, w, h);
mac_reset_clipping (s->display, s->window);
}
***************
*** 4560,4572 ****
&& 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);
XClearArea (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f),
! left, top, area_width, height, 0);
#if 0
if (sb_left + sb_width >= FRAME_PIXEL_WIDTH (f))
--- 4535,4544 ----
&& XINT (bar->width) == sb_width
&& XINT (bar->height) == height))
{
! /* 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, width, height, 0);
#if 0
if (sb_left + sb_width >= FRAME_PIXEL_WIDTH (f))