[gimp/gimp-2-10] Fix screen resolution detection on OSX
- From: Jehan <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gimp-2-10] Fix screen resolution detection on OSX
- Date: Mon, 25 Jun 2018 10:38:40 +0000 (UTC)
commit 75cc48f7c063502b5c2d9ed1adb6ca2cbfc9232b
Author: Oleksii Samorukov <samm os2 kiev ua>
Date: Mon Jun 25 12:35:42 2018 +0200
Fix screen resolution detection on OSX
GTK always returns 72 dpi due to API used. This patch using Cocoa
directly instead. Tested on Retina and non-hidpi displays.
GTK+2 version of commit 5b6126146aec878b6c56171e03feab56b8104299.
Cf. MR !14.
app/widgets/gimpwidgets-utils.c | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
---
diff --git a/app/widgets/gimpwidgets-utils.c b/app/widgets/gimpwidgets-utils.c
index 510dccfd45..4235923897 100644
--- a/app/widgets/gimpwidgets-utils.c
+++ b/app/widgets/gimpwidgets-utils.c
@@ -33,6 +33,10 @@
#include <gdk/gdkx.h>
#endif
+#ifdef PLATFORM_OSX
+#include <Carbon/Carbon.h>
+#endif
+
#include "libgimpbase/gimpbase.h"
#include "libgimpconfig/gimpconfig.h"
#include "libgimpmath/gimpmath.h"
@@ -855,16 +859,31 @@ gimp_get_monitor_resolution (GdkScreen *screen,
gint width_mm, height_mm;
gdouble x = 0.0;
gdouble y = 0.0;
+#ifdef PLATFORM_OSX
+ CGSize size;
+#endif
g_return_if_fail (GDK_IS_SCREEN (screen));
g_return_if_fail (xres != NULL);
g_return_if_fail (yres != NULL);
+#ifndef PLATFORM_OSX
gdk_screen_get_monitor_geometry (screen, monitor, &size_pixels);
width_mm = gdk_screen_get_monitor_width_mm (screen, monitor);
height_mm = gdk_screen_get_monitor_height_mm (screen, monitor);
-
+#else
+ width_mm = 0;
+ height_mm = 0;
+ size = CGDisplayScreenSize (kCGDirectMainDisplay);
+ if (!CGSizeEqualToSize (size, CGSizeZero))
+ {
+ width_mm = size.width;
+ height_mm = size.height;
+ }
+ size_pixels.width = CGDisplayPixelsWide (kCGDirectMainDisplay);
+ size_pixels.height = CGDisplayPixelsHigh (kCGDirectMainDisplay);
+#endif
/*
* From xdpyinfo.c:
*
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]