Make bell and libstartup-notification bits work without X11

https://bugzilla.gnome.org/show_bug.cgi?id=759538
This commit is contained in:
Armin Krezović
2017-08-26 22:35:18 +02:00
committed by Jonas Ådahl
parent 8adab02757
commit 9333a6da75
8 changed files with 245 additions and 152 deletions

View File

@ -528,11 +528,6 @@ meta_startup_notification_finalize (GObject *object)
{
MetaStartupNotification *sn = META_STARTUP_NOTIFICATION (object);
#ifdef HAVE_STARTUP_NOTIFICATION
sn_monitor_context_unref (sn->sn_context);
sn_display_unref (sn->sn_display);
#endif
if (sn->startup_sequence_timeout)
g_source_remove (sn->startup_sequence_timeout);
@ -660,6 +655,33 @@ meta_startup_notification_sn_event (SnMonitorEvent *event,
sn_startup_sequence_unref (sequence);
}
static void
on_x11_display_opened (MetaStartupNotification *sn)
{
MetaX11Display *x11_display = sn->display->x11_display;
sn->sn_display = sn_display_new (x11_display->xdisplay,
sn_error_trap_push,
sn_error_trap_pop);
sn->sn_context =
sn_monitor_context_new (sn->sn_display,
meta_x11_display_get_screen_number (x11_display),
meta_startup_notification_sn_event,
sn,
NULL);
}
static void
on_x11_display_closing (MetaStartupNotification *sn)
{
sn_monitor_context_unref (sn->sn_context);
sn->sn_context = NULL;
sn_display_unref (sn->sn_display);
sn->sn_display = NULL;
}
#endif
static void
@ -670,16 +692,22 @@ meta_startup_notification_constructed (GObject *object)
g_assert (sn->display != NULL);
#ifdef HAVE_STARTUP_NOTIFICATION
sn->sn_display = sn_display_new (sn->display->x11_display->xdisplay,
sn_error_trap_push,
sn_error_trap_pop);
sn->sn_context =
sn_monitor_context_new (sn->sn_display,
meta_ui_get_screen_number (),
meta_startup_notification_sn_event,
sn,
NULL);
sn->sn_display = NULL;
sn->sn_context = NULL;
g_signal_connect_object (sn->display,
"x11-display-opened",
G_CALLBACK (on_x11_display_opened),
sn,
G_CONNECT_SWAPPED);
g_signal_connect_object (sn->display,
"x11-display-closing",
G_CALLBACK (on_x11_display_closing),
sn,
G_CONNECT_SWAPPED);
#endif
sn->startup_sequences = NULL;
sn->startup_sequence_timeout = 0;
}
@ -753,6 +781,9 @@ meta_startup_notification_get_sequences (MetaStartupNotification *sn)
#ifdef HAVE_STARTUP_NOTIFICATION
GSList *l;
if (!sn->sn_display)
return sequences;
/* We return a list of SnStartupSequences here */
for (l = sn->startup_sequences; l; l = l->next)
{