diff options
author | John Ralls <jralls@ceridwen.us> | 2017-04-02 18:16:59 -0700 |
---|---|---|
committer | John Ralls <jralls@ceridwen.us> | 2017-04-11 16:10:51 -0700 |
commit | 139b669196f63ccc567f8cd904f125b62997a017 (patch) | |
tree | a7ad38f9f4a01e3f51f0cf3a8fc5b070b5396ba1 /gdk/quartz | |
parent | 400db31ad3466c2839ea6cc6d193db8023225247 (diff) | |
download | gtk+-139b669196f63ccc567f8cd904f125b62997a017.tar.gz |
Replace NSScreen:userSpaceScaleFactor, deprecated since MacOS X 10.7.
userSpaceScaleFactor is not compatible with high-resolution (aka HiDPI)
displays.
Diffstat (limited to 'gdk/quartz')
-rw-r--r-- | 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 661193dc92..97443e44b5 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 |