diff --git a/gdk/quartz/gdkscreen-quartz.c b/gdk/quartz/gdkscreen-quartz.c index 84269f5999..e83c87b958 100644 --- a/gdk/quartz/gdkscreen-quartz.c +++ b/gdk/quartz/gdkscreen-quartz.c @@ -427,6 +427,35 @@ gdk_quartz_screen_get_monitor_workarea (GdkScreen *screen, GDK_QUARTZ_RELEASE_POOL; } +/* Protocol to build cleanly for OSX < 10.7 */ +@protocol ScaleFactor +- (CGFloat) backingScaleFactor; +@end + +gint +_gdk_quartz_screen_get_monitor_scale_factor (GdkScreen *screen, + gint monitor_num) +{ + GdkQuartzScreen *quartz_screen; + NSArray *array; + NSScreen *nsscreen; + gint scale_factor = 1; + + quartz_screen = GDK_QUARTZ_SCREEN (screen); + + GDK_QUARTZ_ALLOC_POOL; + + array = [NSScreen screens]; + nsscreen = [array objectAtIndex:monitor_num]; + + if (gdk_quartz_osx_version() >= GDK_OSX_LION) + scale_factor = [(id ) nsscreen backingScaleFactor]; + + GDK_QUARTZ_RELEASE_POOL; + + return scale_factor; +} + static gchar * gdk_quartz_screen_make_display_name (GdkScreen *screen) { @@ -491,4 +520,5 @@ gdk_quartz_screen_class_init (GdkQuartzScreenClass *klass) screen_class->query_depths = _gdk_quartz_screen_query_depths; screen_class->query_visual_types = _gdk_quartz_screen_query_visual_types; screen_class->list_visuals = _gdk_quartz_screen_list_visuals; + screen_class->get_monitor_scale_factor = _gdk_quartz_screen_get_monitor_scale_factor; } diff --git a/gdk/quartz/gdkwindow-quartz.c b/gdk/quartz/gdkwindow-quartz.c index 48891abd78..d6f45bbb30 100644 --- a/gdk/quartz/gdkwindow-quartz.c +++ b/gdk/quartz/gdkwindow-quartz.c @@ -2901,6 +2901,26 @@ gdk_quartz_window_get_input_shape (GdkWindow *window) return NULL; } +/* Protocol to build cleanly for OSX < 10.7 */ +@protocol ScaleFactor +- (CGFloat) backingScaleFactor; +@end + +static gint +gdk_quartz_window_get_scale_factor (GdkWindow *window) +{ + GdkWindowImplQuartz *impl; + + if (GDK_WINDOW_DESTROYED (window)) + return 1; + + impl = GDK_WINDOW_IMPL_QUARTZ (window->impl); + + if (gdk_quartz_osx_version() >= GDK_OSX_LION) + return [(id ) impl->toplevel backingScaleFactor]; + + return 1; +} static void gdk_window_impl_quartz_class_init (GdkWindowImplQuartzClass *klass) @@ -2940,6 +2960,7 @@ gdk_window_impl_quartz_class_init (GdkWindowImplQuartzClass *klass) impl_class->get_input_shape = gdk_quartz_window_get_input_shape; impl_class->begin_paint_region = gdk_window_impl_quartz_begin_paint_region; impl_class->end_paint = gdk_window_impl_quartz_end_paint; + impl_class->get_scale_factor = gdk_quartz_window_get_scale_factor; impl_class->focus = gdk_quartz_window_focus; impl_class->set_type_hint = gdk_quartz_window_set_type_hint;