diff --git a/src/lightdm-webkit2-greeter-ext.c b/src/lightdm-webkit2-greeter-ext.c index b98695c..a46744e 100644 --- a/src/lightdm-webkit2-greeter-ext.c +++ b/src/lightdm-webkit2-greeter-ext.c @@ -1042,7 +1042,6 @@ webkit_web_extension_initialize(WebKitWebExtension *extension) { g_signal_connect(G_OBJECT(greeter), "authentication-complete", G_CALLBACK(authentication_complete_cb), 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); - g_signal_connect(G_OBJECT(greeter), "show-error", G_CALLBACK(show_message_cb), extension); // 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); diff --git a/src/lightdm-webkit2-greeter.c b/src/lightdm-webkit2-greeter.c index b1ed6f3..48c093a 100644 --- a/src/lightdm-webkit2-greeter.c +++ b/src/lightdm-webkit2-greeter.c @@ -14,6 +14,9 @@ #include #include +#include +#include +#include #include #include #include @@ -43,6 +46,38 @@ sigterm_cb (int signum) exit (0); } +static GdkFilterReturn +wm_window_filter (GdkXEvent *gxevent, GdkEvent *event, gpointer data) +{ + XEvent *xevent = (XEvent*)gxevent; + if (xevent->type == MapNotify) + { + GdkDisplay *display = gdk_x11_lookup_xdisplay (xevent->xmap.display); + 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 && + win_type != GDK_WINDOW_TYPE_HINT_NOTIFICATION) + /* + if (win_type == GDK_WINDOW_TYPE_HINT_DESKTOP || + win_type == GDK_WINDOW_TYPE_HINT_DIALOG) + */ + gdk_window_focus (win, GDK_CURRENT_TIME); + } + else if (xevent->type == UnmapNotify) + { + Window xwin; + int revert_to = RevertToNone; + + XGetInputFocus (xevent->xunmap.display, &xwin, &revert_to); + if (revert_to == RevertToNone) + gdk_window_lower (gtk_widget_get_window (gtk_widget_get_toplevel (GTK_WIDGET (screen_overlay)))); + } + + return GDK_FILTER_CONTINUE; +} + int main(int argc, char **argv) { GdkScreen *screen; @@ -87,6 +122,11 @@ main(int argc, char **argv) { webkit_web_view_load_uri(WEBKIT_WEB_VIEW(web_view), g_strdup_printf("file://%s/%s/index.html", THEME_DIR, theme)); + /* There is no window manager, so we need to implement some of its functionality */ + GdkWindow* root_window = gdk_get_default_root_window (); + gdk_window_set_events (root_window, gdk_window_get_events (root_window) | GDK_SUBSTRUCTURE_MASK); + gdk_window_add_filter (root_window, wm_window_filter, NULL); + gtk_widget_show_all(window); gtk_main();