Merge lp:~brandontschaefer/unity/lp.966030-fix into lp:unity

Proposed by Brandon Schaefer
Status: Merged
Approved by: Marco Trevisan (Treviño)
Approved revision: no longer in the source branch.
Merged at revision: 3380
Proposed branch: lp:~brandontschaefer/unity/lp.966030-fix
Merge into: lp:unity
Diff against target: 143 lines (+50/-3)
3 files modified
plugins/unityshell/src/unityshell.cpp (+24/-3)
unity-shared/PluginAdapter.cpp (+24/-0)
unity-shared/PluginAdapter.h (+2/-0)
To merge this branch: bzr merge lp:~brandontschaefer/unity/lp.966030-fix
Reviewer Review Type Date Requested Status
Marco Trevisan (Treviño) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+170180@code.launchpad.net

Commit message

Show desktop now only works for individual workspaces. Also if any new windows are opened, or one is restored on that workspace then the next Show desktop will minimize those. The only time windows are restored are when no new windows have been mapped, and no windows have been restored for that workspace only.

Description of the change

Changes to the show desktop icon:

- Only minimizes windows on current workspace.
- Will only restore windows if and only if:
  -- No new windows have been mapped (opened).
  -- No new windows have been unminimized.
  -- The user has not moved workspaces.
- When we are restoring windows from Show desktop, all of them are unminimzed on all workspaces.

Testing this might be hard, but im looking into it :).

Video does not show the new restore fix, but still good to show what it does now.
Video: http://ubuntuone.com/2G483y5nLc0OBkhHWww1gm

So overall things to manually test:
- Only windows in current workspace get minimized.
- Windows on the same workspace only get restored IFF, no new windows have been opened,
no windows have been restore from that workspace.
- All windows must be restored if returning to a workspace that is empty.
- If any new window, or a window is restore, then the next time a ShowDesktop is activated for that workspace all the windows are minimized (for that workspace only).

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
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
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 :

Works fine here.

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-06-18 18:48:31 +0000
3+++ plugins/unityshell/src/unityshell.cpp 2013-06-20 19:47:26 +0000
4@@ -857,9 +857,11 @@
5 {
6 for (CompWindow *w : screen->windows ())
7 {
8+ CompPoint const& viewport = w->defaultViewport();
9 UnityWindow *uw = UnityWindow::get (w);
10
11- if (ShowdesktopHandler::ShouldHide (static_cast <ShowdesktopHandlerWindowInterface *> (uw)))
12+ if (viewport == uScreen->screen->vp() &&
13+ ShowdesktopHandler::ShouldHide (static_cast <ShowdesktopHandlerWindowInterface *> (uw)))
14 {
15 UnityWindow::get (w)->enterShowDesktop ();
16 // the animation plugin does strange things here ...
17@@ -900,7 +902,10 @@
18 {
19 for (CompWindow *cw : screen->windows ())
20 {
21- if (cw->inShowDesktopMode ())
22+ CompPoint const& viewport = cw->defaultViewport();
23+
24+ if (viewport == uScreen->screen->vp() &&
25+ cw->inShowDesktopMode ())
26 {
27 UnityWindow::get (cw)->leaveShowDesktop ();
28 // the animation plugin does strange things here ...
29@@ -911,7 +916,17 @@
30
31 PluginAdapter::Default().OnLeaveDesktop();
32
33- screen->leaveShowDesktopMode (w);
34+ if (w)
35+ {
36+ CompPoint const& viewport = w->defaultViewport();
37+
38+ if (viewport == uScreen->screen->vp())
39+ screen->leaveShowDesktopMode (w);
40+ }
41+ else
42+ {
43+ screen->focusDefaultWindow();
44+ }
45 }
46 else
47 {
48@@ -977,6 +992,8 @@
49 ShowdesktopHandler::InhibitLeaveShowdesktopMode (window->id ());
50 window->activate ();
51 ShowdesktopHandler::AllowLeaveShowdesktopMode (window->id ());
52+
53+ PluginAdapter::Default().OnLeaveDesktop();
54 }
55
56 void UnityWindow::DoEnableFocus ()
57@@ -2781,6 +2798,8 @@
58 window->unminimizeSetEnabled (this, false);
59 window->minimizedSetEnabled (this, false);
60 }
61+
62+ PluginAdapter::Default().UpdateShowDesktopState();
63 break;
64 case CompWindowNotifyBeforeDestroy:
65 being_destroyed.emit();
66@@ -3395,6 +3414,8 @@
67 GLWindowInterface::setHandler(gWindow);
68 ScaleWindowInterface::setHandler (ScaleWindow::get (window));
69
70+ PluginAdapter::Default().OnLeaveDesktop();
71+
72 /* This needs to happen before we set our wrapable functions, since we
73 * need to ask core (and not ourselves) whether or not the window is
74 * minimized */
75
76=== modified file 'unity-shared/PluginAdapter.cpp'
77--- unity-shared/PluginAdapter.cpp 2013-05-17 22:53:57 +0000
78+++ unity-shared/PluginAdapter.cpp 2013-06-20 19:47:26 +0000
79@@ -217,6 +217,8 @@
80 }
81 else if (g_strcmp0(event, "end_viewport_switch") == 0)
82 {
83+ UpdateShowDesktopState();
84+
85 _vp_switch_started = false;
86 screen_viewport_switch_ended.emit();
87 }
88@@ -610,6 +612,20 @@
89 return 0;
90 }
91
92+bool PluginAdapter::IsCurrentViewportEmpty() const
93+{
94+ Window win = GetTopMostValidWindowInViewport();
95+
96+ if (win)
97+ {
98+ CompWindow* cwin = m_Screen->findWindow(win);
99+ if (!(cwin->type() & NO_FOCUS_MASK))
100+ return false;
101+ }
102+
103+ return true;
104+}
105+
106 Window PluginAdapter::GetTopWindowAbove(Window xid) const
107 {
108 CompWindow* window;
109@@ -930,6 +946,14 @@
110 _in_show_desktop = false;
111 }
112
113+void PluginAdapter::UpdateShowDesktopState()
114+{
115+ if (!IsCurrentViewportEmpty())
116+ OnLeaveDesktop();
117+ else
118+ OnShowDesktop();
119+}
120+
121 int PluginAdapter::GetWindowMonitor(Window window_id) const
122 {
123 // FIXME, we should use window->outputDevice() but this is not UScreen friendly
124
125=== modified file 'unity-shared/PluginAdapter.h'
126--- unity-shared/PluginAdapter.h 2013-05-17 22:53:57 +0000
127+++ unity-shared/PluginAdapter.h 2013-06-20 19:47:26 +0000
128@@ -97,6 +97,7 @@
129
130 void OnShowDesktop ();
131 void OnLeaveDesktop ();
132+ void UpdateShowDesktopState();
133
134 void TerminateScale();
135 bool IsScaleActive() const;
136@@ -206,6 +207,7 @@
137 unsigned long GetMwnDecorations(Window xid) const;
138
139 Window GetTopMostValidWindowInViewport() const;
140+ bool IsCurrentViewportEmpty() const;
141
142 std::string GetTextProperty(Window xid, Atom atom) const;
143 std::string GetUtf8Property(Window xid, Atom atom) const;