Merge lp:~unity-team/unity/unity.fix_732997 into lp:unity

Proposed by Sam Spilsbury
Status: Merged
Merged at revision: 1582
Proposed branch: lp:~unity-team/unity/unity.fix_732997
Merge into: lp:unity
Diff against target: 332 lines (+78/-44)
13 files modified
plugins/unityshell/src/BamfLauncherIcon.cpp (+7/-1)
plugins/unityshell/src/PluginAdapter.cpp (+12/-0)
plugins/unityshell/src/PluginAdapter.h (+1/-0)
plugins/unityshell/src/SwitcherController.cpp (+7/-12)
plugins/unityshell/src/SwitcherController.h (+1/-3)
plugins/unityshell/src/SwitcherModel.cpp (+4/-4)
plugins/unityshell/src/SwitcherModel.h (+1/-1)
plugins/unityshell/src/SwitcherView.cpp (+1/-1)
plugins/unityshell/src/SwitcherView.h (+1/-1)
plugins/unityshell/src/WindowManager.cpp (+5/-0)
plugins/unityshell/src/WindowManager.h (+1/-0)
plugins/unityshell/src/compizminimizedwindowhandler.h (+4/-3)
plugins/unityshell/src/unityshell.cpp (+33/-18)
To merge this branch: bzr merge lp:~unity-team/unity/unity.fix_732997
Reviewer Review Type Date Requested Status
Jason Smith (community) Approve
Review via email: mp+76065@code.launchpad.net

Description of the change

Don't override minimization and unminimization for windows that have not yet been mapped and do not show windows with inaccessible pixmaps (because they're withdrawn or started unmapped) in the switcher detail view

To post a comment you must log in.
Revision history for this message
Jason Smith (jassmith) :
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/BamfLauncherIcon.cpp'
2--- plugins/unityshell/src/BamfLauncherIcon.cpp 2011-09-12 14:59:42 +0000
3+++ plugins/unityshell/src/BamfLauncherIcon.cpp 2011-09-19 16:41:04 +0000
4@@ -246,13 +246,19 @@
5 std::vector<Window> results;
6 GList* children, *l;
7 BamfView* view;
8+ WindowManager *wm = WindowManager::Default ();
9
10 children = bamf_view_get_children(BAMF_VIEW(m_App));
11 for (l = children; l; l = l->next)
12 {
13 view = (BamfView*) l->data;
14 if (BAMF_IS_WINDOW(view))
15- results.push_back ((Window) bamf_window_get_xid(BAMF_WINDOW(view)));
16+ {
17+ guint32 xid = bamf_window_get_xid(BAMF_WINDOW(view));
18+
19+ if (wm->IsWindowMapped(xid))
20+ results.push_back ((Window) xid);
21+ }
22 }
23
24 g_list_free(children);
25
26=== modified file 'plugins/unityshell/src/PluginAdapter.cpp'
27--- plugins/unityshell/src/PluginAdapter.cpp 2011-09-12 02:41:10 +0000
28+++ plugins/unityshell/src/PluginAdapter.cpp 2011-09-19 16:41:04 +0000
29@@ -458,6 +458,18 @@
30 return false;
31 }
32
33+bool
34+PluginAdapter::IsWindowMapped(guint32 xid)
35+{
36+ Window win = (Window) xid;
37+ CompWindow* window;
38+
39+ window = m_Screen->findWindow(win);
40+ if (window)
41+ return window->mapNum () > 0;
42+ return true;
43+}
44+
45 void
46 PluginAdapter::Restore(guint32 xid)
47 {
48
49=== modified file 'plugins/unityshell/src/PluginAdapter.h'
50--- plugins/unityshell/src/PluginAdapter.h 2011-08-31 20:31:03 +0000
51+++ plugins/unityshell/src/PluginAdapter.h 2011-09-19 16:41:04 +0000
52@@ -113,6 +113,7 @@
53 bool IsWindowDecorated(guint xid);
54 bool IsWindowOnCurrentDesktop(guint xid);
55 bool IsWindowObscured(guint xid);
56+ bool IsWindowMapped(guint xid);
57 void Restore(guint32 xid);
58 void Minimize(guint32 xid);
59 void Close(guint32 xid);
60
61=== modified file 'plugins/unityshell/src/SwitcherController.cpp'
62--- plugins/unityshell/src/SwitcherController.cpp 2011-09-15 23:12:57 +0000
63+++ plugins/unityshell/src/SwitcherController.cpp 2011-09-19 16:41:04 +0000
64@@ -188,7 +188,8 @@
65 }
66 else
67 {
68- if (selection->GetQuirk (AbstractLauncherIcon::QUIRK_ACTIVE))
69+ if (selection->GetQuirk (AbstractLauncherIcon::QUIRK_ACTIVE) &&
70+ !model_->DetailXids().empty ())
71 {
72 selection->Activate(ActionArg (ActionArg::SWITCHER, 0, model_->DetailXids()[0]));
73 }
74@@ -225,13 +226,6 @@
75 return visible_;
76 }
77
78-int SwitcherController::WindowsRelatedToSelection()
79-{
80- if (model_->Selection())
81- return model_->Selection()->RelatedWindows ();
82- return 0;
83-}
84-
85 void SwitcherController::Next()
86 {
87 if (!model_)
88@@ -242,7 +236,7 @@
89 switch (detail_mode_)
90 {
91 case TAB_NEXT_WINDOW:
92- if (model_->detail_selection_index < WindowsRelatedToSelection() - 1)
93+ if (model_->detail_selection_index < model_->Selection()->RelatedXids ().size () - 1)
94 model_->NextDetail();
95 else
96 model_->Next();
97@@ -271,7 +265,7 @@
98 switch (detail_mode_)
99 {
100 case TAB_NEXT_WINDOW:
101- if (model_->detail_selection_index > 0)
102+ if (model_->detail_selection_index > (unsigned int) 0)
103 model_->PrevDetail();
104 else
105 model_->Prev();
106@@ -295,9 +289,10 @@
107 return view_.GetPointer();
108 }
109
110-void SwitcherController::SetDetail(bool value, int min_windows)
111+void SwitcherController::SetDetail(bool value, unsigned
112+int min_windows)
113 {
114- if (value && model_->Selection()->RelatedWindows() >= min_windows)
115+ if (value && model_->Selection()->RelatedXids().size () >= min_windows)
116 {
117 model_->detail_selection = true;
118 detail_mode_ = TAB_NEXT_WINDOW_LOOP;
119
120=== modified file 'plugins/unityshell/src/SwitcherController.h'
121--- plugins/unityshell/src/SwitcherController.h 2011-08-25 03:53:17 +0000
122+++ plugins/unityshell/src/SwitcherController.h 2011-09-19 16:41:04 +0000
123@@ -72,7 +72,7 @@
124
125 void Select (int index);
126
127- void SetDetail(bool detail, int min_windows = 1);
128+ void SetDetail(bool detail, unsigned int min_windows = 1);
129
130 void SelectFirstItem();
131
132@@ -94,8 +94,6 @@
133
134 void OnModelSelectionChanged(AbstractLauncherIcon *icon);
135
136- int WindowsRelatedToSelection();
137-
138 static void OnBackgroundUpdate (GVariant *data, SwitcherController *self);
139
140 SwitcherModel::Ptr model_;
141
142=== modified file 'plugins/unityshell/src/SwitcherModel.cpp'
143--- plugins/unityshell/src/SwitcherModel.cpp 2011-09-13 22:06:17 +0000
144+++ plugins/unityshell/src/SwitcherModel.cpp 2011-09-19 16:41:04 +0000
145@@ -130,7 +130,7 @@
146 Window
147 SwitcherModel::DetailSelectionWindow ()
148 {
149- if (!detail_selection)
150+ if (!detail_selection || DetailXids ().empty())
151 return 0;
152
153 return DetailXids()[detail_selection_index];
154@@ -171,7 +171,7 @@
155 if (!detail_selection())
156 return;
157
158- if (detail_selection_index < Selection()->RelatedWindows () - 1)
159+ if (detail_selection_index < Selection()->RelatedXids ().size () - 1)
160 detail_selection_index = detail_selection_index + 1;
161 else
162 detail_selection_index = 0;
163@@ -182,10 +182,10 @@
164 if (!detail_selection())
165 return;
166
167- if (detail_selection_index > 0)
168+ if (detail_selection_index >= (unsigned int) 1)
169 detail_selection_index = detail_selection_index - 1;
170 else
171- detail_selection_index = Selection()->RelatedWindows () - 1;
172+ detail_selection_index = Selection()->RelatedXids ().size () - 1;
173 }
174
175 void
176
177=== modified file 'plugins/unityshell/src/SwitcherModel.h'
178--- plugins/unityshell/src/SwitcherModel.h 2011-08-17 20:43:46 +0000
179+++ plugins/unityshell/src/SwitcherModel.h 2011-09-19 16:41:04 +0000
180@@ -44,7 +44,7 @@
181 typedef Base::reverse_iterator reverse_iterator;
182
183 nux::Property<bool> detail_selection;
184- nux::Property<int> detail_selection_index;
185+ nux::Property<unsigned int> detail_selection_index;
186
187 // Icons are owned externally and assumed valid for life of switcher.
188 // When AbstractLauncherIcon is complete, it will be passed as a shared pointer and this
189
190=== modified file 'plugins/unityshell/src/SwitcherView.cpp'
191--- plugins/unityshell/src/SwitcherView.cpp 2011-09-14 20:59:39 +0000
192+++ plugins/unityshell/src/SwitcherView.cpp 2011-09-19 16:41:04 +0000
193@@ -130,7 +130,7 @@
194 clock_gettime(CLOCK_MONOTONIC, &save_time_);
195 }
196
197-void SwitcherView::OnDetailSelectionIndexChanged (int index)
198+void SwitcherView::OnDetailSelectionIndexChanged (unsigned int index)
199 {
200 if (model_->detail_selection)
201 {
202
203=== modified file 'plugins/unityshell/src/SwitcherView.h'
204--- plugins/unityshell/src/SwitcherView.h 2011-09-14 20:59:39 +0000
205+++ plugins/unityshell/src/SwitcherView.h 2011-09-19 16:41:04 +0000
206@@ -82,7 +82,7 @@
207 private:
208 void OnSelectionChanged(AbstractLauncherIcon* selection);
209 void OnDetailSelectionChanged (bool detail);
210- void OnDetailSelectionIndexChanged (int index);
211+ void OnDetailSelectionIndexChanged (unsigned int index);
212
213 void OnIconSizeChanged (int size);
214 void OnTileSizeChanged (int size);
215
216=== modified file 'plugins/unityshell/src/WindowManager.cpp'
217--- plugins/unityshell/src/WindowManager.cpp 2011-09-12 01:07:57 +0000
218+++ plugins/unityshell/src/WindowManager.cpp 2011-09-19 16:41:04 +0000
219@@ -62,6 +62,11 @@
220 return false;
221 }
222
223+ bool IsWindowMapped(guint32 xid)
224+ {
225+ return true;
226+ }
227+
228 void Restore(guint32 xid)
229 {
230 g_debug("%s", G_STRFUNC);
231
232=== modified file 'plugins/unityshell/src/WindowManager.h'
233--- plugins/unityshell/src/WindowManager.h 2011-09-08 03:04:04 +0000
234+++ plugins/unityshell/src/WindowManager.h 2011-09-19 16:41:04 +0000
235@@ -52,6 +52,7 @@
236 virtual bool IsWindowDecorated(guint32 xid) = 0;
237 virtual bool IsWindowOnCurrentDesktop(guint32 xid) = 0;
238 virtual bool IsWindowObscured(guint32 xid) = 0;
239+ virtual bool IsWindowMapped(guint32 xid) = 0;
240
241 virtual void ShowDesktop() = 0;
242
243
244=== modified file 'plugins/unityshell/src/compizminimizedwindowhandler.h'
245--- plugins/unityshell/src/compizminimizedwindowhandler.h 2011-09-09 13:21:10 +0000
246+++ plugins/unityshell/src/compizminimizedwindowhandler.h 2011-09-19 16:41:04 +0000
247@@ -287,12 +287,13 @@
248 for (CompWindow *w : screen->windows ())
249 {
250 bool m = w->minimized ();
251+ bool enable = keepMinimized && w->mapNum () > 0;
252
253 if (m)
254 w->unminimize ();
255- w->minimizeSetEnabled (Window::get (w), keepMinimized);
256- w->unminimizeSetEnabled (Window::get (w), keepMinimized);
257- w->minimizedSetEnabled (Window::get (w), keepMinimized);
258+ w->minimizeSetEnabled (Window::get (w), enable);
259+ w->unminimizeSetEnabled (Window::get (w), enable);
260+ w->minimizedSetEnabled (Window::get (w), enable);
261 if (m)
262 Window::get (w)->window->minimize ();
263 }
264
265=== modified file 'plugins/unityshell/src/unityshell.cpp'
266--- plugins/unityshell/src/unityshell.cpp 2011-09-16 14:10:10 +0000
267+++ plugins/unityshell/src/unityshell.cpp 2011-09-19 16:41:04 +0000
268@@ -1592,6 +1592,36 @@
269 void UnityWindow::windowNotify(CompWindowNotify n)
270 {
271 PluginAdapter::Default()->Notify(window, n);
272+
273+ switch (n)
274+ {
275+ case CompWindowNotifyMap:
276+ case CompWindowNotifyUnmap:
277+ if (UnityScreen::get (screen)->optionGetShowMinimizedWindows () &&
278+ window->mapNum ())
279+ {
280+ bool wasMinimized = window->minimized ();
281+ if (wasMinimized)
282+ window->unminimize ();
283+ window->minimizeSetEnabled (this, true);
284+ window->unminimizeSetEnabled (this, true);
285+ window->minimizedSetEnabled (this, true);
286+
287+ if (wasMinimized)
288+ window->minimize ();
289+ }
290+ else
291+ {
292+ window->minimizeSetEnabled (this, false);
293+ window->unminimizeSetEnabled (this, false);
294+ window->minimizedSetEnabled (this, false);
295+ }
296+ break;
297+ default:
298+ break;
299+ }
300+
301+
302 window->windowNotify(n);
303
304 // We do this after the notify to ensure input focus has actually been moved.
305@@ -2141,24 +2171,9 @@
306 WindowInterface::setHandler(window);
307 GLWindowInterface::setHandler(gWindow);
308
309- if (UnityScreen::get (screen)->optionGetShowMinimizedWindows ())
310- {
311- bool wasMinimized = window->minimized ();
312- if (wasMinimized)
313- window->unminimize ();
314- window->minimizeSetEnabled (this, true);
315- window->unminimizeSetEnabled (this, true);
316- window->minimizedSetEnabled (this, true);
317-
318- if (wasMinimized)
319- window->minimize ();
320- }
321- else
322- {
323- window->minimizeSetEnabled (this, false);
324- window->unminimizeSetEnabled (this, false);
325- window->minimizedSetEnabled (this, false);
326- }
327+ window->minimizedSetEnabled (this, false);
328+ window->minimizeSetEnabled (this, false);
329+ window->unminimizeSetEnabled (this, false);
330
331 if (window->state () & CompWindowStateFullscreenMask)
332 UnityScreen::get (screen)->fullscreen_windows_.push_back(window);