[gimp] Bug 740634 - Color picker crashes when there are multiple monitors
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] Bug 740634 - Color picker crashes when there are multiple monitors
- Date: Thu, 6 Apr 2017 21:57:56 +0000 (UTC)
commit c585c99e8084998b3203b6ebf854499d074f3ee4
Author: Éric Hoffman <ehoffman videotron ca>
Date: Thu Apr 6 23:50:26 2017 +0200
Bug 740634 - Color picker crashes when there are multiple monitors
Use Windows API directly to get a screen pixel, works for all kinds of
monitor layouts.
libgimpwidgets/gimppickbutton-default.c | 40 ++++++++++++++++++++++++++++--
1 files changed, 37 insertions(+), 3 deletions(-)
---
diff --git a/libgimpwidgets/gimppickbutton-default.c b/libgimpwidgets/gimppickbutton-default.c
index 3fec04a..683b65e 100644
--- a/libgimpwidgets/gimppickbutton-default.c
+++ b/libgimpwidgets/gimppickbutton-default.c
@@ -22,6 +22,11 @@
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
+#ifdef G_OS_WIN32
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#endif
+
#include "libgimpcolor/gimpcolor.h"
#include "gimpwidgetstypes.h"
@@ -199,14 +204,41 @@ gimp_pick_button_pick (GdkScreen *screen,
gint y_root,
GimpPickButton *button)
{
+ GimpRGB rgb;
+ GimpColorProfile *monitor_profile;
+ gint monitor;
+
+#ifdef G_OS_WIN32
+
+ HDC hdc;
+ RECT rect;
+ COLORREF win32_color;
+
+ /* For MS Windows, use native GDI functions to get the pixel, as
+ * cairo does not handle the case where you have multiple monitors
+ * with a monitor on the left or above the primary monitor. That
+ * scenario create a cairo primary surface with negative extent,
+ * which is not handled properly (bug 740634).
+ */
+
+ hdc = GetDC (HWND_DESKTOP);
+ GetClipBox (hdc, &rect);
+ win32_color = GetPixel (hdc, x_root + rect.left, y_root + rect.top);
+ ReleaseDC (HWND_DESKTOP, hdc);
+
+ gimp_rgba_set_uchar (&rgb,
+ GetRValue (win32_color),
+ GetGValue (win32_color),
+ GetBValue (win32_color),
+ 255);
+
+#else
+
GdkWindow *root_window = gdk_screen_get_root_window (screen);
cairo_surface_t *image;
cairo_t *cr;
guchar *data;
guchar color[3];
- GimpRGB rgb;
- GimpColorProfile *monitor_profile;
- gint monitor;
image = cairo_image_surface_create (CAIRO_FORMAT_RGB24, 1, 1);
@@ -224,6 +256,8 @@ gimp_pick_button_pick (GdkScreen *screen,
gimp_rgba_set_uchar (&rgb, color[0], color[1], color[2], 255);
+#endif
+
monitor = gdk_screen_get_monitor_at_point (screen, x_root, y_root);
monitor_profile = gimp_screen_get_color_profile (screen, monitor);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]