From f30794f3a73d3174ec671d01e0b4cb914c6b7cef Mon Sep 17 00:00:00 2001 From: Dustin Falgout Date: Wed, 28 Oct 2015 03:15:29 -0500 Subject: [PATCH] fade out animation for sigterm callback --- src/lightdm-webkit2-greeter-ext.c | 28 -------------------------- src/lightdm-webkit2-greeter.c | 33 ++++++++++++++++++++++++------- 2 files changed, 26 insertions(+), 35 deletions(-) diff --git a/src/lightdm-webkit2-greeter-ext.c b/src/lightdm-webkit2-greeter-ext.c index b53ade7..47524a6 100644 --- a/src/lightdm-webkit2-greeter-ext.c +++ b/src/lightdm-webkit2-greeter-ext.c @@ -1030,28 +1030,6 @@ authentication_complete_cb(LightDMGreeter *greeter, WebKitWebExtension *extensio } } -static gboolean -fade_timer_cb(gpointer data) { - gdouble opacity; - - opacity = gtk_widget_get_opacity(window); - opacity -= 0.1; - if (opacity <= 0) { - gtk_main_quit(); - return FALSE; - } - gtk_widget_set_opacity(window, opacity); - - return TRUE; -} - -static void -quit_cb(LightDMGreeter *greeter, const gchar *username) { - - // Fade out the greeter - g_timeout_add(40, (GSourceFunc) fade_timer_cb, NULL); -} - G_MODULE_EXPORT void webkit_web_extension_initialize(WebKitWebExtension *extension) { @@ -1063,12 +1041,6 @@ webkit_web_extension_initialize(WebKitWebExtension *extension) { g_signal_connect(G_OBJECT(greeter), "show-prompt", G_CALLBACK(show_prompt_cb), extension); g_signal_connect(G_OBJECT(greeter), "show-message", G_CALLBACK(show_message_cb), extension); - /* TODO: Find the best way to send quit signal to the main window from our web-extension (probably dbus). - * g_signal_connect(G_OBJECT(greeter), "quit", G_CALLBACK(quit_cb), extension); - */ - - /* g_signal_connect(extension, "page-created", G_CALLBACK(web_page_created_callback), NULL); */ - g_signal_connect(webkit_script_world_get_default(), "window-object-cleared", G_CALLBACK(window_object_cleared_callback), greeter); diff --git a/src/lightdm-webkit2-greeter.c b/src/lightdm-webkit2-greeter.c index 760aaec..216fa53 100644 --- a/src/lightdm-webkit2-greeter.c +++ b/src/lightdm-webkit2-greeter.c @@ -48,11 +48,6 @@ static GtkWidget *window; static WebKitSettings *webkit_settings; -static void -sigterm_cb(int signum) { - exit(0); -} - static GdkFilterReturn wm_window_filter(GdkXEvent *gxevent, GdkEvent *event, gpointer data) { @@ -62,7 +57,8 @@ wm_window_filter(GdkXEvent *gxevent, GdkEvent *event, gpointer data) { GdkWindow *win = gdk_x11_window_foreign_new_for_display(display, xevent->xmap.window); GdkWindowTypeHint win_type = gdk_window_get_type_hint(win); - if (win_type != GDK_WINDOW_TYPE_HINT_COMBO && win_type != GDK_WINDOW_TYPE_HINT_TOOLTIP + if (win_type != GDK_WINDOW_TYPE_HINT_COMBO + && win_type != GDK_WINDOW_TYPE_HINT_TOOLTIP && win_type != GDK_WINDOW_TYPE_HINT_NOTIFICATION) { gdk_window_focus(win, GDK_CURRENT_TIME); @@ -114,6 +110,29 @@ context_menu_cb(WebKitWebView *web_view, return TRUE; } +static gboolean +fade_timer_cb(gpointer data) { + gdouble opacity; + + opacity = gtk_widget_get_opacity(window); + opacity -= 0.1; + if (opacity <= 0) { + gtk_main_quit(); + return FALSE; + } + gtk_widget_set_opacity(window, opacity); + + return TRUE; +} + +static void +quit_cb(void) { + + // Fade out the greeter + g_timeout_add(40, (GSourceFunc) fade_timer_cb, NULL); +} + + int main(int argc, char **argv) { GdkScreen *screen; @@ -123,7 +142,7 @@ main(int argc, char **argv) { gchar *theme; GdkRGBA bg_color; - g_unix_signal_add(SIGTERM, (GSourceFunc) sigterm_cb, /* is_callback */ GINT_TO_POINTER(TRUE)); + g_unix_signal_add(SIGTERM, (GSourceFunc) quit_cb, /* is_callback */ GINT_TO_POINTER(TRUE)); gtk_init(&argc, &argv);