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

Proposed by Michael Terry
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 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.
Revision history for this message
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
432. By Michael Terry

Make sure to not focus our onscreen keyboard

Revision history for this message
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
=== modified file 'src/main-window.vala'
--- src/main-window.vala 2012-04-16 08:33:55 +0000
+++ src/main-window.vala 2012-05-30 15:45:26 +0000
@@ -21,10 +21,10 @@
21public class MainWindow : Gtk.Window21public class MainWindow : Gtk.Window
22{22{
23 public UserList user_list;23 public UserList user_list;
24 public MenuBar menubar;
2425
25 private List<Monitor> monitors;26 private List<Monitor> monitors;
26 private Background background;27 private Background background;
27 private MenuBar menubar;
28 private Gtk.Box login_box;28 private Gtk.Box login_box;
2929
30 private uint change_background_timeout = 0;30 private uint change_background_timeout = 0;
3131
=== modified file 'src/menubar.vala'
--- src/menubar.vala 2012-03-21 20:00:39 +0000
+++ src/menubar.vala 2012-05-30 15:45:26 +0000
@@ -67,6 +67,7 @@
67{67{
68 public Background? background {get; construct; default = null;}68 public Background? background {get; construct; default = null;}
69 public bool high_contrast {get; private set; default = false;}69 public bool high_contrast {get; private set; default = false;}
70 public Gtk.Window? keyboard_window {get; private set; default = null;}
7071
71 public Gtk.AccelGroup? accel_group {get; construct;}72 public Gtk.AccelGroup? accel_group {get; construct;}
7273
@@ -121,7 +122,6 @@
121 private Gtk.CheckMenuItem high_contrast_item;122 private Gtk.CheckMenuItem high_contrast_item;
122 private Gtk.Label keyboard_label = null;123 private Gtk.Label keyboard_label = null;
123 private Pid keyboard_pid = 0;124 private Pid keyboard_pid = 0;
124 private Gtk.Window? keyboard_window = null;
125125
126 construct126 construct
127 {127 {
128128
=== modified file 'src/unity-greeter.vala'
--- src/unity-greeter.vala 2012-05-29 16:40:24 +0000
+++ src/unity-greeter.vala 2012-05-30 15:45:26 +0000
@@ -43,7 +43,7 @@
4343
44 private SettingsDaemon settings_daemon;44 private SettingsDaemon settings_daemon;
4545
46 private MainWindow main_window;46 private static MainWindow main_window;
47 public UserList user_list;47 public UserList user_list;
4848
49 private LightDM.Greeter greeter;49 private LightDM.Greeter greeter;
@@ -686,17 +686,23 @@
686 }686 }
687 }687 }
688688
689 private Gdk.FilterReturn focus_upon_map (X.Event xevent, Gdk.Event event)689 private static Gdk.FilterReturn focus_upon_map (Gdk.XEvent gxevent, Gdk.Event event)
690 {690 {
691 var xevent = (X.Event*)gxevent;
691 if (xevent.type == X.EventType.MapNotify)692 if (xevent.type == X.EventType.MapNotify)
692 {693 {
693 var display = Gdk.Display.get_default ();694 var display = Gdk.Display.get_default ();
694 var win = Gdk.X11Window.foreign_new_for_display (display, xevent.xmap.window);695 var xwin = xevent.xmap.window;
695696 var win = Gdk.X11Window.foreign_new_for_display (display, xwin);
696 if (win.get_accept_focus ())697
698 // Check to see if this window is our onboard window, since we
699 // don't want to focus it.
700 X.Window keyboard_xid = 0;
701 if (main_window.menubar.keyboard_window != null)
702 keyboard_xid = Gdk.X11Window.get_xid (main_window.menubar.keyboard_window.get_window ());
703
704 if (xwin != keyboard_xid)
697 win.focus (Gdk.CURRENT_TIME);705 win.focus (Gdk.CURRENT_TIME);
698 else
699 user_list.focus_prompt ();
700 }706 }
701 return Gdk.FilterReturn.CONTINUE;707 return Gdk.FilterReturn.CONTINUE;
702 }708 }
@@ -709,7 +715,7 @@
709 continuing even if not actually marked as modal) */715 continuing even if not actually marked as modal) */
710 var root = Gdk.get_default_root_window ();716 var root = Gdk.get_default_root_window ();
711 root.set_events (root.get_events () | Gdk.EventMask.SUBSTRUCTURE_MASK);717 root.set_events (root.get_events () | Gdk.EventMask.SUBSTRUCTURE_MASK);
712 root.add_filter ((Gdk.FilterFunc) focus_upon_map);718 root.add_filter (focus_upon_map);
713 }719 }
714720
715 private static Cairo.XlibSurface? create_root_surface (Gdk.Screen screen)721 private static Cairo.XlibSurface? create_root_surface (Gdk.Screen screen)

Subscribers

People subscribed via source and target branches