Merge lp:~3v1n0/unity/wm-click-actions into lp:unity
- wm-click-actions
- Merge into trunk
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Stephen M. Webb | ||||
Approved revision: | no longer in the source branch. | ||||
Merged at revision: | 3770 | ||||
Proposed branch: | lp:~3v1n0/unity/wm-click-actions | ||||
Merge into: | lp:unity | ||||
Prerequisite: | lp:~3v1n0/unity/right-left-click-maximize-fix | ||||
Diff against target: |
756 lines (+362/-65) 14 files modified
decorations/DecorationsGrabEdge.cpp (+56/-6) decorations/DecorationsGrabEdge.h (+1/-0) panel/PanelMenuView.cpp (+77/-42) panel/PanelMenuView.h (+4/-3) panel/PanelTitlebarGrabAreaView.cpp (+4/-4) panel/PanelTitlebarGrabAreaView.h (+4/-4) unity-shared/DecorationStyle.cpp (+51/-0) unity-shared/DecorationStyle.h (+21/-0) unity-shared/PluginAdapter.cpp (+41/-1) unity-shared/PluginAdapter.h (+5/-0) unity-shared/StandaloneDecorationStyle.cpp (+34/-0) unity-shared/StandaloneWindowManager.cpp (+53/-5) unity-shared/StandaloneWindowManager.h (+6/-0) unity-shared/WindowManager.h (+5/-0) |
||||
To merge this branch: | bzr merge lp:~3v1n0/unity/wm-click-actions | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot (community) | continuous-integration | Approve | |
Brandon Schaefer (community) | Approve | ||
Review via email: mp+213932@code.launchpad.net |
Commit message
DecorationsGrab
Description of the change
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:3760
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:3760
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Preview Diff
1 | === modified file 'decorations/DecorationsGrabEdge.cpp' |
2 | --- decorations/DecorationsGrabEdge.cpp 2014-04-02 21:44:17 +0000 |
3 | +++ decorations/DecorationsGrabEdge.cpp 2014-04-02 21:44:17 +0000 |
4 | @@ -37,8 +37,8 @@ |
5 | { |
6 | if (button != 1) |
7 | { |
8 | - if (button == 3) |
9 | - screen->toolkitAction(Atoms::toolkitActionWindowMenu, timestamp, win_->id(), button, p.x(), p.y()); |
10 | + if (button == 2 || button == 3) |
11 | + PerformWMAction(p, button, timestamp); |
12 | |
13 | return; |
14 | } |
15 | @@ -51,7 +51,7 @@ |
16 | |
17 | auto const& style = Style::Get(); |
18 | unsigned max_time_delta = std::max(0, style->DoubleClickMaxTimeDelta()); |
19 | - bool maximized = false; |
20 | + bool double_clicked = false; |
21 | |
22 | if (timestamp - last_click_time_ < max_time_delta) |
23 | { |
24 | @@ -60,13 +60,13 @@ |
25 | if (std::abs(p.x() - last_click_pos_.x()) < max_distance && |
26 | std::abs(p.y() - last_click_pos_.y()) < max_distance) |
27 | { |
28 | - win_->maximize(MAXIMIZE_STATE); |
29 | - maximized = true; |
30 | + PerformWMAction(p, button, timestamp); |
31 | + double_clicked = true; |
32 | button_down_timer_.reset(); |
33 | } |
34 | } |
35 | |
36 | - if (!maximized) |
37 | + if (!double_clicked) |
38 | { |
39 | button_down_timer_.reset(new glib::Timeout(style->grab_wait())); |
40 | button_down_timer_->Run([this] { |
41 | @@ -96,6 +96,56 @@ |
42 | button_down_ = -1; |
43 | } |
44 | |
45 | +void GrabEdge::PerformWMAction(CompPoint const& p, unsigned button, Time timestamp) |
46 | +{ |
47 | + WMAction action = Style::Get()->WindowManagerAction(WMEvent(button)); |
48 | + |
49 | + switch (action) |
50 | + { |
51 | + case WMAction::TOGGLE_SHADE: |
52 | + if (win_->state() & CompWindowStateShadedMask) |
53 | + win_->changeState(win_->state() & ~CompWindowStateShadedMask); |
54 | + else |
55 | + win_->changeState(win_->state() | CompWindowStateShadedMask); |
56 | + |
57 | + win_->updateAttributes(CompStackingUpdateModeNone); |
58 | + break; |
59 | + case WMAction::TOGGLE_MAXIMIZE: |
60 | + if ((win_->state() & MAXIMIZE_STATE) == MAXIMIZE_STATE) |
61 | + win_->maximize(0); |
62 | + else |
63 | + win_->maximize(MAXIMIZE_STATE); |
64 | + break; |
65 | + case WMAction::TOGGLE_MAXIMIZE_HORIZONTALLY: |
66 | + if (win_->state() & CompWindowStateMaximizedHorzMask) |
67 | + win_->maximize(0); |
68 | + else |
69 | + win_->maximize(CompWindowStateMaximizedHorzMask); |
70 | + break; |
71 | + case WMAction::TOGGLE_MAXIMIZE_VERTICALLY: |
72 | + if (win_->state() & CompWindowStateMaximizedVertMask) |
73 | + win_->maximize(0); |
74 | + else |
75 | + win_->maximize(CompWindowStateMaximizedVertMask); |
76 | + break; |
77 | + case WMAction::MINIMIZE: |
78 | + win_->minimize(); |
79 | + break; |
80 | + case WMAction::SHADE: |
81 | + win_->changeState(win_->state() | CompWindowStateShadedMask); |
82 | + win_->updateAttributes(CompStackingUpdateModeNone); |
83 | + break; |
84 | + case WMAction::MENU: |
85 | + screen->toolkitAction(Atoms::toolkitActionWindowMenu, timestamp, win_->id(), button, p.x(), p.y()); |
86 | + break; |
87 | + case WMAction::LOWER: |
88 | + win_->lower(); |
89 | + break; |
90 | + default: |
91 | + break; |
92 | + } |
93 | +} |
94 | + |
95 | bool GrabEdge::IsGrabbed() const |
96 | { |
97 | return !button_down_timer_; |
98 | |
99 | === modified file 'decorations/DecorationsGrabEdge.h' |
100 | --- decorations/DecorationsGrabEdge.h 2014-02-13 04:45:22 +0000 |
101 | +++ decorations/DecorationsGrabEdge.h 2014-04-02 21:44:17 +0000 |
102 | @@ -44,6 +44,7 @@ |
103 | |
104 | protected: |
105 | void AddProperties(debug::IntrospectionData&); |
106 | + void PerformWMAction(CompPoint const&, unsigned button, Time); |
107 | |
108 | private: |
109 | Time last_click_time_; |
110 | |
111 | === modified file 'panel/PanelMenuView.cpp' |
112 | --- panel/PanelMenuView.cpp 2014-03-31 21:09:08 +0000 |
113 | +++ panel/PanelMenuView.cpp 2014-04-02 21:44:17 +0000 |
114 | @@ -173,10 +173,10 @@ |
115 | { |
116 | titlebar_grab_area_ = new PanelTitlebarGrabArea(); |
117 | titlebar_grab_area_->SetParentObject(this); |
118 | - titlebar_grab_area_->activate_request.connect(sigc::mem_fun(this, &PanelMenuView::OnMaximizedActivate)); |
119 | - titlebar_grab_area_->restore_request.connect(sigc::mem_fun(this, &PanelMenuView::OnMaximizedRestore)); |
120 | - titlebar_grab_area_->lower_request.connect(sigc::mem_fun(this, &PanelMenuView::OnMaximizedLower)); |
121 | - titlebar_grab_area_->menu_request.connect(sigc::mem_fun(this, &PanelMenuView::OnMaximizedShowActionMenu)); |
122 | + titlebar_grab_area_->clicked.connect(sigc::mem_fun(this, &PanelMenuView::OnMaximizedActivate)); |
123 | + titlebar_grab_area_->double_clicked.connect(sigc::mem_fun(this, &PanelMenuView::OnMaximizedDoubleClicked)); |
124 | + titlebar_grab_area_->middle_clicked.connect(sigc::mem_fun(this, &PanelMenuView::OnMaximizedMiddleClicked)); |
125 | + titlebar_grab_area_->right_clicked.connect(sigc::mem_fun(this, &PanelMenuView::OnMaximizedRightClicked)); |
126 | titlebar_grab_area_->grab_started.connect(sigc::mem_fun(this, &PanelMenuView::OnMaximizedGrabStart)); |
127 | titlebar_grab_area_->grab_move.connect(sigc::mem_fun(this, &PanelMenuView::OnMaximizedGrabMove)); |
128 | titlebar_grab_area_->grab_end.connect(sigc::mem_fun(this, &PanelMenuView::OnMaximizedGrabEnd)); |
129 | @@ -1455,44 +1455,79 @@ |
130 | } |
131 | } |
132 | |
133 | -void PanelMenuView::OnMaximizedRestore(int x, int y) |
134 | -{ |
135 | - Window maximized = GetMaximizedWindow(); |
136 | - |
137 | - if (maximized != 0) |
138 | - { |
139 | - WindowManager::Default().Restore(maximized); |
140 | - is_inside_ = true; |
141 | - } |
142 | -} |
143 | - |
144 | -void PanelMenuView::OnMaximizedLower(int x, int y) |
145 | -{ |
146 | - Window maximized = GetMaximizedWindow(); |
147 | - |
148 | - if (maximized != 0) |
149 | - { |
150 | - WindowManager::Default().Lower(maximized); |
151 | - } |
152 | -} |
153 | - |
154 | -void PanelMenuView::OnMaximizedShowActionMenu(int x, int y) |
155 | -{ |
156 | - Window maximized = GetMaximizedWindow(); |
157 | - |
158 | - if (maximized != 0) |
159 | - { |
160 | - auto const& event = nux::GetGraphicsDisplay()->GetCurrentEvent(); |
161 | - auto const& abs_geo = titlebar_grab_area_->GetAbsoluteGeometry(); |
162 | - int button = event.GetEventButton(); |
163 | - nux::Point click(abs_geo.x + x, abs_geo.y + y); |
164 | - auto& wm = WindowManager::Default(); |
165 | - wm.UnGrabMousePointer(event.x11_timestamp, button, click.x, click.y); |
166 | - wm.ShowActionMenu(event.x11_timestamp, maximized, button, click); |
167 | - |
168 | - is_inside_ = false; |
169 | - QueueDraw(); |
170 | - } |
171 | +void PanelMenuView::MaximizedWindowWMAction(int x, int y, unsigned button) |
172 | +{ |
173 | + Window maximized = GetMaximizedWindow(); |
174 | + |
175 | + if (!maximized) |
176 | + return; |
177 | + |
178 | + using namespace decoration; |
179 | + auto& wm = WindowManager::Default(); |
180 | + auto action = decoration::Style::Get()->WindowManagerAction(WMEvent(button)); |
181 | + |
182 | + switch (action) |
183 | + { |
184 | + case WMAction::TOGGLE_SHADE: |
185 | + if (wm.IsWindowShaded(maximized)) |
186 | + wm.UnShade(maximized); |
187 | + else |
188 | + wm.Shade(maximized); |
189 | + break; |
190 | + case WMAction::TOGGLE_MAXIMIZE: |
191 | + wm.Restore(maximized); |
192 | + is_inside_ = true; |
193 | + break; |
194 | + case WMAction::TOGGLE_MAXIMIZE_HORIZONTALLY: |
195 | + wm.HorizontallyMaximize(maximized); |
196 | + is_inside_ = true; |
197 | + break; |
198 | + case WMAction::TOGGLE_MAXIMIZE_VERTICALLY: |
199 | + wm.VerticallyMaximize(maximized); |
200 | + is_inside_ = true; |
201 | + break; |
202 | + case WMAction::MINIMIZE: |
203 | + wm.Minimize(maximized); |
204 | + is_inside_ = true; |
205 | + break; |
206 | + case WMAction::SHADE: |
207 | + wm.Shade(maximized); |
208 | + break; |
209 | + case WMAction::MENU: |
210 | + { |
211 | + auto const& event = nux::GetGraphicsDisplay()->GetCurrentEvent(); |
212 | + auto const& abs_geo = titlebar_grab_area_->GetAbsoluteGeometry(); |
213 | + int button = event.GetEventButton(); |
214 | + nux::Point click(abs_geo.x + x, abs_geo.y + y); |
215 | + auto& wm = WindowManager::Default(); |
216 | + wm.UnGrabMousePointer(event.x11_timestamp, button, click.x, click.y); |
217 | + wm.ShowActionMenu(event.x11_timestamp, maximized, button, click); |
218 | + |
219 | + is_inside_ = false; |
220 | + QueueDraw(); |
221 | + break; |
222 | + } |
223 | + case WMAction::LOWER: |
224 | + wm.Lower(maximized); |
225 | + break; |
226 | + default: |
227 | + break; |
228 | + } |
229 | +} |
230 | + |
231 | +void PanelMenuView::OnMaximizedDoubleClicked(int x, int y) |
232 | +{ |
233 | + MaximizedWindowWMAction(x, y, 1); |
234 | +} |
235 | + |
236 | +void PanelMenuView::OnMaximizedMiddleClicked(int x, int y) |
237 | +{ |
238 | + MaximizedWindowWMAction(x, y, 2); |
239 | +} |
240 | + |
241 | +void PanelMenuView::OnMaximizedRightClicked(int x, int y) |
242 | +{ |
243 | + MaximizedWindowWMAction(x, y, 3); |
244 | } |
245 | |
246 | void PanelMenuView::OnMaximizedGrabStart(int x, int y) |
247 | |
248 | === modified file 'panel/PanelMenuView.h' |
249 | --- panel/PanelMenuView.h 2014-03-06 09:26:03 +0000 |
250 | +++ panel/PanelMenuView.h 2014-04-02 21:44:17 +0000 |
251 | @@ -105,12 +105,13 @@ |
252 | void OnWindowMoved(Window xid); |
253 | |
254 | void OnMaximizedActivate(int x, int y); |
255 | - void OnMaximizedRestore(int x, int y); |
256 | - void OnMaximizedLower(int x, int y); |
257 | - void OnMaximizedShowActionMenu(int x, int y); |
258 | + void OnMaximizedDoubleClicked(int x, int y); |
259 | + void OnMaximizedMiddleClicked(int x, int y); |
260 | + void OnMaximizedRightClicked(int x, int y); |
261 | void OnMaximizedGrabStart(int x, int y); |
262 | void OnMaximizedGrabMove(int x, int y); |
263 | void OnMaximizedGrabEnd(int x, int y); |
264 | + void MaximizedWindowWMAction(int x, int y, unsigned button); |
265 | |
266 | void FullRedraw(); |
267 | std::string GetCurrentTitle() const; |
268 | |
269 | === modified file 'panel/PanelTitlebarGrabAreaView.cpp' |
270 | --- panel/PanelTitlebarGrabAreaView.cpp 2014-02-14 19:01:49 +0000 |
271 | +++ panel/PanelTitlebarGrabAreaView.cpp 2014-04-02 21:44:17 +0000 |
272 | @@ -44,7 +44,7 @@ |
273 | mouse_double_click.connect([this] (int x, int y, unsigned long button_flags, unsigned long) |
274 | { |
275 | if (nux::GetEventButton(button_flags) == 1) |
276 | - restore_request.emit(x, y); |
277 | + double_clicked.emit(x, y); |
278 | }); |
279 | } |
280 | |
281 | @@ -105,11 +105,11 @@ |
282 | } |
283 | else if (mouse_down_button_ == 2) |
284 | { |
285 | - lower_request.emit(x, y); |
286 | + middle_clicked.emit(x, y); |
287 | } |
288 | else if (mouse_down_button_ == 3) |
289 | { |
290 | - menu_request.emit(x, y); |
291 | + right_clicked.emit(x, y); |
292 | } |
293 | } |
294 | |
295 | @@ -122,7 +122,7 @@ |
296 | if (mouse_down_timer_) |
297 | { |
298 | mouse_down_timer_.reset(); |
299 | - activate_request.emit(x, y); |
300 | + clicked.emit(x, y); |
301 | } |
302 | |
303 | if (grab_started_) |
304 | |
305 | === modified file 'panel/PanelTitlebarGrabAreaView.h' |
306 | --- panel/PanelTitlebarGrabAreaView.h 2014-02-14 03:10:56 +0000 |
307 | +++ panel/PanelTitlebarGrabAreaView.h 2014-04-02 21:44:17 +0000 |
308 | @@ -43,10 +43,10 @@ |
309 | void SetGrabbed(bool enabled); |
310 | bool IsGrabbed(); |
311 | |
312 | - sigc::signal<void, int, int> lower_request; |
313 | - sigc::signal<void, int, int> activate_request; |
314 | - sigc::signal<void, int, int> restore_request; |
315 | - sigc::signal<void, int, int> menu_request; |
316 | + sigc::signal<void, int, int> clicked; |
317 | + sigc::signal<void, int, int> middle_clicked; |
318 | + sigc::signal<void, int, int> double_clicked; |
319 | + sigc::signal<void, int, int> right_clicked; |
320 | sigc::signal<void, int, int> grab_started; |
321 | sigc::signal<void, int, int> grab_move; |
322 | sigc::signal<void, int, int> grab_end; |
323 | |
324 | === modified file 'unity-shared/DecorationStyle.cpp' |
325 | --- unity-shared/DecorationStyle.cpp 2014-03-31 19:02:32 +0000 |
326 | +++ unity-shared/DecorationStyle.cpp 2014-04-02 21:44:17 +0000 |
327 | @@ -61,6 +61,9 @@ |
328 | const std::string SETTINGS_NAME = "org.gnome.desktop.wm.preferences"; |
329 | const std::string FONT_KEY = "titlebar-font"; |
330 | const std::string USE_SYSTEM_FONT_KEY = "titlebar-uses-system-font"; |
331 | +const std::string ACTION_DOUBLE_CLICK = "action-double-click-titlebar"; |
332 | +const std::string ACTION_MIDDLE_CLICK = "action-middle-click-titlebar"; |
333 | +const std::string ACTION_RIGHT_CLICK = "action-right-click-titlebar"; |
334 | |
335 | const std::string UNITY_SETTINGS_NAME = "com.canonical.Unity.Decorations"; |
336 | const std::string GRAB_WAIT_KEY = "grab-wait"; |
337 | @@ -299,6 +302,49 @@ |
338 | return value; |
339 | } |
340 | |
341 | + WMAction WMActionFromString(std::string const& action) const |
342 | + { |
343 | + if (action == "toggle-shade") |
344 | + return WMAction::TOGGLE_SHADE; |
345 | + else if (action == "toggle-maximize") |
346 | + return WMAction::TOGGLE_MAXIMIZE; |
347 | + else if (action == "toggle-maximize-horizontally") |
348 | + return WMAction::TOGGLE_MAXIMIZE_HORIZONTALLY; |
349 | + else if (action == "toggle-maximize-vertically") |
350 | + return WMAction::TOGGLE_MAXIMIZE_VERTICALLY; |
351 | + else if (action == "minimize") |
352 | + return WMAction::MINIMIZE; |
353 | + else if (action == "shade") |
354 | + return WMAction::SHADE; |
355 | + else if (action == "menu") |
356 | + return WMAction::MENU; |
357 | + else if (action == "lower") |
358 | + return WMAction::LOWER; |
359 | + |
360 | + return WMAction::NONE; |
361 | + } |
362 | + |
363 | + WMAction WindowManagerAction(WMEvent event) const |
364 | + { |
365 | + std::string action_setting; |
366 | + |
367 | + switch (event) |
368 | + { |
369 | + case WMEvent::DOUBLE_CLICK: |
370 | + action_setting = ACTION_DOUBLE_CLICK; |
371 | + break; |
372 | + case WMEvent::MIDDLE_CLICK: |
373 | + action_setting = ACTION_MIDDLE_CLICK; |
374 | + break; |
375 | + case WMEvent::RIGHT_CLICK: |
376 | + action_setting = ACTION_RIGHT_CLICK; |
377 | + break; |
378 | + } |
379 | + |
380 | + glib::String action_string(g_settings_get_string(settings_, action_setting.c_str())); |
381 | + return WMActionFromString(action_string.Str()); |
382 | + } |
383 | + |
384 | inline GtkStateFlags GtkStateFromWidgetState(WidgetState ws) |
385 | { |
386 | switch (ws) |
387 | @@ -776,6 +822,11 @@ |
388 | return impl_->glow_color_; |
389 | } |
390 | |
391 | +WMAction Style::WindowManagerAction(WMEvent event) const |
392 | +{ |
393 | + return impl_->WindowManagerAction(event); |
394 | +} |
395 | + |
396 | int Style::DoubleClickMaxDistance() const |
397 | { |
398 | return impl_->GetSettingValue<int>("gtk-double-click-distance"); |
399 | |
400 | === modified file 'unity-shared/DecorationStyle.h' |
401 | --- unity-shared/DecorationStyle.h 2014-03-31 19:02:32 +0000 |
402 | +++ unity-shared/DecorationStyle.h 2014-04-02 21:44:17 +0000 |
403 | @@ -68,6 +68,26 @@ |
404 | Size |
405 | }; |
406 | |
407 | +enum class WMEvent |
408 | +{ |
409 | + DOUBLE_CLICK = 1, |
410 | + MIDDLE_CLICK = 2, |
411 | + RIGHT_CLICK = 3 |
412 | +}; |
413 | + |
414 | +enum class WMAction |
415 | +{ |
416 | + TOGGLE_SHADE, |
417 | + TOGGLE_MAXIMIZE, |
418 | + TOGGLE_MAXIMIZE_HORIZONTALLY, |
419 | + TOGGLE_MAXIMIZE_VERTICALLY, |
420 | + MINIMIZE, |
421 | + SHADE, |
422 | + MENU, |
423 | + LOWER, |
424 | + NONE |
425 | +}; |
426 | + |
427 | struct Border |
428 | { |
429 | Border(int top, int left, int right, int bottom) |
430 | @@ -127,6 +147,7 @@ |
431 | std::string WindowButtonFile(WindowButtonType, WidgetState) const; |
432 | void DrawWindowButton(WindowButtonType, WidgetState, cairo_t*, double width, double height); |
433 | |
434 | + WMAction WindowManagerAction(WMEvent) const; |
435 | int DoubleClickMaxDistance() const; |
436 | int DoubleClickMaxTimeDelta() const; |
437 | |
438 | |
439 | === modified file 'unity-shared/PluginAdapter.cpp' |
440 | --- unity-shared/PluginAdapter.cpp 2014-03-12 23:45:48 +0000 |
441 | +++ unity-shared/PluginAdapter.cpp 2014-04-02 21:44:17 +0000 |
442 | @@ -573,6 +573,14 @@ |
443 | return false; |
444 | } |
445 | |
446 | +bool PluginAdapter::IsWindowShaded(Window window_id) const |
447 | +{ |
448 | + if (CompWindow* window = m_Screen->findWindow(window_id)) |
449 | + return (window->state() & CompWindowStateShadedMask); |
450 | + |
451 | + return false; |
452 | +} |
453 | + |
454 | bool PluginAdapter::IsWindowOnTop(Window window_id) const |
455 | { |
456 | if (window_id == GetTopMostValidWindowInViewport()) |
457 | @@ -683,7 +691,19 @@ |
458 | void PluginAdapter::Maximize(Window window_id) |
459 | { |
460 | if (CompWindow* window = m_Screen->findWindow(window_id)) |
461 | - window->maximize(MAXIMIZE_STATE); |
462 | + window->maximize(CompWindowStateMaximizedVertMask); |
463 | +} |
464 | + |
465 | +void PluginAdapter::VerticallyMaximize(Window window_id) |
466 | +{ |
467 | + if (CompWindow* window = m_Screen->findWindow(window_id)) |
468 | + window->maximize(CompWindowStateMaximizedVertMask); |
469 | +} |
470 | + |
471 | +void PluginAdapter::HorizontallyMaximize(Window window_id) |
472 | +{ |
473 | + if (CompWindow* window = m_Screen->findWindow(window_id)) |
474 | + window->maximize(CompWindowStateMaximizedHorzMask); |
475 | } |
476 | |
477 | void PluginAdapter::Restore(Window window_id) |
478 | @@ -730,6 +750,26 @@ |
479 | window->unminimize(); |
480 | } |
481 | |
482 | +void PluginAdapter::Shade(Window window_id) |
483 | +{ |
484 | + CompWindow* window = m_Screen->findWindow(window_id); |
485 | + if (window && (window->actions() & CompWindowActionShadeMask)) |
486 | + { |
487 | + window->changeState(window->state() | CompWindowStateShadedMask); |
488 | + window->updateAttributes(CompStackingUpdateModeNone); |
489 | + } |
490 | +} |
491 | + |
492 | +void PluginAdapter::UnShade(Window window_id) |
493 | +{ |
494 | + CompWindow* window = m_Screen->findWindow(window_id); |
495 | + if (window && (window->actions() & CompWindowActionShadeMask)) |
496 | + { |
497 | + window->changeState(window->state() & ~CompWindowStateShadedMask); |
498 | + window->updateAttributes(CompStackingUpdateModeNone); |
499 | + } |
500 | +} |
501 | + |
502 | void PluginAdapter::Close(Window window_id) |
503 | { |
504 | CompWindow* window = m_Screen->findWindow(window_id); |
505 | |
506 | === modified file 'unity-shared/PluginAdapter.h' |
507 | --- unity-shared/PluginAdapter.h 2014-02-19 02:16:22 +0000 |
508 | +++ unity-shared/PluginAdapter.h 2014-04-02 21:44:17 +0000 |
509 | @@ -128,6 +128,7 @@ |
510 | bool IsWindowMapped(Window window_id) const; |
511 | bool IsWindowVisible(Window window_id) const; |
512 | bool IsWindowOnTop(Window window_id) const; |
513 | + bool IsWindowShaded(Window window_id) const; |
514 | bool IsWindowClosable(Window window_id) const; |
515 | bool IsWindowMinimized(Window window_id) const; |
516 | bool IsWindowMinimizable(Window window_id) const; |
517 | @@ -136,10 +137,14 @@ |
518 | |
519 | void ShowActionMenu(Time, Window, unsigned button, nux::Point const&); |
520 | void Maximize(Window window_id); |
521 | + void VerticallyMaximize(Window window_id); |
522 | + void HorizontallyMaximize(Window window_id); |
523 | void Restore(Window window_id); |
524 | void RestoreAt(Window window_id, int x, int y); |
525 | void Minimize(Window window_id); |
526 | void UnMinimize(Window window_id); |
527 | + void Shade(Window window_id); |
528 | + void UnShade(Window window_id); |
529 | void Close(Window window_id); |
530 | void Activate(Window window_id); |
531 | void Raise(Window window_id); |
532 | |
533 | === modified file 'unity-shared/StandaloneDecorationStyle.cpp' |
534 | --- unity-shared/StandaloneDecorationStyle.cpp 2014-01-21 12:19:42 +0000 |
535 | +++ unity-shared/StandaloneDecorationStyle.cpp 2014-04-02 21:44:17 +0000 |
536 | @@ -40,6 +40,33 @@ |
537 | return os; |
538 | } |
539 | |
540 | +std::ostream& operator<<(std::ostream &os, WMAction const& a) |
541 | +{ |
542 | + switch (a) |
543 | + { |
544 | + case WMAction::TOGGLE_SHADE: |
545 | + return os << "toggle-shade"; |
546 | + case WMAction::TOGGLE_MAXIMIZE: |
547 | + return os << "toggle-maximize"; |
548 | + case WMAction::TOGGLE_MAXIMIZE_HORIZONTALLY: |
549 | + return os << "toggle-maximize_horizontally"; |
550 | + case WMAction::TOGGLE_MAXIMIZE_VERTICALLY: |
551 | + return os << "toggle-maximize_vertically"; |
552 | + case WMAction::MINIMIZE: |
553 | + return os << "minimize"; |
554 | + case WMAction::SHADE: |
555 | + return os << "shade"; |
556 | + case WMAction::MENU: |
557 | + return os << "menu"; |
558 | + case WMAction::LOWER: |
559 | + return os << "lower"; |
560 | + case WMAction::NONE: |
561 | + return os << "none"; |
562 | + } |
563 | + |
564 | + return os; |
565 | +} |
566 | + |
567 | std::ostream& operator<<(std::ostream &os, Border const& b) |
568 | { |
569 | return os << "top " << b.top << ", left " << b.left << ", right " << b.right << ", bottom " << b.bottom; |
570 | @@ -132,6 +159,13 @@ |
571 | std::cout << "Button 'maximize' state 'backdrop_pressed' '" << style->WindowButtonFile(WindowButtonType::MAXIMIZE, WidgetState::BACKDROP_PRESSED) << "'" << std::endl; |
572 | std::cout << "---" << std::endl; |
573 | |
574 | + std::cout << "---" << std::endl; |
575 | + |
576 | + std::cout << "Double click action " << style->WindowManagerAction(WMEvent::DOUBLE_CLICK) << std::endl; |
577 | + std::cout << "Middle click action " << style->WindowManagerAction(WMEvent::MIDDLE_CLICK) << std::endl; |
578 | + std::cout << "Right click action " << style->WindowManagerAction(WMEvent::RIGHT_CLICK) << std::endl; |
579 | + std::cout << "---" << std::endl; |
580 | + |
581 | std::cout << "Maximum Double click distance " << style->DoubleClickMaxDistance() << "px" << std::endl; |
582 | std::cout << "Maximum Double click Time delta " << style->DoubleClickMaxTimeDelta() << "ms " << std::endl; |
583 | std::cout << "---" << std::endl; |
584 | |
585 | === modified file 'unity-shared/StandaloneWindowManager.cpp' |
586 | --- unity-shared/StandaloneWindowManager.cpp 2014-02-19 02:16:22 +0000 |
587 | +++ unity-shared/StandaloneWindowManager.cpp 2014-04-02 21:44:17 +0000 |
588 | @@ -45,6 +45,7 @@ |
589 | , v_maximized(false) |
590 | , h_maximized(false) |
591 | , minimized(false) |
592 | + , shaded(false) |
593 | , decorated(true) |
594 | , has_decorations(true) |
595 | , on_top(false) |
596 | @@ -72,15 +73,16 @@ |
597 | maximized.SetSetterFunction([this] (bool value) { |
598 | if (maximized() == value) |
599 | return false; |
600 | - |
601 | + |
602 | v_maximized = value; |
603 | h_maximized = value; |
604 | decorated = !value; |
605 | return true; |
606 | }); |
607 | - |
608 | + |
609 | v_maximized.changed.connect([this] (bool value) { maximized.changed.emit(maximized()); }); |
610 | h_maximized.changed.connect([this] (bool value) { maximized.changed.emit(maximized()); }); |
611 | + shaded.changed.connect([this] (bool value) { minimized = value; }); |
612 | } |
613 | |
614 | WindowManagerPtr create_window_manager() |
615 | @@ -156,16 +158,16 @@ |
616 | auto window = GetWindowByXid(window_id); |
617 | if (window) |
618 | return window->v_maximized; |
619 | - |
620 | + |
621 | return false; |
622 | } |
623 | - |
624 | + |
625 | bool StandaloneWindowManager::IsWindowHorizontallyMaximized(Window window_id) const |
626 | { |
627 | auto window = GetWindowByXid(window_id); |
628 | if (window) |
629 | return window->h_maximized; |
630 | - |
631 | + |
632 | return false; |
633 | } |
634 | |
635 | @@ -285,6 +287,28 @@ |
636 | } |
637 | } |
638 | |
639 | +void StandaloneWindowManager::VerticallyMaximize(Window window_id) |
640 | +{ |
641 | + auto window = GetWindowByXid(window_id); |
642 | + if (window) |
643 | + { |
644 | + window->h_maximized = false; |
645 | + window->v_maximized = true; |
646 | + window->decorated = true; |
647 | + } |
648 | +} |
649 | + |
650 | +void StandaloneWindowManager::HorizontallyMaximize(Window window_id) |
651 | +{ |
652 | + auto window = GetWindowByXid(window_id); |
653 | + if (window) |
654 | + { |
655 | + window->v_maximized = false; |
656 | + window->h_maximized = true; |
657 | + window->decorated = true; |
658 | + } |
659 | +} |
660 | + |
661 | void StandaloneWindowManager::Restore(Window window_id) |
662 | { |
663 | auto window = GetWindowByXid(window_id); |
664 | @@ -589,6 +613,30 @@ |
665 | return std::vector<long>(); |
666 | } |
667 | |
668 | +bool StandaloneWindowManager::IsWindowShaded(Window window_id) const |
669 | +{ |
670 | + auto window = GetWindowByXid(window_id); |
671 | + if (window) |
672 | + return window->shaded; |
673 | + |
674 | + return false; |
675 | +} |
676 | + |
677 | +void StandaloneWindowManager::Shade(Window window_id) |
678 | +{ |
679 | + auto window = GetWindowByXid(window_id); |
680 | + if (window) |
681 | + window->shaded = true; |
682 | +} |
683 | + |
684 | +void StandaloneWindowManager::UnShade(Window window_id) |
685 | +{ |
686 | + auto window = GetWindowByXid(window_id); |
687 | + if (window) |
688 | + window->shaded = false; |
689 | +} |
690 | + |
691 | + |
692 | |
693 | // Mock functions |
694 | |
695 | |
696 | === modified file 'unity-shared/StandaloneWindowManager.h' |
697 | --- unity-shared/StandaloneWindowManager.h 2014-02-17 21:17:51 +0000 |
698 | +++ unity-shared/StandaloneWindowManager.h 2014-04-02 21:44:17 +0000 |
699 | @@ -52,6 +52,7 @@ |
700 | nux::Property<bool> v_maximized; |
701 | nux::Property<bool> h_maximized; |
702 | nux::Property<bool> minimized; |
703 | + nux::Property<bool> shaded; |
704 | nux::Property<bool> decorated; |
705 | nux::Property<bool> has_decorations; |
706 | nux::Property<bool> on_top; |
707 | @@ -83,6 +84,7 @@ |
708 | virtual bool IsWindowMapped(Window window_id) const; |
709 | virtual bool IsWindowVisible(Window window_id) const; |
710 | virtual bool IsWindowOnTop(Window window_id) const; |
711 | + virtual bool IsWindowShaded(Window window_id) const; |
712 | virtual bool IsWindowClosable(Window window_id) const; |
713 | virtual bool IsWindowMinimized(Window window_id) const; |
714 | virtual bool IsWindowMinimizable(Window window_id) const; |
715 | @@ -94,10 +96,14 @@ |
716 | |
717 | virtual void ShowActionMenu(Time, Window, unsigned button, nux::Point const&) {} |
718 | virtual void Maximize(Window window_id); |
719 | + virtual void VerticallyMaximize(Window window_id); |
720 | + virtual void HorizontallyMaximize(Window window_id); |
721 | virtual void Restore(Window window_id); |
722 | virtual void RestoreAt(Window window_id, int x, int y); |
723 | virtual void Minimize(Window window_id); |
724 | virtual void UnMinimize(Window window_id); |
725 | + virtual void Shade(Window window_id); |
726 | + virtual void UnShade(Window window_id); |
727 | virtual void Close(Window window_id); |
728 | |
729 | virtual void Activate(Window window_id); |
730 | |
731 | === modified file 'unity-shared/WindowManager.h' |
732 | --- unity-shared/WindowManager.h 2014-03-06 20:49:14 +0000 |
733 | +++ unity-shared/WindowManager.h 2014-04-02 21:44:17 +0000 |
734 | @@ -89,6 +89,7 @@ |
735 | virtual bool IsWindowMapped(Window window_id) const = 0; |
736 | virtual bool IsWindowVisible(Window window_id) const = 0; |
737 | virtual bool IsWindowOnTop(Window window_id) const = 0; |
738 | + virtual bool IsWindowShaded(Window window_id) const = 0; |
739 | virtual bool IsWindowClosable(Window window_id) const = 0; |
740 | virtual bool IsWindowMinimized(Window window_id) const = 0; |
741 | virtual bool IsWindowMinimizable(Window window_id) const = 0; |
742 | @@ -100,10 +101,14 @@ |
743 | |
744 | virtual void ShowActionMenu(Time, Window, unsigned button, nux::Point const&) = 0; |
745 | virtual void Maximize(Window window_id) = 0; |
746 | + virtual void VerticallyMaximize(Window window_id) = 0; |
747 | + virtual void HorizontallyMaximize(Window window_id) = 0; |
748 | virtual void Restore(Window window_id) = 0; |
749 | virtual void RestoreAt(Window window_id, int x, int y) = 0; |
750 | virtual void Minimize(Window window_id) = 0; |
751 | virtual void UnMinimize(Window window_id) = 0; |
752 | + virtual void Shade(Window window_id) = 0; |
753 | + virtual void UnShade(Window window_id) = 0; |
754 | virtual void Close(Window window_id) = 0; |
755 | |
756 | virtual void Activate(Window window_id) = 0; |
LGTM