[gtk+/wip/window-scales2: 5/40] quartz: Implement get_scale_factor() on screen and window
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/window-scales2: 5/40] quartz: Implement get_scale_factor() on screen and window
- Date: Wed, 3 Jul 2013 12:42:23 +0000 (UTC)
commit d4607be00375d505fe082ee95ba42fc17bbbf57f
Author: Michael Natterer <mitch gimp org>
Date: Fri Jan 18 15:47:29 2013 +0100
quartz: Implement get_scale_factor() on screen and window
gdk/quartz/gdkscreen-quartz.c | 30 ++++++++++++++++++++++++++++++
gdk/quartz/gdkwindow-quartz.c | 21 +++++++++++++++++++++
2 files changed, 51 insertions(+), 0 deletions(-)
---
diff --git a/gdk/quartz/gdkscreen-quartz.c b/gdk/quartz/gdkscreen-quartz.c
index 84269f5..e83c87b 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 <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;
}
diff --git a/gdk/quartz/gdkwindow-quartz.c b/gdk/quartz/gdkwindow-quartz.c
index 48891ab..d6f45bb 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 <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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]