From 9cdd488421a5154daac4be814bbc20d7b37a6d25 Mon Sep 17 00:00:00 2001 From: Steven Tamm Date: Sun, 16 Jan 2005 00:10:18 +0000 Subject: [PATCH] * macfns.c (x_set_foreground_color, x_set_background_color): Sync with xfns.c. (mac_window, x_create_tip_frame): Use XSetWindowBackground. * macterm.c (XSetBackground, XSetWindowBackground): New functions. * macterm.h (XSetBackground, XSetWindowBackground): Add externs. --- src/ChangeLog | 8 ++++++++ src/macfns.c | 42 ++++++++++++++++++++++++++++++++++++-- src/macterm.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/macterm.h | 2 ++ 4 files changed, 106 insertions(+), 2 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index e707c61b83f..07beb35f685 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,11 @@ +2005-01-15 YAMAMOTO Mitsuharu + + * macfns.c (x_set_foreground_color, x_set_background_color): Sync + with xfns.c. + (mac_window, x_create_tip_frame): Use XSetWindowBackground. + * macterm.c (XSetBackground, XSetWindowBackground): New functions. + * macterm.h (XSetBackground, XSetWindowBackground): Add externs. + 2005-01-14 Kim F. Storm * keyboard.c (Fposn_at_x_y): Add optional arg WHOLE. diff --git a/src/macfns.c b/src/macfns.c index 9a8382e413c..2b223dfdfb5 100644 --- a/src/macfns.c +++ b/src/macfns.c @@ -1385,6 +1385,7 @@ x_set_foreground_color (f, arg, oldval) struct frame *f; Lisp_Object arg, oldval; { + struct mac_output *mac = f->output_data.mac; unsigned long fg, old_fg; fg = x_decode_color (f, arg, BLACK_PIX_DEFAULT (f)); @@ -1393,10 +1394,28 @@ x_set_foreground_color (f, arg, oldval) if (FRAME_MAC_WINDOW (f) != 0) { + Display *dpy = FRAME_MAC_DISPLAY (f); + + BLOCK_INPUT; + XSetForeground (dpy, mac->normal_gc, fg); + XSetBackground (dpy, mac->reverse_gc, fg); + + if (mac->cursor_pixel == old_fg) + { + unload_color (f, mac->cursor_pixel); + mac->cursor_pixel = fg; + XSetBackground (dpy, mac->cursor_gc, mac->cursor_pixel); + } + + UNBLOCK_INPUT; + update_face_from_frame_parameter (f, Qforeground_color, arg); + if (FRAME_VISIBLE_P (f)) redraw_frame (f); } + + unload_color (f, old_fg); } void @@ -1404,11 +1423,24 @@ x_set_background_color (f, arg, oldval) struct frame *f; Lisp_Object arg, oldval; { - FRAME_BACKGROUND_PIXEL (f) - = x_decode_color (f, arg, WHITE_PIX_DEFAULT (f)); + struct mac_output *mac = f->output_data.mac; + unsigned long bg; + + bg = x_decode_color (f, arg, WHITE_PIX_DEFAULT (f)); + unload_color (f, FRAME_BACKGROUND_PIXEL (f)); + FRAME_BACKGROUND_PIXEL (f) = bg; if (FRAME_MAC_WINDOW (f) != 0) { + Display *dpy = FRAME_MAC_DISPLAY (f); + + BLOCK_INPUT; + XSetBackground (dpy, mac->normal_gc, bg); + XSetForeground (dpy, mac->reverse_gc, bg); + XSetWindowBackground (dpy, FRAME_MAC_WINDOW (f), bg); + XSetForeground (dpy, mac->cursor_gc, bg); + + UNBLOCK_INPUT; update_face_from_frame_parameter (f, Qbackground_color, arg); if (FRAME_VISIBLE_P (f)) @@ -2297,6 +2329,10 @@ mac_window (f) /* so that update events can find this mac_output struct */ f->output_data.mac->mFP = f; /* point back to emacs frame */ + if (FRAME_MAC_WINDOW (f)) + XSetWindowBackground (FRAME_MAC_DISPLAY(f), FRAME_MAC_WINDOW (f), + FRAME_BACKGROUND_PIXEL (f)); + validate_x_resource_name (); /* x_set_name normally ignores requests to set the name if the @@ -3856,6 +3892,8 @@ x_create_tip_frame (dpyinfo, parms, text) #endif { FRAME_MAC_WINDOW (f) = tip_window; + XSetWindowBackground (FRAME_MAC_DISPLAY(f), tip_window, + FRAME_BACKGROUND_PIXEL (f)); SetWRefCon (tip_window, (long) f->output_data.mac); /* so that update events can find this mac_output struct */ f->output_data.mac->mFP = f; diff --git a/src/macterm.c b/src/macterm.c index 566f0c5b04b..0dc530cda8e 100644 --- a/src/macterm.c +++ b/src/macterm.c @@ -1091,6 +1091,62 @@ XSetForeground (display, gc, color) } +/* Mac replacement for XSetBackground. */ + +void +XSetBackground (display, gc, color) + Display *display; + GC gc; + unsigned long color; +{ + gc->background = color; +} + + +/* Mac replacement for XSetWindowBackground. */ + +void +XSetWindowBackground (display, w, color) + Display *display; + WindowPtr w; + unsigned long color; +{ +#if !TARGET_API_MAC_CARBON + AuxWinHandle aw_handle; + CTabHandle ctab_handle; + ColorSpecPtr ct_table; + short ct_size; +#endif + RGBColor bg_color; + + bg_color.red = RED16_FROM_ULONG (color); + bg_color.green = GREEN16_FROM_ULONG (color); + bg_color.blue = BLUE16_FROM_ULONG (color); + +#if TARGET_API_MAC_CARBON + SetWindowContentColor (w, &bg_color); +#else + if (GetAuxWin (w, &aw_handle)) + { + ctab_handle = (*aw_handle)->awCTable; + HandToHand ((Handle *) &ctab_handle); + ct_table = (*ctab_handle)->ctTable; + ct_size = (*ctab_handle)->ctSize; + while (ct_size > -1) + { + if (ct_table->value == 0) + { + ct_table->rgb = bg_color; + CTabChanged (ctab_handle); + SetWinColor (w, (WCTabHandle) ctab_handle); + } + ct_size--; + } + } +#endif +} + + /* Mac replacement for XSetFont. */ static void diff --git a/src/macterm.h b/src/macterm.h index fd6b066af4c..f32b13000e6 100644 --- a/src/macterm.h +++ b/src/macterm.h @@ -602,6 +602,8 @@ extern Pixmap XCreatePixmapFromBitmapData P_ ((Display *, WindowPtr, char *, unsigned int)); extern void XFreePixmap P_ ((Display *, Pixmap)); extern void XSetForeground P_ ((Display *, GC, unsigned long)); +extern void XSetBackground P_ ((Display *, GC, unsigned long)); +extern void XSetWindowBackground P_ ((Display *, WindowPtr, unsigned long)); extern void mac_draw_line_to_pixmap P_ ((Display *, Pixmap, GC, int, int, int, int)); extern void mac_unload_font P_ ((struct mac_display_info *, XFontStruct *)); -- 2.39.5