display: Emit signals when opening and closing X11 display

This is needed so that other parts can initialize and deinitialize X11
dependent functionality.

https://bugzilla.gnome.org/show_bug.cgi?id=759538
This commit is contained in:
Jonas Ådahl 2018-06-30 08:55:48 +02:00
parent 3d2b9a3a69
commit 522f9b4c38

View File

@ -118,6 +118,8 @@ G_DEFINE_TYPE(MetaDisplay, meta_display, G_TYPE_OBJECT);
/* Signals */ /* Signals */
enum enum
{ {
X11_DISPLAY_OPENED,
X11_DISPLAY_CLOSING,
OVERLAY_KEY, OVERLAY_KEY,
ACCELERATOR_ACTIVATED, ACCELERATOR_ACTIVATED,
MODIFIERS_ACCELERATOR_ACTIVATED, MODIFIERS_ACCELERATOR_ACTIVATED,
@ -206,6 +208,22 @@ meta_display_class_init (MetaDisplayClass *klass)
object_class->get_property = meta_display_get_property; object_class->get_property = meta_display_get_property;
object_class->set_property = meta_display_set_property; object_class->set_property = meta_display_set_property;
display_signals[X11_DISPLAY_OPENED] =
g_signal_new ("x11-display-opened",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
0,
NULL, NULL, NULL,
G_TYPE_NONE, 0);
display_signals[X11_DISPLAY_CLOSING] =
g_signal_new ("x11-display-closing",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
0,
NULL, NULL, NULL,
G_TYPE_NONE, 0);
display_signals[OVERLAY_KEY] = display_signals[OVERLAY_KEY] =
g_signal_new ("overlay-key", g_signal_new ("overlay-key",
G_TYPE_FROM_CLASS (klass), G_TYPE_FROM_CLASS (klass),
@ -673,6 +691,7 @@ meta_display_open (void)
x11_display = meta_x11_display_new (display, &error); x11_display = meta_x11_display_new (display, &error);
g_assert (x11_display != NULL); /* Required, for now */ g_assert (x11_display != NULL); /* Required, for now */
display->x11_display = x11_display; display->x11_display = x11_display;
g_signal_emit (display, display_signals[X11_DISPLAY_OPENED], 0);
/* here we use XDisplayName which is what the user /* here we use XDisplayName which is what the user
* probably put in, vs. DisplayString(display) which is * probably put in, vs. DisplayString(display) which is
@ -1170,6 +1189,7 @@ meta_display_close (MetaDisplay *display,
if (display->x11_display) if (display->x11_display)
{ {
g_signal_emit (display, display_signals[X11_DISPLAY_CLOSING], 0);
g_object_run_dispose (G_OBJECT (display->x11_display)); g_object_run_dispose (G_OBJECT (display->x11_display));
g_clear_object (&display->x11_display); g_clear_object (&display->x11_display);
} }