Merge lp:~kalgasnik/lightdm-gtk-greeter/focus_fix into lp:~lightdm-gtk-greeter-team/lightdm-gtk-greeter/trunk

Proposed by Andrew P.
Status: Merged
Merged at revision: 159
Proposed branch: lp:~kalgasnik/lightdm-gtk-greeter/focus_fix
Merge into: lp:~lightdm-gtk-greeter-team/lightdm-gtk-greeter/trunk
Diff against target: 67 lines (+50/-0)
1 file modified
src/lightdm-gtk-greeter.c (+50/-0)
To merge this branch: bzr merge lp:~kalgasnik/lightdm-gtk-greeter/focus_fix
Reviewer Review Type Date Requested Status
Sean Davis Approve
Review via email: mp+199652@code.launchpad.net

Description of the change

Switching focus between greeter windows is not handled correctly .
Open/close shutdown dialog to reproduce it - only window under cursor can have focus (and catch keys press, so you can close this dialog using "escape" key only when dialog is under cursor).
The solution for this problem is taken (copy/paste) from unity-greeter.

To post a comment you must log in.
Revision history for this message
Sean Davis (bluesabre) wrote :

Also looks good, merged. I'll be doing a release with all the new features you've added soon. Thanks so much!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/lightdm-gtk-greeter.c'
2--- src/lightdm-gtk-greeter.c 2013-12-13 02:56:06 +0000
3+++ src/lightdm-gtk-greeter.c 2013-12-19 12:01:59 +0000
4@@ -1748,6 +1748,51 @@
5 return x != NULL;
6 }
7
8+static GdkFilterReturn
9+focus_upon_map (GdkXEvent *gxevent, GdkEvent *event, gpointer data)
10+{
11+ XEvent* xevent = (XEvent*)gxevent;
12+ if (xevent->type == MapNotify)
13+ {
14+ Window xwin = xevent->xmap.window;
15+ Window keyboard_xid = 0;
16+ GdkDisplay* display = gdk_x11_lookup_xdisplay (xevent->xmap.display);
17+ GdkWindow* win = gdk_x11_window_foreign_new_for_display (display, xwin);
18+ GdkWindow* keyboard_win = onboard_window ? gtk_widget_get_window (GTK_WIDGET (onboard_window)) : NULL;
19+
20+ /* Check to see if this window is our onboard window, since we don't want to focus it. */
21+ if (keyboard_win)
22+#if GTK_CHECK_VERSION (3, 0, 0)
23+ keyboard_xid = gdk_x11_window_get_xid (keyboard_win);
24+#else
25+ keyboard_xid = gdk_x11_drawable_get_xid (keyboard_win);
26+#endif
27+
28+ if (xwin != keyboard_xid && gdk_window_get_type_hint (win) != GDK_WINDOW_TYPE_HINT_NOTIFICATION)
29+ {
30+ gdk_window_focus (win, GDK_CURRENT_TIME);
31+ /* Make sure to keep keyboard above */
32+ if (onboard_window)
33+ gdk_window_raise (keyboard_win);
34+ }
35+ }
36+ else if (xevent->type == UnmapNotify)
37+ {
38+ Window xwin;
39+ int revert_to;
40+ XGetInputFocus (xevent->xunmap.display, &xwin, &revert_to);
41+
42+ if (revert_to == RevertToNone)
43+ {
44+ gdk_window_focus (gtk_widget_get_window (GTK_WIDGET (login_window)), GDK_CURRENT_TIME);
45+ /* Make sure to keep keyboard above */
46+ if (onboard_window)
47+ gdk_window_raise (gtk_widget_get_window (GTK_WIDGET (onboard_window)));
48+ }
49+ }
50+ return GDK_FILTER_CONTINUE;
51+}
52+
53 int
54 main (int argc, char **argv)
55 {
56@@ -2221,6 +2266,11 @@
57
58 gdk_threads_add_timeout( 100, (GSourceFunc) clock_timeout_thread, NULL );
59
60+ /* focus fix (source: unity-greeter) */
61+ GdkWindow* root_window = gdk_get_default_root_window ();
62+ gdk_window_set_events (root_window, gdk_window_get_events (root_window) | GDK_SUBSTRUCTURE_MASK);
63+ gdk_window_add_filter (root_window, focus_upon_map, NULL);
64+
65 #if GTK_CHECK_VERSION (3, 0, 0)
66 #else
67 gdk_threads_enter();

Subscribers

People subscribed via source and target branches