summaryrefslogtreecommitdiff
path: root/gdk/x11/gdkdisplay-x11.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2016-04-03 00:12:39 -0400
committerMatthias Clasen <mclasen@redhat.com>2016-04-27 23:18:16 -0400
commitd92fda2103bc79043465b5218323a14edd05183e (patch)
treec839dee9536ecca9915912dbfdec371e9d7a5ada /gdk/x11/gdkdisplay-x11.c
parent79a0286ab13efd63cadfd2345d09d17387697592 (diff)
downloadgtk+-d92fda2103bc79043465b5218323a14edd05183e.tar.gz
x11: Port to new monitor api
Diffstat (limited to 'gdk/x11/gdkdisplay-x11.c')
-rw-r--r--gdk/x11/gdkdisplay-x11.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/gdk/x11/gdkdisplay-x11.c b/gdk/x11/gdkdisplay-x11.c
index 6804ed2006..f7c79c4559 100644
--- a/gdk/x11/gdkdisplay-x11.c
+++ b/gdk/x11/gdkdisplay-x11.c
@@ -180,6 +180,7 @@ G_DEFINE_TYPE_WITH_CODE (GdkX11Display, gdk_x11_display, GDK_TYPE_DISPLAY,
static void
gdk_x11_display_init (GdkX11Display *display)
{
+ display->monitors = g_ptr_array_new_with_free_func (g_object_unref);
}
static void
@@ -1903,6 +1904,8 @@ gdk_x11_display_finalize (GObject *object)
g_object_unref (display_x11->screen);
g_list_free_full (display_x11->screens, g_object_unref);
+ g_ptr_array_free (display_x11->monitors, TRUE);
+
g_free (display_x11->startup_notification_id);
/* X ID hashtable */
@@ -2903,6 +2906,38 @@ gdk_x11_display_get_default_seat (GdkDisplay *display)
return NULL;
}
+static int
+gdk_x11_display_get_n_monitors (GdkDisplay *display)
+{
+ GdkX11Display *x11_display = GDK_X11_DISPLAY (display);
+
+ return x11_display->monitors->len;
+}
+
+
+static GdkMonitor *
+gdk_x11_display_get_monitor (GdkDisplay *display,
+ int monitor_num)
+{
+ GdkX11Display *x11_display = GDK_X11_DISPLAY (display);
+
+ if (0 <= monitor_num || monitor_num < x11_display->monitors->len)
+ return (GdkMonitor *)x11_display->monitors->pdata[monitor_num];
+
+ return NULL;
+}
+
+static GdkMonitor *
+gdk_x11_display_get_primary_monitor (GdkDisplay *display)
+{
+ GdkX11Display *x11_display = GDK_X11_DISPLAY (display);
+
+ if (0 <= x11_display->primary_monitor && x11_display->primary_monitor < x11_display->monitors->len)
+ return x11_display->monitors->pdata[x11_display->primary_monitor];
+
+ return NULL;
+}
+
static void
gdk_x11_display_class_init (GdkX11DisplayClass * class)
{
@@ -2959,5 +2994,9 @@ gdk_x11_display_class_init (GdkX11DisplayClass * class)
display_class->get_default_seat = gdk_x11_display_get_default_seat;
+ display_class->get_n_monitors = gdk_x11_display_get_n_monitors;
+ display_class->get_monitor = gdk_x11_display_get_monitor;
+ display_class->get_primary_monitor = gdk_x11_display_get_primary_monitor;
+
_gdk_x11_windowing_init ();
}