quartz: don't ask for userSpaceScaleFactor on newer macOS
Taken from Ardour's YTK: - ecd22e9a (Robin Gareus)
This commit is contained in:
parent
e8f7b336e1
commit
8dc64fe904
1 changed files with 14 additions and 2 deletions
|
|
@ -62,6 +62,7 @@
|
|||
static void gdk_screen_quartz_dispose (GObject *object);
|
||||
static void gdk_screen_quartz_finalize (GObject *object);
|
||||
static void gdk_screen_quartz_calculate_layout (GdkScreenQuartz *screen);
|
||||
static CGFloat gdk_quartz_screen_user_space_scale (NSScreen *screen);
|
||||
|
||||
static void display_reconfiguration_callback (CGDirectDisplayID display,
|
||||
CGDisplayChangeSummaryFlags flags,
|
||||
|
|
@ -89,7 +90,7 @@ _gdk_screen_quartz_init (GdkScreenQuartz *screen_quartz)
|
|||
|
||||
nsscreen = [[NSScreen screens] objectAtIndex:0];
|
||||
gdk_screen_set_resolution (screen,
|
||||
72.0 * [nsscreen userSpaceScaleFactor]);
|
||||
72.0 * gdk_quartz_screen_user_space_scale (nsscreen));
|
||||
|
||||
gdk_screen_quartz_calculate_layout (screen_quartz);
|
||||
|
||||
|
|
@ -354,6 +355,17 @@ gdk_screen_get_height (GdkScreen *screen)
|
|||
return GDK_SCREEN_QUARTZ (screen)->height;
|
||||
}
|
||||
|
||||
/* -userSpaceScaleFactor is the scale of the resolution independence of
|
||||
* 10.4 to 10.6; newer systems no longer have the message, and sending
|
||||
* it there throws (as Ardour found) */
|
||||
static CGFloat
|
||||
gdk_quartz_screen_user_space_scale (NSScreen *screen)
|
||||
{
|
||||
if ([screen respondsToSelector:@selector(userSpaceScaleFactor)])
|
||||
return (CGFloat) [(id) screen userSpaceScaleFactor];
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
static gint
|
||||
get_mm_from_pixels (NSScreen *screen, int pixels)
|
||||
{
|
||||
|
|
@ -362,7 +374,7 @@ get_mm_from_pixels (NSScreen *screen, int pixels)
|
|||
* 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;
|
||||
float dpi = gdk_quartz_screen_user_space_scale (screen) * 72.0;
|
||||
#else
|
||||
float dpi = 96.0 / 72.0;
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in a new issue