Merge lp:~3v1n0/unity/workspace-aware-launcher into lp:unity

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Marco Trevisan (Treviño)
Approved revision: no longer in the source branch.
Merged at revision: 1856
Proposed branch: lp:~3v1n0/unity/workspace-aware-launcher
Merge into: lp:unity
Diff against target: 268 lines (+71/-71)
4 files modified
manual-tests/Launcher.txt (+40/-0)
plugins/unityshell/src/BamfLauncherIcon.cpp (+28/-65)
plugins/unityshell/src/BamfLauncherIcon.h (+1/-3)
plugins/unityshell/src/PluginAdapter.cpp (+2/-3)
To merge this branch: bzr merge lp:~3v1n0/unity/workspace-aware-launcher
Reviewer Review Type Date Requested Status
Mirco Müller Pending
Review via email: mp+89429@code.launchpad.net

This proposal supersedes a proposal from 2012-01-20.

Description of the change

Make the launcher be aware of the window's workspace

Fixed another part of bug #689733 that we were missing, making the launcher to count only the windows in the current workspace when drawing the left "pips".

Also fixed the unity side of the bug #690143 to make the launcher to spread only the windows in the current workspace.

Manual tests included.

To post a comment you must log in.
Revision history for this message
Mirco Müller (macslow) wrote : Posted in a previous version of this proposal

Code looking good, manual test work as advertised... only complain I have is that the manual tests should be a bit more explicit, telling the test which applicaiton to use for testing this. Really a dull step-by-step instructions à la:

Preperation
-----------
1.) from clean session start/open a nautilus window on initial workspace
2.) goto right workspace, start two more instances of nautilus by middle-clicking twice on the nautilus-icon on the launcher
3.) goto bottom right workspace, start three more instances of nautilus by middle-clicking on the nautilus-icon on the launcher
4.) ...

Tests
-----
1.) Go to top right workspace select on of the nautilus windows
2.) Go to top left workspace open and focus a non-nautilus window (e.g. devhelp)
3.) Left click nautilus-icon on launcher -> outcome: you're moved to top right workspace to last focused nautilus-window (from step 1.))

etc.

review: Approve
Revision history for this message
Unity Merger (unity-merger) wrote : Posted in a previous version of this proposal

The prerequisite lp:~3v1n0/unity/manage-user-invisible-windows has not yet been merged into lp:unity.

Revision history for this message
Unity Merger (unity-merger) wrote : Posted in a previous version of this proposal

No proposals found for merge of lp:~3v1n0/unity/manage-user-invisible-windows into lp:unity.

Revision history for this message
Unity Merger (unity-merger) wrote : Posted in a previous version of this proposal

Attempt to merge into lp:unity failed due to conflicts:

text conflict in plugins/unityshell/src/BamfLauncherIcon.cpp

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote : Posted in a previous version of this proposal

I've fixed the conflicts with current trunk, approving it for merge since nothing changed since last approval.

Revision history for this message
Unity Merger (unity-merger) wrote : Posted in a previous version of this proposal

No proposals found for merge of lp:~3v1n0/unity/manage-user-invisible-windows into lp:unity.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== renamed file 'manual-tests/launcher.txt' => 'manual-tests/Launcher.txt'
2--- manual-tests/launcher.txt 2012-01-10 10:40:45 +0000
3+++ manual-tests/Launcher.txt 2012-01-20 13:05:14 +0000
4@@ -0,0 +1,40 @@
5+Test Launcher Icon with Windows in multiple workspaces
6+------------------------------------------------------
7+This test shows how the launcher should draw when there are application windows
8+in multiple workspaces.
9+
10+#. Start on a fresh login
11+#. Run an application
12+#. Run another instance of this application and keep it on the initial workspace
13+#. Run another instance of this application and move it no another workspaces
14+#. Go back to the initial workspace
15+
16+Outcome
17+ The Launcher icon "pips" should reflect the number of windows in the current
18+ workspace, so when showing the "initial" workspace the launcher icon should
19+ have 2 "pips", when moving to the second workspace (where there's only 1 window)
20+ the launcher application icon should show 1 pip.
21+ When moving to a workspace where there are no windows, the launcher icon should
22+ use an empty arrow as left indicator.
23+
24+
25+Test Launcher Spread with Windows in multiple workspaces
26+--------------------------------------------------------
27+This test shows how the launcher should spread the windows when they are in
28+multiple workspaces.
29+
30+#. Start on a fresh login
31+#. Run an application
32+#. Run another instance of this application and keep it on the initial workspace
33+#. Run another instance of this application and move it no another workspaces
34+#. Go back to the initial workspace and focus the application windows
35+
36+Outcome
37+ When in the current workspace there are multiple windows of the same
38+ application and one of them is focused, clicking on the launcher should spread
39+ only the windows that are in the current workspace.
40+ If in the current workspace there is just one window, clicking on the launcher
41+ icon should only focus it and nothing else (also with multiple clicks).
42+ When moving to a workspace where there are no window o the given application,
43+ clicking on its launcher icon should bring to focus the last focused window
44+ in the last used workspace.
45
46=== modified file 'plugins/unityshell/src/BamfLauncherIcon.cpp'
47--- plugins/unityshell/src/BamfLauncherIcon.cpp 2012-01-13 14:30:52 +0000
48+++ plugins/unityshell/src/BamfLauncherIcon.cpp 2012-01-20 13:05:14 +0000
49@@ -142,7 +142,7 @@
50 {
51 if (arg.source != ActionArg::SWITCHER)
52 {
53- Spread(0, false);
54+ Spread(true, 0, false);
55 }
56 }
57 }
58@@ -153,7 +153,7 @@
59 WindowManager::Default()->TerminateScale();
60 Focus(arg);
61 if (arg.source != ActionArg::SWITCHER)
62- Spread(0, false);
63+ Spread(true, 0, false);
64 }
65 else // #3 above
66 {
67@@ -213,8 +213,8 @@
68
69 WindowManager::Default()->window_minimized.connect(sigc::mem_fun(this, &BamfLauncherIcon::OnWindowMinimized));
70 WindowManager::Default()->window_moved.connect(sigc::mem_fun(this, &BamfLauncherIcon::OnWindowMoved));
71- WindowManager::Default()->compiz_screen_viewport_switch_ended.connect(sigc::mem_fun(this, &BamfLauncherIcon::OnViewPortSwitchEnded));
72- WindowManager::Default()->terminate_expo.connect(sigc::mem_fun(this, &BamfLauncherIcon::OnViewPortSwitchEnded));
73+ WindowManager::Default()->compiz_screen_viewport_switch_ended.connect(sigc::mem_fun(this, &BamfLauncherIcon::EnsureWindowState));
74+ WindowManager::Default()->terminate_expo.connect(sigc::mem_fun(this, &BamfLauncherIcon::EnsureWindowState));
75 IconManager->hidden_changed.connect(sigc::mem_fun(this, &BamfLauncherIcon::OnLauncherHiddenChanged));
76
77 // hack
78@@ -348,40 +348,6 @@
79 UpdateQuirkTimeDelayed(300, QUIRK_SHIMMER);
80 }
81
82-gboolean BamfLauncherIcon::OnWindowMovedTimeout(gpointer data)
83-{
84- BamfLauncherIcon *self = static_cast <BamfLauncherIcon *> (data);
85- GList *children = bamf_view_get_children(BAMF_VIEW(self->m_App));
86-
87- bool any_on_current = false;
88- bool found_moved = (self->_window_moved_xid != 0 ? false : true);
89-
90- for (GList *l = children; l; l = l->next)
91- {
92- BamfView *view = BAMF_VIEW(l->data);
93-
94- if (BAMF_IS_WINDOW(view))
95- {
96- Window xid = bamf_window_get_xid(BAMF_WINDOW(view));
97-
98- if (self->_window_moved_xid == xid)
99- found_moved = true;
100-
101- if (WindowManager::Default()->IsWindowOnCurrentDesktop(xid))
102- any_on_current = true;
103-
104- if (found_moved && any_on_current)
105- break;
106- }
107- }
108-
109- self->SetHasWindowOnViewport(any_on_current);
110- self->_window_moved_id = 0;
111- g_list_free(children);
112-
113- return FALSE;
114-}
115-
116 void BamfLauncherIcon::OnWindowMoved(guint32 moved_win)
117 {
118 if (_window_moved_id != 0)
119@@ -389,20 +355,13 @@
120
121 _window_moved_xid = moved_win;
122
123- if (_window_moved_xid == 0)
124- {
125- OnWindowMovedTimeout(this);
126- }
127- else
128- {
129- _window_moved_id = g_timeout_add(250,
130- (GSourceFunc)BamfLauncherIcon::OnWindowMovedTimeout, this);
131- }
132-}
133-
134-void BamfLauncherIcon::OnViewPortSwitchEnded()
135-{
136- OnWindowMoved(0);
137+ _window_moved_id = g_timeout_add(250, [] (gpointer data) -> gboolean
138+ {
139+ BamfLauncherIcon* self = static_cast<BamfLauncherIcon*>(data);
140+ self->EnsureWindowState();
141+ self->_window_moved_id = 0;
142+ return FALSE;
143+ }, this);
144 }
145
146 bool BamfLauncherIcon::IsSticky()
147@@ -652,11 +611,12 @@
148 }
149 }
150
151-bool BamfLauncherIcon::Spread(int state, bool force)
152+bool BamfLauncherIcon::Spread(bool current_desktop, int state, bool force)
153 {
154 BamfView* view;
155 GList* children, *l;
156 children = bamf_view_get_children(BAMF_VIEW(m_App));
157+ WindowManager* wm = WindowManager::Default();
158
159 std::vector<Window> windowList;
160 for (l = children; l; l = l->next)
161@@ -666,7 +626,11 @@
162 if (BAMF_IS_WINDOW(view))
163 {
164 guint32 xid = bamf_window_get_xid(BAMF_WINDOW(view));
165- windowList.push_back((Window) xid);
166+
167+ if (!current_desktop || (current_desktop && wm->IsWindowOnCurrentDesktop(xid)))
168+ {
169+ windowList.push_back((Window) xid);
170+ }
171 }
172 }
173
174@@ -719,9 +683,9 @@
175 void BamfLauncherIcon::EnsureWindowState()
176 {
177 GList* children, *l;
178+ bool has_win_on_current_vp = false;
179+ unsigned int user_visible_count = 0;
180 unsigned int children_count = 0;
181- unsigned int user_visible_count = 0;
182- bool has_visible = false;
183
184 children = bamf_view_get_children(BAMF_VIEW(m_App));
185 for (l = children; l; l = l->next)
186@@ -729,16 +693,15 @@
187 if (!BAMF_IS_WINDOW(l->data))
188 continue;
189
190- if (!has_visible)
191+ Window xid = bamf_window_get_xid(BAMF_WINDOW(l->data));
192+ if (WindowManager::Default()->IsWindowOnCurrentDesktop(xid))
193 {
194- Window xid = bamf_window_get_xid(BAMF_WINDOW(l->data));
195- if (WindowManager::Default()->IsWindowOnCurrentDesktop(xid))
196- has_visible = true;
197- }
198+ has_win_on_current_vp = true;
199
200- if (bamf_view_user_visible (BAMF_VIEW (l->data)))
201- {
202- user_visible_count++;
203+ if (bamf_view_user_visible (BAMF_VIEW (l->data)))
204+ {
205+ user_visible_count++;
206+ }
207 }
208
209 children_count++;
210@@ -753,7 +716,7 @@
211 SetRelatedWindows(1);
212 }
213
214- SetHasWindowOnViewport(has_visible);
215+ SetHasWindowOnViewport(has_win_on_current_vp);
216
217 g_list_free(children);
218 }
219
220=== modified file 'plugins/unityshell/src/BamfLauncherIcon.h'
221--- plugins/unityshell/src/BamfLauncherIcon.h 2011-12-20 21:41:32 +0000
222+++ plugins/unityshell/src/BamfLauncherIcon.h 2012-01-20 13:05:14 +0000
223@@ -116,13 +116,12 @@
224
225 void OpenInstanceWithUris(std::set<std::string> uris);
226 void Focus(ActionArg arg);
227- bool Spread(int state, bool force);
228+ bool Spread(bool current_desktop, int state, bool force);
229
230 void EnsureMenuItemsReady();
231
232 void OnWindowMinimized(guint32 xid);
233 void OnWindowMoved(guint32 xid);
234- void OnViewPortSwitchEnded();
235 bool OwnsWindow(Window w);
236
237 const std::set<std::string>& GetSupportedTypes();
238@@ -147,7 +146,6 @@
239
240 static gboolean OnDndHoveredTimeout(gpointer data);
241 static gboolean FillSupportedTypes(gpointer data);
242- static gboolean OnWindowMovedTimeout(gpointer data);
243 };
244
245 }
246
247=== modified file 'plugins/unityshell/src/PluginAdapter.cpp'
248--- plugins/unityshell/src/PluginAdapter.cpp 2011-10-14 09:46:14 +0000
249+++ plugins/unityshell/src/PluginAdapter.cpp 2012-01-20 13:05:14 +0000
250@@ -624,7 +624,7 @@
251 * or scale, so unconditionally unminimize those
252 * windows when the launcher icon is activated */
253 if ((focus_visibility == WindowManager::FocusVisibility::ForceUnminimizeOnCurrentDesktop &&
254- WindowManager::Default ()->IsWindowOnCurrentDesktop(win->id ())) ||
255+ target_vp == m_Screen->vp()) ||
256 (focus_visibility == WindowManager::FocusVisibility::ForceUnminimizeInvisible &&
257 win->mapNum () == 0))
258 {
259@@ -640,8 +640,7 @@
260 }
261 else if ((any_mapped && !win->minimized()) || !any_mapped)
262 {
263- if (!forced_unminimize ||
264- WindowManager::Default ()->IsWindowOnCurrentDesktop (win->id ()))
265+ if (!forced_unminimize || target_vp == m_Screen->vp())
266 {
267 win->raise();
268 top_win = win;