aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Djärv2004-06-28 14:36:48 +0000
committerJan Djärv2004-06-28 14:36:48 +0000
commit03ecb80fd660afdbe221df5c63e3578454f5c6d9 (patch)
treef25077c95f8cdb600e16c8efa548e024caaca47f
parent74cdfe05c657fa32b8c34b2322ff8f4b39f325cf (diff)
downloademacs-03ecb80fd660afdbe221df5c63e3578454f5c6d9.tar.gz
emacs-03ecb80fd660afdbe221df5c63e3578454f5c6d9.zip
(xg_get_image_for_pixmap): Add workaround for monochrome displays
so insensitive and activated icons look ok.
-rw-r--r--src/ChangeLog2
-rw-r--r--src/gtkutil.c46
2 files changed, 47 insertions, 1 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 2b3d33e7d7a..1cdabd1fb1e 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -2,6 +2,8 @@
2 2
3 * gtkutil.c (xg_get_image_for_pixmap): Call g_object_unref on 3 * gtkutil.c (xg_get_image_for_pixmap): Call g_object_unref on
4 gpix and gmask just before return to avoid memory leak. 4 gpix and gmask just before return to avoid memory leak.
5 (xg_get_image_for_pixmap): Add workaround for monochrome displays
6 so insensitive and activated icons look ok.
5 7
62004-06-27 Jason Rumney <jasonr@gnu.org> 82004-06-27 Jason Rumney <jasonr@gnu.org>
7 9
diff --git a/src/gtkutil.c b/src/gtkutil.c
index 3c4c06a9a53..3ffba0ba745 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -248,8 +248,46 @@ xg_get_image_for_pixmap (f, img, widget, old_widget)
248{ 248{
249 GdkPixmap *gpix; 249 GdkPixmap *gpix;
250 GdkPixmap *gmask; 250 GdkPixmap *gmask;
251 GdkDisplay *gdpy = gdk_x11_lookup_xdisplay (FRAME_X_DISPLAY (f)); 251 GdkDisplay *gdpy;
252
253 /* If we are on a one bit display, let GTK do all the image handling.
254 This seems to be the only way to make insensitive and activated icons
255 look good. */
256 if (x_screen_planes (f) == 1)
257 {
258 Lisp_Object specified_file = Qnil;
259 Lisp_Object tail;
260 extern Lisp_Object QCfile;
261
262 for (tail = XCDR (img->spec);
263 NILP (specified_file) && CONSP (tail) && CONSP (XCDR (tail));
264 tail = XCDR (XCDR (tail)))
265 if (EQ (XCAR (tail), QCfile))
266 specified_file = XCAR (XCDR (tail));
267
268 if (STRINGP (specified_file))
269 {
270
271 Lisp_Object file = Qnil;
272 struct gcpro gcpro1;
273 GCPRO1 (file);
274
275 file = x_find_image_file (specified_file);
276 /* We already loaded the image once before calling this
277 function, so this should not fail. */
278 xassert (STRINGP (file) != 0);
279
280 if (! old_widget)
281 old_widget = GTK_IMAGE (gtk_image_new_from_file (SDATA (file)));
282 else
283 gtk_image_set_from_file (old_widget, SDATA (file));
284
285 UNGCPRO;
286 return GTK_WIDGET (old_widget);
287 }
288 }
252 289
290 gdpy = gdk_x11_lookup_xdisplay (FRAME_X_DISPLAY (f));
253 gpix = gdk_pixmap_foreign_new_for_display (gdpy, img->pixmap); 291 gpix = gdk_pixmap_foreign_new_for_display (gdpy, img->pixmap);
254 gmask = img->mask ? gdk_pixmap_foreign_new_for_display (gdpy, img->mask) : 0; 292 gmask = img->mask ? gdk_pixmap_foreign_new_for_display (gdpy, img->mask) : 0;
255 293
@@ -262,6 +300,12 @@ xg_get_image_for_pixmap (f, img, widget, old_widget)
262 } 300 }
263 else 301 else
264 { 302 {
303 /* This is a workaround to make icons look good on pseudo color
304 displays. Apparently GTK expects the images to have an alpha
305 channel. If they don't, insensitive and activated icons will
306 look bad. This workaround does not work on monochrome displays,
307 and is not needed on true color/static color displays (i.e.
308 16 bits and higher). */
265 int x, y, width, height, rowstride, mask_rowstride; 309 int x, y, width, height, rowstride, mask_rowstride;
266 GdkPixbuf *icon_buf, *tmp_buf; 310 GdkPixbuf *icon_buf, *tmp_buf;
267 guchar *pixels; 311 guchar *pixels;