Merge lp:~mterry/unity-greeter/fix-focus into lp:unity-greeter

Proposed by Michael Terry on 2012-05-29
Status: Merged
Merged at revision: 516
Proposed branch: lp:~mterry/unity-greeter/fix-focus
Merge into: lp:unity-greeter
Diff against target: 87 lines (+16/-10)
3 files modified
src/main-window.vala (+1/-1)
src/menubar.vala (+1/-1)
src/unity-greeter.vala (+14/-8)
To merge this branch: bzr merge lp:~mterry/unity-greeter/fix-focus
Reviewer Review Type Date Requested Status
Unity Greeter Development Team 2012-05-29 Pending
Review via email: mp+107859@code.launchpad.net

Description of the change

There are two problems currently with the focus-on-map logic:

1) The signature of the function was wrong, so vala was expecting the *this* pointer as the first argument, when it should have been expecting an XEvent pointer. This made our check for what type of event it was incorrect.

2) We shouldn't try to see if the window has requested not to be focused on map. For some reason, the shutdown dialog does that (though in my Unity session, compiz does focus it on map). This must be one of those vagaries of window managers. It doesn't hurt to focus everything as it comes by.

To post a comment you must log in.
Robert Ancell (robert-ancell) wrote :

Can you check this works with onboard? That code was changed so onboard didn't get focus:
http://bazaar.launchpad.net/~unity-greeter-team/unity-greeter/trunk/revision/363.1.1

lp:~mterry/unity-greeter/fix-focus updated on 2012-05-30
432. By Michael Terry on 2012-05-30

Make sure to not focus our onscreen keyboard

Michael Terry (mterry) wrote :

Fixed now. Please review again.

I found that we couldn't seem to rely on the types and flags of foreign GdkWindows, but since we do keep track of the xid of the onboard window we create, I used that to detect whether the new window was the onboard one.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/main-window.vala'
2--- src/main-window.vala 2012-04-16 08:33:55 +0000
3+++ src/main-window.vala 2012-05-30 15:45:26 +0000
4@@ -21,10 +21,10 @@
5 public class MainWindow : Gtk.Window
6 {
7 public UserList user_list;
8+ public MenuBar menubar;
9
10 private List<Monitor> monitors;
11 private Background background;
12- private MenuBar menubar;
13 private Gtk.Box login_box;
14
15 private uint change_background_timeout = 0;
16
17=== modified file 'src/menubar.vala'
18--- src/menubar.vala 2012-03-21 20:00:39 +0000
19+++ src/menubar.vala 2012-05-30 15:45:26 +0000
20@@ -67,6 +67,7 @@
21 {
22 public Background? background {get; construct; default = null;}
23 public bool high_contrast {get; private set; default = false;}
24+ public Gtk.Window? keyboard_window {get; private set; default = null;}
25
26 public Gtk.AccelGroup? accel_group {get; construct;}
27
28@@ -121,7 +122,6 @@
29 private Gtk.CheckMenuItem high_contrast_item;
30 private Gtk.Label keyboard_label = null;
31 private Pid keyboard_pid = 0;
32- private Gtk.Window? keyboard_window = null;
33
34 construct
35 {
36
37=== modified file 'src/unity-greeter.vala'
38--- src/unity-greeter.vala 2012-05-29 16:40:24 +0000
39+++ src/unity-greeter.vala 2012-05-30 15:45:26 +0000
40@@ -43,7 +43,7 @@
41
42 private SettingsDaemon settings_daemon;
43
44- private MainWindow main_window;
45+ private static MainWindow main_window;
46 public UserList user_list;
47
48 private LightDM.Greeter greeter;
49@@ -686,17 +686,23 @@
50 }
51 }
52
53- private Gdk.FilterReturn focus_upon_map (X.Event xevent, Gdk.Event event)
54+ private static Gdk.FilterReturn focus_upon_map (Gdk.XEvent gxevent, Gdk.Event event)
55 {
56+ var xevent = (X.Event*)gxevent;
57 if (xevent.type == X.EventType.MapNotify)
58 {
59 var display = Gdk.Display.get_default ();
60- var win = Gdk.X11Window.foreign_new_for_display (display, xevent.xmap.window);
61-
62- if (win.get_accept_focus ())
63+ var xwin = xevent.xmap.window;
64+ var win = Gdk.X11Window.foreign_new_for_display (display, xwin);
65+
66+ // Check to see if this window is our onboard window, since we
67+ // don't want to focus it.
68+ X.Window keyboard_xid = 0;
69+ if (main_window.menubar.keyboard_window != null)
70+ keyboard_xid = Gdk.X11Window.get_xid (main_window.menubar.keyboard_window.get_window ());
71+
72+ if (xwin != keyboard_xid)
73 win.focus (Gdk.CURRENT_TIME);
74- else
75- user_list.focus_prompt ();
76 }
77 return Gdk.FilterReturn.CONTINUE;
78 }
79@@ -709,7 +715,7 @@
80 continuing even if not actually marked as modal) */
81 var root = Gdk.get_default_root_window ();
82 root.set_events (root.get_events () | Gdk.EventMask.SUBSTRUCTURE_MASK);
83- root.add_filter ((Gdk.FilterFunc) focus_upon_map);
84+ root.add_filter (focus_upon_map);
85 }
86
87 private static Cairo.XlibSurface? create_root_surface (Gdk.Screen screen)

Subscribers

People subscribed via source and target branches