]> git.eshelyaron.com Git - emacs.git/commitdiff
(xg_get_image_for_pixmap): Add workaround for monochrome displays
authorJan Djärv <jan.h.d@swipnet.se>
Mon, 28 Jun 2004 14:36:48 +0000 (14:36 +0000)
committerJan Djärv <jan.h.d@swipnet.se>
Mon, 28 Jun 2004 14:36:48 +0000 (14:36 +0000)
so insensitive and activated icons look ok.

src/ChangeLog
src/gtkutil.c

index 2b3d33e7d7a43a678e928a22eec37ce3dd7600c2..1cdabd1fb1e03085f00b71ec4ae090fc1510c5d9 100644 (file)
@@ -2,6 +2,8 @@
 
        * gtkutil.c (xg_get_image_for_pixmap): Call g_object_unref on
        gpix and gmask just before return to avoid memory leak.
+       (xg_get_image_for_pixmap): Add workaround for monochrome displays
+       so insensitive and activated icons look ok.
 
 2004-06-27  Jason Rumney  <jasonr@gnu.org>
 
index 3c4c06a9a53aaa94d5f3ce64c4882d99d493121b..3ffba0ba745e1a0b4c848f67da418d841d4843aa 100644 (file)
@@ -248,8 +248,46 @@ xg_get_image_for_pixmap (f, img, widget, old_widget)
 {
   GdkPixmap *gpix;
   GdkPixmap *gmask;
-  GdkDisplay *gdpy = gdk_x11_lookup_xdisplay (FRAME_X_DISPLAY (f));
+  GdkDisplay *gdpy;
+
+  /* If we are on a one bit display, let GTK do all the image handling.
+     This seems to be the only way to make insensitive and activated icons
+     look good.  */
+  if (x_screen_planes (f) == 1)
+    {
+      Lisp_Object specified_file = Qnil;
+      Lisp_Object tail;
+      extern Lisp_Object QCfile;
+
+      for (tail = XCDR (img->spec);
+          NILP (specified_file) && CONSP (tail) && CONSP (XCDR (tail));
+          tail = XCDR (XCDR (tail)))
+       if (EQ (XCAR (tail), QCfile))
+         specified_file = XCAR (XCDR (tail));
+
+       if (STRINGP (specified_file))
+         {
+
+           Lisp_Object file = Qnil;
+           struct gcpro gcpro1;
+           GCPRO1 (file);
+
+           file = x_find_image_file (specified_file);
+           /* We already loaded the image once before calling this
+              function, so this should not fail.  */
+           xassert (STRINGP (file) != 0);
+
+           if (! old_widget)
+             old_widget = GTK_IMAGE (gtk_image_new_from_file (SDATA (file)));
+           else
+             gtk_image_set_from_file (old_widget, SDATA (file));
+
+           UNGCPRO;
+           return GTK_WIDGET (old_widget);
+         }
+    }
 
+  gdpy = gdk_x11_lookup_xdisplay (FRAME_X_DISPLAY (f));
   gpix = gdk_pixmap_foreign_new_for_display (gdpy, img->pixmap);
   gmask = img->mask ? gdk_pixmap_foreign_new_for_display (gdpy, img->mask) : 0;
 
@@ -262,6 +300,12 @@ xg_get_image_for_pixmap (f, img, widget, old_widget)
     }
   else
     {
+      /* This is a workaround to make icons look good on pseudo color
+         displays.  Apparently GTK expects the images to have an alpha
+         channel.  If they don't, insensitive and activated icons will
+         look bad.  This workaround does not work on monochrome displays,
+         and is not needed on true color/static color displays (i.e.
+         16 bits and higher).  */
       int x, y, width, height, rowstride, mask_rowstride;
       GdkPixbuf *icon_buf, *tmp_buf;
       guchar *pixels;