mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-25 05:01:09 +00:00
displaymanager: Handle the default display
... instead of having every backend do it on their own.
This commit is contained in:
parent
ad764c8a58
commit
839f402191
@ -34,7 +34,6 @@ struct _GdkBroadwayDisplayManager
|
||||
{
|
||||
GdkDisplayManager parent;
|
||||
|
||||
GdkDisplay *default_display;
|
||||
GSList *displays;
|
||||
|
||||
gboolean init_failed;
|
||||
@ -99,21 +98,6 @@ gdk_broadway_display_manager_list_displays (GdkDisplayManager *manager)
|
||||
return g_slist_copy (manager_broadway->displays);
|
||||
}
|
||||
|
||||
static GdkDisplay *
|
||||
gdk_broadway_display_manager_get_default_display (GdkDisplayManager *manager)
|
||||
{
|
||||
return GDK_BROADWAY_DISPLAY_MANAGER (manager)->default_display;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_broadway_display_manager_set_default_display (GdkDisplayManager *manager,
|
||||
GdkDisplay *display)
|
||||
{
|
||||
GdkBroadwayDisplayManager *manager_broadway = GDK_BROADWAY_DISPLAY_MANAGER (manager);
|
||||
|
||||
manager_broadway->default_display = display;
|
||||
}
|
||||
|
||||
#include "../gdkkeynames.c"
|
||||
|
||||
static gchar *
|
||||
@ -154,8 +138,6 @@ gdk_broadway_display_manager_class_init (GdkBroadwayDisplayManagerClass *class)
|
||||
|
||||
manager_class->open_display = gdk_broadway_display_manager_open_display;
|
||||
manager_class->list_displays = gdk_broadway_display_manager_list_displays;
|
||||
manager_class->set_default_display = gdk_broadway_display_manager_set_default_display;
|
||||
manager_class->get_default_display = gdk_broadway_display_manager_get_default_display;
|
||||
manager_class->atom_intern = _gdk_broadway_display_manager_atom_intern;
|
||||
manager_class->get_atom_name = _gdk_broadway_display_manager_get_atom_name;
|
||||
manager_class->lookup_keyval = gdk_broadway_display_manager_lookup_keyval;
|
||||
@ -182,7 +164,7 @@ _gdk_broadway_display_manager_remove_display (GdkDisplayManager *manager,
|
||||
|
||||
manager_broadway->displays = g_slist_remove (manager_broadway->displays, display);
|
||||
|
||||
if (manager_broadway->default_display == display)
|
||||
if (gdk_display_manager_get_default_display (manager) == display)
|
||||
{
|
||||
if (manager_broadway->displays)
|
||||
gdk_display_manager_set_default_display (manager, manager_broadway->displays->data);
|
||||
|
@ -421,7 +421,7 @@ _gdk_display_manager_get_nocreate (void)
|
||||
GdkDisplay *
|
||||
gdk_display_manager_get_default_display (GdkDisplayManager *manager)
|
||||
{
|
||||
return GDK_DISPLAY_MANAGER_GET_CLASS (manager)->get_default_display (manager);
|
||||
return manager->default_display;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -478,7 +478,10 @@ void
|
||||
gdk_display_manager_set_default_display (GdkDisplayManager *manager,
|
||||
GdkDisplay *display)
|
||||
{
|
||||
GDK_DISPLAY_MANAGER_GET_CLASS (manager)->set_default_display (manager, display);
|
||||
manager->default_display = display;
|
||||
|
||||
if (GDK_DISPLAY_MANAGER_GET_CLASS (manager)->set_default_display)
|
||||
GDK_DISPLAY_MANAGER_GET_CLASS (manager)->set_default_display (manager, display);
|
||||
|
||||
g_object_notify (G_OBJECT (manager), "default-display");
|
||||
}
|
||||
|
@ -31,6 +31,8 @@ typedef struct _GdkDisplayManagerClass GdkDisplayManagerClass;
|
||||
struct _GdkDisplayManager
|
||||
{
|
||||
GObject parent_instance;
|
||||
|
||||
GdkDisplay *default_display;
|
||||
};
|
||||
|
||||
struct _GdkDisplayManagerClass
|
||||
@ -38,7 +40,6 @@ struct _GdkDisplayManagerClass
|
||||
GObjectClass parent_class;
|
||||
|
||||
GSList * (*list_displays) (GdkDisplayManager *manager);
|
||||
GdkDisplay * (*get_default_display) (GdkDisplayManager *manager);
|
||||
void (*set_default_display) (GdkDisplayManager *manager,
|
||||
GdkDisplay *display);
|
||||
GdkDisplay * (*open_display) (GdkDisplayManager *manager,
|
||||
|
@ -36,7 +36,6 @@ struct _GdkQuartzDisplayManager
|
||||
{
|
||||
GdkDisplayManager parent;
|
||||
|
||||
GdkDisplay *default_display;
|
||||
GSList *displays;
|
||||
};
|
||||
|
||||
@ -58,21 +57,6 @@ gdk_quartz_display_manager_list_displays (GdkDisplayManager *manager)
|
||||
return g_slist_copy (manager_quartz->displays);
|
||||
}
|
||||
|
||||
static GdkDisplay *
|
||||
gdk_quartz_display_manager_get_default_display (GdkDisplayManager *manager)
|
||||
{
|
||||
return GDK_QUARTZ_DISPLAY_MANAGER (manager)->default_display;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_quartz_display_manager_set_default_display (GdkDisplayManager *manager,
|
||||
GdkDisplay *display)
|
||||
{
|
||||
GdkQuartzDisplayManager *manager_quartz = GDK_QUARTZ_DISPLAY_MANAGER (manager);
|
||||
|
||||
manager_quartz->default_display = display;
|
||||
}
|
||||
|
||||
#include "../gdkkeynames.c"
|
||||
|
||||
static gchar *
|
||||
@ -123,8 +107,6 @@ gdk_quartz_display_manager_class_init (GdkQuartzDisplayManagerClass *class)
|
||||
|
||||
manager_class->open_display = gdk_quartz_display_manager_open_display;
|
||||
manager_class->list_displays = gdk_quartz_display_manager_list_displays;
|
||||
manager_class->set_default_display = gdk_quartz_display_manager_set_default_display;
|
||||
manager_class->get_default_display = gdk_quartz_display_manager_get_default_display;
|
||||
manager_class->atom_intern = _gdk_quartz_display_manager_atom_intern;
|
||||
manager_class->get_atom_name = _gdk_quartz_display_manager_get_atom_name;
|
||||
manager_class->lookup_keyval = gdk_quartz_display_manager_lookup_keyval;
|
||||
@ -151,7 +133,7 @@ _gdk_quartz_display_manager_remove_display (GdkDisplayManager *manager,
|
||||
|
||||
manager_quartz->displays = g_slist_remove (manager_quartz->displays, display);
|
||||
|
||||
if (manager_quartz->default_display == display)
|
||||
if (gdk_display_manager_get_default_display (manager) == display)
|
||||
{
|
||||
if (manager_quartz->displays)
|
||||
gdk_display_manager_set_default_display (manager, manager_quartz->displays->data);
|
||||
|
@ -33,7 +33,6 @@ struct _GdkWaylandDisplayManager
|
||||
{
|
||||
GdkDisplayManager parent;
|
||||
|
||||
GdkDisplay *default_display;
|
||||
GSList *displays;
|
||||
|
||||
GHashTable *name_to_atoms;
|
||||
@ -111,17 +110,9 @@ static void
|
||||
gdk_wayland_display_manager_set_default_display (GdkDisplayManager *manager,
|
||||
GdkDisplay *display)
|
||||
{
|
||||
GDK_WAYLAND_DISPLAY_MANAGER (manager)->default_display = display;
|
||||
|
||||
_gdk_wayland_display_make_default (display);
|
||||
}
|
||||
|
||||
static GdkDisplay *
|
||||
gdk_wayland_display_manager_get_default_display (GdkDisplayManager *manager)
|
||||
{
|
||||
return GDK_WAYLAND_DISPLAY_MANAGER (manager)->default_display;
|
||||
}
|
||||
|
||||
static GdkAtom
|
||||
gdk_wayland_display_manager_atom_intern (GdkDisplayManager *manager_in,
|
||||
const gchar *atom_name,
|
||||
@ -215,7 +206,6 @@ gdk_wayland_display_manager_class_init (GdkWaylandDisplayManagerClass *class)
|
||||
manager_class->open_display = gdk_wayland_display_manager_open_display;
|
||||
manager_class->list_displays = gdk_wayland_display_manager_list_displays;
|
||||
manager_class->set_default_display = gdk_wayland_display_manager_set_default_display;
|
||||
manager_class->get_default_display = gdk_wayland_display_manager_get_default_display;
|
||||
manager_class->atom_intern = gdk_wayland_display_manager_atom_intern;
|
||||
manager_class->get_atom_name = gdk_wayland_display_manager_get_atom_name;
|
||||
manager_class->lookup_keyval = gdk_wayland_display_manager_lookup_keyval;
|
||||
@ -282,7 +272,7 @@ _gdk_wayland_display_manager_remove_display (GdkDisplayManager *manager,
|
||||
|
||||
manager_wayland->displays = g_slist_remove (manager_wayland->displays, display);
|
||||
|
||||
if (manager_wayland->default_display == display)
|
||||
if (gdk_display_manager_get_default_display (manager) == display)
|
||||
{
|
||||
if (manager_wayland->displays)
|
||||
gdk_display_manager_set_default_display (manager, manager_wayland->displays->data);
|
||||
|
@ -51,19 +51,6 @@ gdk_win32_display_manager_list_displays (GdkDisplayManager *manager)
|
||||
return g_slist_append (NULL, gdk_display_get_default ());
|
||||
}
|
||||
|
||||
static GdkDisplay *
|
||||
gdk_win32_display_manager_get_default_display (GdkDisplayManager *manager)
|
||||
{
|
||||
return _gdk_win32_display_open (NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_win32_display_manager_set_default_display (GdkDisplayManager *manager,
|
||||
GdkDisplay *display)
|
||||
{
|
||||
g_assert (gdk_display_get_default () == display);
|
||||
}
|
||||
|
||||
#include "../gdkkeynames.c"
|
||||
|
||||
static gchar *
|
||||
@ -110,8 +97,6 @@ gdk_win32_display_manager_class_init (GdkWin32DisplayManagerClass *class)
|
||||
|
||||
manager_class->open_display = gdk_win32_display_manager_open_display;
|
||||
manager_class->list_displays = gdk_win32_display_manager_list_displays;
|
||||
manager_class->set_default_display = gdk_win32_display_manager_set_default_display;
|
||||
manager_class->get_default_display = gdk_win32_display_manager_get_default_display;
|
||||
manager_class->atom_intern = _gdk_win32_display_manager_atom_intern;
|
||||
manager_class->get_atom_name = _gdk_win32_display_manager_get_atom_name;
|
||||
manager_class->lookup_keyval = gdk_win32_display_manager_lookup_keyval;
|
||||
|
@ -32,7 +32,6 @@ struct _GdkX11DisplayManager
|
||||
{
|
||||
GdkDisplayManager parent;
|
||||
|
||||
GdkDisplay *default_display;
|
||||
GSList *displays;
|
||||
|
||||
gboolean init_failed;
|
||||
@ -79,13 +78,12 @@ static GdkDisplay *
|
||||
gdk_x11_display_manager_open_display (GdkDisplayManager *manager,
|
||||
const gchar *name)
|
||||
{
|
||||
GdkX11DisplayManager *manager_x11 = GDK_X11_DISPLAY_MANAGER (manager);
|
||||
GdkDisplay *display;
|
||||
|
||||
display = _gdk_x11_display_open (name);
|
||||
if (display != NULL)
|
||||
{
|
||||
if (manager_x11->default_display == NULL)
|
||||
if (gdk_display_manager_get_default_display (manager) == NULL)
|
||||
gdk_display_manager_set_default_display (manager, display);
|
||||
|
||||
g_signal_emit_by_name (manager, "display-opened", display);
|
||||
@ -100,18 +98,10 @@ gdk_x11_display_manager_list_displays (GdkDisplayManager *manager)
|
||||
return g_slist_copy (GDK_X11_DISPLAY_MANAGER (manager)->displays);
|
||||
}
|
||||
|
||||
static GdkDisplay *
|
||||
gdk_x11_display_manager_get_default_display (GdkDisplayManager *manager)
|
||||
{
|
||||
return GDK_X11_DISPLAY_MANAGER (manager)->default_display;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_x11_display_manager_set_default_display (GdkDisplayManager *manager,
|
||||
GdkDisplay *display)
|
||||
{
|
||||
GDK_X11_DISPLAY_MANAGER (manager)->default_display = display;
|
||||
|
||||
if (display)
|
||||
_gdk_x11_display_make_default (display);
|
||||
}
|
||||
@ -141,7 +131,6 @@ gdk_x11_display_manager_class_init (GdkX11DisplayManagerClass *class)
|
||||
manager_class->open_display = gdk_x11_display_manager_open_display;
|
||||
manager_class->list_displays = gdk_x11_display_manager_list_displays;
|
||||
manager_class->set_default_display = gdk_x11_display_manager_set_default_display;
|
||||
manager_class->get_default_display = gdk_x11_display_manager_get_default_display;
|
||||
manager_class->atom_intern = _gdk_x11_display_manager_atom_intern;
|
||||
manager_class->get_atom_name = _gdk_x11_display_manager_get_atom_name;
|
||||
manager_class->lookup_keyval = _gdk_x11_display_manager_lookup_keyval;
|
||||
@ -166,7 +155,7 @@ _gdk_x11_display_manager_remove_display (GdkDisplayManager *manager,
|
||||
|
||||
manager_x11->displays = g_slist_remove (manager_x11->displays, display);
|
||||
|
||||
if (manager_x11->default_display == display)
|
||||
if (gdk_display_manager_get_default_display (manager) == display)
|
||||
{
|
||||
if (manager_x11->displays)
|
||||
gdk_display_manager_set_default_display (manager, manager_x11->displays->data);
|
||||
|
Loading…
Reference in New Issue
Block a user