]> git.eshelyaron.com Git - emacs.git/commitdiff
* macfns.c (x_set_foreground_color, x_set_background_color): Sync
authorSteven Tamm <steventamm@mac.com>
Sun, 16 Jan 2005 00:10:18 +0000 (00:10 +0000)
committerSteven Tamm <steventamm@mac.com>
Sun, 16 Jan 2005 00:10:18 +0000 (00:10 +0000)
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
src/macfns.c
src/macterm.c
src/macterm.h

index e707c61b83fa4737add06e6cb71d23ee50a61bf2..07beb35f6853097e45bb20b44fc95e9fadb4b56b 100644 (file)
@@ -1,3 +1,11 @@
+2005-01-15  YAMAMOTO Mitsuharu  <mituharu@math.s.chiba-u.ac.jp>
+
+       * 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  <storm@cua.dk>
 
        * keyboard.c (Fposn_at_x_y): Add optional arg WHOLE.
index 9a8382e413ca5fe8ebc7300ad90b11f67fb49f66..2b223dfdfb557990b3659b315e656750ca14880a 100644 (file)
@@ -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;
index 566f0c5b04b2fe2dc32b489135c61f771adb8bf1..0dc530cda8e231f02b22172132e70180b5460244 100644 (file)
@@ -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
index fd6b066af4cf9343a11f601428e9661fc732749f..f32b13000e60fcd809a15ba8b7108250881c2aaa 100644 (file)
@@ -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 *));