GNU bug report logs - #15837
24.3; invalid colour conversion from Gtk+3 to X11

Previous Next

Package: emacs;

Reported by: Łukasz Stelmach <stlman <at> poczta.fm>

Date: Fri, 8 Nov 2013 18:29:01 UTC

Severity: normal

Tags: patch

Found in version 24.3

Done: Jan Djärv <jan.h.d <at> swipnet.se>

Bug is archived. No further changes may be made.

Full log


Message #8 received at 15837 <at> debbugs.gnu.org (full text, mbox):

From: Łukasz Stelmach <stlman <at> poczta.fm>
To: 15837 <at> debbugs.gnu.org
Cc: Łukasz Stelmach <stlman <at> poczta.fm>
Subject: [PATCH] Pass colours using rgb: instead of rgbi:
Date: Fri,  8 Nov 2013 19:41:05 +0100
X procedures apply gamma correction to RGBi values which makes colours
obtained from Gtk+ 3.0 and displayed by Emacs look different than in
other Gtk applications.

Signed-off-by: Łukasz Stelmach <stlman <at> poczta.fm>
---
 src/gtkutil.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/gtkutil.c b/src/gtkutil.c
index 7e304d4..b8d8610 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -596,14 +596,17 @@ xg_check_special_colors (struct frame *f,
     GtkStyleContext *gsty
       = gtk_widget_get_style_context (FRAME_GTK_OUTER_WIDGET (f));
     GdkRGBA col;
-    char buf[sizeof "rgbi://" + 3 * (DBL_MAX_10_EXP + sizeof "-1.000000" - 1)];
+    char buf[sizeof "rgb:rrrr/gggg/bbbb" ];
     int state = GTK_STATE_FLAG_SELECTED|GTK_STATE_FLAG_FOCUSED;
     if (get_fg)
       gtk_style_context_get_color (gsty, state, &col);
     else
       gtk_style_context_get_background_color (gsty, state, &col);
 
-    sprintf (buf, "rgbi:%lf/%lf/%lf", col.red, col.green, col.blue);
+    sprintf (buf, "rgb:%04x/%04x/%04x",
+             (int)(col.red * 65535),
+             (int)(col.green * 65535),
+             (int)(col.blue * 65535));
     success_p = (XParseColor (FRAME_X_DISPLAY (f), FRAME_X_COLORMAP (f),
 			      buf, color)
 		 != 0);
-- 
1.8.1.5





This bug report was last modified 11 years and 195 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.