Merge lp:~brandontschaefer/unity/lp1086988-fix-x-focus-dash-hud-xim into lp:unity

Proposed by Brandon Schaefer
Status: Merged
Approved by: Andrea Azzarone
Approved revision: no longer in the source branch.
Merged at revision: 2978
Proposed branch: lp:~brandontschaefer/unity/lp1086988-fix-x-focus-dash-hud-xim
Merge into: lp:unity
Diff against target: 218 lines (+59/-27)
6 files modified
dash/DashController.cpp (+22/-9)
dash/DashController.h (+4/-0)
hud/HudController.cpp (+20/-8)
hud/HudController.h (+3/-0)
plugins/unityshell/src/unityshell.cpp (+10/-5)
tests/autopilot/unity/tests/xim/test_gcin.py (+0/-5)
To merge this branch: bzr merge lp:~brandontschaefer/unity/lp1086988-fix-x-focus-dash-hud-xim
Reviewer Review Type Date Requested Status
Andrea Azzarone (community) Approve
PS Jenkins bot continuous-integration Pending
Review via email: mp+138617@code.launchpad.net

Commit message

The Dash/HUD have X focus when open now, instead of the launcher.

Description of the change

=== Problem ===
When the Dash or Hud was open, the launcher would have X focus. This means events generated by X would think the launcher is focused. This causes problems when trying to use XIM, as it think the Launcher is generating events not the Dash or Hud, so XIM fails to work.

=== Fix ===
Make it re focus the key input for the dash or hud when an external application is opened when the Dash/Hud is open.

=== Test ===
Removing the explicit skip in XIM tests, as they all pass now, and skip correctly if no gcin is found.

Video showing hime (An input method) in action.
http://ubuntuone.com/7lZkpPRRJklEsMMJJ4HWcX

To post a comment you must log in.
Revision history for this message
Andrea Azzarone (azzar1) wrote :

Works here.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'dash/DashController.cpp'
2--- dash/DashController.cpp 2012-12-11 23:36:53 +0000
3+++ dash/DashController.cpp 2012-12-13 01:36:21 +0000
4@@ -308,6 +308,19 @@
5
6 view_->AboutToShow();
7
8+ FocusWindow();
9+
10+ need_show_ = false;
11+ visible_ = true;
12+
13+ StartShowHideTimeline();
14+
15+ GVariant* info = g_variant_new(UBUS_OVERLAY_FORMAT_STRING, "dash", TRUE, monitor_);
16+ ubus_manager_.SendMessage(UBUS_OVERLAY_SHOWN, info);
17+}
18+
19+void Controller::FocusWindow()
20+{
21 window_->ShowWindow(true);
22 window_->PushToFront();
23 if (!Settings::Instance().is_standalone) // in standalone mode, we do not need an input window. we are one.
24@@ -317,18 +330,9 @@
25 window_->UpdateInputWindowGeometry();
26 }
27 window_->SetInputFocus();
28- window_->CaptureMouseDownAnyWhereElse(true);
29 window_->QueueDraw();
30
31 nux::GetWindowCompositor().SetKeyFocusArea(view_->default_focus());
32-
33- need_show_ = false;
34- visible_ = true;
35-
36- StartShowHideTimeline();
37-
38- GVariant* info = g_variant_new(UBUS_OVERLAY_FORMAT_STRING, "dash", TRUE, monitor_);
39- ubus_manager_.SendMessage(UBUS_OVERLAY_SHOWN, info);
40 }
41
42 void Controller::HideDash(bool restore)
43@@ -427,6 +431,15 @@
44 .add("monitor", monitor_);
45 }
46
47+void Controller::ReFocusKeyInput()
48+{
49+ if (visible_)
50+ {
51+ window_->PushToFront();
52+ window_->SetInputFocus();
53+ }
54+}
55+
56 bool Controller::IsVisible() const
57 {
58 return visible_;
59
60=== modified file 'dash/DashController.h'
61--- dash/DashController.h 2012-12-11 23:36:53 +0000
62+++ dash/DashController.h 2012-12-13 01:36:21 +0000
63@@ -61,6 +61,8 @@
64 void HideDash(bool restore_focus = true);
65 void ShowDash();
66
67+ void ReFocusKeyInput();
68+
69 bool IsVisible() const;
70 nux::Geometry GetInputWindowGeometry();
71
72@@ -84,6 +86,8 @@
73 void OnExternalHideDash(GVariant* variant);
74 void OnActivateRequest(GVariant* variant);
75
76+ void FocusWindow();
77+
78 void StartShowHideTimeline();
79 void OnViewShowHideFrame(double progress);
80
81
82=== modified file 'hud/HudController.cpp'
83--- hud/HudController.cpp 2012-12-11 23:37:17 +0000
84+++ hud/HudController.cpp 2012-12-13 01:36:21 +0000
85@@ -302,6 +302,15 @@
86 visible_ ? HideHud(true) : ShowHud();
87 }
88
89+void Controller::ReFocusKeyInput()
90+{
91+ if (visible_)
92+ {
93+ window_->PushToFront();
94+ window_->SetInputFocus();
95+ }
96+}
97+
98 bool Controller::IsVisible()
99 {
100 return visible_;
101@@ -351,14 +360,7 @@
102 LOG_DEBUG(logger) << "Taking application icon: " << focused_app_icon_;
103 SetIcon(focused_app_icon_);
104
105- window_->ShowWindow(true);
106- window_->PushToFront();
107- window_->EnableInputWindow(true, "Hud", true, false);
108- window_->UpdateInputWindowGeometry();
109- window_->SetInputFocus();
110- window_->CaptureMouseDownAnyWhereElse(true);
111- view_->CaptureMouseDownAnyWhereElse(true);
112- window_->QueueDraw();
113+ FocusWindow();
114
115 view_->ResetToDefault();
116 need_show_ = true;
117@@ -376,6 +378,16 @@
118 window_->SetEnterFocusInputArea(view_->default_focus());
119 }
120
121+void Controller::FocusWindow()
122+{
123+ window_->ShowWindow(true);
124+ window_->PushToFront();
125+ window_->EnableInputWindow(true, "Hud", true, false);
126+ window_->UpdateInputWindowGeometry();
127+ window_->SetInputFocus();
128+ window_->QueueDraw();
129+}
130+
131 void Controller::HideHud(bool restore)
132 {
133 LOG_DEBUG (logger) << "hiding the hud";
134
135=== modified file 'hud/HudController.h'
136--- hud/HudController.h 2012-12-11 23:37:17 +0000
137+++ hud/HudController.h 2012-12-13 01:36:21 +0000
138@@ -61,6 +61,7 @@
139 void ShowHideHud();
140 void ShowHud();
141 void HideHud(bool restore_focus = true);
142+ void ReFocusKeyInput();
143 bool IsVisible();
144
145 nux::Geometry GetInputWindowGeometry();
146@@ -77,6 +78,8 @@
147 void RegisterUBusInterests();
148 void SetIcon(std::string const& icon_name);
149
150+ void FocusWindow();
151+
152 int GetIdealMonitor();
153 bool IsLockedToLauncher(int monitor);
154
155
156=== modified file 'plugins/unityshell/src/unityshell.cpp'
157--- plugins/unityshell/src/unityshell.cpp 2012-12-07 04:21:35 +0000
158+++ plugins/unityshell/src/unityshell.cpp 2012-12-13 01:36:21 +0000
159@@ -2729,12 +2729,17 @@
160 {
161 UnityScreen* us = UnityScreen::get(screen);
162
163- // can't rely on launcher->IsOverlayVisible on focus change (because ubus is async close on focus change.)
164- if (us && (us->dash_controller_->IsVisible() || us->hud_controller_->IsVisible()))
165+ // If focus gets moved to an external program while the Dash/Hud is open, refocus key input.
166+ if (us)
167 {
168- CompWindow *lw;
169- lw = screen->findWindow(us->launcher_controller_->LauncherWindowId(0));
170- lw->moveInputFocusTo();
171+ if (us->dash_controller_->IsVisible())
172+ {
173+ us->dash_controller_->ReFocusKeyInput();
174+ }
175+ else if (us->hud_controller_->IsVisible())
176+ {
177+ us->hud_controller_->ReFocusKeyInput();
178+ }
179 }
180 }
181 }
182
183=== modified file 'tests/autopilot/unity/tests/xim/test_gcin.py'
184--- tests/autopilot/unity/tests/xim/test_gcin.py 2012-10-11 01:44:15 +0000
185+++ tests/autopilot/unity/tests/xim/test_gcin.py 2012-12-13 01:36:21 +0000
186@@ -19,7 +19,6 @@
187 class GcinTestCase(UnityTestCase):
188 """Tests the Input Method gcin."""
189
190- @skip("Currenlty no XIM support in Nux")
191 def setUp(self):
192 super(GcinTestCase, self).setUp()
193
194@@ -44,17 +43,14 @@
195 ('national script', {'input': 'gug mun ', 'result': u'\uad6d\ubb38'}),
196 ]
197
198- @skip("Currenlty no XIM support in Nux")
199 def setUp(self):
200 super(GcinTestHangul, self).setUp()
201
202- @skip("Currenlty no XIM support in Nux")
203 def enter_hangul_mode(self):
204 """Ctrl+Space turns gcin on, Ctrl+Alt+/ turns hangul on."""
205 self.keyboard.press_and_release("Ctrl+Space")
206 self.keyboard.press_and_release("Ctrl+Alt+/")
207
208- @skip("Currenlty no XIM support in Nux")
209 def test_dash_input(self):
210 """Entering an input string through gcin will result in a Korean string result in the dash."""
211
212@@ -65,7 +61,6 @@
213 self.keyboard.type(self.input)
214 self.assertThat(self.dash.search_string, Eventually(Equals(self.result)))
215
216- @skip("Currenlty no XIM support in Nux")
217 def test_hud_input(self):
218 """Entering an input string through gcin will result in a Korean string result in the hud."""
219