[gtk+/wip/matthiasc/monitor: 2/4] Add gdk_display_list_monitors



commit 10606363fdb0b7ba1b82e11f7c665a5698fe9996
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu Mar 31 23:10:37 2016 -0400

    Add gdk_display_list_monitors
    
    This follows our general direction of moving functionality
    from GdkScreen to GdkDisplay.

 gdk/gdkdisplay.c        |   56 +++++++++++++++++++++++++++++++++++++++++++++++
 gdk/gdkdisplay.h        |    3 ++
 gdk/gdkdisplayprivate.h |    6 +++++
 3 files changed, 65 insertions(+), 0 deletions(-)
---
diff --git a/gdk/gdkdisplay.c b/gdk/gdkdisplay.c
index 6150ef7..c3979de 100644
--- a/gdk/gdkdisplay.c
+++ b/gdk/gdkdisplay.c
@@ -71,6 +71,8 @@ enum {
   CLOSED,
   SEAT_ADDED,
   SEAT_REMOVED,
+  MONITOR_ADDED,
+  MONITOR_REMOVED,
   LAST_SIGNAL
 };
 
@@ -227,6 +229,21 @@ gdk_display_class_init (GdkDisplayClass *class)
                  0, NULL, NULL,
                   g_cclosure_marshal_VOID__OBJECT,
                  G_TYPE_NONE, 1, GDK_TYPE_SEAT);
+
+  signals[MONITOR_ADDED] =
+    g_signal_new (g_intern_static_string ("monitor-added"),
+                 G_OBJECT_CLASS_TYPE (object_class),
+                 G_SIGNAL_RUN_LAST,
+                 0, NULL, NULL,
+                  g_cclosure_marshal_VOID__OBJECT,
+                 G_TYPE_NONE, 1, GDK_TYPE_MONITOR);
+  signals[MONITOR_REMOVED] =
+    g_signal_new (g_intern_static_string ("monitor-removed"),
+                 G_OBJECT_CLASS_TYPE (object_class),
+                 G_SIGNAL_RUN_LAST,
+                 0, NULL, NULL,
+                  g_cclosure_marshal_VOID__OBJECT,
+                 G_TYPE_NONE, 1, GDK_TYPE_MONITOR);
 }
 
 static void
@@ -2464,3 +2481,42 @@ gdk_display_list_seats (GdkDisplay *display)
 
   return g_list_copy (display->seats);
 }
+
+GList *
+gdk_display_list_monitors (GdkDisplay *display)
+{
+  g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
+
+  return g_list_copy (display->monitors);
+}
+
+void
+gdk_display_add_monitor (GdkDisplay *display,
+                         GdkMonitor *monitor)
+{
+  g_return_if_fail (GDK_IS_DISPLAY (display));
+  g_return_if_fail (GDK_IS_MONITOR (monitor));
+
+  display->monitors = g_list_append (display->monitors, g_object_ref (monitor));
+  g_signal_emit (display, signals[MONITOR_ADDED], 0, monitor);
+}
+
+void
+gdk_display_remove_monitor (GdkDisplay *display,
+                            GdkMonitor *monitor)
+{
+  GList *link;
+
+  g_return_if_fail (GDK_IS_DISPLAY (display));
+  g_return_if_fail (GDK_IS_MONITOR (monitor));
+
+  link = g_list_find (display->monitors, monitor);
+
+  if (link)
+    {
+      display->monitors = g_list_remove_link (display->monitors, link);
+      g_signal_emit (display, signals[MONITOR_REMOVED], 0, monitor);
+      g_object_unref (link->data);
+      g_list_free (link);
+    }
+}
diff --git a/gdk/gdkdisplay.h b/gdk/gdkdisplay.h
index 6e06cc8..270aef7 100644
--- a/gdk/gdkdisplay.h
+++ b/gdk/gdkdisplay.h
@@ -178,6 +178,9 @@ GdkSeat * gdk_display_get_default_seat (GdkDisplay *display);
 GDK_AVAILABLE_IN_3_20
 GList   * gdk_display_list_seats       (GdkDisplay *display);
 
+GDK_AVAILABLE_IN_3_22
+GList   * gdk_display_list_monitors    (GdkDisplay *display);
+
 G_END_DECLS
 
 #endif  /* __GDK_DISPLAY_H__ */
diff --git a/gdk/gdkdisplayprivate.h b/gdk/gdkdisplayprivate.h
index 1b174d5..3be1988 100644
--- a/gdk/gdkdisplayprivate.h
+++ b/gdk/gdkdisplayprivate.h
@@ -21,6 +21,7 @@
 #include "gdkdisplay.h"
 #include "gdkwindow.h"
 #include "gdkcursor.h"
+#include "gdkmonitor.h"
 #include "gdkinternals.h"
 
 G_BEGIN_DECLS
@@ -128,6 +129,7 @@ struct _GdkDisplay
   GdkRenderingMode rendering_mode;
 
   GList *seats;
+  GList *monitors;
 };
 
 struct _GdkDisplayClass
@@ -328,6 +330,10 @@ void                gdk_display_add_seat              (GdkDisplay       *display
                                                        GdkSeat          *seat);
 void                gdk_display_remove_seat           (GdkDisplay       *display,
                                                        GdkSeat          *seat);
+void                gdk_display_add_monitor           (GdkDisplay       *display,
+                                                       GdkMonitor       *monitor);
+void                gdk_display_remove_monitor        (GdkDisplay       *display,
+                                                       GdkMonitor       *monitor);
 
 G_END_DECLS
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]