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
1=== modified file 'plugins/unityshell/src/LauncherController.cpp'
2--- plugins/unityshell/src/LauncherController.cpp 2012-02-12 10:43:11 +0000
3+++ plugins/unityshell/src/LauncherController.cpp 2012-02-29 03:53:18 +0000
4@@ -908,9 +908,9 @@
5 pimpl->launcher_label_show_handler_id_ = g_timeout_add(local::shortcuts_show_delay, show_shortcuts, pimpl);
6 }
7
8-void Controller::HandleLauncherKeyRelease()
9+void Controller::HandleLauncherKeyRelease(bool was_tap)
10 {
11- if (pimpl->TapTimeUnderLimit())
12+ if (pimpl->TapTimeUnderLimit() && was_tap)
13 {
14 pimpl->SendHomeActivationRequest();
15 }
16
17=== modified file 'plugins/unityshell/src/LauncherController.h'
18--- plugins/unityshell/src/LauncherController.h 2012-02-12 10:43:11 +0000
19+++ plugins/unityshell/src/LauncherController.h 2012-02-29 03:53:18 +0000
20@@ -60,7 +60,7 @@
21 void SetShowDesktopIcon(bool show_desktop_icon);
22
23 void HandleLauncherKeyPress();
24- void HandleLauncherKeyRelease();
25+ void HandleLauncherKeyRelease(bool was_tap);
26 bool HandleLauncherKeyEvent(Display *display,
27 unsigned int key_sym,
28 unsigned long key_code,
29
30=== modified file 'plugins/unityshell/src/unityshell.cpp'
31--- plugins/unityshell/src/unityshell.cpp 2012-02-28 08:29:22 +0000
32+++ plugins/unityshell/src/unityshell.cpp 2012-02-29 03:53:18 +0000
33@@ -89,7 +89,12 @@
34 gboolean is_extension_supported(const gchar* extensions, const gchar* extension);
35 gfloat get_opengl_version_f32(const gchar* version_string);
36
37-}
38+namespace local
39+{
40+// Tap duration in milliseconds.
41+const int ALT_TAP_DURATION = 250;
42+} // namespace local
43+} // anon namespace
44
45 UnityScreen::UnityScreen(CompScreen* screen)
46 : BaseSwitchScreen (screen)
47@@ -1501,11 +1506,11 @@
48 if (state & CompAction::StateCancel)
49 return false;
50
51- bool accept_state = (state & CompAction::StateCancel) == 0;
52+ bool was_tap = state & CompAction::StateTermTapped;
53
54 super_keypressed_ = false;
55- launcher_controller_->KeyNavTerminate(accept_state);
56- launcher_controller_->HandleLauncherKeyRelease();
57+ launcher_controller_->KeyNavTerminate(true);
58+ launcher_controller_->HandleLauncherKeyRelease(was_tap);
59 EnableCancelAction(false);
60
61 shortcut_controller_->SetEnabled(enable_shortcut_overlay_);
62@@ -1770,41 +1775,55 @@
63 PluginAdapter::Default ()->restoreInputFocus ();
64 }
65
66-bool UnityScreen::ShowHudInitiate(CompAction* action, CompAction::State state, CompOption::Vector& options)
67+bool UnityScreen::ShowHudInitiate(CompAction* action,
68+ CompAction::State state,
69+ CompOption::Vector& options)
70 {
71 // to receive the Terminate event
72 if (state & CompAction::StateInitKey)
73- action->setState(action->state() | CompAction::StateTermKey);
74-
75+ action->setState(action->state() | CompAction::StateTermKey);
76 last_hud_show_time_ = g_get_monotonic_time();
77
78 return false;
79 }
80
81-bool UnityScreen::ShowHudTerminate(CompAction* action, CompAction::State state, CompOption::Vector& options)
82+bool UnityScreen::ShowHudTerminate(CompAction* action,
83+ CompAction::State state,
84+ CompOption::Vector& options)
85 {
86- if (optionGetShowHud().key().toString() == action->key().toString())
87- {
88- if (switcher_controller_->Visible())
89- return false; // early exit if the switcher is open
90-
91- gint64 current_time = g_get_monotonic_time();
92- if (current_time - last_hud_show_time_ < 150 * 1000)
93- {
94- if (hud_controller_->IsVisible())
95- {
96- ubus_manager_.SendMessage(UBUS_HUD_CLOSE_REQUEST);
97- }
98- else
99- {
100- hud_controller_->ShowHud();
101- }
102- last_hud_show_time_ = 0;
103- }
104- }
105+ // Remember StateCancel and StateCommit will be broadcast to all actions
106+ // so we need to verify that we are actually being toggled...
107+ if (!(state & CompAction::StateTermKey))
108+ return false;
109
110 action->setState(action->state() & ~CompAction::StateTermKey);
111
112+ // And only respond to key taps
113+ if (!(state & CompAction::StateTermTapped))
114+ return false;
115+
116+ gint64 current_time = g_get_monotonic_time();
117+ if (current_time - last_hud_show_time_ > (local::ALT_TAP_DURATION * 1000))
118+ {
119+ LOG_DEBUG(logger) << "Tap too long";
120+ return false;
121+ }
122+
123+ if (switcher_controller_->Visible())
124+ {
125+ LOG_ERROR(logger) << "this should never happen";
126+ return false; // early exit if the switcher is open
127+ }
128+
129+ if (hud_controller_->IsVisible())
130+ {
131+ ubus_manager_.SendMessage(UBUS_HUD_CLOSE_REQUEST);
132+ }
133+ else
134+ {
135+ hud_controller_->ShowHud();
136+ }
137+
138 return false;
139 }
140
141
142=== modified file 'tests/autopilot/autopilot/emulators/unity/hud.py'
143--- tests/autopilot/autopilot/emulators/unity/hud.py 2012-02-27 20:57:20 +0000
144+++ tests/autopilot/autopilot/emulators/unity/hud.py 2012-02-29 03:53:18 +0000
145@@ -28,6 +28,6 @@
146 self.refresh_state()
147 return self.visible
148
149- def toggle_reveal(self):
150+ def toggle_reveal(self, tap_delay=0.1):
151 """Tap the 'Alt' key to toggle the hud visibility."""
152- self.keybinding("hud/reveal", 0.1)
153+ self.keybinding("hud/reveal", tap_delay)
154
155=== modified file 'tests/autopilot/autopilot/tests/test_hud.py'
156--- tests/autopilot/autopilot/tests/test_hud.py 2012-02-20 01:12:01 +0000
157+++ tests/autopilot/autopilot/tests/test_hud.py 2012-02-29 03:53:18 +0000
158@@ -33,26 +33,44 @@
159 num_active += 1
160 return num_active
161
162+ def test_initially_hidden(self):
163+ hud = self.get_hud_controller()
164+ self.assertFalse(hud.is_visible())
165+
166+ def test_reveal_hud(self):
167+ hud = self.get_hud_controller()
168+ hud.toggle_reveal()
169+ self.addCleanup(hud.toggle_reveal)
170+ self.assertTrue(hud.is_visible())
171+
172+ def test_slow_tap_not_reveal_hud(self):
173+ hud = self.get_hud_controller()
174+ hud.toggle_reveal(tap_delay=0.3)
175+ self.assertFalse(hud.is_visible())
176+
177+ def test_alt_f4_doesnt_show_hud(self):
178+ hud = self.get_hud_controller()
179+ self.start_app('Calculator')
180+ sleep(1)
181+ # Do a very fast Alt+F4
182+ self.keyboard.press_and_release("Alt+F4", 0.05)
183+ self.assertFalse(hud.is_visible())
184+
185 def test_reveal_hud_with_no_apps(self):
186 """Hud must show even with no visible applications."""
187- controller = self.get_hud_controller()
188-
189- self.assertFalse(controller.visible)
190- kb = Keyboard()
191- kb.press_and_release("Ctrl+Alt+d")
192- self.addCleanup(kb.press_and_release, "Ctrl+Alt+d")
193- sleep(1)
194-
195- # we need a *fast* keypress to reveal the hud:
196- kb.press_and_release("Alt", delay=0.1)
197- sleep(1)
198- controller.refresh_state()
199- self.assertTrue(controller.visible)
200-
201- kb.press_and_release("Alt", delay=0.1)
202- sleep(1)
203- controller.refresh_state()
204- self.assertFalse(controller.visible)
205+ hud = self.get_hud_controller()
206+
207+ self.keyboard.press_and_release("Ctrl+Alt+d")
208+ self.addCleanup(self.keyboard.press_and_release, "Ctrl+Alt+d")
209+ sleep(1)
210+
211+ hud.toggle_reveal()
212+ sleep(1)
213+ self.assertTrue(hud.is_visible())
214+
215+ hud.toggle_reveal()
216+ sleep(1)
217+ self.assertFalse(hud.is_visible())
218
219 def test_multiple_hud_reveal_does_not_break_launcher(self):
220 """Multiple Hud reveals must not cause the launcher to set multiple
221@@ -61,15 +79,12 @@
222 """
223 hud_controller = self.get_hud_controller()
224 launcher = Launcher()
225- bamf = Bamf()
226
227 # We need an app to switch to:
228- bamf.launch_application("gucharmap.desktop")
229- self.addCleanup(call, ["killall", "gucharmap"])
230-
231+ self.start_app('Character Map')
232 # We need an application to play with - I'll use the calculator.
233- bamf.launch_application("gcalctool.desktop")
234- self.addCleanup(call, ["killall", "gcalctool"])
235+ self.start_app('Calculator')
236+ sleep(1)
237
238 # before we start, make sure there's only one active icon:
239 num_active = self.get_num_active_launcher_icons(launcher)