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
This commit is contained in:
Jehan 2022-08-18 21:25:46 +02:00
parent 34ae339099
commit 9b21688501

View file

@ -22,6 +22,10 @@
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h> #include <gdk/gdkkeysyms.h>
#ifdef GDK_WINDOWING_X11
#include <gdk/gdkx.h>
#endif
#include "libgimpcolor/gimpcolor.h" #include "libgimpcolor/gimpcolor.h"
#include "gimpwidgetstypes.h" #include "gimpwidgetstypes.h"
@ -144,6 +148,21 @@ gimp_pick_button_clicked (GtkButton *button)
#ifdef GDK_WINDOWING_QUARTZ #ifdef GDK_WINDOWING_QUARTZ
_gimp_pick_button_quartz_pick (GIMP_PICK_BUTTON (button)); _gimp_pick_button_quartz_pick (GIMP_PICK_BUTTON (button));
#else #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 ()) if (_gimp_pick_button_xdg_available ())
_gimp_pick_button_xdg_pick (GIMP_PICK_BUTTON (button)); _gimp_pick_button_xdg_pick (GIMP_PICK_BUTTON (button));
else if (_gimp_pick_button_kwin_available ()) else if (_gimp_pick_button_kwin_available ())