Merge lp:~thumper/unity/hud-alt-tap into lp:unity

Proposed by Tim Penhey
Status: Merged
Approved by: Didier Roche-Tolomelli
Approved revision: no longer in the source branch.
Merged at revision: 2041
Proposed branch: lp:~thumper/unity/hud-alt-tap
Merge into: lp:unity
Diff against target: 239 lines (+90/-56)
5 files modified
plugins/unityshell/src/LauncherController.cpp (+2/-2)
plugins/unityshell/src/LauncherController.h (+1/-1)
plugins/unityshell/src/unityshell.cpp (+46/-27)
tests/autopilot/autopilot/emulators/unity/hud.py (+2/-2)
tests/autopilot/autopilot/tests/test_hud.py (+39/-24)
To merge this branch: bzr merge lp:~thumper/unity/hud-alt-tap
Reviewer Review Type Date Requested Status
Thomi Richards (community) Approve
Mirco Müller (community) Approve
Review via email: mp+93331@code.launchpad.net

Commit message

Uses the new modifier-tap ability in compiz to only show the HUD if someone hasn't used another key with alt (or the associated key).

Description of the change

Uses the new modifier-tap ability in compiz to only show the HUD if someone hasn't used another key with alt (or the associated key).

Needs lp:compiz-core r3003 or above.

UNBLOCK

To post a comment you must log in.
Revision history for this message
Mirco Müller (macslow) wrote :

I like these kind of lines :)

  LOG_ERROR(logger) << "this should never happen";

review: Approve
Revision history for this message
Unity Merger (unity-merger) wrote :

The Jenkins job https://jenkins.qa.ubuntu.com/job/automerge-unity/336/console reported an error when processing this lp:~thumper/unity/hud-alt-tap branch.
Not merging it.

Revision history for this message
Tim Penhey (thumper) wrote :

Moving this to work in progress until the compiz branch is ready.

Revision history for this message
Thomi Richards (thomir-deactivatedaccount) wrote :

My name is Thomi, and I approve this merge proposal.

review: Approve
Revision history for this message
Unity Merger (unity-merger) wrote :

The Jenkins job https://jenkins.qa.ubuntu.com/job/automerge-unity/365/console reported an error when processing this lp:~thumper/unity/hud-alt-tap branch.
Not merging it.

Revision history for this message
Thomi Richards (thomir-deactivatedaccount) wrote :

Still looks damn sexy.

review: Approve
Revision history for this message
Unity Merger (unity-merger) wrote :

The Jenkins job https://jenkins.qa.ubuntu.com/job/automerge-unity/368/console reported an error when processing this lp:~thumper/unity/hud-alt-tap branch.
Not merging it.

Revision history for this message
Didier Roche-Tolomelli (didrocks) wrote :

The bot will recognize its master ;)

Revision history for this message
Unity Merger (unity-merger) wrote :

The Jenkins job https://jenkins.qa.ubuntu.com/job/automerge-unity/370/console reported an error when processing this lp:~thumper/unity/hud-alt-tap branch.
Not merging it.

Revision history for this message
Didier Roche-Tolomelli (didrocks) wrote :

for the record: it took 17 minutes for compiz uploaded in the staging ppa once built to be available to the QA lab (proxy/mirroring issue?). Anyway, to avoid such skews, I think that shows that adding compiz to the autolanding process is needed.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'plugins/unityshell/src/LauncherController.cpp'
--- plugins/unityshell/src/LauncherController.cpp 2012-02-12 10:43:11 +0000
+++ plugins/unityshell/src/LauncherController.cpp 2012-02-29 03:53:18 +0000
@@ -908,9 +908,9 @@
908 pimpl->launcher_label_show_handler_id_ = g_timeout_add(local::shortcuts_show_delay, show_shortcuts, pimpl);908 pimpl->launcher_label_show_handler_id_ = g_timeout_add(local::shortcuts_show_delay, show_shortcuts, pimpl);
909}909}
910910
911void Controller::HandleLauncherKeyRelease()911void Controller::HandleLauncherKeyRelease(bool was_tap)
912{912{
913 if (pimpl->TapTimeUnderLimit())913 if (pimpl->TapTimeUnderLimit() && was_tap)
914 {914 {
915 pimpl->SendHomeActivationRequest();915 pimpl->SendHomeActivationRequest();
916 }916 }
917917
=== modified file 'plugins/unityshell/src/LauncherController.h'
--- plugins/unityshell/src/LauncherController.h 2012-02-12 10:43:11 +0000
+++ plugins/unityshell/src/LauncherController.h 2012-02-29 03:53:18 +0000
@@ -60,7 +60,7 @@
60 void SetShowDesktopIcon(bool show_desktop_icon);60 void SetShowDesktopIcon(bool show_desktop_icon);
6161
62 void HandleLauncherKeyPress();62 void HandleLauncherKeyPress();
63 void HandleLauncherKeyRelease();63 void HandleLauncherKeyRelease(bool was_tap);
64 bool HandleLauncherKeyEvent(Display *display, 64 bool HandleLauncherKeyEvent(Display *display,
65 unsigned int key_sym, 65 unsigned int key_sym,
66 unsigned long key_code, 66 unsigned long key_code,
6767
=== modified file 'plugins/unityshell/src/unityshell.cpp'
--- plugins/unityshell/src/unityshell.cpp 2012-02-28 08:29:22 +0000
+++ plugins/unityshell/src/unityshell.cpp 2012-02-29 03:53:18 +0000
@@ -89,7 +89,12 @@
89gboolean is_extension_supported(const gchar* extensions, const gchar* extension);89gboolean is_extension_supported(const gchar* extensions, const gchar* extension);
90gfloat get_opengl_version_f32(const gchar* version_string);90gfloat get_opengl_version_f32(const gchar* version_string);
9191
92}92namespace local
93{
94// Tap duration in milliseconds.
95const int ALT_TAP_DURATION = 250;
96} // namespace local
97} // anon namespace
9398
94UnityScreen::UnityScreen(CompScreen* screen)99UnityScreen::UnityScreen(CompScreen* screen)
95 : BaseSwitchScreen (screen)100 : BaseSwitchScreen (screen)
@@ -1501,11 +1506,11 @@
1501 if (state & CompAction::StateCancel)1506 if (state & CompAction::StateCancel)
1502 return false;1507 return false;
15031508
1504 bool accept_state = (state & CompAction::StateCancel) == 0;1509 bool was_tap = state & CompAction::StateTermTapped;
15051510
1506 super_keypressed_ = false;1511 super_keypressed_ = false;
1507 launcher_controller_->KeyNavTerminate(accept_state);1512 launcher_controller_->KeyNavTerminate(true);
1508 launcher_controller_->HandleLauncherKeyRelease();1513 launcher_controller_->HandleLauncherKeyRelease(was_tap);
1509 EnableCancelAction(false);1514 EnableCancelAction(false);
15101515
1511 shortcut_controller_->SetEnabled(enable_shortcut_overlay_);1516 shortcut_controller_->SetEnabled(enable_shortcut_overlay_);
@@ -1770,41 +1775,55 @@
1770 PluginAdapter::Default ()->restoreInputFocus ();1775 PluginAdapter::Default ()->restoreInputFocus ();
1771}1776}
17721777
1773bool UnityScreen::ShowHudInitiate(CompAction* action, CompAction::State state, CompOption::Vector& options)1778bool UnityScreen::ShowHudInitiate(CompAction* action,
1779 CompAction::State state,
1780 CompOption::Vector& options)
1774{1781{
1775 // to receive the Terminate event1782 // to receive the Terminate event
1776 if (state & CompAction::StateInitKey)1783 if (state & CompAction::StateInitKey)
1777 action->setState(action->state() | CompAction::StateTermKey); 1784 action->setState(action->state() | CompAction::StateTermKey);
1778
1779 last_hud_show_time_ = g_get_monotonic_time();1785 last_hud_show_time_ = g_get_monotonic_time();
17801786
1781 return false;1787 return false;
1782}1788}
17831789
1784bool UnityScreen::ShowHudTerminate(CompAction* action, CompAction::State state, CompOption::Vector& options)1790bool UnityScreen::ShowHudTerminate(CompAction* action,
1791 CompAction::State state,
1792 CompOption::Vector& options)
1785{1793{
1786 if (optionGetShowHud().key().toString() == action->key().toString())1794 // Remember StateCancel and StateCommit will be broadcast to all actions
1787 {1795 // so we need to verify that we are actually being toggled...
1788 if (switcher_controller_->Visible())1796 if (!(state & CompAction::StateTermKey))
1789 return false; // early exit if the switcher is open1797 return false;
1790
1791 gint64 current_time = g_get_monotonic_time();
1792 if (current_time - last_hud_show_time_ < 150 * 1000)
1793 {
1794 if (hud_controller_->IsVisible())
1795 {
1796 ubus_manager_.SendMessage(UBUS_HUD_CLOSE_REQUEST);
1797 }
1798 else
1799 {
1800 hud_controller_->ShowHud();
1801 }
1802 last_hud_show_time_ = 0;
1803 }
1804 }
18051798
1806 action->setState(action->state() & ~CompAction::StateTermKey);1799 action->setState(action->state() & ~CompAction::StateTermKey);
18071800
1801 // And only respond to key taps
1802 if (!(state & CompAction::StateTermTapped))
1803 return false;
1804
1805 gint64 current_time = g_get_monotonic_time();
1806 if (current_time - last_hud_show_time_ > (local::ALT_TAP_DURATION * 1000))
1807 {
1808 LOG_DEBUG(logger) << "Tap too long";
1809 return false;
1810 }
1811
1812 if (switcher_controller_->Visible())
1813 {
1814 LOG_ERROR(logger) << "this should never happen";
1815 return false; // early exit if the switcher is open
1816 }
1817
1818 if (hud_controller_->IsVisible())
1819 {
1820 ubus_manager_.SendMessage(UBUS_HUD_CLOSE_REQUEST);
1821 }
1822 else
1823 {
1824 hud_controller_->ShowHud();
1825 }
1826
1808 return false;1827 return false;
1809}1828}
18101829
18111830
=== modified file 'tests/autopilot/autopilot/emulators/unity/hud.py'
--- tests/autopilot/autopilot/emulators/unity/hud.py 2012-02-27 20:57:20 +0000
+++ tests/autopilot/autopilot/emulators/unity/hud.py 2012-02-29 03:53:18 +0000
@@ -28,6 +28,6 @@
28 self.refresh_state()28 self.refresh_state()
29 return self.visible29 return self.visible
3030
31 def toggle_reveal(self):31 def toggle_reveal(self, tap_delay=0.1):
32 """Tap the 'Alt' key to toggle the hud visibility."""32 """Tap the 'Alt' key to toggle the hud visibility."""
33 self.keybinding("hud/reveal", 0.1)33 self.keybinding("hud/reveal", tap_delay)
3434
=== modified file 'tests/autopilot/autopilot/tests/test_hud.py'
--- tests/autopilot/autopilot/tests/test_hud.py 2012-02-20 01:12:01 +0000
+++ tests/autopilot/autopilot/tests/test_hud.py 2012-02-29 03:53:18 +0000
@@ -33,26 +33,44 @@
33 num_active += 133 num_active += 1
34 return num_active34 return num_active
3535
36 def test_initially_hidden(self):
37 hud = self.get_hud_controller()
38 self.assertFalse(hud.is_visible())
39
40 def test_reveal_hud(self):
41 hud = self.get_hud_controller()
42 hud.toggle_reveal()
43 self.addCleanup(hud.toggle_reveal)
44 self.assertTrue(hud.is_visible())
45
46 def test_slow_tap_not_reveal_hud(self):
47 hud = self.get_hud_controller()
48 hud.toggle_reveal(tap_delay=0.3)
49 self.assertFalse(hud.is_visible())
50
51 def test_alt_f4_doesnt_show_hud(self):
52 hud = self.get_hud_controller()
53 self.start_app('Calculator')
54 sleep(1)
55 # Do a very fast Alt+F4
56 self.keyboard.press_and_release("Alt+F4", 0.05)
57 self.assertFalse(hud.is_visible())
58
36 def test_reveal_hud_with_no_apps(self):59 def test_reveal_hud_with_no_apps(self):
37 """Hud must show even with no visible applications."""60 """Hud must show even with no visible applications."""
38 controller = self.get_hud_controller()61 hud = self.get_hud_controller()
3962
40 self.assertFalse(controller.visible)63 self.keyboard.press_and_release("Ctrl+Alt+d")
41 kb = Keyboard()64 self.addCleanup(self.keyboard.press_and_release, "Ctrl+Alt+d")
42 kb.press_and_release("Ctrl+Alt+d")65 sleep(1)
43 self.addCleanup(kb.press_and_release, "Ctrl+Alt+d")66
44 sleep(1)67 hud.toggle_reveal()
4568 sleep(1)
46 # we need a *fast* keypress to reveal the hud:69 self.assertTrue(hud.is_visible())
47 kb.press_and_release("Alt", delay=0.1)70
48 sleep(1)71 hud.toggle_reveal()
49 controller.refresh_state()72 sleep(1)
50 self.assertTrue(controller.visible)73 self.assertFalse(hud.is_visible())
51
52 kb.press_and_release("Alt", delay=0.1)
53 sleep(1)
54 controller.refresh_state()
55 self.assertFalse(controller.visible)
5674
57 def test_multiple_hud_reveal_does_not_break_launcher(self):75 def test_multiple_hud_reveal_does_not_break_launcher(self):
58 """Multiple Hud reveals must not cause the launcher to set multiple76 """Multiple Hud reveals must not cause the launcher to set multiple
@@ -61,15 +79,12 @@
61 """79 """
62 hud_controller = self.get_hud_controller()80 hud_controller = self.get_hud_controller()
63 launcher = Launcher()81 launcher = Launcher()
64 bamf = Bamf()
6582
66 # We need an app to switch to:83 # We need an app to switch to:
67 bamf.launch_application("gucharmap.desktop")84 self.start_app('Character Map')
68 self.addCleanup(call, ["killall", "gucharmap"])
69
70 # We need an application to play with - I'll use the calculator.85 # We need an application to play with - I'll use the calculator.
71 bamf.launch_application("gcalctool.desktop")86 self.start_app('Calculator')
72 self.addCleanup(call, ["killall", "gcalctool"])87 sleep(1)
7388
74 # before we start, make sure there's only one active icon:89 # before we start, make sure there's only one active icon:
75 num_active = self.get_num_active_launcher_icons(launcher)90 num_active = self.get_num_active_launcher_icons(launcher)