quartz: Implement get_scale_factor() on screen and window

This commit is contained in:
Michael Natterer 2013-01-18 15:47:29 +01:00 committed by Alexander Larsson
parent 30080faf2b
commit d4607be003
2 changed files with 51 additions and 0 deletions

View File

@ -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 <ScaleFactor>) 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;
}

View File

@ -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 <ScaleFactor>) 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;