Commit 7ef508ff authored by Benjamin Otte's avatar Benjamin Otte

displaymanager: Handle list of displays in base class

This moves the add/remove_display() functions from the subclasses to
GdkDisplay and GdkDisplayManager. It also gets rid of the list_displays
vfunc.
parent d29a4411
......@@ -55,8 +55,6 @@ G_DEFINE_TYPE (GdkBroadwayDisplay, gdk_broadway_display, GDK_TYPE_DISPLAY)
static void
gdk_broadway_display_init (GdkBroadwayDisplay *display)
{
_gdk_broadway_display_manager_add_display (gdk_display_manager_get (),
GDK_DISPLAY_OBJECT (display));
display->id_ht = g_hash_table_new (NULL, NULL);
}
......@@ -239,9 +237,6 @@ gdk_broadway_display_dispose (GObject *object)
{
GdkBroadwayDisplay *broadway_display = GDK_BROADWAY_DISPLAY (object);
_gdk_broadway_display_manager_remove_display (gdk_display_manager_get (),
GDK_DISPLAY_OBJECT (object));
g_list_foreach (broadway_display->input_devices, (GFunc) g_object_run_dispose, NULL);
_gdk_screen_close (broadway_display->screens[0]);
......
......@@ -34,8 +34,6 @@ struct _GdkBroadwayDisplayManager
{
GdkDisplayManager parent;
GSList *displays;
gboolean init_failed;
};
......@@ -90,14 +88,6 @@ gdk_broadway_display_manager_open_display (GdkDisplayManager *manager,
return _gdk_broadway_display_open (name);
}
static GSList *
gdk_broadway_display_manager_list_displays (GdkDisplayManager *manager)
{
GdkBroadwayDisplayManager *manager_broadway = GDK_BROADWAY_DISPLAY_MANAGER (manager);
return g_slist_copy (manager_broadway->displays);
}
#include "../gdkkeynames.c"
static gchar *
......@@ -137,38 +127,8 @@ gdk_broadway_display_manager_class_init (GdkBroadwayDisplayManagerClass *class)
object_class->finalize = gdk_broadway_display_manager_finalize;
manager_class->open_display = gdk_broadway_display_manager_open_display;
manager_class->list_displays = gdk_broadway_display_manager_list_displays;
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;
manager_class->get_keyval_name = gdk_broadway_display_manager_get_keyval_name;
}
void
_gdk_broadway_display_manager_add_display (GdkDisplayManager *manager,
GdkDisplay *display)
{
GdkBroadwayDisplayManager *manager_broadway = GDK_BROADWAY_DISPLAY_MANAGER (manager);
if (manager_broadway->displays == NULL)
gdk_display_manager_set_default_display (manager, display);
manager_broadway->displays = g_slist_prepend (manager_broadway->displays, display);
}
void
_gdk_broadway_display_manager_remove_display (GdkDisplayManager *manager,
GdkDisplay *display)
{
GdkBroadwayDisplayManager *manager_broadway = GDK_BROADWAY_DISPLAY_MANAGER (manager);
manager_broadway->displays = g_slist_remove (manager_broadway->displays, 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);
else
gdk_display_manager_set_default_display (manager, NULL);
}
}
......@@ -44,10 +44,6 @@ void _gdk_broadway_windowing_init (void);
gchar * _gdk_broadway_display_manager_get_atom_name (GdkDisplayManager *manager,
GdkAtom atom);
void _gdk_broadway_display_manager_add_display (GdkDisplayManager *manager,
GdkDisplay *display);
void _gdk_broadway_display_manager_remove_display (GdkDisplayManager *manager,
GdkDisplay *display);
GdkAtom _gdk_broadway_display_manager_atom_intern_static_string (GdkDisplayManager *manager,
const gchar *atom_name);
GdkAtom _gdk_broadway_display_manager_atom_intern (GdkDisplayManager *manager,
......
......@@ -25,6 +25,7 @@
#include "gdkdisplayprivate.h"
#include "gdkdeviceprivate.h"
#include "gdkdisplaymanagerprivate.h"
#include "gdkevents.h"
#include "gdkwindowimpl.h"
#include "gdkinternals.h"
......@@ -206,6 +207,8 @@ gdk_display_init (GdkDisplay *display)
g_signal_connect (display, "opened",
G_CALLBACK (gdk_display_opened), NULL);
_gdk_display_manager_add_display (gdk_display_manager_get (), display);
}
static void
......@@ -216,6 +219,8 @@ gdk_display_dispose (GObject *object)
device_manager = gdk_display_get_device_manager (GDK_DISPLAY (object));
_gdk_display_manager_remove_display (gdk_display_manager_get (), display);
g_list_free_full (display->queued_events, (GDestroyNotify) gdk_event_free);
display->queued_events = NULL;
display->queued_tail = NULL;
......
......@@ -502,7 +502,7 @@ gdk_display_manager_set_default_display (GdkDisplayManager *manager,
GSList *
gdk_display_manager_list_displays (GdkDisplayManager *manager)
{
return GDK_DISPLAY_MANAGER_GET_CLASS (manager)->list_displays (manager);
return g_slist_copy (manager->displays);
}
/**
......@@ -589,3 +589,29 @@ gdk_atom_name (GdkAtom atom)
return GDK_DISPLAY_MANAGER_GET_CLASS (manager)->get_atom_name (manager, atom);
}
void
_gdk_display_manager_add_display (GdkDisplayManager *manager,
GdkDisplay *display)
{
if (manager->displays == NULL)
gdk_display_manager_set_default_display (manager, display);
manager->displays = g_slist_prepend (manager->displays, display);
}
/* NB: This function can be called multiple times per display. */
void
_gdk_display_manager_remove_display (GdkDisplayManager *manager,
GdkDisplay *display)
{
manager->displays = g_slist_remove (manager->displays, display);
if (manager->default_display == display)
{
if (manager->displays)
gdk_display_manager_set_default_display (manager, manager->displays->data);
else
gdk_display_manager_set_default_display (manager, NULL);
}
}
......@@ -33,13 +33,14 @@ struct _GdkDisplayManager
GObject parent_instance;
GdkDisplay *default_display;
GSList *displays;
};
struct _GdkDisplayManagerClass
{
GObjectClass parent_class;
GSList * (*list_displays) (GdkDisplayManager *manager);
GdkDisplay * (*open_display) (GdkDisplayManager *manager,
const gchar *name);
......@@ -66,6 +67,11 @@ struct _GdkDisplayManagerClass
GdkDisplayManager *
_gdk_display_manager_get_nocreate (void);
void _gdk_display_manager_add_display (GdkDisplayManager *manager,
GdkDisplay *display);
void _gdk_display_manager_remove_display (GdkDisplayManager *manager,
GdkDisplay *display);
G_END_DECLS
#endif
......@@ -265,8 +265,6 @@ G_DEFINE_TYPE (GdkQuartzDisplay, gdk_quartz_display, GDK_TYPE_DISPLAY)
static void
gdk_quartz_display_init (GdkQuartzDisplay *display)
{
_gdk_quartz_display_manager_add_display (gdk_display_manager_get (),
GDK_DISPLAY_OBJECT (display));
}
static void
......@@ -274,9 +272,6 @@ gdk_quartz_display_dispose (GObject *object)
{
GdkQuartzDisplay *display_quartz = GDK_QUARTZ_DISPLAY (object);
_gdk_quartz_display_manager_remove_display (gdk_display_manager_get (),
GDK_DISPLAY_OBJECT (object));
g_list_foreach (display_quartz->input_devices,
(GFunc) g_object_run_dispose, NULL);
......
......@@ -35,8 +35,6 @@
struct _GdkQuartzDisplayManager
{
GdkDisplayManager parent;
GSList *displays;
};
......@@ -49,14 +47,6 @@ gdk_quartz_display_manager_open_display (GdkDisplayManager *manager,
return _gdk_quartz_display_open (name);
}
static GSList *
gdk_quartz_display_manager_list_displays (GdkDisplayManager *manager)
{
GdkQuartzDisplayManager *manager_quartz = GDK_QUARTZ_DISPLAY_MANAGER (manager);
return g_slist_copy (manager_quartz->displays);
}
#include "../gdkkeynames.c"
static gchar *
......@@ -106,38 +96,8 @@ gdk_quartz_display_manager_class_init (GdkQuartzDisplayManagerClass *class)
object_class->finalize = gdk_quartz_display_manager_finalize;
manager_class->open_display = gdk_quartz_display_manager_open_display;
manager_class->list_displays = gdk_quartz_display_manager_list_displays;
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;
manager_class->get_keyval_name = gdk_quartz_display_manager_get_keyval_name;
}
void
_gdk_quartz_display_manager_add_display (GdkDisplayManager *manager,
GdkDisplay *display)
{
GdkQuartzDisplayManager *manager_quartz = GDK_QUARTZ_DISPLAY_MANAGER (manager);
if (manager_quartz->displays == NULL)
gdk_display_manager_set_default_display (manager, display);
manager_quartz->displays = g_slist_prepend (manager_quartz->displays, display);
}
void
_gdk_quartz_display_manager_remove_display (GdkDisplayManager *manager,
GdkDisplay *display)
{
GdkQuartzDisplayManager *manager_quartz = GDK_QUARTZ_DISPLAY_MANAGER (manager);
manager_quartz->displays = g_slist_remove (manager_quartz->displays, 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);
else
gdk_display_manager_set_default_display (manager, NULL);
}
}
......@@ -155,12 +155,6 @@ gchar * _gdk_quartz_display_utf8_to_string_target (GdkDisplay *disp
const gchar *str);
/* Display manager */
void _gdk_quartz_display_manager_add_display (GdkDisplayManager *manager,
GdkDisplay *display);
void _gdk_quartz_display_manager_remove_display (GdkDisplayManager *manager,
GdkDisplay *display);
/* Display manager methods - events */
GdkAtom _gdk_quartz_display_manager_atom_intern (GdkDisplayManager *manager,
const gchar *atom_name,
......
......@@ -100,12 +100,6 @@ gdk_wayland_display_manager_open_display (GdkDisplayManager *manager,
return _gdk_wayland_display_open (name);
}
static GSList *
gdk_wayland_display_manager_list_displays (GdkDisplayManager *manager)
{
return g_slist_copy (GDK_WAYLAND_DISPLAY_MANAGER (manager)->displays);
}
static GdkAtom
gdk_wayland_display_manager_atom_intern (GdkDisplayManager *manager_in,
const gchar *atom_name,
......@@ -197,7 +191,6 @@ gdk_wayland_display_manager_class_init (GdkWaylandDisplayManagerClass *class)
object_class->finalize = gdk_wayland_display_manager_finalize;
manager_class->open_display = gdk_wayland_display_manager_open_display;
manager_class->list_displays = gdk_wayland_display_manager_list_displays;
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;
......
......@@ -45,12 +45,6 @@ gdk_win32_display_manager_open_display (GdkDisplayManager *manager,
return _gdk_win32_display_open (name);
}
static GSList *
gdk_win32_display_manager_list_displays (GdkDisplayManager *manager)
{
return g_slist_append (NULL, gdk_display_get_default ());
}
#include "../gdkkeynames.c"
static gchar *
......@@ -96,7 +90,6 @@ gdk_win32_display_manager_class_init (GdkWin32DisplayManagerClass *class)
object_class->finalize = gdk_win32_display_manager_finalize;
manager_class->open_display = gdk_win32_display_manager_open_display;
manager_class->list_displays = gdk_win32_display_manager_list_displays;
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;
......
......@@ -176,8 +176,6 @@ G_DEFINE_TYPE_WITH_CODE (GdkX11Display, gdk_x11_display, GDK_TYPE_DISPLAY,
static void
gdk_x11_display_init (GdkX11Display *display)
{
_gdk_x11_display_manager_add_display (gdk_display_manager_get (),
GDK_DISPLAY (display));
}
static void
......@@ -1836,11 +1834,8 @@ gdk_x11_display_ungrab (GdkDisplay *display)
static void
gdk_x11_display_dispose (GObject *object)
{
GdkDisplay *display = GDK_DISPLAY (object);
GdkX11Display *display_x11 = GDK_X11_DISPLAY (object);
_gdk_x11_display_manager_remove_display (gdk_display_manager_get (), display);
g_list_foreach (display_x11->input_devices, (GFunc) g_object_run_dispose, NULL);
_gdk_screen_close (display_x11->screen);
......
......@@ -32,8 +32,6 @@ struct _GdkX11DisplayManager
{
GdkDisplayManager parent;
GSList *displays;
gboolean init_failed;
};
......@@ -92,12 +90,6 @@ gdk_x11_display_manager_open_display (GdkDisplayManager *manager,
return display;
}
static GSList *
gdk_x11_display_manager_list_displays (GdkDisplayManager *manager)
{
return g_slist_copy (GDK_X11_DISPLAY_MANAGER (manager)->displays);
}
static void
gdk_x11_display_manager_init (GdkX11DisplayManager *manager)
{
......@@ -121,36 +113,9 @@ gdk_x11_display_manager_class_init (GdkX11DisplayManagerClass *class)
object_class->finalize = gdk_x11_display_manager_finalize;
manager_class->open_display = gdk_x11_display_manager_open_display;
manager_class->list_displays = gdk_x11_display_manager_list_displays;
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;
manager_class->get_keyval_name = _gdk_x11_display_manager_get_keyval_name;
manager_class->keyval_convert_case = _gdk_x11_display_manager_keyval_convert_case;
}
void
_gdk_x11_display_manager_add_display (GdkDisplayManager *manager,
GdkDisplay *display)
{
GdkX11DisplayManager *manager_x11 = GDK_X11_DISPLAY_MANAGER (manager);
manager_x11->displays = g_slist_prepend (manager_x11->displays, display);
}
void
_gdk_x11_display_manager_remove_display (GdkDisplayManager *manager,
GdkDisplay *display)
{
GdkX11DisplayManager *manager_x11 = GDK_X11_DISPLAY_MANAGER (manager);
manager_x11->displays = g_slist_remove (manager_x11->displays, 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);
else
gdk_display_manager_set_default_display (manager, NULL);
}
}
......@@ -247,11 +247,6 @@ void _gdk_device_xi2_reset_scroll_valuators (GdkX11DeviceXI2 *device);
void _gdk_x11_event_translate_keyboard_string (GdkEventKey *event);
void _gdk_x11_display_manager_add_display (GdkDisplayManager *manager,
GdkDisplay *display);
void _gdk_x11_display_manager_remove_display (GdkDisplayManager *manager,
GdkDisplay *display);
GdkAtom _gdk_x11_display_manager_atom_intern (GdkDisplayManager *manager,
const gchar *atom_name,
gboolean copy_name);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment