[gtk+] Replace NSScreen:userSpaceScaleFactor, deprecated since MacOS X 10.7.
- From: John Ralls <jralls src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] Replace NSScreen:userSpaceScaleFactor, deprecated since MacOS X 10.7.
- Date: Tue, 11 Apr 2017 23:11:20 +0000 (UTC)
commit 139b669196f63ccc567f8cd904f125b62997a017
Author: John Ralls <jralls ceridwen us>
Date: Sun Apr 2 18:16:59 2017 -0700
Replace NSScreen:userSpaceScaleFactor, deprecated since MacOS X 10.7.
userSpaceScaleFactor is not compatible with high-resolution (aka HiDPI)
displays.
gdk/quartz/gdkscreen-quartz.c | 25 ++++++++-----------------
1 files changed, 8 insertions(+), 17 deletions(-)
---
diff --git a/gdk/quartz/gdkscreen-quartz.c b/gdk/quartz/gdkscreen-quartz.c
index 661193d..97443e4 100644
--- a/gdk/quartz/gdkscreen-quartz.c
+++ b/gdk/quartz/gdkscreen-quartz.c
@@ -76,11 +76,10 @@ static void
gdk_quartz_screen_init (GdkQuartzScreen *quartz_screen)
{
GdkScreen *screen = GDK_SCREEN (quartz_screen);
- NSScreen *nsscreen;
+ NSDictionary *dd = [[[NSScreen screens] objectAtIndex:0] deviceDescription];
+ NSSize size = [[dd valueForKey:NSDeviceResolution] sizeValue];
- nsscreen = [[NSScreen screens] objectAtIndex:0];
- _gdk_screen_set_resolution (screen,
- 72.0 * [nsscreen userSpaceScaleFactor]);
+ _gdk_screen_set_resolution (screen, size.width);
gdk_quartz_screen_calculate_layout (quartz_screen);
@@ -110,8 +109,6 @@ gdk_quartz_screen_dispose (GObject *object)
static void
gdk_quartz_screen_finalize (GObject *object)
{
- GdkQuartzScreen *screen = GDK_QUARTZ_SCREEN (object);
-
G_OBJECT_CLASS (gdk_quartz_screen_parent_class)->finalize (object);
}
@@ -304,17 +301,11 @@ gdk_quartz_screen_get_root_window (GdkScreen *screen)
static gint
get_mm_from_pixels (NSScreen *screen, int pixels)
{
- /* userSpaceScaleFactor is in "pixels per point",
- * 72 is the number of points per inch,
- * and 25.4 is the number of millimeters per inch.
- */
-#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_3
- float dpi = [screen userSpaceScaleFactor] * 72.0;
-#else
- float dpi = 96.0 / 72.0;
-#endif
-
- return (pixels / dpi) * 25.4;
+ const float mm_per_inch = 25.4;
+ NSDictionary *dd = [[[NSScreen screens] objectAtIndex:0] deviceDescription];
+ NSSize size = [[dd valueForKey:NSDeviceResolution] sizeValue];
+ float dpi = size.width;
+ return (pixels / dpi) * mm_per_inch;
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]