diff options
-rw-r--r-- | docs/reference/gdk/gdk4-sections.txt | 1 | ||||
-rw-r--r-- | gdk/broadway/gdkdisplay-broadway.c | 30 | ||||
-rw-r--r-- | gdk/broadway/gdkdisplay-broadway.h | 1 | ||||
-rw-r--r-- | gdk/gdkdisplay.c | 22 | ||||
-rw-r--r-- | gdk/gdkdisplay.h | 2 | ||||
-rw-r--r-- | gdk/gdkdisplayprivate.h | 3 | ||||
-rw-r--r-- | gdk/wayland/gdkdisplay-wayland.c | 9 | ||||
-rw-r--r-- | gdk/win32/gdkdisplay-win32.c | 9 | ||||
-rw-r--r-- | gdk/x11/gdkdisplay-x11.c | 9 |
9 files changed, 80 insertions, 6 deletions
diff --git a/docs/reference/gdk/gdk4-sections.txt b/docs/reference/gdk/gdk4-sections.txt index b753ee9ece..19ac368ccf 100644 --- a/docs/reference/gdk/gdk4-sections.txt +++ b/docs/reference/gdk/gdk4-sections.txt @@ -94,6 +94,7 @@ gdk_display_get_default_seat gdk_display_list_seats gdk_display_get_n_monitors gdk_display_get_monitor +gdk_display_get_monitors gdk_display_get_monitor_at_surface gdk_display_get_clipboard gdk_display_get_primary_clipboard diff --git a/gdk/broadway/gdkdisplay-broadway.c b/gdk/broadway/gdkdisplay-broadway.c index 0a507dc3ae..049670181b 100644 --- a/gdk/broadway/gdkdisplay-broadway.c +++ b/gdk/broadway/gdkdisplay-broadway.c @@ -243,13 +243,18 @@ gdk_broadway_display_get_default_group (GdkDisplay *display) static void gdk_broadway_display_dispose (GObject *object) { - GdkBroadwayDisplay *broadway_display = GDK_BROADWAY_DISPLAY (object); + GdkBroadwayDisplay *self = GDK_BROADWAY_DISPLAY (object); - if (broadway_display->event_source) + if (self->event_source) + { + g_source_destroy (self->event_source); + g_source_unref (self->event_source); + self->event_source = NULL; + } + if (self->monitors) { - g_source_destroy (broadway_display->event_source); - g_source_unref (broadway_display->event_source); - broadway_display->event_source = NULL; + g_list_store_remove_all (self->monitors); + g_clear_object (&self->monitors); } G_OBJECT_CLASS (gdk_broadway_display_parent_class)->dispose (object); @@ -332,6 +337,20 @@ gdk_broadway_display_get_monitor (GdkDisplay *display, return NULL; } +static GListModel * +gdk_broadway_display_get_monitors (GdkDisplay *display) +{ + GdkBroadwayDisplay *self = GDK_BROADWAY_DISPLAY (display); + + if (self->monitors == NULL) + { + self->monitors = g_list_store_new (GDK_TYPE_MONITOR); + g_list_store_append (self->monitors, self->monitor); + } + + return G_LIST_MODEL (self->monitors); +} + static gboolean gdk_broadway_display_get_setting (GdkDisplay *display, const char *name, @@ -430,5 +449,6 @@ gdk_broadway_display_class_init (GdkBroadwayDisplayClass * class) display_class->get_n_monitors = gdk_broadway_display_get_n_monitors; display_class->get_monitor = gdk_broadway_display_get_monitor; + display_class->get_monitors = gdk_broadway_display_get_monitors; display_class->get_setting = gdk_broadway_display_get_setting; } diff --git a/gdk/broadway/gdkdisplay-broadway.h b/gdk/broadway/gdkdisplay-broadway.h index b8e11168ef..0a2f1c91a5 100644 --- a/gdk/broadway/gdkdisplay-broadway.h +++ b/gdk/broadway/gdkdisplay-broadway.h @@ -52,6 +52,7 @@ struct _GdkBroadwayDisplay GdkBroadwayServer *server; gpointer move_resize_data; + GListStore *monitors; GdkMonitor *monitor; int scale_factor; diff --git a/gdk/gdkdisplay.c b/gdk/gdkdisplay.c index 88e5057e65..a072e3f23f 100644 --- a/gdk/gdkdisplay.c +++ b/gdk/gdkdisplay.c @@ -1570,6 +1570,28 @@ gdk_display_get_monitor (GdkDisplay *display, } /** + * gdk_display_get_monitors: + * @display: a #GdkDisplay + * + * Gets the list of monitors associated with this display. + * + * Subsequent calls to this function will always return the same list for the + * same display. + * + * You can listen to the GListModel::items-changed signal on this list + * to monitor changes to the monitor of this display. + * + * Returns: (transfer none): a #GListModel of #GdkMonitor + */ +GListModel * +gdk_display_get_monitors (GdkDisplay *self) +{ + g_return_val_if_fail (GDK_IS_DISPLAY (self), NULL); + + return GDK_DISPLAY_GET_CLASS (self)->get_monitors (self); +} + +/** * gdk_display_get_monitor_at_surface: * @display: a #GdkDisplay * @surface: a #GdkSurface diff --git a/gdk/gdkdisplay.h b/gdk/gdkdisplay.h index bb421f405d..26918478c2 100644 --- a/gdk/gdkdisplay.h +++ b/gdk/gdkdisplay.h @@ -112,6 +112,8 @@ GDK_AVAILABLE_IN_ALL GdkMonitor * gdk_display_get_monitor (GdkDisplay *display, int monitor_num); GDK_AVAILABLE_IN_ALL +GListModel * gdk_display_get_monitors (GdkDisplay *self) G_GNUC_PURE; +GDK_AVAILABLE_IN_ALL GdkMonitor * gdk_display_get_monitor_at_surface (GdkDisplay *display, GdkSurface *surface); diff --git a/gdk/gdkdisplayprivate.h b/gdk/gdkdisplayprivate.h index a6afeaa50a..25d1f697ff 100644 --- a/gdk/gdkdisplayprivate.h +++ b/gdk/gdkdisplayprivate.h @@ -158,7 +158,8 @@ struct _GdkDisplayClass int (*get_n_monitors) (GdkDisplay *display); GdkMonitor * (*get_monitor) (GdkDisplay *display, int index); - GdkMonitor * (*get_monitor_at_surface) (GdkDisplay *display, + GListModel * (*get_monitors) (GdkDisplay *self); + GdkMonitor * (*get_monitor_at_surface) (GdkDisplay *display, GdkSurface *surface); gboolean (*get_setting) (GdkDisplay *display, const char *name, diff --git a/gdk/wayland/gdkdisplay-wayland.c b/gdk/wayland/gdkdisplay-wayland.c index f052a0069e..b3ffe0060f 100644 --- a/gdk/wayland/gdkdisplay-wayland.c +++ b/gdk/wayland/gdkdisplay-wayland.c @@ -977,6 +977,14 @@ gdk_wayland_display_get_monitor (GdkDisplay *display, return monitor; } +static GListModel * +gdk_wayland_display_get_monitors (GdkDisplay *display) +{ + GdkWaylandDisplay *self = GDK_WAYLAND_DISPLAY (display); + + return G_LIST_MODEL (self->monitors); +} + static GdkMonitor * gdk_wayland_display_get_monitor_at_surface (GdkDisplay *display, GdkSurface *window) @@ -1046,6 +1054,7 @@ gdk_wayland_display_class_init (GdkWaylandDisplayClass *class) display_class->get_n_monitors = gdk_wayland_display_get_n_monitors; display_class->get_monitor = gdk_wayland_display_get_monitor; + display_class->get_monitors = gdk_wayland_display_get_monitors; display_class->get_monitor_at_surface = gdk_wayland_display_get_monitor_at_surface; display_class->get_setting = gdk_wayland_display_get_setting; display_class->set_cursor_theme = gdk_wayland_display_set_cursor_theme; diff --git a/gdk/win32/gdkdisplay-win32.c b/gdk/win32/gdkdisplay-win32.c index 8861f6928b..4898dce1ef 100644 --- a/gdk/win32/gdkdisplay-win32.c +++ b/gdk/win32/gdkdisplay-win32.c @@ -990,6 +990,14 @@ gdk_win32_display_get_primary_monitor (GdkDisplay *display) return gdk_win32_display_get_monitor (display, 0); } +static GListModel * +gdk_win32_display_get_monitors (GdkDisplay *display) +{ + GdkWin32Display *self = GDK_WIN32_DISPLAY (display); + + return self->monitors; +} + guint _gdk_win32_display_get_monitor_scale_factor (GdkWin32Display *win32_display, HMONITOR hmonitor, @@ -1114,6 +1122,7 @@ gdk_win32_display_class_init (GdkWin32DisplayClass *klass) display_class->get_n_monitors = gdk_win32_display_get_n_monitors; display_class->get_monitor = gdk_win32_display_get_monitor; + display_class->get_monitors = gdk_win32_display_get_monitors; #ifdef GDK_RENDERING_VULKAN display_class->vk_context_type = GDK_TYPE_WIN32_VULKAN_CONTEXT; diff --git a/gdk/x11/gdkdisplay-x11.c b/gdk/x11/gdkdisplay-x11.c index 73737984b3..203feadcf5 100644 --- a/gdk/x11/gdkdisplay-x11.c +++ b/gdk/x11/gdkdisplay-x11.c @@ -2923,6 +2923,14 @@ gdk_x11_display_get_monitor (GdkDisplay *display, return NULL; } +static GListModel * +gdk_x11_display_get_monitors (GdkDisplay *display) +{ + GdkX11Display *self = GDK_X11_DISPLAY (display); + + return G_LIST_MODEL (self->monitors); +} + /** * gdk_x11_display_get_primary_monitor: * @self: a #GdkDisplay @@ -3045,6 +3053,7 @@ gdk_x11_display_class_init (GdkX11DisplayClass * class) display_class->get_n_monitors = gdk_x11_display_get_n_monitors; display_class->get_monitor = gdk_x11_display_get_monitor; + display_class->get_monitors = gdk_x11_display_get_monitors; display_class->get_setting = gdk_x11_display_get_setting; display_class->set_cursor_theme = gdk_x11_display_set_cursor_theme; |