Merge lp:~3v1n0/unity/flickerless-alt+f10-on-keydown into lp:unity

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Tim Penhey
Approved revision: no longer in the source branch.
Merged at revision: 2161
Proposed branch: lp:~3v1n0/unity/flickerless-alt+f10-on-keydown
Merge into: lp:unity
Diff against target: 219 lines (+56/-48)
7 files modified
manual-tests/PanelIndicators.txt (+21/-0)
plugins/unityshell/src/PanelController.cpp (+10/-33)
plugins/unityshell/src/PanelController.h (+1/-2)
plugins/unityshell/src/PanelView.cpp (+5/-6)
plugins/unityshell/src/PanelView.h (+1/-2)
plugins/unityshell/src/unityshell.cpp (+17/-5)
plugins/unityshell/src/unityshell.h (+1/-0)
To merge this branch: bzr merge lp:~3v1n0/unity/flickerless-alt+f10-on-keydown
Reviewer Review Type Date Requested Status
Daniel van Vugt Needs Information
Tim Penhey (community) Approve
Review via email: mp+98918@code.launchpad.net

Commit message

Open the Menus Indicators on ButtonPress avoiding flickers

Now the indicator menus shows once Alt+F10 keybinding has been pressed, and is not anymore needed to release the Alt key.
Also, fixed the panel issue reported in bug #948522 that could happen when using menus. To avoid it we use now a timeout to filter the events that we can ignore not to make unity-panel-service crazy.

Description of the change

Open the Menus Indicators on ButtonPress avoiding flickers

UNBLOCK as requested by didrocks

To post a comment you must log in.
Revision history for this message
Tim Penhey (thumper) wrote :

The code looks fine.

review: Approve
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

3v1n0, your fix for this bug is missing the safety check to avoid crashing on Alt+Enter. Like we did for:
https://code.launchpad.net/~vanvugt/unity/fix-960957/+merge/98593

I wonder if that's going to be a problem?...

review: Needs Information
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

No, I thought about that while doing it, but I didn't include the check since it seems to cause troubles only on terminate cb, and we don't use that here.
On initiate, the action should be properly filled.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'manual-tests/PanelIndicators.txt'
2--- manual-tests/PanelIndicators.txt 2011-12-08 04:48:50 +0000
3+++ manual-tests/PanelIndicators.txt 2012-03-22 20:28:25 +0000
4@@ -25,3 +25,24 @@
5
6 Outcome
7 Window buttons should appear.
8+
9+
10+Open Indicators from Keyboard
11+-----------------------------
12+This test shows how indicators can be opened via keyboard bindings.
13+
14+#. Start a clean screen
15+#. Press Alt+F10
16+
17+Outcome
18+ The menu of the first indicator visible (looking left to right)
19+ should pop-up on keydown (once F10 has been pressed).
20+ Pressing Alt+F10 again or clicking in an empty area of the screen should close it.
21+
22+#. Start an application window with menus
23+#. Press Alt+F10
24+
25+Outcome
26+ The first menu of the window (looking left to right) should pop-up on keydown
27+ (once F10 has been pressed). Pressing Alt+F10 again or clicking in an empty area
28+ of the screenshould pop down it.
29
30=== modified file 'plugins/unityshell/src/PanelController.cpp'
31--- plugins/unityshell/src/PanelController.cpp 2012-03-21 12:31:11 +0000
32+++ plugins/unityshell/src/PanelController.cpp 2012-03-22 20:28:25 +0000
33@@ -43,8 +43,7 @@
34 Impl();
35 ~Impl();
36
37- void StartFirstMenuShow();
38- void EndFirstMenuShow();
39+ void FirstMenuShow();
40 void QueueRedraw();
41
42 unsigned int GetTrayXid();
43@@ -72,7 +71,6 @@
44 std::vector<nux::BaseWindow*> windows_;
45 float opacity_;
46 bool opacity_maximized_toggle_;
47- bool open_menu_start_received_;
48 int menus_fadein_;
49 int menus_fadeout_;
50 int menus_discovery_;
51@@ -84,7 +82,6 @@
52 Controller::Impl::Impl()
53 : opacity_(1.0f)
54 , opacity_maximized_toggle_(false)
55- , open_menu_start_received_(false)
56 , menus_fadein_(0)
57 , menus_fadeout_(0)
58 , menus_discovery_(0)
59@@ -121,27 +118,12 @@
60 return geometries;
61 }
62
63-void Controller::Impl::StartFirstMenuShow()
64-{
65- for (auto window: windows_)
66- {
67- PanelView* view = ViewForWindow(window);
68- view->StartFirstMenuShow();
69- }
70-
71- open_menu_start_received_ = true;
72-}
73-
74-void Controller::Impl::EndFirstMenuShow()
75-{
76- if (!open_menu_start_received_)
77- return;
78- open_menu_start_received_ = false;
79-
80- for (auto window: windows_)
81- {
82- PanelView* view = ViewForWindow(window);
83- view->EndFirstMenuShow();
84+void Controller::Impl::FirstMenuShow()
85+{
86+ for (auto window: windows_)
87+ {
88+ if (ViewForWindow(window)->FirstMenuShow())
89+ break;
90 }
91 }
92
93@@ -317,14 +299,9 @@
94 delete pimpl;
95 }
96
97-void Controller::StartFirstMenuShow()
98-{
99- pimpl->StartFirstMenuShow();
100-}
101-
102-void Controller::EndFirstMenuShow()
103-{
104- pimpl->EndFirstMenuShow();
105+void Controller::FirstMenuShow()
106+{
107+ pimpl->FirstMenuShow();
108 }
109
110 void Controller::SetOpacity(float opacity)
111
112=== modified file 'plugins/unityshell/src/PanelController.h'
113--- plugins/unityshell/src/PanelController.h 2012-03-21 12:31:11 +0000
114+++ plugins/unityshell/src/PanelController.h 2012-03-22 20:28:25 +0000
115@@ -39,8 +39,7 @@
116 Controller();
117 ~Controller();
118
119- void StartFirstMenuShow();
120- void EndFirstMenuShow();
121+ void FirstMenuShow();
122 void QueueRedraw();
123
124 unsigned int GetTrayXid ();
125
126=== modified file 'plugins/unityshell/src/PanelView.cpp'
127--- plugins/unityshell/src/PanelView.cpp 2012-03-21 12:31:11 +0000
128+++ plugins/unityshell/src/PanelView.cpp 2012-03-22 20:28:25 +0000
129@@ -637,18 +637,17 @@
130 //
131 // Useful Public Methods
132 //
133-void PanelView::StartFirstMenuShow()
134+bool PanelView::FirstMenuShow()
135 {
136-}
137+ bool ret = false;
138
139-void PanelView::EndFirstMenuShow()
140-{
141 if (!_menu_view->GetControlsActive())
142- return;
143+ return ret;
144
145- bool ret;
146 ret = _menu_view->ActivateIfSensitive();
147 if (!ret) _indicators->ActivateIfSensitive();
148+
149+ return ret;
150 }
151
152 void
153
154=== modified file 'plugins/unityshell/src/PanelView.h'
155--- plugins/unityshell/src/PanelView.h 2012-03-21 12:31:11 +0000
156+++ plugins/unityshell/src/PanelView.h 2012-03-22 20:28:25 +0000
157@@ -66,8 +66,7 @@
158 bool GetPrimary();
159 void SetMonitor(int monitor);
160
161- void StartFirstMenuShow();
162- void EndFirstMenuShow();
163+ bool FirstMenuShow();
164
165 void SetOpacity(float opacity);
166 void SetOpacityMaximizedToggle(bool enabled);
167
168=== modified file 'plugins/unityshell/src/unityshell.cpp'
169--- plugins/unityshell/src/unityshell.cpp 2012-03-21 14:44:41 +0000
170+++ plugins/unityshell/src/unityshell.cpp 2012-03-22 20:28:25 +0000
171@@ -1606,10 +1606,24 @@
172 CompAction::State state,
173 CompOption::Vector& options)
174 {
175- grab_index_ = screen->pushGrab (None, "unityshell");
176- // to receive the Terminate event
177+ /* In order to avoid too many events when keeping the keybinding pressed,
178+ * that would make the unity-panel-service to go crazy (see bug #948522)
179+ * we need to filter them, just considering an event every 750 ms */
180+ int event_time = options[7].value().i(); // XEvent time in millisec
181+
182+ if (event_time - first_menu_keypress_time_ < 750)
183+ {
184+ first_menu_keypress_time_ = event_time;
185+ return false;
186+ }
187+
188+ first_menu_keypress_time_ = event_time;
189+
190+ /* Even if we do nothing on key terminate, we must enable it, not to to hide
191+ * the menus entries after that a menu has been shown and hidden via the
192+ * keyboard and the Alt key is still pressed */
193 action->setState(action->state() | CompAction::StateTermKey);
194- panel_controller_->StartFirstMenuShow();
195+ panel_controller_->FirstMenuShow();
196 return true;
197 }
198
199@@ -1617,9 +1631,7 @@
200 CompAction::State state,
201 CompOption::Vector& options)
202 {
203- screen->removeGrab(grab_index_, NULL);
204 action->setState (action->state() & (unsigned)~(CompAction::StateTermKey));
205- panel_controller_->EndFirstMenuShow();
206 return true;
207 }
208
209
210=== modified file 'plugins/unityshell/src/unityshell.h'
211--- plugins/unityshell/src/unityshell.h 2012-03-21 12:31:11 +0000
212+++ plugins/unityshell/src/unityshell.h 2012-03-22 20:28:25 +0000
213@@ -338,6 +338,7 @@
214 unsigned int tray_paint_mask_;
215 unsigned int last_scroll_event_;
216 int hud_keypress_time_;
217+ int first_menu_keypress_time_;
218
219 GLMatrix panel_shadow_matrix_;
220