Merge lp:~didrocks/unity/fix-lens-shortcuts into lp:unity
- fix-lens-shortcuts
- Merge into trunk
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Neil J. Patel | ||||
Approved revision: | no longer in the source branch. | ||||
Merged at revision: | 1520 | ||||
Proposed branch: | lp:~didrocks/unity/fix-lens-shortcuts | ||||
Merge into: | lp:unity | ||||
Diff against target: |
387 lines (+110/-33) 10 files modified
UnityCore/FilesystemLenses.cpp (+22/-6) UnityCore/FilesystemLenses.h (+1/-0) plugins/unityshell/src/DashController.cpp (+18/-0) plugins/unityshell/src/DashController.h (+3/-0) plugins/unityshell/src/DashView.cpp (+21/-0) plugins/unityshell/src/DashView.h (+3/-0) plugins/unityshell/src/Launcher.cpp (+15/-17) plugins/unityshell/src/Launcher.h (+1/-1) plugins/unityshell/src/unityshell.cpp (+23/-8) plugins/unityshell/src/unityshell.h (+3/-1) |
||||
To merge this branch: | bzr merge lp:~didrocks/unity/fix-lens-shortcuts | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Neil J. Patel (community) | Approve | ||
Review via email: mp+74468@code.launchpad.net |
Commit message
Description of the change
bring back lenses shortcut activation. Seems there is still an issue on
registering keybinding on first super invocation, but good enough for
main cases (LP: #834078).
No python code was written during this hacking period.
Mikkel Kamstrup Erlandsen (kamstrup) wrote : | # |
The missing numbers and letters when holding down super is already in
Oneiric, so definitely not from this branch.
Tim Penhey (thumper) wrote : | # |
On 08/09/11 04:10, Didier Roche wrote:
+Lens::Ptr FilesystemLense
lens_shortcut) const
+{
+ Lens::Ptr p;
+
+ for (Lens::Ptr lens: lenses_)
+ {
+ if (lens->shortcut == lens_shortcut)
+ {
+ p = lens;
+ break;
+ }
+ }
+
+ return p;
+}
In a previous branch I found some weirdness with break nor exiting the
new range based for loop. What I found fixed it was to return. So
something like this:
Lens::Ptr FilesystemLense
lens_shortcut) const
{
for (auto lens : lenses_)
{
if (lens->shortcut == lens_shortcut)
return lens
}
return Lens::Ptr();
}
You could use "auto" or "Lens::Ptr const&". Using just Lens::Ptr causes
an extra object to be constructed and destroyed for each time through
the loop.
Tim
Didier Roche-Tolomelli (didrocks) wrote : | # |
I've made the change mentionned by Tim in UnityCore, I've also fixed another one in UnityCore which had a similar pattern.
The "quick typing shortcut" is now fixed as well. But that makes me thing that we should have a keybinding controller which has a reference to both models to trigger the actions in both the Launcher and Dash, being able to know about both part and so avoiding the "show/hide" in a short period of time like we had there.
I initially put everything in the Launcher as it's where we controlled all the Super keys, but it's not the case anymore with this branch, so we should think about it. I'll get to it, but maybe after this release.
Please tell me if it fixes this :)
There is still the issue in first launch (will need to check compiz registration process with Sam)
The numbers not showing and acting is an oneiric regression, indeed, not related to this branch. I'll try to have a look there as well later (some people will apparently break some libunity ABI, and that + patch piloting + zomg new Qt! needs some attention from now ;))
Neil J. Patel (njpatel) wrote : | # |
Sweet, approved!
Preview Diff
1 | === modified file 'UnityCore/FilesystemLenses.cpp' | |||
2 | --- UnityCore/FilesystemLenses.cpp 2011-08-07 09:21:37 +0000 | |||
3 | +++ UnityCore/FilesystemLenses.cpp 2011-09-08 06:47:28 +0000 | |||
4 | @@ -114,6 +114,7 @@ | |||
5 | 114 | LensList GetLenses() const; | 114 | LensList GetLenses() const; |
6 | 115 | Lens::Ptr GetLens(std::string const& lens_id) const; | 115 | Lens::Ptr GetLens(std::string const& lens_id) const; |
7 | 116 | Lens::Ptr GetLensAtIndex(std::size_t index) const; | 116 | Lens::Ptr GetLensAtIndex(std::size_t index) const; |
8 | 117 | Lens::Ptr GetLensForShortcut(std::string const& lens_shortcut) const; | ||
9 | 117 | std::size_t count() const; | 118 | std::size_t count() const; |
10 | 118 | 119 | ||
11 | 119 | void Init(); | 120 | void Init(); |
12 | @@ -334,18 +335,15 @@ | |||
13 | 334 | 335 | ||
14 | 335 | Lens::Ptr FilesystemLenses::Impl::GetLens(std::string const& lens_id) const | 336 | Lens::Ptr FilesystemLenses::Impl::GetLens(std::string const& lens_id) const |
15 | 336 | { | 337 | { |
19 | 337 | Lens::Ptr p; | 338 | for (auto lens: lenses_) |
17 | 338 | |||
18 | 339 | for (Lens::Ptr lens: lenses_) | ||
20 | 340 | { | 339 | { |
21 | 341 | if (lens->id == lens_id) | 340 | if (lens->id == lens_id) |
22 | 342 | { | 341 | { |
25 | 343 | p = lens; | 342 | return lens; |
24 | 344 | break; | ||
26 | 345 | } | 343 | } |
27 | 346 | } | 344 | } |
28 | 347 | 345 | ||
30 | 348 | return p; | 346 | return Lens::Ptr(); |
31 | 349 | } | 347 | } |
32 | 350 | 348 | ||
33 | 351 | Lens::Ptr FilesystemLenses::Impl::GetLensAtIndex(std::size_t index) const | 349 | Lens::Ptr FilesystemLenses::Impl::GetLensAtIndex(std::size_t index) const |
34 | @@ -361,6 +359,19 @@ | |||
35 | 361 | return Lens::Ptr(); | 359 | return Lens::Ptr(); |
36 | 362 | } | 360 | } |
37 | 363 | 361 | ||
38 | 362 | Lens::Ptr FilesystemLenses::Impl::GetLensForShortcut(std::string const& lens_shortcut) const | ||
39 | 363 | { | ||
40 | 364 | for (auto lens: lenses_) | ||
41 | 365 | { | ||
42 | 366 | if (lens->shortcut == lens_shortcut) | ||
43 | 367 | { | ||
44 | 368 | return lens; | ||
45 | 369 | } | ||
46 | 370 | } | ||
47 | 371 | |||
48 | 372 | return Lens::Ptr(); | ||
49 | 373 | } | ||
50 | 374 | |||
51 | 364 | std::size_t FilesystemLenses::Impl::count() const | 375 | std::size_t FilesystemLenses::Impl::count() const |
52 | 365 | { | 376 | { |
53 | 366 | return lenses_.size(); | 377 | return lenses_.size(); |
54 | @@ -404,5 +415,10 @@ | |||
55 | 404 | return pimpl->GetLensAtIndex(index); | 415 | return pimpl->GetLensAtIndex(index); |
56 | 405 | } | 416 | } |
57 | 406 | 417 | ||
58 | 418 | Lens::Ptr FilesystemLenses::GetLensForShortcut(std::string const& lens_shortcut) const | ||
59 | 419 | { | ||
60 | 420 | return pimpl->GetLensForShortcut(lens_shortcut); | ||
61 | 421 | } | ||
62 | 422 | |||
63 | 407 | } | 423 | } |
64 | 408 | } | 424 | } |
65 | 409 | 425 | ||
66 | === modified file 'UnityCore/FilesystemLenses.h' | |||
67 | --- UnityCore/FilesystemLenses.h 2011-07-27 17:35:31 +0000 | |||
68 | +++ UnityCore/FilesystemLenses.h 2011-09-08 06:47:28 +0000 | |||
69 | @@ -48,6 +48,7 @@ | |||
70 | 48 | LensList GetLenses() const; | 48 | LensList GetLenses() const; |
71 | 49 | Lens::Ptr GetLens(std::string const& lens_id) const; | 49 | Lens::Ptr GetLens(std::string const& lens_id) const; |
72 | 50 | Lens::Ptr GetLensAtIndex(std::size_t index) const; | 50 | Lens::Ptr GetLensAtIndex(std::size_t index) const; |
73 | 51 | Lens::Ptr GetLensForShortcut(std::string const& lens_shortcut) const; | ||
74 | 51 | 52 | ||
75 | 52 | sigc::signal<void> lenses_loaded; | 53 | sigc::signal<void> lenses_loaded; |
76 | 53 | 54 | ||
77 | 54 | 55 | ||
78 | === modified file 'plugins/unityshell/src/DashController.cpp' | |||
79 | --- plugins/unityshell/src/DashController.cpp 2011-09-08 04:49:34 +0000 | |||
80 | +++ plugins/unityshell/src/DashController.cpp 2011-09-08 06:47:28 +0000 | |||
81 | @@ -308,6 +308,24 @@ | |||
82 | 308 | ShowDash(); | 308 | ShowDash(); |
83 | 309 | } | 309 | } |
84 | 310 | 310 | ||
85 | 311 | gboolean DashController::CheckShortcutActivation(const char* key_string) | ||
86 | 312 | { | ||
87 | 313 | EnsureDash(); | ||
88 | 314 | std::string lens_id = view_->GetIdForShortcutActivation(std::string(key_string)); | ||
89 | 315 | if (lens_id != "") | ||
90 | 316 | { | ||
91 | 317 | OnActivateRequest(g_variant_new("(sus)", lens_id.c_str(), 0, "")); | ||
92 | 318 | return true; | ||
93 | 319 | } | ||
94 | 320 | return false; | ||
95 | 321 | } | ||
96 | 322 | |||
97 | 323 | std::vector<char> DashController::GetAllShortcuts() | ||
98 | 324 | { | ||
99 | 325 | EnsureDash(); | ||
100 | 326 | return view_->GetAllShortcuts(); | ||
101 | 327 | } | ||
102 | 328 | |||
103 | 311 | // Introspectable | 329 | // Introspectable |
104 | 312 | const gchar* DashController::GetName() | 330 | const gchar* DashController::GetName() |
105 | 313 | { | 331 | { |
106 | 314 | 332 | ||
107 | === modified file 'plugins/unityshell/src/DashController.h' | |||
108 | --- plugins/unityshell/src/DashController.h 2011-09-08 04:49:34 +0000 | |||
109 | +++ plugins/unityshell/src/DashController.h 2011-09-08 06:47:28 +0000 | |||
110 | @@ -48,6 +48,9 @@ | |||
111 | 48 | 48 | ||
112 | 49 | nux::BaseWindow* window() const; | 49 | nux::BaseWindow* window() const; |
113 | 50 | 50 | ||
114 | 51 | gboolean CheckShortcutActivation(const char* key_string); | ||
115 | 52 | std::vector<char> GetAllShortcuts(); | ||
116 | 53 | |||
117 | 51 | nux::Property<int> launcher_width; | 54 | nux::Property<int> launcher_width; |
118 | 52 | nux::Property<int> panel_height; | 55 | nux::Property<int> panel_height; |
119 | 53 | 56 | ||
120 | 54 | 57 | ||
121 | === modified file 'plugins/unityshell/src/DashView.cpp' | |||
122 | --- plugins/unityshell/src/DashView.cpp 2011-09-08 03:04:04 +0000 | |||
123 | +++ plugins/unityshell/src/DashView.cpp 2011-09-08 06:47:28 +0000 | |||
124 | @@ -768,6 +768,27 @@ | |||
125 | 768 | return false; | 768 | return false; |
126 | 769 | } | 769 | } |
127 | 770 | 770 | ||
128 | 771 | std::string const DashView::GetIdForShortcutActivation(std::string const& shortcut) const | ||
129 | 772 | { | ||
130 | 773 | Lens::Ptr lens = lenses_.GetLensForShortcut(shortcut); | ||
131 | 774 | if (lens) | ||
132 | 775 | return lens->id; | ||
133 | 776 | return ""; | ||
134 | 777 | } | ||
135 | 778 | |||
136 | 779 | std::vector<char> DashView::GetAllShortcuts() | ||
137 | 780 | { | ||
138 | 781 | std::vector<char> result; | ||
139 | 782 | |||
140 | 783 | for (Lens::Ptr lens: lenses_.GetLenses()) | ||
141 | 784 | { | ||
142 | 785 | std::string shortcut = lens->shortcut; | ||
143 | 786 | if(shortcut.size() > 0) | ||
144 | 787 | result.push_back(shortcut.at(0)); | ||
145 | 788 | } | ||
146 | 789 | return result; | ||
147 | 790 | } | ||
148 | 791 | |||
149 | 771 | bool DashView::InspectKeyEvent(unsigned int eventType, | 792 | bool DashView::InspectKeyEvent(unsigned int eventType, |
150 | 772 | unsigned int key_sym, | 793 | unsigned int key_sym, |
151 | 773 | const char* character) | 794 | const char* character) |
152 | 774 | 795 | ||
153 | === modified file 'plugins/unityshell/src/DashView.h' | |||
154 | --- plugins/unityshell/src/DashView.h 2011-09-07 09:50:44 +0000 | |||
155 | +++ plugins/unityshell/src/DashView.h 2011-09-08 06:47:28 +0000 | |||
156 | @@ -56,6 +56,9 @@ | |||
157 | 56 | void DisableBlur(); | 56 | void DisableBlur(); |
158 | 57 | void OnActivateRequest(GVariant* args); | 57 | void OnActivateRequest(GVariant* args); |
159 | 58 | 58 | ||
160 | 59 | std::string const GetIdForShortcutActivation(std::string const& shortcut) const; | ||
161 | 60 | std::vector<char> GetAllShortcuts(); | ||
162 | 61 | |||
163 | 59 | nux::View* default_focus() const; | 62 | nux::View* default_focus() const; |
164 | 60 | 63 | ||
165 | 61 | private: | 64 | private: |
166 | 62 | 65 | ||
167 | === modified file 'plugins/unityshell/src/Launcher.cpp' | |||
168 | --- plugins/unityshell/src/Launcher.cpp 2011-09-08 04:49:34 +0000 | |||
169 | +++ plugins/unityshell/src/Launcher.cpp 2011-09-08 06:47:28 +0000 | |||
170 | @@ -235,7 +235,6 @@ | |||
171 | 235 | _ignore_repeat_shortcut_handle = 0; | 235 | _ignore_repeat_shortcut_handle = 0; |
172 | 236 | 236 | ||
173 | 237 | _latest_shortcut = 0; | 237 | _latest_shortcut = 0; |
174 | 238 | _super_pressed = false; | ||
175 | 239 | _shortcuts_shown = false; | 238 | _shortcuts_shown = false; |
176 | 240 | _floating = false; | 239 | _floating = false; |
177 | 241 | _hovered = false; | 240 | _hovered = false; |
178 | @@ -1366,7 +1365,6 @@ | |||
179 | 1366 | 1365 | ||
180 | 1367 | void Launcher::StartKeyShowLauncher() | 1366 | void Launcher::StartKeyShowLauncher() |
181 | 1368 | { | 1367 | { |
182 | 1369 | _super_pressed = true; | ||
183 | 1370 | _hide_machine->SetQuirk(LauncherHideMachine::LAST_ACTION_ACTIVATE, false); | 1368 | _hide_machine->SetQuirk(LauncherHideMachine::LAST_ACTION_ACTIVATE, false); |
184 | 1371 | 1369 | ||
185 | 1372 | SetTimeStruct(&_times[TIME_TAP_SUPER]); | 1370 | SetTimeStruct(&_times[TIME_TAP_SUPER]); |
186 | @@ -1391,7 +1389,6 @@ | |||
187 | 1391 | clock_gettime(CLOCK_MONOTONIC, ¤t); | 1389 | clock_gettime(CLOCK_MONOTONIC, ¤t); |
188 | 1392 | 1390 | ||
189 | 1393 | _hover_machine->SetQuirk(LauncherHoverMachine::SHORTCUT_KEYS_VISIBLE, false); | 1391 | _hover_machine->SetQuirk(LauncherHoverMachine::SHORTCUT_KEYS_VISIBLE, false); |
190 | 1394 | _super_pressed = false; | ||
191 | 1395 | _shortcuts_shown = false; | 1392 | _shortcuts_shown = false; |
192 | 1396 | QueueDraw(); | 1393 | QueueDraw(); |
193 | 1397 | 1394 | ||
194 | @@ -2509,9 +2506,6 @@ | |||
195 | 2509 | unsigned long key_state, | 2506 | unsigned long key_state, |
196 | 2510 | char* key_string) | 2507 | char* key_string) |
197 | 2511 | { | 2508 | { |
198 | 2512 | if (!_super_pressed) | ||
199 | 2513 | return false; | ||
200 | 2514 | |||
201 | 2515 | LauncherModel::iterator it; | 2509 | LauncherModel::iterator it; |
202 | 2516 | 2510 | ||
203 | 2517 | // Shortcut to start launcher icons. Only relies on Keycode, ignore modifier | 2511 | // Shortcut to start launcher icons. Only relies on Keycode, ignore modifier |
204 | @@ -2520,16 +2514,6 @@ | |||
205 | 2520 | if ((XKeysymToKeycode(x_display, (*it)->GetShortcut()) == key_code) || | 2514 | if ((XKeysymToKeycode(x_display, (*it)->GetShortcut()) == key_code) || |
206 | 2521 | ((gchar)((*it)->GetShortcut()) == key_string[0])) | 2515 | ((gchar)((*it)->GetShortcut()) == key_string[0])) |
207 | 2522 | { | 2516 | { |
208 | 2523 | /* | ||
209 | 2524 | * start a timeout while repressing the same shortcut will be ignored. | ||
210 | 2525 | * This is because the keypress repeat is handled by Xorg and we have no | ||
211 | 2526 | * way to know if a press is an actual press or just an automated repetition | ||
212 | 2527 | * because the button is hold down. (key release events are sent in both cases) | ||
213 | 2528 | */ | ||
214 | 2529 | if (_ignore_repeat_shortcut_handle > 0) | ||
215 | 2530 | g_source_remove(_ignore_repeat_shortcut_handle); | ||
216 | 2531 | _ignore_repeat_shortcut_handle = g_timeout_add(IGNORE_REPEAT_SHORTCUT_DURATION, &Launcher::ResetRepeatShorcutTimeout, this); | ||
217 | 2532 | |||
218 | 2533 | if (_latest_shortcut == (*it)->GetShortcut()) | 2517 | if (_latest_shortcut == (*it)->GetShortcut()) |
219 | 2534 | return true; | 2518 | return true; |
220 | 2535 | 2519 | ||
221 | @@ -2538,7 +2522,7 @@ | |||
222 | 2538 | else | 2522 | else |
223 | 2539 | (*it)->Activate(ActionArg(ActionArg::LAUNCHER, 0)); | 2523 | (*it)->Activate(ActionArg(ActionArg::LAUNCHER, 0)); |
224 | 2540 | 2524 | ||
226 | 2541 | _latest_shortcut = (*it)->GetShortcut(); | 2525 | SetLatestShortcut((*it)->GetShortcut()); |
227 | 2542 | 2526 | ||
228 | 2543 | // disable the "tap on super" check | 2527 | // disable the "tap on super" check |
229 | 2544 | _times[TIME_TAP_SUPER].tv_sec = 0; | 2528 | _times[TIME_TAP_SUPER].tv_sec = 0; |
230 | @@ -2550,6 +2534,20 @@ | |||
231 | 2550 | return false; | 2534 | return false; |
232 | 2551 | } | 2535 | } |
233 | 2552 | 2536 | ||
234 | 2537 | void Launcher::SetLatestShortcut(guint64 shortcut) | ||
235 | 2538 | { | ||
236 | 2539 | _latest_shortcut = shortcut; | ||
237 | 2540 | /* | ||
238 | 2541 | * start a timeout while repressing the same shortcut will be ignored. | ||
239 | 2542 | * This is because the keypress repeat is handled by Xorg and we have no | ||
240 | 2543 | * way to know if a press is an actual press or just an automated repetition | ||
241 | 2544 | * because the button is hold down. (key release events are sent in both cases) | ||
242 | 2545 | */ | ||
243 | 2546 | if (_ignore_repeat_shortcut_handle > 0) | ||
244 | 2547 | g_source_remove(_ignore_repeat_shortcut_handle); | ||
245 | 2548 | _ignore_repeat_shortcut_handle = g_timeout_add(IGNORE_REPEAT_SHORTCUT_DURATION, &Launcher::ResetRepeatShorcutTimeout, this); | ||
246 | 2549 | } | ||
247 | 2550 | |||
248 | 2553 | void | 2551 | void |
249 | 2554 | Launcher::EdgeRevealTriggered(int mouse_x, int mouse_y) | 2552 | Launcher::EdgeRevealTriggered(int mouse_x, int mouse_y) |
250 | 2555 | { | 2553 | { |
251 | 2556 | 2554 | ||
252 | === modified file 'plugins/unityshell/src/Launcher.h' | |||
253 | --- plugins/unityshell/src/Launcher.h 2011-09-08 04:49:34 +0000 | |||
254 | +++ plugins/unityshell/src/Launcher.h 2011-09-08 06:47:28 +0000 | |||
255 | @@ -156,6 +156,7 @@ | |||
256 | 156 | void EdgeRevealTriggered(int x, int y); | 156 | void EdgeRevealTriggered(int x, int y); |
257 | 157 | 157 | ||
258 | 158 | gboolean CheckSuperShortcutPressed(Display *x_display, unsigned int key_sym, unsigned long key_code, unsigned long key_state, char* key_string); | 158 | gboolean CheckSuperShortcutPressed(Display *x_display, unsigned int key_sym, unsigned long key_code, unsigned long key_state, char* key_string); |
259 | 159 | void SetLatestShortcut(guint64 shortcut); | ||
260 | 159 | 160 | ||
261 | 160 | nux::BaseWindow* GetParent() | 161 | nux::BaseWindow* GetParent() |
262 | 161 | { | 162 | { |
263 | @@ -397,7 +398,6 @@ | |||
264 | 397 | bool _check_window_over_launcher; | 398 | bool _check_window_over_launcher; |
265 | 398 | 399 | ||
266 | 399 | bool _shortcuts_shown; | 400 | bool _shortcuts_shown; |
267 | 400 | bool _super_pressed; | ||
268 | 401 | bool _keynav_activated; | 401 | bool _keynav_activated; |
269 | 402 | guint64 _latest_shortcut; | 402 | guint64 _latest_shortcut; |
270 | 403 | 403 | ||
271 | 404 | 404 | ||
272 | === modified file 'plugins/unityshell/src/unityshell.cpp' | |||
273 | --- plugins/unityshell/src/unityshell.cpp 2011-09-08 03:04:04 +0000 | |||
274 | +++ plugins/unityshell/src/unityshell.cpp 2011-09-08 06:47:28 +0000 | |||
275 | @@ -225,6 +225,7 @@ | |||
276 | 225 | this); | 225 | this); |
277 | 226 | 226 | ||
278 | 227 | g_timeout_add(0, &UnityScreen::initPluginActions, this); | 227 | g_timeout_add(0, &UnityScreen::initPluginActions, this); |
279 | 228 | super_keypressed_ = false; | ||
280 | 228 | 229 | ||
281 | 229 | GeisAdapter::Default()->Run(); | 230 | GeisAdapter::Default()->Run(); |
282 | 230 | gestureEngine = new GestureEngine(screen); | 231 | gestureEngine = new GestureEngine(screen); |
283 | @@ -237,8 +238,6 @@ | |||
284 | 237 | ubus_manager_.RegisterInterest(UBUS_PLACE_VIEW_SHOWN, [&](GVariant * args) { dash_is_open_ = true; }); | 238 | ubus_manager_.RegisterInterest(UBUS_PLACE_VIEW_SHOWN, [&](GVariant * args) { dash_is_open_ = true; }); |
285 | 238 | ubus_manager_.RegisterInterest(UBUS_PLACE_VIEW_HIDDEN, [&](GVariant * args) { dash_is_open_ = false; }); | 239 | ubus_manager_.RegisterInterest(UBUS_PLACE_VIEW_HIDDEN, [&](GVariant * args) { dash_is_open_ = false; }); |
286 | 239 | 240 | ||
287 | 240 | EnsureKeybindings(); | ||
288 | 241 | |||
289 | 242 | LOG_INFO(logger) << "UnityScreen constructed: " << timer.ElapsedSeconds() << "s"; | 241 | LOG_INFO(logger) << "UnityScreen constructed: " << timer.ElapsedSeconds() << "s"; |
290 | 243 | } | 242 | } |
291 | 244 | 243 | ||
292 | @@ -301,7 +300,7 @@ | |||
293 | 301 | 300 | ||
294 | 302 | } | 301 | } |
295 | 303 | 302 | ||
297 | 304 | void UnityScreen::EnsureKeybindings() | 303 | void UnityScreen::EnsureSuperKeybindings() |
298 | 305 | { | 304 | { |
299 | 306 | for (auto action : _shortcut_actions) | 305 | for (auto action : _shortcut_actions) |
300 | 307 | screen->removeAction(action.get()); | 306 | screen->removeAction(action.get()); |
301 | @@ -313,19 +312,26 @@ | |||
302 | 313 | guint64 shortcut = icon->GetShortcut(); | 312 | guint64 shortcut = icon->GetShortcut(); |
303 | 314 | if (shortcut == 0) | 313 | if (shortcut == 0) |
304 | 315 | continue; | 314 | continue; |
306 | 316 | 315 | CreateSuperNewAction(static_cast<char>(shortcut)); | |
307 | 316 | } | ||
308 | 317 | |||
309 | 318 | for (auto shortcut : dashController->GetAllShortcuts()) | ||
310 | 319 | CreateSuperNewAction(shortcut); | ||
311 | 320 | } | ||
312 | 321 | |||
313 | 322 | void UnityScreen::CreateSuperNewAction(char shortcut) | ||
314 | 323 | { | ||
315 | 317 | CompActionPtr action(new CompAction()); | 324 | CompActionPtr action(new CompAction()); |
316 | 318 | 325 | ||
317 | 319 | CompAction::KeyBinding binding; | 326 | CompAction::KeyBinding binding; |
318 | 320 | std::ostringstream sout; | 327 | std::ostringstream sout; |
320 | 321 | sout << "<Super>" << static_cast<char>(shortcut); | 328 | sout << "<Super>" << shortcut; |
321 | 322 | binding.fromString(sout.str()); | 329 | binding.fromString(sout.str()); |
322 | 323 | 330 | ||
323 | 324 | action->setKey(binding); | 331 | action->setKey(binding); |
324 | 325 | 332 | ||
325 | 326 | screen->addAction(action.get()); | 333 | screen->addAction(action.get()); |
326 | 327 | _shortcut_actions.push_back(action); | 334 | _shortcut_actions.push_back(action); |
327 | 328 | } | ||
328 | 329 | } | 335 | } |
329 | 330 | 336 | ||
330 | 331 | void UnityScreen::nuxPrologue() | 337 | void UnityScreen::nuxPrologue() |
331 | @@ -871,7 +877,14 @@ | |||
332 | 871 | if ((result = XLookupString(&(event->xkey), key_string, 2, &key_sym, 0)) > 0) | 877 | if ((result = XLookupString(&(event->xkey), key_string, 2, &key_sym, 0)) > 0) |
333 | 872 | { | 878 | { |
334 | 873 | key_string[result] = 0; | 879 | key_string[result] = 0; |
336 | 874 | skip_other_plugins = launcher->CheckSuperShortcutPressed(screen->dpy(), key_sym, event->xkey.keycode, event->xkey.state, key_string); | 880 | if (super_keypressed_) { |
337 | 881 | skip_other_plugins = launcher->CheckSuperShortcutPressed(screen->dpy(), key_sym, event->xkey.keycode, event->xkey.state, key_string); | ||
338 | 882 | if (!skip_other_plugins) { | ||
339 | 883 | skip_other_plugins = dashController->CheckShortcutActivation(key_string); | ||
340 | 884 | if (skip_other_plugins) | ||
341 | 885 | launcher->SetLatestShortcut(key_string[0]); | ||
342 | 886 | } | ||
343 | 887 | } | ||
344 | 875 | } | 888 | } |
345 | 876 | break; | 889 | break; |
346 | 877 | } | 890 | } |
347 | @@ -907,8 +920,9 @@ | |||
348 | 907 | if (state & CompAction::StateInitKey) | 920 | if (state & CompAction::StateInitKey) |
349 | 908 | action->setState(action->state() | CompAction::StateTermKey); | 921 | action->setState(action->state() | CompAction::StateTermKey); |
350 | 909 | 922 | ||
351 | 923 | super_keypressed_ = true; | ||
352 | 910 | launcher->StartKeyShowLauncher(); | 924 | launcher->StartKeyShowLauncher(); |
354 | 911 | EnsureKeybindings (); | 925 | EnsureSuperKeybindings (); |
355 | 912 | return false; | 926 | return false; |
356 | 913 | } | 927 | } |
357 | 914 | 928 | ||
358 | @@ -916,6 +930,7 @@ | |||
359 | 916 | CompAction::State state, | 930 | CompAction::State state, |
360 | 917 | CompOption::Vector& options) | 931 | CompOption::Vector& options) |
361 | 918 | { | 932 | { |
362 | 933 | super_keypressed_ = false; | ||
363 | 919 | launcher->EndKeyShowLauncher(); | 934 | launcher->EndKeyShowLauncher(); |
364 | 920 | return false; | 935 | return false; |
365 | 921 | } | 936 | } |
366 | 922 | 937 | ||
367 | === modified file 'plugins/unityshell/src/unityshell.h' | |||
368 | --- plugins/unityshell/src/unityshell.h 2011-09-08 03:04:04 +0000 | |||
369 | +++ plugins/unityshell/src/unityshell.h 2011-09-08 06:47:28 +0000 | |||
370 | @@ -235,7 +235,8 @@ | |||
371 | 235 | 235 | ||
372 | 236 | void SendExecuteCommand(); | 236 | void SendExecuteCommand(); |
373 | 237 | 237 | ||
375 | 238 | void EnsureKeybindings (); | 238 | void EnsureSuperKeybindings (); |
376 | 239 | void CreateSuperNewAction(char shortcut); | ||
377 | 239 | 240 | ||
378 | 240 | static gboolean initPluginActions(gpointer data); | 241 | static gboolean initPluginActions(gpointer data); |
379 | 241 | static void initLauncher(nux::NThread* thread, void* InitData); | 242 | static void initLauncher(nux::NThread* thread, void* InitData); |
380 | @@ -281,6 +282,7 @@ | |||
381 | 281 | typedef std::shared_ptr<CompAction> CompActionPtr; | 282 | typedef std::shared_ptr<CompAction> CompActionPtr; |
382 | 282 | typedef std::vector<CompActionPtr> ShortcutActions; | 283 | typedef std::vector<CompActionPtr> ShortcutActions; |
383 | 283 | ShortcutActions _shortcut_actions; | 284 | ShortcutActions _shortcut_actions; |
384 | 285 | bool super_keypressed_; | ||
385 | 284 | 286 | ||
386 | 285 | /* keyboard-nav mode */ | 287 | /* keyboard-nav mode */ |
387 | 286 | CompWindow* newFocusedWindow; | 288 | CompWindow* newFocusedWindow; |
Awesome stuff! I found a couple of niggles, not sure if they are to do with your branch or not, so let me know:
- Pressing Super no longer shows the numbers on the icons :/
- If I press Super+f quickly, then the dash shows and hides, instead of just showing. I have to press super, wait around 100ms and then press f to make it show.
Any ideas?