Merge lp:~3v1n0/unity/switcher-no-inputwin-5.0 into lp:unity/5.0
- switcher-no-inputwin-5.0
- Merge into 5.0
Proposed by
Marco Trevisan (Treviño)
Status: | Merged | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Approved by: | Marco Trevisan (Treviño) | ||||||||||||||||||||
Approved revision: | no longer in the source branch. | ||||||||||||||||||||
Merged at revision: | 2419 | ||||||||||||||||||||
Proposed branch: | lp:~3v1n0/unity/switcher-no-inputwin-5.0 | ||||||||||||||||||||
Merge into: | lp:unity/5.0 | ||||||||||||||||||||
Diff against target: |
574 lines (+185/-78) 11 files modified
plugins/unityshell/src/DashView.cpp (+14/-9) plugins/unityshell/src/HudView.cpp (+13/-0) plugins/unityshell/src/IconRenderer.cpp (+36/-10) plugins/unityshell/src/SwitcherController.cpp (+7/-5) plugins/unityshell/src/SwitcherController.h (+0/-1) plugins/unityshell/src/SwitcherModel.h (+2/-2) plugins/unityshell/src/WindowManager.h (+4/-0) plugins/unityshell/src/unityshell.cpp (+86/-46) plugins/unityshell/src/unityshell.h (+5/-5) tests/autopilot/autopilot/tests/test_dash.py (+9/-0) tests/autopilot/autopilot/tests/test_hud.py (+9/-0) |
||||||||||||||||||||
To merge this branch: | bzr merge lp:~3v1n0/unity/switcher-no-inputwin-5.0 | ||||||||||||||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Brandon Schaefer (community) | Approve | ||
Review via email: mp+160253@code.launchpad.net |
Commit message
SwitcherController: use again the SwitcherView as non-input window
Otherwise it could only lead to focusing troubles.
Added utilities to manage the WindowManager default close-window keybinding and using
it in our views.
Description of the change
Backported branches lp:~3v1n0/unity/switcher-noinputwin, lp:~3v1n0/unity/bigger-switcher-pips, lp:~thomir/unity/fix-hud-closing and lp:~brandontschaefer/unity/alt+f4-closes-hud to unity-5.0.
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === added file 'plugins/unityshell/resources/launcher_pip_large_ltr.png' | |||
2 | 0 | Binary files plugins/unityshell/resources/launcher_pip_large_ltr.png 1970-01-01 00:00:00 +0000 and plugins/unityshell/resources/launcher_pip_large_ltr.png 2013-04-23 02:51:28 +0000 differ | 0 | Binary files plugins/unityshell/resources/launcher_pip_large_ltr.png 1970-01-01 00:00:00 +0000 and plugins/unityshell/resources/launcher_pip_large_ltr.png 2013-04-23 02:51:28 +0000 differ |
3 | === added file 'plugins/unityshell/resources/launcher_pip_large_rtl.png' | |||
4 | 1 | Binary files plugins/unityshell/resources/launcher_pip_large_rtl.png 1970-01-01 00:00:00 +0000 and plugins/unityshell/resources/launcher_pip_large_rtl.png 2013-04-23 02:51:28 +0000 differ | 1 | Binary files plugins/unityshell/resources/launcher_pip_large_rtl.png 1970-01-01 00:00:00 +0000 and plugins/unityshell/resources/launcher_pip_large_rtl.png 2013-04-23 02:51:28 +0000 differ |
5 | === modified file 'plugins/unityshell/src/DashView.cpp' | |||
6 | --- plugins/unityshell/src/DashView.cpp 2012-06-28 08:49:20 +0000 | |||
7 | +++ plugins/unityshell/src/DashView.cpp 2013-04-23 02:51:28 +0000 | |||
8 | @@ -33,6 +33,7 @@ | |||
9 | 33 | #include "DashSettings.h" | 33 | #include "DashSettings.h" |
10 | 34 | #include "UBusMessages.h" | 34 | #include "UBusMessages.h" |
11 | 35 | #include "KeyboardUtil.h" | 35 | #include "KeyboardUtil.h" |
12 | 36 | #include "WindowManager.h" | ||
13 | 36 | 37 | ||
14 | 37 | namespace unity | 38 | namespace unity |
15 | 38 | { | 39 | { |
16 | @@ -494,7 +495,7 @@ | |||
17 | 494 | }); | 495 | }); |
18 | 495 | 496 | ||
19 | 496 | // global search done is handled by the home lens, no need to connect to it | 497 | // global search done is handled by the home lens, no need to connect to it |
21 | 497 | // BUT, we will special case global search finished coming from | 498 | // BUT, we will special case global search finished coming from |
22 | 498 | // the applications lens, because we want to be able to launch applications | 499 | // the applications lens, because we want to be able to launch applications |
23 | 499 | // immediately without waiting for the search finished signal which will | 500 | // immediately without waiting for the search finished signal which will |
24 | 500 | // be delayed by all the lenses we're searching | 501 | // be delayed by all the lenses we're searching |
25 | @@ -808,6 +809,10 @@ | |||
26 | 808 | unsigned long x11_key_code, | 809 | unsigned long x11_key_code, |
27 | 809 | unsigned long special_keys_state) | 810 | unsigned long special_keys_state) |
28 | 810 | { | 811 | { |
29 | 812 | // Only care about states of Alt, Ctrl, Super, Shift, not the lock keys | ||
30 | 813 | special_keys_state &= (nux::NUX_STATE_ALT | nux::NUX_STATE_CTRL | | ||
31 | 814 | nux::NUX_STATE_SUPER | nux::NUX_STATE_SHIFT); | ||
32 | 815 | |||
33 | 811 | // Do what nux::View does, but if the event isn't a key navigation, | 816 | // Do what nux::View does, but if the event isn't a key navigation, |
34 | 812 | // designate the text entry to process it. | 817 | // designate the text entry to process it. |
35 | 813 | 818 | ||
36 | @@ -841,15 +846,15 @@ | |||
37 | 841 | // Not sure if Enter should be a navigation key | 846 | // Not sure if Enter should be a navigation key |
38 | 842 | direction = KEY_NAV_ENTER; | 847 | direction = KEY_NAV_ENTER; |
39 | 843 | break; | 848 | break; |
40 | 844 | case NUX_VK_F4: | ||
41 | 845 | // Maybe we should not do it here, but it needs to be checked where | ||
42 | 846 | // we are able to know if alt is pressed. | ||
43 | 847 | if (special_keys_state & NUX_STATE_ALT) | ||
44 | 848 | { | ||
45 | 849 | ubus_manager_.SendMessage(UBUS_PLACE_VIEW_CLOSE_REQUEST); | ||
46 | 850 | } | ||
47 | 851 | break; | ||
48 | 852 | default: | 849 | default: |
49 | 850 | auto const& close_key = WindowManager::Default()->close_window_key(); | ||
50 | 851 | |||
51 | 852 | if (close_key.first == special_keys_state && close_key.second == x11_key_code) | ||
52 | 853 | { | ||
53 | 854 | ubus_manager_.SendMessage(UBUS_PLACE_VIEW_CLOSE_REQUEST); | ||
54 | 855 | return nullptr; | ||
55 | 856 | } | ||
56 | 857 | |||
57 | 853 | direction = KEY_NAV_NONE; | 858 | direction = KEY_NAV_NONE; |
58 | 854 | } | 859 | } |
59 | 855 | 860 | ||
60 | 856 | 861 | ||
61 | === modified file 'plugins/unityshell/src/HudView.cpp' | |||
62 | --- plugins/unityshell/src/HudView.cpp 2012-08-20 14:52:48 +0000 | |||
63 | +++ plugins/unityshell/src/HudView.cpp 2013-04-23 02:51:28 +0000 | |||
64 | @@ -29,6 +29,7 @@ | |||
65 | 29 | 29 | ||
66 | 30 | #include "UBusMessages.h" | 30 | #include "UBusMessages.h" |
67 | 31 | #include "DashStyle.h" | 31 | #include "DashStyle.h" |
68 | 32 | #include "WindowManager.h" | ||
69 | 32 | 33 | ||
70 | 33 | namespace unity | 34 | namespace unity |
71 | 34 | { | 35 | { |
72 | @@ -563,6 +564,10 @@ | |||
73 | 563 | unsigned long x11_key_code, | 564 | unsigned long x11_key_code, |
74 | 564 | unsigned long special_keys_state) | 565 | unsigned long special_keys_state) |
75 | 565 | { | 566 | { |
76 | 567 | // Only care about states of Alt, Ctrl, Super, Shift, not the lock keys | ||
77 | 568 | special_keys_state &= (nux::NUX_STATE_ALT | nux::NUX_STATE_CTRL | | ||
78 | 569 | nux::NUX_STATE_SUPER | nux::NUX_STATE_SHIFT); | ||
79 | 570 | |||
80 | 566 | nux::KeyNavDirection direction = nux::KEY_NAV_NONE; | 571 | nux::KeyNavDirection direction = nux::KEY_NAV_NONE; |
81 | 567 | switch (x11_key_code) | 572 | switch (x11_key_code) |
82 | 568 | { | 573 | { |
83 | @@ -590,6 +595,14 @@ | |||
84 | 590 | direction = nux::KEY_NAV_ENTER; | 595 | direction = nux::KEY_NAV_ENTER; |
85 | 591 | break; | 596 | break; |
86 | 592 | default: | 597 | default: |
87 | 598 | auto const& close_key = WindowManager::Default()->close_window_key(); | ||
88 | 599 | |||
89 | 600 | if (close_key.first == special_keys_state && close_key.second == x11_key_code) | ||
90 | 601 | { | ||
91 | 602 | ubus.SendMessage(UBUS_HUD_CLOSE_REQUEST); | ||
92 | 603 | return nullptr; | ||
93 | 604 | } | ||
94 | 605 | |||
95 | 593 | direction = nux::KEY_NAV_NONE; | 606 | direction = nux::KEY_NAV_NONE; |
96 | 594 | break; | 607 | break; |
97 | 595 | } | 608 | } |
98 | 596 | 609 | ||
99 | === modified file 'plugins/unityshell/src/IconRenderer.cpp' | |||
100 | --- plugins/unityshell/src/IconRenderer.cpp 2012-10-17 17:46:12 +0000 | |||
101 | +++ plugins/unityshell/src/IconRenderer.cpp 2013-04-23 02:51:28 +0000 | |||
102 | @@ -188,6 +188,8 @@ | |||
103 | 188 | nux::BaseTexture* progress_bar_fill = 0; | 188 | nux::BaseTexture* progress_bar_fill = 0; |
104 | 189 | nux::BaseTexture* pip_ltr = 0; | 189 | nux::BaseTexture* pip_ltr = 0; |
105 | 190 | nux::BaseTexture* pip_rtl = 0; | 190 | nux::BaseTexture* pip_rtl = 0; |
106 | 191 | nux::BaseTexture* large_pip_ltr = 0; | ||
107 | 192 | nux::BaseTexture* large_pip_rtl = 0; | ||
108 | 191 | nux::BaseTexture* arrow_ltr = 0; | 193 | nux::BaseTexture* arrow_ltr = 0; |
109 | 192 | nux::BaseTexture* arrow_rtl = 0; | 194 | nux::BaseTexture* arrow_rtl = 0; |
110 | 193 | nux::BaseTexture* arrow_empty_ltr = 0; | 195 | nux::BaseTexture* arrow_empty_ltr = 0; |
111 | @@ -871,8 +873,8 @@ | |||
112 | 871 | if (running > 0) | 873 | if (running > 0) |
113 | 872 | { | 874 | { |
114 | 873 | int scale = 1; | 875 | int scale = 1; |
115 | 874 | |||
116 | 875 | int markerX; | 876 | int markerX; |
117 | 877 | |||
118 | 876 | if (pip_style == OUTSIDE_TILE) | 878 | if (pip_style == OUTSIDE_TILE) |
119 | 877 | { | 879 | { |
120 | 878 | markerX = geo.x; | 880 | markerX = geo.x; |
121 | @@ -880,8 +882,7 @@ | |||
122 | 880 | else | 882 | else |
123 | 881 | { | 883 | { |
124 | 882 | auto bounds = arg.icon->GetTransform(ui::IconTextureSource::TRANSFORM_TILE, monitor); | 884 | auto bounds = arg.icon->GetTransform(ui::IconTextureSource::TRANSFORM_TILE, monitor); |
127 | 883 | markerX = bounds[0].x + 2; | 885 | markerX = bounds[0].x + 1; |
126 | 884 | scale = 2; | ||
128 | 885 | } | 886 | } |
129 | 886 | 887 | ||
130 | 887 | nux::TexCoordXForm texxform; | 888 | nux::TexCoordXForm texxform; |
131 | @@ -902,26 +903,47 @@ | |||
132 | 902 | 903 | ||
133 | 903 | if (!arg.running_on_viewport) | 904 | if (!arg.running_on_viewport) |
134 | 904 | { | 905 | { |
135 | 906 | scale = (pip_style == OUTSIDE_TILE) ? 1 : 2; | ||
136 | 905 | markers[0] = markerCenter; | 907 | markers[0] = markerCenter; |
137 | 906 | texture = local::arrow_empty_ltr; | 908 | texture = local::arrow_empty_ltr; |
138 | 907 | } | 909 | } |
139 | 908 | else if (running == 1) | 910 | else if (running == 1) |
140 | 909 | { | 911 | { |
141 | 912 | scale = (pip_style == OUTSIDE_TILE) ? 1 : 2; | ||
142 | 910 | markers[0] = markerCenter; | 913 | markers[0] = markerCenter; |
143 | 911 | texture = local::arrow_ltr; | 914 | texture = local::arrow_ltr; |
144 | 912 | } | 915 | } |
145 | 913 | else if (running == 2) | 916 | else if (running == 2) |
146 | 914 | { | 917 | { |
150 | 915 | markers[0] = markerCenter - 2 * scale; | 918 | if (pip_style == OUTSIDE_TILE) |
151 | 916 | markers[1] = markerCenter + 2 * scale; | 919 | { |
152 | 917 | texture = local::pip_ltr; | 920 | texture = local::pip_ltr; |
153 | 921 | markers[0] = markerCenter - 2; | ||
154 | 922 | markers[1] = markerCenter + 2; | ||
155 | 923 | } | ||
156 | 924 | else | ||
157 | 925 | { | ||
158 | 926 | texture = local::large_pip_ltr; | ||
159 | 927 | markers[0] = markerCenter - 4; | ||
160 | 928 | markers[1] = markerCenter + 4; | ||
161 | 929 | } | ||
162 | 918 | } | 930 | } |
163 | 919 | else | 931 | else |
164 | 920 | { | 932 | { |
169 | 921 | markers[0] = markerCenter - 4 * scale; | 933 | if (pip_style == OUTSIDE_TILE) |
170 | 922 | markers[1] = markerCenter; | 934 | { |
171 | 923 | markers[2] = markerCenter + 4 * scale; | 935 | texture = local::pip_ltr; |
172 | 924 | texture = local::pip_ltr; | 936 | markers[0] = markerCenter - 4; |
173 | 937 | markers[1] = markerCenter; | ||
174 | 938 | markers[2] = markerCenter + 4; | ||
175 | 939 | } | ||
176 | 940 | else | ||
177 | 941 | { | ||
178 | 942 | texture = local::large_pip_ltr; | ||
179 | 943 | markers[0] = markerCenter - 8; | ||
180 | 944 | markers[1] = markerCenter; | ||
181 | 945 | markers[2] = markerCenter + 8; | ||
182 | 946 | } | ||
183 | 925 | } | 947 | } |
184 | 926 | 948 | ||
185 | 927 | 949 | ||
186 | @@ -1218,10 +1240,12 @@ | |||
187 | 1218 | squircle_shine = load_texture(PKGDATADIR"/squircle_shine_54.png"); | 1240 | squircle_shine = load_texture(PKGDATADIR"/squircle_shine_54.png"); |
188 | 1219 | 1241 | ||
189 | 1220 | pip_ltr = load_texture(PKGDATADIR"/launcher_pip_ltr.png"); | 1242 | pip_ltr = load_texture(PKGDATADIR"/launcher_pip_ltr.png"); |
190 | 1243 | large_pip_ltr = load_texture(PKGDATADIR"/launcher_pip_large_ltr.png"); | ||
191 | 1221 | arrow_ltr = load_texture(PKGDATADIR"/launcher_arrow_ltr.png"); | 1244 | arrow_ltr = load_texture(PKGDATADIR"/launcher_arrow_ltr.png"); |
192 | 1222 | arrow_empty_ltr = load_texture(PKGDATADIR"/launcher_arrow_outline_ltr.png"); | 1245 | arrow_empty_ltr = load_texture(PKGDATADIR"/launcher_arrow_outline_ltr.png"); |
193 | 1223 | 1246 | ||
194 | 1224 | pip_rtl = load_texture(PKGDATADIR"/launcher_pip_rtl.png"); | 1247 | pip_rtl = load_texture(PKGDATADIR"/launcher_pip_rtl.png"); |
195 | 1248 | large_pip_rtl = load_texture(PKGDATADIR"/launcher_pip_large_rt.png"); | ||
196 | 1225 | arrow_rtl = load_texture(PKGDATADIR"/launcher_arrow_rtl.png"); | 1249 | arrow_rtl = load_texture(PKGDATADIR"/launcher_arrow_rtl.png"); |
197 | 1226 | arrow_empty_rtl = load_texture(PKGDATADIR"/launcher_arrow_outline_rtl.png"); | 1250 | arrow_empty_rtl = load_texture(PKGDATADIR"/launcher_arrow_outline_rtl.png"); |
198 | 1227 | 1251 | ||
199 | @@ -1248,6 +1272,8 @@ | |||
200 | 1248 | progress_bar_fill->UnReference(); | 1272 | progress_bar_fill->UnReference(); |
201 | 1249 | pip_ltr->UnReference(); | 1273 | pip_ltr->UnReference(); |
202 | 1250 | pip_rtl->UnReference(); | 1274 | pip_rtl->UnReference(); |
203 | 1275 | large_pip_ltr->UnReference(); | ||
204 | 1276 | large_pip_rtl->UnReference(); | ||
205 | 1251 | arrow_ltr->UnReference(); | 1277 | arrow_ltr->UnReference(); |
206 | 1252 | arrow_rtl->UnReference(); | 1278 | arrow_rtl->UnReference(); |
207 | 1253 | arrow_empty_ltr->UnReference(); | 1279 | arrow_empty_ltr->UnReference(); |
208 | 1254 | 1280 | ||
209 | === modified file 'plugins/unityshell/src/SwitcherController.cpp' | |||
210 | --- plugins/unityshell/src/SwitcherController.cpp 2012-06-25 23:18:15 +0000 | |||
211 | +++ plugins/unityshell/src/SwitcherController.cpp 2013-04-23 02:51:28 +0000 | |||
212 | @@ -40,7 +40,7 @@ | |||
213 | 40 | } | 40 | } |
214 | 41 | 41 | ||
215 | 42 | Controller::Controller(unsigned int load_timeout) | 42 | Controller::Controller(unsigned int load_timeout) |
217 | 43 | : timeout_length(75) | 43 | : timeout_length(50) |
218 | 44 | , detail_on_timeout(true) | 44 | , detail_on_timeout(true) |
219 | 45 | , detail_timeout_length(500) | 45 | , detail_timeout_length(500) |
220 | 46 | , initial_detail_timeout_length(1500) | 46 | , initial_detail_timeout_length(1500) |
221 | @@ -91,12 +91,15 @@ | |||
222 | 91 | void Controller::Show(ShowMode show, SortMode sort, bool reverse, | 91 | void Controller::Show(ShowMode show, SortMode sort, bool reverse, |
223 | 92 | std::vector<AbstractLauncherIcon::Ptr> results) | 92 | std::vector<AbstractLauncherIcon::Ptr> results) |
224 | 93 | { | 93 | { |
225 | 94 | if (results.empty() || visible_) | ||
226 | 95 | return; | ||
227 | 96 | |||
228 | 94 | if (sort == SortMode::FOCUS_ORDER) | 97 | if (sort == SortMode::FOCUS_ORDER) |
229 | 95 | { | 98 | { |
230 | 96 | std::sort(results.begin(), results.end(), CompareSwitcherItemsPriority); | 99 | std::sort(results.begin(), results.end(), CompareSwitcherItemsPriority); |
231 | 97 | } | 100 | } |
232 | 98 | 101 | ||
234 | 99 | model_.reset(new SwitcherModel(results)); | 102 | model_ = std::make_shared<SwitcherModel>(results); |
235 | 100 | AddChild(model_.get()); | 103 | AddChild(model_.get()); |
236 | 101 | model_->selection_changed.connect(sigc::mem_fun(this, &Controller::OnModelSelectionChanged)); | 104 | model_->selection_changed.connect(sigc::mem_fun(this, &Controller::OnModelSelectionChanged)); |
237 | 102 | model_->only_detail_on_viewport = (show == ShowMode::CURRENT_VIEWPORT); | 105 | model_->only_detail_on_viewport = (show == ShowMode::CURRENT_VIEWPORT); |
238 | @@ -192,7 +195,8 @@ | |||
239 | 192 | 195 | ||
240 | 193 | ubus_manager_.SendMessage(UBUS_SWITCHER_START); | 196 | ubus_manager_.SendMessage(UBUS_SWITCHER_START); |
241 | 194 | 197 | ||
243 | 195 | if (view_window_) { | 198 | if (view_window_) |
244 | 199 | { | ||
245 | 196 | view_window_->ShowWindow(true); | 200 | view_window_->ShowWindow(true); |
246 | 197 | view_window_->PushToFront(); | 201 | view_window_->PushToFront(); |
247 | 198 | view_window_->SetOpacity(1.0f); | 202 | view_window_->SetOpacity(1.0f); |
248 | @@ -218,7 +222,6 @@ | |||
249 | 218 | view_window_->SetLayout(main_layout_); | 222 | view_window_->SetLayout(main_layout_); |
250 | 219 | view_window_->SetBackgroundColor(nux::Color(0x00000000)); | 223 | view_window_->SetBackgroundColor(nux::Color(0x00000000)); |
251 | 220 | view_window_->SetGeometry(workarea_); | 224 | view_window_->SetGeometry(workarea_); |
252 | 221 | view_window_->EnableInputWindow(true, "Switcher", false, false); | ||
253 | 222 | } | 225 | } |
254 | 223 | } | 226 | } |
255 | 224 | 227 | ||
256 | @@ -303,7 +306,6 @@ | |||
257 | 303 | view_window_->SetOpacity(0.0f); | 306 | view_window_->SetOpacity(0.0f); |
258 | 304 | view_window_->ShowWindow(false); | 307 | view_window_->ShowWindow(false); |
259 | 305 | view_window_->PushToBack(); | 308 | view_window_->PushToBack(); |
260 | 306 | view_window_->EnableInputWindow(false); | ||
261 | 307 | } | 309 | } |
262 | 308 | 310 | ||
263 | 309 | if (show_timer_) | 311 | if (show_timer_) |
264 | 310 | 312 | ||
265 | === modified file 'plugins/unityshell/src/SwitcherController.h' | |||
266 | --- plugins/unityshell/src/SwitcherController.h 2012-06-25 23:18:15 +0000 | |||
267 | +++ plugins/unityshell/src/SwitcherController.h 2013-04-23 02:51:28 +0000 | |||
268 | @@ -29,7 +29,6 @@ | |||
269 | 29 | #include "SwitcherView.h" | 29 | #include "SwitcherView.h" |
270 | 30 | #include "UBusWrapper.h" | 30 | #include "UBusWrapper.h" |
271 | 31 | 31 | ||
272 | 32 | #include <boost/shared_ptr.hpp> | ||
273 | 33 | #include <sigc++/sigc++.h> | 32 | #include <sigc++/sigc++.h> |
274 | 34 | 33 | ||
275 | 35 | #include <Nux/Nux.h> | 34 | #include <Nux/Nux.h> |
276 | 36 | 35 | ||
277 | === modified file 'plugins/unityshell/src/SwitcherModel.h' | |||
278 | --- plugins/unityshell/src/SwitcherModel.h 2012-08-15 18:26:01 +0000 | |||
279 | +++ plugins/unityshell/src/SwitcherModel.h 2013-04-23 02:51:28 +0000 | |||
280 | @@ -27,7 +27,7 @@ | |||
281 | 27 | 27 | ||
282 | 28 | #include "Introspectable.h" | 28 | #include "Introspectable.h" |
283 | 29 | 29 | ||
285 | 30 | #include <boost/shared_ptr.hpp> | 30 | #include <memory> |
286 | 31 | #include <sigc++/sigc++.h> | 31 | #include <sigc++/sigc++.h> |
287 | 32 | 32 | ||
288 | 33 | namespace unity | 33 | namespace unity |
289 | @@ -39,7 +39,7 @@ | |||
290 | 39 | { | 39 | { |
291 | 40 | 40 | ||
292 | 41 | public: | 41 | public: |
294 | 42 | typedef boost::shared_ptr<SwitcherModel> Ptr; | 42 | typedef std::shared_ptr<SwitcherModel> Ptr; |
295 | 43 | 43 | ||
296 | 44 | typedef std::vector<launcher::AbstractLauncherIcon::Ptr> Base; | 44 | typedef std::vector<launcher::AbstractLauncherIcon::Ptr> Base; |
297 | 45 | typedef Base::iterator iterator; | 45 | typedef Base::iterator iterator; |
298 | 46 | 46 | ||
299 | === modified file 'plugins/unityshell/src/WindowManager.h' | |||
300 | --- plugins/unityshell/src/WindowManager.h 2013-03-18 21:20:01 +0000 | |||
301 | +++ plugins/unityshell/src/WindowManager.h 2013-04-23 02:51:28 +0000 | |||
302 | @@ -20,6 +20,7 @@ | |||
303 | 20 | #define WINDOW_MANAGER_H | 20 | #define WINDOW_MANAGER_H |
304 | 21 | 21 | ||
305 | 22 | #include <Nux/Nux.h> | 22 | #include <Nux/Nux.h> |
306 | 23 | #include <NuxCore/Property.h> | ||
307 | 23 | #include <gdk/gdkx.h> | 24 | #include <gdk/gdkx.h> |
308 | 24 | #include <core/core.h> | 25 | #include <core/core.h> |
309 | 25 | 26 | ||
310 | @@ -110,6 +111,9 @@ | |||
311 | 110 | virtual bool saveInputFocus() = 0; | 111 | virtual bool saveInputFocus() = 0; |
312 | 111 | virtual bool restoreInputFocus() = 0; | 112 | virtual bool restoreInputFocus() = 0; |
313 | 112 | 113 | ||
314 | 114 | // Nux Modifiers, Nux Keycode (= X11 KeySym) | ||
315 | 115 | nux::Property<std::pair<unsigned, unsigned>> close_window_key; | ||
316 | 116 | |||
317 | 113 | // Signals | 117 | // Signals |
318 | 114 | sigc::signal<void, guint32> window_mapped; | 118 | sigc::signal<void, guint32> window_mapped; |
319 | 115 | sigc::signal<void, guint32> window_unmapped; | 119 | sigc::signal<void, guint32> window_unmapped; |
320 | 116 | 120 | ||
321 | === modified file 'plugins/unityshell/src/unityshell.cpp' | |||
322 | --- plugins/unityshell/src/unityshell.cpp 2013-04-04 18:37:52 +0000 | |||
323 | +++ plugins/unityshell/src/unityshell.cpp 2013-04-23 02:51:28 +0000 | |||
324 | @@ -351,12 +351,6 @@ | |||
325 | 351 | ubus_manager_.RegisterInterest(UBUS_LAUNCHER_END_KEY_SWTICHER, | 351 | ubus_manager_.RegisterInterest(UBUS_LAUNCHER_END_KEY_SWTICHER, |
326 | 352 | sigc::mem_fun(this, &UnityScreen::OnLauncherEndKeyNav)); | 352 | sigc::mem_fun(this, &UnityScreen::OnLauncherEndKeyNav)); |
327 | 353 | 353 | ||
328 | 354 | ubus_manager_.RegisterInterest(UBUS_SWITCHER_START, | ||
329 | 355 | sigc::mem_fun(this, &UnityScreen::OnSwitcherStart)); | ||
330 | 356 | |||
331 | 357 | ubus_manager_.RegisterInterest(UBUS_SWITCHER_END, | ||
332 | 358 | sigc::mem_fun(this, &UnityScreen::OnSwitcherEnd)); | ||
333 | 359 | |||
334 | 360 | g_idle_add_full (G_PRIORITY_DEFAULT, &UnityScreen::initPluginActions, this, NULL); | 354 | g_idle_add_full (G_PRIORITY_DEFAULT, &UnityScreen::initPluginActions, this, NULL); |
335 | 361 | super_keypressed_ = false; | 355 | super_keypressed_ = false; |
336 | 362 | 356 | ||
337 | @@ -944,7 +938,7 @@ | |||
338 | 944 | { | 938 | { |
339 | 945 | /* Create a new keybinding for the Escape key and the current modifiers, | 939 | /* Create a new keybinding for the Escape key and the current modifiers, |
340 | 946 | * compiz will take of the ref-counting of the repeated actions */ | 940 | * compiz will take of the ref-counting of the repeated actions */ |
342 | 947 | KeyCode escape = XKeysymToKeycode(screen->dpy(), XStringToKeysym("Escape")); | 941 | KeyCode escape = XKeysymToKeycode(screen->dpy(), XK_Escape); |
343 | 948 | CompAction::KeyBinding binding(escape, modifiers); | 942 | CompAction::KeyBinding binding(escape, modifiers); |
344 | 949 | 943 | ||
345 | 950 | CompActionPtr &escape_action = _escape_actions[target]; | 944 | CompActionPtr &escape_action = _escape_actions[target]; |
346 | @@ -1604,6 +1598,16 @@ | |||
347 | 1604 | break; | 1598 | break; |
348 | 1605 | } | 1599 | } |
349 | 1606 | } | 1600 | } |
350 | 1601 | else if (switcher_controller_->Visible()) | ||
351 | 1602 | { | ||
352 | 1603 | auto const& close_key = PluginAdapter::Default()->close_window_key(); | ||
353 | 1604 | |||
354 | 1605 | if (key_sym == close_key.second && XModifiersToNux(event->xkey.state) == close_key.first) | ||
355 | 1606 | { | ||
356 | 1607 | switcher_controller_->Hide(false); | ||
357 | 1608 | skip_other_plugins = true; | ||
358 | 1609 | } | ||
359 | 1610 | } | ||
360 | 1607 | 1611 | ||
361 | 1608 | if (result > 0) | 1612 | if (result > 0) |
362 | 1609 | { | 1613 | { |
363 | @@ -1673,10 +1677,9 @@ | |||
364 | 1673 | } | 1677 | } |
365 | 1674 | 1678 | ||
366 | 1675 | if (!skip_other_plugins && | 1679 | if (!skip_other_plugins && |
369 | 1676 | screen->otherGrabExist("deco", "move", "switcher", "resize", NULL) && | 1680 | screen->otherGrabExist("deco", "move", "switcher", "resize", "unity-switcher", nullptr)) |
368 | 1677 | !switcher_controller_->Visible()) | ||
370 | 1678 | { | 1681 | { |
372 | 1679 | wt->ProcessForeignEvent(event, NULL); | 1682 | wt->ProcessForeignEvent(event, nullptr); |
373 | 1680 | } | 1683 | } |
374 | 1681 | } | 1684 | } |
375 | 1682 | 1685 | ||
376 | @@ -2105,41 +2108,10 @@ | |||
377 | 2105 | 2108 | ||
378 | 2106 | void UnityScreen::OnLauncherEndKeyNav(GVariant* data) | 2109 | void UnityScreen::OnLauncherEndKeyNav(GVariant* data) |
379 | 2107 | { | 2110 | { |
380 | 2108 | RestoreWindow(data); | ||
381 | 2109 | } | ||
382 | 2110 | |||
383 | 2111 | void UnityScreen::OnSwitcherStart(GVariant* data) | ||
384 | 2112 | { | ||
385 | 2113 | if (switcher_controller_->Visible()) | ||
386 | 2114 | { | ||
387 | 2115 | newFocusedWindow = screen->findWindow(switcher_controller_->GetSwitcherInputWindowId()); | ||
388 | 2116 | |||
389 | 2117 | if (switcher_controller_->GetSwitcherInputWindowId() != screen->activeWindow()) | ||
390 | 2118 | PluginAdapter::Default()->saveInputFocus(); | ||
391 | 2119 | |||
392 | 2120 | if (newFocusedWindow) | ||
393 | 2121 | newFocusedWindow->moveInputFocusTo(); | ||
394 | 2122 | } | ||
395 | 2123 | } | ||
396 | 2124 | |||
397 | 2125 | void UnityScreen::OnSwitcherEnd(GVariant* data) | ||
398 | 2126 | { | ||
399 | 2127 | RestoreWindow(data); | ||
400 | 2128 | } | ||
401 | 2129 | |||
402 | 2130 | void UnityScreen::RestoreWindow(GVariant* data) | ||
403 | 2131 | { | ||
404 | 2132 | bool preserve_focus = false; | ||
405 | 2133 | |||
406 | 2134 | if (data) | ||
407 | 2135 | { | ||
408 | 2136 | preserve_focus = g_variant_get_boolean(data); | ||
409 | 2137 | } | ||
410 | 2138 | |||
411 | 2139 | // Return input-focus to previously focused window (before key-nav-mode was | 2111 | // Return input-focus to previously focused window (before key-nav-mode was |
412 | 2140 | // entered) | 2112 | // entered) |
415 | 2141 | if (preserve_focus) | 2113 | if (data && g_variant_get_boolean(data)) |
416 | 2142 | PluginAdapter::Default ()->restoreInputFocus (); | 2114 | PluginAdapter::Default()->restoreInputFocus(); |
417 | 2143 | } | 2115 | } |
418 | 2144 | 2116 | ||
419 | 2145 | bool UnityScreen::ShowHud() | 2117 | bool UnityScreen::ShowHud() |
420 | @@ -2226,9 +2198,70 @@ | |||
421 | 2226 | return ShowHud(); | 2198 | return ShowHud(); |
422 | 2227 | } | 2199 | } |
423 | 2228 | 2200 | ||
424 | 2201 | unsigned UnityScreen::CompizModifiersToNux(unsigned input) const | ||
425 | 2202 | { | ||
426 | 2203 | unsigned modifiers = 0; | ||
427 | 2204 | |||
428 | 2205 | if (input & CompAltMask) | ||
429 | 2206 | { | ||
430 | 2207 | input &= ~CompAltMask; | ||
431 | 2208 | input |= Mod1Mask; | ||
432 | 2209 | } | ||
433 | 2210 | |||
434 | 2211 | if (modifiers & CompSuperMask) | ||
435 | 2212 | { | ||
436 | 2213 | input &= ~CompSuperMask; | ||
437 | 2214 | input |= Mod4Mask; | ||
438 | 2215 | } | ||
439 | 2216 | |||
440 | 2217 | return XModifiersToNux(input); | ||
441 | 2218 | } | ||
442 | 2219 | |||
443 | 2220 | unsigned UnityScreen::XModifiersToNux(unsigned input) const | ||
444 | 2221 | { | ||
445 | 2222 | unsigned modifiers = 0; | ||
446 | 2223 | |||
447 | 2224 | if (input & Mod1Mask) | ||
448 | 2225 | modifiers |= nux::KEY_MODIFIER_ALT; | ||
449 | 2226 | |||
450 | 2227 | if (input & ShiftMask) | ||
451 | 2228 | modifiers |= nux::KEY_MODIFIER_SHIFT; | ||
452 | 2229 | |||
453 | 2230 | if (input & ControlMask) | ||
454 | 2231 | modifiers |= nux::KEY_MODIFIER_CTRL; | ||
455 | 2232 | |||
456 | 2233 | if (input & Mod4Mask) | ||
457 | 2234 | modifiers |= nux::KEY_MODIFIER_SUPER; | ||
458 | 2235 | |||
459 | 2236 | return modifiers; | ||
460 | 2237 | } | ||
461 | 2238 | |||
462 | 2239 | void UnityScreen::UpdateCloseWindowKey(CompAction::KeyBinding const& keybind) | ||
463 | 2240 | { | ||
464 | 2241 | KeySym keysym = XkbKeycodeToKeysym(screen->dpy(), keybind.keycode(), 0, 0); | ||
465 | 2242 | unsigned modifiers = CompizModifiersToNux(keybind.modifiers()); | ||
466 | 2243 | |||
467 | 2244 | WindowManager::Default()->close_window_key = std::make_pair(modifiers, keysym); | ||
468 | 2245 | } | ||
469 | 2246 | |||
470 | 2229 | gboolean UnityScreen::initPluginActions(gpointer data) | 2247 | gboolean UnityScreen::initPluginActions(gpointer data) |
471 | 2230 | { | 2248 | { |
473 | 2231 | CompPlugin* p = CompPlugin::find("expo"); | 2249 | CompPlugin* p = CompPlugin::find("core"); |
474 | 2250 | auto self = static_cast<UnityScreen*>(data); | ||
475 | 2251 | |||
476 | 2252 | if (p) | ||
477 | 2253 | { | ||
478 | 2254 | for (CompOption& option : p->vTable->getOptions()) | ||
479 | 2255 | { | ||
480 | 2256 | if (option.name() == "close_window_key") | ||
481 | 2257 | { | ||
482 | 2258 | self->UpdateCloseWindowKey(option.value().action().key()); | ||
483 | 2259 | break; | ||
484 | 2260 | } | ||
485 | 2261 | } | ||
486 | 2262 | } | ||
487 | 2263 | |||
488 | 2264 | p = CompPlugin::find("expo"); | ||
489 | 2232 | 2265 | ||
490 | 2233 | if (p) | 2266 | if (p) |
491 | 2234 | { | 2267 | { |
492 | @@ -2995,9 +3028,16 @@ | |||
493 | 2995 | bool status = screen->setOptionForPlugin(plugin, name, v); | 3028 | bool status = screen->setOptionForPlugin(plugin, name, v); |
494 | 2996 | if (status) | 3029 | if (status) |
495 | 2997 | { | 3030 | { |
497 | 2998 | if (strcmp(plugin, "core") == 0 && strcmp(name, "hsize") == 0) | 3031 | if (strcmp(plugin, "core") == 0) |
498 | 2999 | { | 3032 | { |
500 | 3000 | launcher_controller_->UpdateNumWorkspaces(screen->vpSize().width() * screen->vpSize().height()); | 3033 | if (strcmp(name, "hsize") == 0 || strcmp(name, "vsize") == 0) |
501 | 3034 | { | ||
502 | 3035 | launcher_controller_->UpdateNumWorkspaces(screen->vpSize().width() * screen->vpSize().height()); | ||
503 | 3036 | } | ||
504 | 3037 | else if (strcmp(name, "close_window_key") == 0) | ||
505 | 3038 | { | ||
506 | 3039 | UpdateCloseWindowKey(v.action().key()); | ||
507 | 3040 | } | ||
508 | 3001 | } | 3041 | } |
509 | 3002 | } | 3042 | } |
510 | 3003 | return status; | 3043 | return status; |
511 | 3004 | 3044 | ||
512 | === modified file 'plugins/unityshell/src/unityshell.h' | |||
513 | --- plugins/unityshell/src/unityshell.h 2013-04-04 18:18:50 +0000 | |||
514 | +++ plugins/unityshell/src/unityshell.h 2013-04-23 02:51:28 +0000 | |||
515 | @@ -232,15 +232,15 @@ | |||
516 | 232 | void OnLauncherStartKeyNav(GVariant* data); | 232 | void OnLauncherStartKeyNav(GVariant* data); |
517 | 233 | void OnLauncherEndKeyNav(GVariant* data); | 233 | void OnLauncherEndKeyNav(GVariant* data); |
518 | 234 | 234 | ||
519 | 235 | void OnSwitcherStart(GVariant* data); | ||
520 | 236 | void OnSwitcherEnd(GVariant* data); | ||
521 | 237 | |||
522 | 238 | void RestoreWindow(GVariant* data); | ||
523 | 239 | |||
524 | 240 | void InitHints(); | 235 | void InitHints(); |
525 | 241 | 236 | ||
526 | 242 | void OnPanelStyleChanged(); | 237 | void OnPanelStyleChanged(); |
527 | 243 | 238 | ||
528 | 239 | unsigned CompizModifiersToNux(unsigned input) const; | ||
529 | 240 | unsigned XModifiersToNux(unsigned input) const; | ||
530 | 241 | |||
531 | 242 | void UpdateCloseWindowKey(CompAction::KeyBinding const&); | ||
532 | 243 | |||
533 | 244 | dash::Settings dash_settings_; | 244 | dash::Settings dash_settings_; |
534 | 245 | dash::Style dash_style_; | 245 | dash::Style dash_style_; |
535 | 246 | panel::Style panel_style_; | 246 | panel::Style panel_style_; |
536 | 247 | 247 | ||
537 | === modified file 'tests/autopilot/autopilot/tests/test_dash.py' | |||
538 | --- tests/autopilot/autopilot/tests/test_dash.py 2012-06-27 01:19:32 +0000 | |||
539 | +++ tests/autopilot/autopilot/tests/test_dash.py 2013-04-23 02:51:28 +0000 | |||
540 | @@ -60,6 +60,15 @@ | |||
541 | 60 | self.keyboard.press_and_release("Alt+F4") | 60 | self.keyboard.press_and_release("Alt+F4") |
542 | 61 | self.assertThat(self.dash.visible, Eventually(Equals(False))) | 61 | self.assertThat(self.dash.visible, Eventually(Equals(False))) |
543 | 62 | 62 | ||
544 | 63 | def test_alt_f4_close_dash_with_capslock_on(self): | ||
545 | 64 | """Dash must close on Alt+F4 even when the capslock is turned on.""" | ||
546 | 65 | self.keyboard.press_and_release("Caps_Lock") | ||
547 | 66 | self.addCleanup(self.keyboard.press_and_release, "Caps_Lock") | ||
548 | 67 | |||
549 | 68 | self.dash.ensure_visible() | ||
550 | 69 | self.keyboard.press_and_release("Alt+F4") | ||
551 | 70 | self.assertThat(self.dash.visible, Eventually(Equals(False))) | ||
552 | 71 | |||
553 | 63 | def test_dash_closes_on_spread(self): | 72 | def test_dash_closes_on_spread(self): |
554 | 64 | """This test shows that when the spread is initiated, the dash closes.""" | 73 | """This test shows that when the spread is initiated, the dash closes.""" |
555 | 65 | self.dash.ensure_visible() | 74 | self.dash.ensure_visible() |
556 | 66 | 75 | ||
557 | === modified file 'tests/autopilot/autopilot/tests/test_hud.py' | |||
558 | --- tests/autopilot/autopilot/tests/test_hud.py 2012-06-25 22:02:54 +0000 | |||
559 | +++ tests/autopilot/autopilot/tests/test_hud.py 2013-04-23 02:51:28 +0000 | |||
560 | @@ -266,6 +266,15 @@ | |||
561 | 266 | 266 | ||
562 | 267 | self.assertThat(self.hud.visible, Eventually(Equals(False))) | 267 | self.assertThat(self.hud.visible, Eventually(Equals(False))) |
563 | 268 | 268 | ||
564 | 269 | def test_alt_f4_close_hud_with_capslock_on(self): | ||
565 | 270 | """Hud must close on Alt+F4 even when the capslock is turned on.""" | ||
566 | 271 | self.keyboard.press_and_release("Caps_Lock") | ||
567 | 272 | self.addCleanup(self.keyboard.press_and_release, "Caps_Lock") | ||
568 | 273 | |||
569 | 274 | self.hud.ensure_visible() | ||
570 | 275 | self.keyboard.press_and_release("Alt+F4") | ||
571 | 276 | self.assertThat(self.hud.visible, Eventually(Equals(False))) | ||
572 | 277 | |||
573 | 269 | 278 | ||
574 | 270 | class HudLauncherInteractionsTests(HudTestsBase): | 279 | class HudLauncherInteractionsTests(HudTestsBase): |
575 | 271 | 280 |
Sweet, looks good to me!