forked from AuroraMiddleware/gtk
gdk: Add gdk_display_get_monitors()
Returns a GListModel of GDK_TYPE_MONITOR. This will replace the current andling of monitors in GdkDisplay.
This commit is contained in:
parent
bc88f01165
commit
dd7d76f389
@ -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
|
||||
|
@ -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 (broadway_display->event_source);
|
||||
g_source_unref (broadway_display->event_source);
|
||||
broadway_display->event_source = NULL;
|
||||
g_source_destroy (self->event_source);
|
||||
g_source_unref (self->event_source);
|
||||
self->event_source = NULL;
|
||||
}
|
||||
if (self->monitors)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
@ -52,6 +52,7 @@ struct _GdkBroadwayDisplay
|
||||
GdkBroadwayServer *server;
|
||||
gpointer move_resize_data;
|
||||
|
||||
GListStore *monitors;
|
||||
GdkMonitor *monitor;
|
||||
int scale_factor;
|
||||
|
||||
|
@ -1569,6 +1569,28 @@ gdk_display_get_monitor (GdkDisplay *display,
|
||||
return GDK_DISPLAY_GET_CLASS (display)->get_monitor (display, monitor_num);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user