Merge lp:~townsend/unity/fix-lp1251777.2 into lp:unity

Proposed by Christopher Townsend
Status: Merged
Approved by: Marco Trevisan (Treviño)
Approved revision: no longer in the source branch.
Merged at revision: 3607
Proposed branch: lp:~townsend/unity/fix-lp1251777.2
Merge into: lp:unity
Diff against target: 456 lines (+23/-201)
10 files modified
plugins/unityshell/src/unityshell.cpp (+0/-21)
plugins/unityshell/src/unityshell.h (+0/-2)
plugins/unityshell/unityshell.xml.in (+0/-12)
shortcuts/CompizShortcutModeller.cpp (+6/-6)
tests/autopilot/unity/tests/test_wm_keybindings.py (+8/-0)
unity-shared/PluginAdapter.cpp (+0/-69)
unity-shared/PluginAdapter.h (+0/-8)
unity-shared/StandaloneWindowManager.cpp (+7/-71)
unity-shared/StandaloneWindowManager.h (+1/-7)
unity-shared/WindowManager.h (+1/-5)
To merge this branch: bzr merge lp:~townsend/unity/fix-lp1251777.2
Reviewer Review Type Date Requested Status
Marco Trevisan (Treviño) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+197792@code.launchpad.net

Commit message

* Revert most of lp:unity revno. 3509 as the Compiz Grid plugin is a better place to handle the Ctrl-Super-Left/Right shortcuts.
* Expanded autopilot test to check for correct window placement when semi-maximizing and restoring.

Description of the change

= Issue =
Due to revno. 3509, when vertically semi-maximizing a window using Ctrl-Super-Left/Right and then restoring the window, the window would not return to the same place and correct size.

= Fix =
It is better to have the Compiz Grid plugin handle this since it already handles semi-maximizing windows and duplicating code in Unity is not a worthy exercise. This basically reverts most of revno. 3509 except the test_wm_shortcuts Autopilot tests.

= Test =
Added testing of correct window placement in the semi-maximize/restore Autopilot test.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

Goodbye code!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/unityshell/src/unityshell.cpp'
2--- plugins/unityshell/src/unityshell.cpp 2013-11-20 21:39:40 +0000
3+++ plugins/unityshell/src/unityshell.cpp 2013-12-04 19:57:31 +0000
4@@ -352,9 +352,6 @@
5 optionSetLauncherSwitcherPrevInitiate(boost::bind(&UnityScreen::launcherSwitcherPrevInitiate, this, _1, _2, _3));
6 optionSetLauncherSwitcherForwardTerminate(boost::bind(&UnityScreen::launcherSwitcherTerminate, this, _1, _2, _3));
7
8- optionSetWindowRightMaximizeInitiate(boost::bind(&UnityScreen::rightMaximizeKeyInitiate, this, _1, _2, _3));
9- optionSetWindowLeftMaximizeInitiate(boost::bind(&UnityScreen::leftMaximizeKeyInitiate, this, _1, _2, _3));
10-
11 optionSetStopVelocityNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));
12 optionSetRevealPressureNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));
13 optionSetEdgeResponsivenessNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));
14@@ -2274,20 +2271,6 @@
15 return true;
16 }
17
18-bool UnityScreen::rightMaximizeKeyInitiate(CompAction* action, CompAction::State state, CompOption::Vector& options)
19-{
20- auto& WM = WindowManager::Default();
21- WM.RightMaximize(WM.GetActiveWindow());
22- return true;
23-}
24-
25-bool UnityScreen::leftMaximizeKeyInitiate(CompAction* action, CompAction::State state, CompOption::Vector& options)
26-{
27- auto& WM = WindowManager::Default();
28- WM.LeftMaximize(WM.GetActiveWindow());
29- return true;
30-}
31-
32 void UnityScreen::OnLauncherStartKeyNav(GVariant* data)
33 {
34 // Put the launcher BaseWindow at the top of the BaseWindow stack. The
35@@ -3682,10 +3665,6 @@
36 .add("xid", (uint64_t)xid)
37 .add("title", wm.GetWindowName(xid))
38 .add("fake_decorated", uScreen->fake_decorated_windows_.find(this) != uScreen->fake_decorated_windows_.end())
39- .add("maximized", wm.IsWindowVerticallyMaximized(xid))
40- .add("horizontally_maximized", wm.IsWindowHorizontallyMaximized(xid))
41- .add("vertically_maximized", wm.IsWindowVerticallyMaximized(xid))
42- .add("minimized", wm.IsWindowMinimized(xid))
43 .add("scaled", scaled)
44 .add("scaled_close_geo", close_button_geo_)
45 .add("scaled_close_x", close_button_geo_.x)
46
47=== modified file 'plugins/unityshell/src/unityshell.h'
48--- plugins/unityshell/src/unityshell.h 2013-11-20 21:39:40 +0000
49+++ plugins/unityshell/src/unityshell.h 2013-12-04 19:57:31 +0000
50@@ -179,8 +179,6 @@
51 bool launcherSwitcherForwardInitiate(CompAction* action, CompAction::State state, CompOption::Vector& options);
52 bool launcherSwitcherPrevInitiate(CompAction* action, CompAction::State state, CompOption::Vector& options);
53 bool launcherSwitcherTerminate(CompAction* action, CompAction::State state, CompOption::Vector& options);
54- bool rightMaximizeKeyInitiate(CompAction* action, CompAction::State state, CompOption::Vector& options);
55- bool leftMaximizeKeyInitiate(CompAction* action, CompAction::State state, CompOption::Vector& options);
56
57 /* handle option changes and change settings inside of the
58 * panel and dock views */
59
60=== modified file 'plugins/unityshell/unityshell.xml.in'
61--- plugins/unityshell/unityshell.xml.in 2013-09-29 23:26:29 +0000
62+++ plugins/unityshell/unityshell.xml.in 2013-12-04 19:57:31 +0000
63@@ -68,18 +68,6 @@
64 <default>&lt;Alt&gt;F10</default>
65 </option>
66
67- <option name="window_right_maximize" type="key">
68- <_short>Key to vertically maximize the focused window to the right</_short>
69- <_long>Semi-maximize vertically the focused window on the half right width of the screen</_long>
70- <default>&lt;Control&gt;&lt;Super&gt;Right</default>
71- </option>
72-
73- <option name="window_left_maximize" type="key">
74- <_short>Key to vertically maximize the focused window to the left</_short>
75- <_long>Semi-maximize vertically the focused window to the half left width of the screen</_long>
76- <default>&lt;Control&gt;&lt;Super&gt;Left</default>
77- </option>
78-
79 <option name="panel_opacity" type="float">
80 <_short>Panel Opacity</_short>
81 <_long>The opacity of the Panel background.</_long>
82
83=== modified file 'shortcuts/CompizShortcutModeller.cpp'
84--- shortcuts/CompizShortcutModeller.cpp 2013-09-16 14:18:57 +0000
85+++ shortcuts/CompizShortcutModeller.cpp 2013-12-04 19:57:31 +0000
86@@ -32,6 +32,7 @@
87 // Compiz' plug-in names
88 const std::string CORE_PLUGIN_NAME = "core";
89 const std::string EXPO_PLUGIN_NAME = "expo";
90+ const std::string GRID_PLUGIN_NAME = "grid";
91 const std::string MOVE_PLUGIN_NAME = "move";
92 const std::string RESIZE_PLUGIN_NAME = "resize";
93 const std::string SCALE_PLUGIN_NAME = "scale";
94@@ -48,6 +49,9 @@
95 // Compiz Expo Options
96 const std::string EXPO_OPTION_EXPO_KEY = "expo_key";
97
98+ // Compiz Grid Options
99+ const std::string GRID_OPTION_LEFT_MAXIMIZE = "left_maximize";
100+
101 // Compiz Move Options
102 const std::string MOVE_OPTION_INITIATE_BUTTON = "initiate_button";
103
104@@ -65,10 +69,6 @@
105 const std::string UNITYSHELL_OPTION_PANEL_FIRST_MENU = "panel_first_menu";
106 const std::string UNITYSHELL_OPTION_ALT_TAB_FORWARD = "alt_tab_forward";
107 const std::string UNITYSHELL_OPTION_ALT_TAB_NEXT_WINDOW = "alt_tab_next_window";
108- const std::string UNITYSHELL_OPTION_MAXIMIZE = "window_maximize";
109- const std::string UNITYSHELL_OPTION_LEFT_MAXIMIZE = "window_left_maximize";
110- const std::string UNITYSHELL_OPTION_RIGHT_MAXIMIZE = "window_right_maximize";
111- const std::string UNITYSHELL_OPTION_RESTORE_MINIMIZE = "window_restore_minimize";
112
113 // Compiz Wall Options
114 const std::string WALL_OPTION_LEFT_KEY = "left_key";
115@@ -315,8 +315,8 @@
116 hints.push_back(std::make_shared<shortcut::Hint>(windows, "", _(" or Right"),
117 _("Semi-maximise the current window."),
118 shortcut::OptionType::COMPIZ_KEY,
119- UNITYSHELL_PLUGIN_NAME,
120- UNITYSHELL_OPTION_LEFT_MAXIMIZE));
121+ GRID_PLUGIN_NAME,
122+ GRID_OPTION_LEFT_MAXIMIZE));
123
124 hints.push_back(std::make_shared<shortcut::Hint>(windows, "", "",
125 _("Closes the current window."),
126
127=== modified file 'tests/autopilot/unity/tests/test_wm_keybindings.py'
128--- tests/autopilot/unity/tests/test_wm_keybindings.py 2013-10-08 14:20:04 +0000
129+++ tests/autopilot/unity/tests/test_wm_keybindings.py 2013-12-04 19:57:31 +0000
130@@ -126,10 +126,18 @@
131 if not self.start_restored:
132 self.addCleanup(self.keybinding, "window/maximize")
133 self.keybinding("window/restore")
134+ (x1, y1, w1, h1) = self.screen_win.geometry
135 self.keyboard.press_and_release("Ctrl+Super+Right")
136 self.keybinding("window/restore")
137+ (x2, y2, w2, h2) = self.screen_win.geometry
138+
139 self.assertThat(self.screen_win.vertically_maximized, Eventually(Equals(False)))
140 self.assertThat(self.screen_win.minimized, Eventually(Equals(False)))
141+ # Make sure the window restored to its same geometry before vertically maximizing
142+ self.assertThat(x1, Equals(x2))
143+ self.assertThat(y1, Equals(y2))
144+ self.assertThat(w1, Equals(w2))
145+ self.assertThat(h1, Equals(h2))
146
147 def test_minimize_restored_window(self):
148 if not self.start_restored:
149
150=== modified file 'unity-shared/PluginAdapter.cpp'
151--- unity-shared/PluginAdapter.cpp 2013-11-14 00:17:19 +0000
152+++ unity-shared/PluginAdapter.cpp 2013-12-04 19:57:31 +0000
153@@ -460,22 +460,6 @@
154 return false;
155 }
156
157-bool PluginAdapter::IsWindowVerticallyMaximized(Window window_id) const
158-{
159- if (CompWindow* window = m_Screen->findWindow(window_id))
160- return (window->state() & CompWindowStateMaximizedVertMask);
161-
162- return false;
163-}
164-
165-bool PluginAdapter::IsWindowHorizontallyMaximized(Window window_id) const
166-{
167- if (CompWindow* window = m_Screen->findWindow(window_id))
168- return (window->state() & CompWindowStateMaximizedHorzMask);
169-
170- return false;
171-}
172-
173 unsigned long PluginAdapter::GetMwnDecorations(Window window_id) const
174 {
175 Display* display = m_Screen->dpy();
176@@ -712,59 +696,6 @@
177 window->maximize(MAXIMIZE_STATE);
178 }
179
180-void PluginAdapter::VerticallyMaximizeWindowAt(CompWindow* window, nux::Geometry const& geo)
181-{
182- if (window && ((window->type() & CompWindowTypeNormalMask) ||
183- ((window->actions() & CompWindowActionMaximizeVertMask) &&
184- window->actions() & CompWindowActionResizeMask)))
185- {
186- /* First we unmaximize the Window */
187- if (window->state() & MAXIMIZE_STATE)
188- window->maximize(0);
189-
190- /* Then we vertically maximize the it so it can be unminimized correctly */
191- if (!(window->state() & CompWindowStateMaximizedVertMask))
192- window->maximize(CompWindowStateMaximizedVertMask);
193-
194- /* Then we resize and move it on the requested place */
195- MoveResizeWindow(window->id(), geo);
196- }
197-}
198-
199-void PluginAdapter::LeftMaximize(Window window_id)
200-{
201- CompWindow* window = m_Screen->findWindow(window_id);
202-
203- if (!window)
204- return;
205-
206- /* Let's compute the area where the window should stay */
207- CompRect workarea = m_Screen->getWorkareaForOutput(window->outputDevice());
208- nux::Geometry win_geo(workarea.x() + window->border().left,
209- workarea.y() + window->border().top,
210- workarea.width() / 2 - (window->border().left + window->border().right),
211- workarea.height() - (window->border().top + window->border().bottom));
212-
213- VerticallyMaximizeWindowAt(window, win_geo);
214-}
215-
216-void PluginAdapter::RightMaximize(Window window_id)
217-{
218- CompWindow* window = m_Screen->findWindow(window_id);
219-
220- if (!window)
221- return;
222-
223- /* Let's compute the area where the window should stay */
224- CompRect workarea = m_Screen->getWorkareaForOutput(window->outputDevice());
225- nux::Geometry win_geo(workarea.x() + workarea.width() / 2 + window->border().left,
226- workarea.y() + window->border().top,
227- workarea.width() / 2 - (window->border().left + window->border().right),
228- workarea.height() - (window->border().top + window->border().bottom));
229-
230- VerticallyMaximizeWindowAt(window, win_geo);
231-}
232-
233 void PluginAdapter::Restore(Window window_id)
234 {
235 CompWindow* window = m_Screen->findWindow(window_id);
236
237=== modified file 'unity-shared/PluginAdapter.h'
238--- unity-shared/PluginAdapter.h 2013-09-19 20:43:30 +0000
239+++ unity-shared/PluginAdapter.h 2013-12-04 19:57:31 +0000
240@@ -130,8 +130,6 @@
241
242 // WindowManager implementation
243 bool IsWindowMaximized(Window window_id) const;
244- bool IsWindowVerticallyMaximized(Window window_id) const;
245- bool IsWindowHorizontallyMaximized(Window window_id) const;
246 bool IsWindowDecorated(Window window_id) const;
247 bool IsWindowOnCurrentDesktop(Window window_id) const;
248 bool IsWindowObscured(Window window_id) const;
249@@ -145,8 +143,6 @@
250 bool HasWindowDecorations(Window window_id) const;
251
252 void Maximize(Window window_id);
253- void LeftMaximize(Window window_id);
254- void RightMaximize(Window window_id);
255 void Restore(Window window_id);
256 void RestoreAt(Window window_id, int x, int y);
257 void Minimize(Window window_id);
258@@ -200,8 +196,6 @@
259
260 Window GetTopWindowAbove(Window xid) const;
261
262- void MoveResizeWindow(guint32 xid, nux::Geometry geometry);
263-
264 protected:
265 PluginAdapter(CompScreen* screen);
266 void AddProperties(debug::IntrospectionData&);
267@@ -221,8 +215,6 @@
268 std::string GetUtf8Property(Window xid, Atom atom) const;
269 std::vector<long> GetCardinalProperty(Window xid, Atom atom) const;
270
271- void VerticallyMaximizeWindowAt(CompWindow* window, nux::Geometry const& geo);
272-
273 CompScreen* m_Screen;
274 MultiActionList m_ExpoActionList;
275 MultiActionList m_ScaleActionList;
276
277=== modified file 'unity-shared/StandaloneWindowManager.cpp'
278--- unity-shared/StandaloneWindowManager.cpp 2013-11-14 00:17:19 +0000
279+++ unity-shared/StandaloneWindowManager.cpp 2013-12-04 19:57:31 +0000
280@@ -42,8 +42,7 @@
281 , active(false)
282 , mapped(true)
283 , visible(true)
284- , v_maximized(false)
285- , h_maximized(false)
286+ , maximized(false)
287 , minimized(false)
288 , decorated(true)
289 , has_decorations(true)
290@@ -67,20 +66,6 @@
291
292 return false;
293 });
294-
295- maximized.SetGetterFunction([this] { return v_maximized && h_maximized; });
296- maximized.SetSetterFunction([this] (bool value) {
297- if (maximized() == value)
298- return false;
299-
300- v_maximized = value;
301- h_maximized = value;
302- decorated = !value;
303- return true;
304- });
305-
306- v_maximized.changed.connect([this] (bool value) { maximized.changed.emit(maximized()); });
307- h_maximized.changed.connect([this] (bool value) { maximized.changed.emit(maximized()); });
308 }
309
310 WindowManagerPtr create_window_manager()
311@@ -139,24 +124,6 @@
312 return false;
313 }
314
315-bool StandaloneWindowManager::IsWindowVerticallyMaximized(Window window_id) const
316-{
317- auto window = GetWindowByXid(window_id);
318- if (window)
319- return window->v_maximized;
320-
321- return false;
322-}
323-
324-bool StandaloneWindowManager::IsWindowHorizontallyMaximized(Window window_id) const
325-{
326- auto window = GetWindowByXid(window_id);
327- if (window)
328- return window->h_maximized;
329-
330- return false;
331-}
332-
333 bool StandaloneWindowManager::IsWindowDecorated(Window window_id) const
334 {
335 auto window = GetWindowByXid(window_id);
336@@ -281,51 +248,20 @@
337 {
338 auto window = GetWindowByXid(window_id);
339 if (window)
340+ {
341 window->maximized = true;
342-}
343-
344-void StandaloneWindowManager::LeftMaximize(Window window_id)
345-{
346- auto window = GetWindowByXid(window_id);
347-
348- if (!window)
349- return;
350-
351- /* Let's compute the area where the window should be put */
352- auto workarea = GetWorkAreaGeometry(window_id);
353- workarea.width /= 2;
354-
355- if (window->maximized)
356- window->maximized = false;
357-
358- window->v_maximized = true;
359- MoveResizeWindow(window_id, workarea);
360-}
361-
362-void StandaloneWindowManager::RightMaximize(Window window_id)
363-{
364- auto window = GetWindowByXid(window_id);
365-
366- if (!window)
367- return;
368-
369- /* Let's compute the area where the window should be put */
370- auto workarea = GetWorkAreaGeometry(window_id);
371- workarea.width /= 2;
372- workarea.x += workarea.width;
373-
374- if (window->maximized)
375- window->maximized = false;
376-
377- window->v_maximized = true;
378- MoveResizeWindow(window_id, workarea);
379+ Undecorate(window_id);
380+ }
381 }
382
383 void StandaloneWindowManager::Restore(Window window_id)
384 {
385 auto window = GetWindowByXid(window_id);
386 if (window)
387+ {
388 window->maximized = false;
389+ Decorate(window_id);
390+ }
391 }
392
393 void StandaloneWindowManager::RestoreAt(Window window_id, int x, int y)
394
395=== modified file 'unity-shared/StandaloneWindowManager.h'
396--- unity-shared/StandaloneWindowManager.h 2013-11-14 00:17:19 +0000
397+++ unity-shared/StandaloneWindowManager.h 2013-12-04 19:57:31 +0000
398@@ -48,9 +48,7 @@
399 nux::Property<bool> active;
400 nux::Property<bool> mapped;
401 nux::Property<bool> visible;
402- nux::RWProperty<bool> maximized;
403- nux::Property<bool> v_maximized;
404- nux::Property<bool> h_maximized;
405+ nux::Property<bool> maximized;
406 nux::Property<bool> minimized;
407 nux::Property<bool> decorated;
408 nux::Property<bool> has_decorations;
409@@ -72,8 +70,6 @@
410 std::vector<Window> GetWindowsInStackingOrder() const override;
411
412 virtual bool IsWindowMaximized(Window window_id) const;
413- virtual bool IsWindowVerticallyMaximized(Window window_id) const;
414- virtual bool IsWindowHorizontallyMaximized(Window window_id) const;
415 virtual bool IsWindowDecorated(Window window_id) const;
416 virtual bool IsWindowOnCurrentDesktop(Window window_id) const;
417 virtual bool IsWindowObscured(Window window_id) const;
418@@ -90,8 +86,6 @@
419 virtual bool InShowDesktop() const;
420
421 virtual void Maximize(Window window_id);
422- virtual void LeftMaximize(Window window_id);
423- virtual void RightMaximize(Window window_id);
424 virtual void Restore(Window window_id);
425 virtual void RestoreAt(Window window_id, int x, int y);
426 virtual void Minimize(Window window_id);
427
428=== modified file 'unity-shared/WindowManager.h'
429--- unity-shared/WindowManager.h 2013-11-14 00:17:19 +0000
430+++ unity-shared/WindowManager.h 2013-12-04 19:57:31 +0000
431@@ -77,9 +77,6 @@
432 virtual std::vector<Window> GetWindowsInStackingOrder() const = 0;
433
434 virtual bool IsWindowMaximized(Window window_id) const = 0;
435- virtual bool IsWindowVerticallyMaximized(Window window_id) const = 0;
436- virtual bool IsWindowHorizontallyMaximized(Window window_id) const = 0;
437- virtual bool IsWindowMaximizable(Window window_id) const = 0;
438 virtual bool IsWindowDecorated(Window window_id) const = 0;
439 virtual bool IsWindowOnCurrentDesktop(Window window_id) const = 0;
440 virtual bool IsWindowObscured(Window window_id) const = 0;
441@@ -89,14 +86,13 @@
442 virtual bool IsWindowClosable(Window window_id) const = 0;
443 virtual bool IsWindowMinimized(Window window_id) const = 0;
444 virtual bool IsWindowMinimizable(Window window_id) const = 0;
445+ virtual bool IsWindowMaximizable(Window window_id) const = 0;
446 virtual bool HasWindowDecorations(Window window_id) const = 0;
447
448 virtual void ShowDesktop() = 0;
449 virtual bool InShowDesktop() const = 0;
450
451 virtual void Maximize(Window window_id) = 0;
452- virtual void LeftMaximize(Window window_id) = 0;
453- virtual void RightMaximize(Window window_id) = 0;
454 virtual void Restore(Window window_id) = 0;
455 virtual void RestoreAt(Window window_id, int x, int y) = 0;
456 virtual void Minimize(Window window_id) = 0;