Merge lp:~brandontschaefer/unity/show-desktop-fix into lp:unity

Proposed by Brandon Schaefer on 2013-07-01
Status: Merged
Approved by: Christopher Townsend on 2013-07-12
Approved revision: 3381
Merged at revision: 3425
Proposed branch: lp:~brandontschaefer/unity/show-desktop-fix
Merge into: lp:unity
Diff against target: 170 lines (+67/-5)
3 files modified
plugins/unityshell/src/unityshell.cpp (+24/-3)
unity-shared/PluginAdapter.cpp (+41/-2)
unity-shared/PluginAdapter.h (+2/-0)
To merge this branch: bzr merge lp:~brandontschaefer/unity/show-desktop-fix
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve on 2013-07-12
Christopher Townsend Approve on 2013-07-11
Marco Trevisan (Treviño) 2013-07-01 Approve on 2013-07-01
Review via email: mp+172399@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

Same as the old branch that was reverted, but now when we move to an empty desktop instead of assuming we are in show desktop mode we have to find a window that is in show desktop mode first, if so then we are in show desktop mode.

To post a comment you must log in.
Marco Trevisan (Treviño) (3v1n0) wrote :

Seems fine to me

review: Approve
Brandon Schaefer (brandontschaefer) wrote :

Im running this through AP tests before a global approval, don't want to cause AP problems!

PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Brandon Schaefer (brandontschaefer) wrote :

These tests are failing on trunk for me, so it is not the cause of my branch... they should get fixed up at somepoint though :)

http://paste.ubuntu.com/5862442/

Brandon Schaefer (brandontschaefer) wrote :

Plus those AP tests are testing the compiz show deskop which this branch does not touch ...

PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Christopher Townsend (townsend) wrote :

We globally approved this because after much investigation, we determined that this commit could not be the cause of the AP test failures that led to the reversion of the original commit.

review: Approve
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Brandon Schaefer (brandontschaefer) wrote :

Shh Jenkins, Shh. Try again!

Christopher Townsend (townsend) wrote :

Try this again, Jenkins.

Seems a dbus test is failing on arm which may be due to the a recent merge of dbus tests. It's not related to this MP, but it's strange that the test is failing when it passed on the dbus merge.

review: Approve (continuous-integration)

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-07-02 03:18:27 +0000
3+++ plugins/unityshell/src/unityshell.cpp 2013-07-10 18:28:28 +0000
4@@ -858,9 +858,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@@ -901,7 +903,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@@ -912,7 +917,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@@ -997,6 +1012,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@@ -2825,6 +2842,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@@ -3439,6 +3458,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-06-27 10:16:04 +0000
78+++ unity-shared/PluginAdapter.cpp 2013-07-10 18:28:28 +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@@ -920,16 +936,39 @@
110
111 void PluginAdapter::OnShowDesktop()
112 {
113- LOG_DEBUG(logger) << "Now in show desktop mode.";
114 _in_show_desktop = true;
115 }
116
117 void PluginAdapter::OnLeaveDesktop()
118 {
119- LOG_DEBUG(logger) << "No longer in show desktop mode.";
120 _in_show_desktop = false;
121 }
122
123+void PluginAdapter::UpdateShowDesktopState()
124+{
125+ if (!IsCurrentViewportEmpty())
126+ {
127+ OnLeaveDesktop();
128+ }
129+ else
130+ {
131+ CompWindow* window;
132+ CompPoint screen_vp = m_Screen->vp();
133+
134+ auto const& windows = m_Screen->windows();
135+ for (auto it = windows.rbegin(); it != windows.rend(); ++it)
136+ {
137+ window = *it;
138+ if (window->defaultViewport() == screen_vp &&
139+ window->inShowDesktopMode())
140+ {
141+ OnShowDesktop();
142+ break;
143+ }
144+ }
145+ }
146+}
147+
148 int PluginAdapter::GetWindowMonitor(Window window_id) const
149 {
150 // FIXME, we should use window->outputDevice() but this is not UScreen friendly
151
152=== modified file 'unity-shared/PluginAdapter.h'
153--- unity-shared/PluginAdapter.h 2013-06-27 10:16:04 +0000
154+++ unity-shared/PluginAdapter.h 2013-07-10 18:28:28 +0000
155@@ -97,6 +97,7 @@
156
157 void OnShowDesktop ();
158 void OnLeaveDesktop ();
159+ void UpdateShowDesktopState();
160
161 void TerminateScale();
162 bool IsScaleActive() const;
163@@ -206,6 +207,7 @@
164 unsigned long GetMwnDecorations(Window xid) const;
165
166 Window GetTopMostValidWindowInViewport() const;
167+ bool IsCurrentViewportEmpty() const;
168
169 std::string GetTextProperty(Window xid, Atom atom) const;
170 std::string GetUtf8Property(Window xid, Atom atom) const;