[gtk+/wip/matthiasc/monitor: 4/4] screen: Implement monitor apis generically
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/matthiasc/monitor: 4/4] screen: Implement monitor apis generically
- Date: Sat, 2 Apr 2016 14:24:38 +0000 (UTC)
commit 1c0a93b3f8a9d9fa3af79b75d0ec807cceaef4f8
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Apr 2 10:18:16 2016 -0400
screen: Implement monitor apis generically
Implement all the monitor-related GdkScreen apis based on
gdk_display_list_monitors.
gdk/gdkscreen.c | 121 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 120 insertions(+), 1 deletions(-)
---
diff --git a/gdk/gdkscreen.c b/gdk/gdkscreen.c
index d217eae..3e2b618 100644
--- a/gdk/gdkscreen.c
+++ b/gdk/gdkscreen.c
@@ -57,6 +57,21 @@ static void gdk_screen_get_property (GObject *object,
GValue *value,
GParamSpec *pspec);
+static gint gdk_screen_real_get_n_monitors (GdkScreen *screen);
+static gint gdk_screen_real_get_primary_monitor (GdkScreen *screen);
+static gint gdk_screen_real_get_monitor_width_mm (GdkScreen *screen,
+ gint monitor_num);
+static gint gdk_screen_real_get_monitor_height_mm (GdkScreen *screen,
+ gint monitor_num);
+static gchar * gdk_screen_real_get_monitor_plug_name (GdkScreen *screen,
+ gint monitor_num);
+static void gdk_screen_real_get_monitor_geometry (GdkScreen *screen,
+ gint monitor_num,
+ GdkRectangle *dest);
+static void gdk_screen_real_get_monitor_workarea (GdkScreen *screen,
+ gint monitor_num,
+ GdkRectangle *dest);
+
enum
{
PROP_0,
@@ -84,7 +99,15 @@ gdk_screen_class_init (GdkScreenClass *klass)
object_class->finalize = gdk_screen_finalize;
object_class->set_property = gdk_screen_set_property;
object_class->get_property = gdk_screen_get_property;
-
+
+ klass->get_n_monitors = gdk_screen_real_get_n_monitors;
+ klass->get_primary_monitor = gdk_screen_real_get_primary_monitor;
+ klass->get_monitor_width_mm = gdk_screen_real_get_monitor_width_mm;
+ klass->get_monitor_height_mm = gdk_screen_real_get_monitor_height_mm;
+ klass->get_monitor_plug_name = gdk_screen_real_get_monitor_plug_name;
+ klass->get_monitor_geometry = gdk_screen_real_get_monitor_geometry;
+ klass->get_monitor_workarea = gdk_screen_real_get_monitor_workarea;
+
g_object_class_install_property (object_class,
PROP_FONT_OPTIONS,
g_param_spec_pointer ("font-options",
@@ -703,6 +726,102 @@ gdk_screen_get_root_window (GdkScreen *screen)
return GDK_SCREEN_GET_CLASS (screen)->get_root_window (screen);
}
+static GdkMonitor *
+get_monitor (GdkScreen *screen,
+ gint n)
+{
+ GdkDisplay *display;
+ GdkMonitor *monitor;
+ GList *list;
+
+ display = gdk_screen_get_display (screen);
+ list = gdk_display_list_monitors (display);
+ monitor = g_list_nth_data (list, n);
+ g_list_free (list);
+
+ return monitor;
+}
+
+static gint
+gdk_screen_real_get_n_monitors (GdkScreen *screen)
+{
+ GdkDisplay *display;
+ GList *list;
+ gint length;
+
+ display = gdk_screen_get_display (screen);
+ list = gdk_display_list_monitors (display);
+ length = g_list_length (list);
+ g_list_free (list);
+ return length;
+}
+
+static gint
+gdk_screen_real_get_primary_monitor (GdkScreen *screen)
+{
+ /* FIXME */
+ return 0;
+}
+
+static gint
+gdk_screen_real_get_monitor_width_mm (GdkScreen *screen,
+ gint monitor_num)
+{
+ GdkMonitor *monitor;
+ int width_mm, height_mm;
+
+ monitor = get_monitor (screen, monitor_num);
+ gdk_monitor_get_size (monitor, &width_mm, &height_mm);
+
+ return width_mm;
+}
+
+static gint
+gdk_screen_real_get_monitor_height_mm (GdkScreen *screen,
+ gint monitor_num)
+{
+ GdkMonitor *monitor;
+ int width_mm, height_mm;
+
+ monitor = get_monitor (screen, monitor_num);
+ gdk_monitor_get_size (monitor, &width_mm, &height_mm);
+
+ return height_mm;
+}
+
+static gchar *
+gdk_screen_real_get_monitor_plug_name (GdkScreen *screen,
+ gint monitor_num)
+{
+ GdkMonitor *monitor;
+
+ monitor = get_monitor (screen, monitor_num);
+ return g_strdup (gdk_monitor_get_model (monitor));
+}
+
+static void
+gdk_screen_real_get_monitor_geometry (GdkScreen *screen,
+ gint monitor_num,
+ GdkRectangle *dest)
+{
+ GdkMonitor *monitor;
+
+ monitor = get_monitor (screen, monitor_num);
+ gdk_monitor_get_geometry (monitor, dest);
+}
+
+static void
+gdk_screen_real_get_monitor_workarea (GdkScreen *screen,
+ gint monitor_num,
+ GdkRectangle *dest)
+{
+ GdkMonitor *monitor;
+
+ monitor = get_monitor (screen, monitor_num);
+ /* FIXME */
+ gdk_monitor_get_geometry (monitor, dest);
+}
+
/**
* gdk_screen_get_n_monitors:
* @screen: a #GdkScreen
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]