[gimp] Issue #6778: Colorpicker (from Colors dockable) shows wrong color.



commit 9b216885019d11de18cae74a6852e6dda2f9e80c
Author: Jehan <jehan girinstud io>
Date:   Thu Aug 18 21:25:46 2022 +0200

    Issue #6778: Colorpicker (from Colors dockable) shows wrong color.
    
    Actually our X11 implementation is right, and the implementation from
    the Freedesktop portal is "as far as it can do", i.e. that we get the
    returned RGB value, which is unfortunately in display space. And it
    doesn't return any space information together (we don't even know which
    display the color comes from, in multi-display setups).
    
    Therefore let's check if we are running GIMP on X11 and if so, let's
    call this implementation first.
    
    See this report on xdg-desktop-portal to get proper space info:
    https://github.com/flatpak/xdg-desktop-portal/issues/862

 libgimpwidgets/gimppickbutton.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
---
diff --git a/libgimpwidgets/gimppickbutton.c b/libgimpwidgets/gimppickbutton.c
index 0a21eaa1fe..67dbc77e27 100644
--- a/libgimpwidgets/gimppickbutton.c
+++ b/libgimpwidgets/gimppickbutton.c
@@ -22,6 +22,10 @@
 #include <gtk/gtk.h>
 #include <gdk/gdkkeysyms.h>
 
+#ifdef GDK_WINDOWING_X11
+#include <gdk/gdkx.h>
+#endif
+
 #include "libgimpcolor/gimpcolor.h"
 
 #include "gimpwidgetstypes.h"
@@ -144,6 +148,21 @@ gimp_pick_button_clicked (GtkButton *button)
 #ifdef GDK_WINDOWING_QUARTZ
   _gimp_pick_button_quartz_pick (GIMP_PICK_BUTTON (button));
 #else
+#ifdef GDK_WINDOWING_X11
+  /* It's a bit weird as we use the default pick code both in first and
+   * last cases. It's because when running GIMP on X11 in particular,
+   * the portals don't return color space information. So the returned
+   * color is in the display space, not in the current image space and
+   * we have no way to convert the data back (well if running on X11, we
+   * could still get a profile from the display, but if there are
+   * several displays, we can't know for sure where the color was picked
+   * from.).
+   * See: https://github.com/flatpak/xdg-desktop-portal/issues/862
+   */
+  if (GDK_IS_X11_DISPLAY (gdk_display_get_default ()))
+    _gimp_pick_button_default_pick (GIMP_PICK_BUTTON (button));
+  else
+#endif
   if (_gimp_pick_button_xdg_available ())
     _gimp_pick_button_xdg_pick (GIMP_PICK_BUTTON (button));
   else if (_gimp_pick_button_kwin_available ())


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]