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
=== modified file 'dash/DashController.cpp'
--- dash/DashController.cpp 2012-12-11 23:36:53 +0000
+++ dash/DashController.cpp 2012-12-13 01:36:21 +0000
@@ -308,6 +308,19 @@
308308
309 view_->AboutToShow();309 view_->AboutToShow();
310310
311 FocusWindow();
312
313 need_show_ = false;
314 visible_ = true;
315
316 StartShowHideTimeline();
317
318 GVariant* info = g_variant_new(UBUS_OVERLAY_FORMAT_STRING, "dash", TRUE, monitor_);
319 ubus_manager_.SendMessage(UBUS_OVERLAY_SHOWN, info);
320}
321
322void Controller::FocusWindow()
323{
311 window_->ShowWindow(true);324 window_->ShowWindow(true);
312 window_->PushToFront();325 window_->PushToFront();
313 if (!Settings::Instance().is_standalone) // in standalone mode, we do not need an input window. we are one.326 if (!Settings::Instance().is_standalone) // in standalone mode, we do not need an input window. we are one.
@@ -317,18 +330,9 @@
317 window_->UpdateInputWindowGeometry();330 window_->UpdateInputWindowGeometry();
318 }331 }
319 window_->SetInputFocus();332 window_->SetInputFocus();
320 window_->CaptureMouseDownAnyWhereElse(true);
321 window_->QueueDraw();333 window_->QueueDraw();
322334
323 nux::GetWindowCompositor().SetKeyFocusArea(view_->default_focus());335 nux::GetWindowCompositor().SetKeyFocusArea(view_->default_focus());
324
325 need_show_ = false;
326 visible_ = true;
327
328 StartShowHideTimeline();
329
330 GVariant* info = g_variant_new(UBUS_OVERLAY_FORMAT_STRING, "dash", TRUE, monitor_);
331 ubus_manager_.SendMessage(UBUS_OVERLAY_SHOWN, info);
332}336}
333337
334void Controller::HideDash(bool restore)338void Controller::HideDash(bool restore)
@@ -427,6 +431,15 @@
427 .add("monitor", monitor_);431 .add("monitor", monitor_);
428}432}
429433
434void Controller::ReFocusKeyInput()
435{
436 if (visible_)
437 {
438 window_->PushToFront();
439 window_->SetInputFocus();
440 }
441}
442
430bool Controller::IsVisible() const443bool Controller::IsVisible() const
431{444{
432 return visible_;445 return visible_;
433446
=== modified file 'dash/DashController.h'
--- dash/DashController.h 2012-12-11 23:36:53 +0000
+++ dash/DashController.h 2012-12-13 01:36:21 +0000
@@ -61,6 +61,8 @@
61 void HideDash(bool restore_focus = true);61 void HideDash(bool restore_focus = true);
62 void ShowDash();62 void ShowDash();
6363
64 void ReFocusKeyInput();
65
64 bool IsVisible() const;66 bool IsVisible() const;
65 nux::Geometry GetInputWindowGeometry();67 nux::Geometry GetInputWindowGeometry();
6668
@@ -84,6 +86,8 @@
84 void OnExternalHideDash(GVariant* variant);86 void OnExternalHideDash(GVariant* variant);
85 void OnActivateRequest(GVariant* variant);87 void OnActivateRequest(GVariant* variant);
8688
89 void FocusWindow();
90
87 void StartShowHideTimeline();91 void StartShowHideTimeline();
88 void OnViewShowHideFrame(double progress);92 void OnViewShowHideFrame(double progress);
8993
9094
=== modified file 'hud/HudController.cpp'
--- hud/HudController.cpp 2012-12-11 23:37:17 +0000
+++ hud/HudController.cpp 2012-12-13 01:36:21 +0000
@@ -302,6 +302,15 @@
302 visible_ ? HideHud(true) : ShowHud();302 visible_ ? HideHud(true) : ShowHud();
303}303}
304304
305void Controller::ReFocusKeyInput()
306{
307 if (visible_)
308 {
309 window_->PushToFront();
310 window_->SetInputFocus();
311 }
312}
313
305bool Controller::IsVisible()314bool Controller::IsVisible()
306{315{
307 return visible_;316 return visible_;
@@ -351,14 +360,7 @@
351 LOG_DEBUG(logger) << "Taking application icon: " << focused_app_icon_;360 LOG_DEBUG(logger) << "Taking application icon: " << focused_app_icon_;
352 SetIcon(focused_app_icon_);361 SetIcon(focused_app_icon_);
353362
354 window_->ShowWindow(true);363 FocusWindow();
355 window_->PushToFront();
356 window_->EnableInputWindow(true, "Hud", true, false);
357 window_->UpdateInputWindowGeometry();
358 window_->SetInputFocus();
359 window_->CaptureMouseDownAnyWhereElse(true);
360 view_->CaptureMouseDownAnyWhereElse(true);
361 window_->QueueDraw();
362364
363 view_->ResetToDefault();365 view_->ResetToDefault();
364 need_show_ = true;366 need_show_ = true;
@@ -376,6 +378,16 @@
376 window_->SetEnterFocusInputArea(view_->default_focus());378 window_->SetEnterFocusInputArea(view_->default_focus());
377}379}
378380
381void Controller::FocusWindow()
382{
383 window_->ShowWindow(true);
384 window_->PushToFront();
385 window_->EnableInputWindow(true, "Hud", true, false);
386 window_->UpdateInputWindowGeometry();
387 window_->SetInputFocus();
388 window_->QueueDraw();
389}
390
379void Controller::HideHud(bool restore)391void Controller::HideHud(bool restore)
380{392{
381 LOG_DEBUG (logger) << "hiding the hud";393 LOG_DEBUG (logger) << "hiding the hud";
382394
=== modified file 'hud/HudController.h'
--- hud/HudController.h 2012-12-11 23:37:17 +0000
+++ hud/HudController.h 2012-12-13 01:36:21 +0000
@@ -61,6 +61,7 @@
61 void ShowHideHud();61 void ShowHideHud();
62 void ShowHud();62 void ShowHud();
63 void HideHud(bool restore_focus = true);63 void HideHud(bool restore_focus = true);
64 void ReFocusKeyInput();
64 bool IsVisible();65 bool IsVisible();
6566
66 nux::Geometry GetInputWindowGeometry();67 nux::Geometry GetInputWindowGeometry();
@@ -77,6 +78,8 @@
77 void RegisterUBusInterests();78 void RegisterUBusInterests();
78 void SetIcon(std::string const& icon_name);79 void SetIcon(std::string const& icon_name);
7980
81 void FocusWindow();
82
80 int GetIdealMonitor();83 int GetIdealMonitor();
81 bool IsLockedToLauncher(int monitor);84 bool IsLockedToLauncher(int monitor);
8285
8386
=== modified file 'plugins/unityshell/src/unityshell.cpp'
--- plugins/unityshell/src/unityshell.cpp 2012-12-07 04:21:35 +0000
+++ plugins/unityshell/src/unityshell.cpp 2012-12-13 01:36:21 +0000
@@ -2729,12 +2729,17 @@
2729 {2729 {
2730 UnityScreen* us = UnityScreen::get(screen);2730 UnityScreen* us = UnityScreen::get(screen);
27312731
2732 // can't rely on launcher->IsOverlayVisible on focus change (because ubus is async close on focus change.)2732 // If focus gets moved to an external program while the Dash/Hud is open, refocus key input.
2733 if (us && (us->dash_controller_->IsVisible() || us->hud_controller_->IsVisible()))2733 if (us)
2734 {2734 {
2735 CompWindow *lw;2735 if (us->dash_controller_->IsVisible())
2736 lw = screen->findWindow(us->launcher_controller_->LauncherWindowId(0));2736 {
2737 lw->moveInputFocusTo();2737 us->dash_controller_->ReFocusKeyInput();
2738 }
2739 else if (us->hud_controller_->IsVisible())
2740 {
2741 us->hud_controller_->ReFocusKeyInput();
2742 }
2738 }2743 }
2739 }2744 }
2740}2745}
27412746
=== modified file 'tests/autopilot/unity/tests/xim/test_gcin.py'
--- tests/autopilot/unity/tests/xim/test_gcin.py 2012-10-11 01:44:15 +0000
+++ tests/autopilot/unity/tests/xim/test_gcin.py 2012-12-13 01:36:21 +0000
@@ -19,7 +19,6 @@
19class GcinTestCase(UnityTestCase):19class GcinTestCase(UnityTestCase):
20 """Tests the Input Method gcin."""20 """Tests the Input Method gcin."""
2121
22 @skip("Currenlty no XIM support in Nux")
23 def setUp(self):22 def setUp(self):
24 super(GcinTestCase, self).setUp()23 super(GcinTestCase, self).setUp()
2524
@@ -44,17 +43,14 @@
44 ('national script', {'input': 'gug mun ', 'result': u'\uad6d\ubb38'}),43 ('national script', {'input': 'gug mun ', 'result': u'\uad6d\ubb38'}),
45 ]44 ]
4645
47 @skip("Currenlty no XIM support in Nux")
48 def setUp(self):46 def setUp(self):
49 super(GcinTestHangul, self).setUp()47 super(GcinTestHangul, self).setUp()
5048
51 @skip("Currenlty no XIM support in Nux")
52 def enter_hangul_mode(self):49 def enter_hangul_mode(self):
53 """Ctrl+Space turns gcin on, Ctrl+Alt+/ turns hangul on."""50 """Ctrl+Space turns gcin on, Ctrl+Alt+/ turns hangul on."""
54 self.keyboard.press_and_release("Ctrl+Space")51 self.keyboard.press_and_release("Ctrl+Space")
55 self.keyboard.press_and_release("Ctrl+Alt+/")52 self.keyboard.press_and_release("Ctrl+Alt+/")
5653
57 @skip("Currenlty no XIM support in Nux")
58 def test_dash_input(self):54 def test_dash_input(self):
59 """Entering an input string through gcin will result in a Korean string result in the dash."""55 """Entering an input string through gcin will result in a Korean string result in the dash."""
6056
@@ -65,7 +61,6 @@
65 self.keyboard.type(self.input)61 self.keyboard.type(self.input)
66 self.assertThat(self.dash.search_string, Eventually(Equals(self.result)))62 self.assertThat(self.dash.search_string, Eventually(Equals(self.result)))
6763
68 @skip("Currenlty no XIM support in Nux")
69 def test_hud_input(self):64 def test_hud_input(self):
70 """Entering an input string through gcin will result in a Korean string result in the hud."""65 """Entering an input string through gcin will result in a Korean string result in the hud."""
7166