[gimp/gimp-2-8] Bug 740634 - Color picker crashes when there are multiple monitors
- From: Michael Schumacher <schumaml src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gimp-2-8] Bug 740634 - Color picker crashes when there are multiple monitors
- Date: Sun, 30 Apr 2017 19:19:42 +0000 (UTC)
commit 33d45047b52c9f51cf0cb7a5c78aa6d7f4b0cd2f
Author: Éric Hoffman <ehoffman videotron ca>
Date: Sun Apr 30 21:17:46 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.c | 35 +++++++++++++++++++++++++++++++++++
1 files changed, 35 insertions(+), 0 deletions(-)
---
diff --git a/libgimpwidgets/gimppickbutton.c b/libgimpwidgets/gimppickbutton.c
index 51546eb..a830f32 100644
--- a/libgimpwidgets/gimppickbutton.c
+++ b/libgimpwidgets/gimppickbutton.c
@@ -38,6 +38,11 @@
#include <ApplicationServices/ApplicationServices.h>
#endif
+#ifdef G_OS_WIN32
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#endif
+
/**
* SECTION: gimppickbutton
* @title: GimpPickButton
@@ -367,6 +372,34 @@ gimp_pick_button_pick (GdkScreen *screen,
gint y_root,
GimpPickButton *button)
{
+
+#ifdef G_OS_WIN32
+
+ HDC hdc;
+ RECT rect;
+ COLORREF win32_color;
+ GimpRGB rgb;
+
+ /* 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
+
#ifndef GDK_WINDOWING_QUARTZ
GdkWindow *root_window = gdk_screen_get_root_window (screen);
@@ -414,5 +447,7 @@ gimp_pick_button_pick (GdkScreen *screen,
#endif /* GDK_WINDOWING_QUARTZ */
+#endif /* G_OS_WIN32 */
+
g_signal_emit (button, pick_button_signals[COLOR_PICKED], 0, &rgb);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]