forked from AuroraMiddleware/gtk
Replace NSScreen:userSpaceScaleFactor, deprecated since MacOS X 10.7.
userSpaceScaleFactor is not compatible with high-resolution (aka HiDPI) displays.
This commit is contained in:
parent
400db31ad3
commit
139b669196
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user