Merge lp:~3v1n0/unity/launcher-primary-indicators-fix 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: 2165
Proposed branch: lp:~3v1n0/unity/launcher-primary-indicators-fix
Merge into: lp:unity
Diff against target: 397 lines (+251/-50)
7 files modified
manual-tests/Launcher.txt (+154/-0)
plugins/unityshell/src/AbstractLauncherIcon.h (+3/-1)
plugins/unityshell/src/BamfLauncherIcon.cpp (+59/-43)
plugins/unityshell/src/BamfLauncherIcon.h (+11/-0)
plugins/unityshell/src/Launcher.cpp (+1/-1)
plugins/unityshell/src/LauncherIcon.h (+7/-5)
plugins/unityshell/src/MockLauncherIcon.h (+16/-0)
To merge this branch: bzr merge lp:~3v1n0/unity/launcher-primary-indicators-fix
Reviewer Review Type Date Requested Status
Thomi Richards (community) Approve
Jason Smith (community) Approve
Review via email: mp+98860@code.launchpad.net

Commit message

BamfLauncherIcon: implement WindowsOnViewport to get only windows on visible VP

This function doesn't take account of the monitors.
Rewritten also BamfLauncherIcon::Windows and ::WindowsForMonitor
to remove code duplication, using the new GetWindows function to perform
filtering via the WindowFilterMask.

Description of the change

UNBLOCK as requested by didrocks

To post a comment you must log in.
Revision history for this message
Jason Smith (jassmith) wrote :

looks good, works good, I like it

review: Approve
Revision history for this message
Thomi Richards (thomir-deactivatedaccount) wrote :

Hi,

Please make the manual test follow the test template (manual-tests/TEST_TEMPLATE.txt). Specifically:

Tests need to be divided with a HR.
Tests need to have three stages: Setup, Actions, Expected Results.
For all three sections, steps should be bullet points, and as simple and explicit as possible.

For example, the first test should be written as:
<snip>
Test Launcher Icon with Windows in multiple monitors
----------------------------------------------------
This test shows how the launcher should draw its iucons when there are
application windows in multiple monitors.

Setup:
 * Run CCSM and ensure that the unity option in "Experimental" -> "Launcher Monitors" is set to "All Desktops"

Actions:
 * Open two GEdit windows on monitor 1, workspace 1.
 * Open one GEdit window on monitor 2, workspace 1.
 * Focus one of the two gedit windows on monitor one.

Expected Results:
 * GEdit launcher icon on monitor 1 must have:
   * Two pips on the left of the icon.
   * A filled-in arrow on the right of the icon.
 * GEDit launcher icon on monitor 2 must have:
   * One pip on the left of the icon
   * One hollow arrow on the right of the icon.
</snip>

...Although you will need to make that correct (I can't understand your test as it is, so I made most of that up).

Create a separate test that describes what should happen when you move workspaces.

Remember: tests should be small and simple.

review: Needs Fixing
Revision history for this message
Tim Penhey (thumper) wrote :

I'd like to see the manual tests become autopilot tests.

Revision history for this message
Thomi Richards (thomir-deactivatedaccount) wrote :

I'd also like to see these made into autopilot tests. The last thing I want to see is a bunch more manual tests that we need to slog through every release.

Ideally I'd like to see the tests not repeat the actions / expected results sections, but this is good enough to be run.

I'll approve this now, on the understanding that someone (ideally not me) turns these into autopilot tests. The only reason we're adding manual tests now is that we're so close to a release.

review: Approve
Revision history for this message
Unity Merger (unity-merger) wrote :

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

text conflict in manual-tests/Launcher.txt

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

> Ideally I'd like to see the tests not repeat the actions / expected results
> sections, but this is good enough to be run.

Yes, but we should also avoid to re-write the same actions for performing different tests.
IMHO we should just support something like "stages"... I.e.

TEST foo

Stage 1
Actions...
Expected results...

Stage 2
Actions...
Expected results...

.

So it will be easier to reference a single failure, but it would still avoid to re-define new tests only because there are actions dependents on the previous ones.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'manual-tests/Launcher.txt'
2--- manual-tests/Launcher.txt 2012-03-23 02:34:18 +0000
3+++ manual-tests/Launcher.txt 2012-03-23 10:29:18 +0000
4@@ -190,6 +190,160 @@
5 from gnome-control-center -> Monitor should update the launcher position.
6
7
8+Test Multiple Launchers with Windows in Multiple Monitors
9+---------------------------------------------------------
10+This test shows how the launchers should draw their icons when there are
11+application windows in multiple monitors.
12+
13+Setup:
14+ * Run CCSM and ensure that the unity option in "Experimental" ->
15+ "Launcher Monitors" is set to "All Desktops"
16+
17+Actions:
18+ * Open 2 Gedit windows on monitor 1, workspace 1.
19+ * Open 1 Gedit window on monitor 2, workspace 1.
20+ * Focus one of the two gedit windows on monitor 1.
21+
22+Expected Results:
23+ * Gedit launcher icon on monitor 1 must have:
24+ * Two pips on the left of the icon.
25+ * A filled-in arrow on the right of the icon.
26+ * Gedit launcher icon on monitor 2 must have:
27+ * One empty arrow on the left of the icon.
28+ * Nothing on the right of the icon.
29+
30+
31+Test Multiple Launchers with Windows in Multiple Monitors and Workspaces
32+------------------------------------------------------------------------
33+This test shows how the launchers should draw their icons when there are
34+application windows in multiple monitors spreaded in multiple workspaces.
35+
36+Setup:
37+ * Run CCSM and ensure that the unity option in "Experimental" ->
38+ "Launcher Monitors" is set to "All Desktops"
39+
40+Actions:
41+ * Open 1 Gedit window on monitor 1, workspace 1.
42+ * Open 2 Gedit windows on monitor 2, workspace 1.
43+ * Open 2 Gedit windows on monitor 1, workspace 2.
44+ * Open 1 Gedit window on monitor 2, workspace 3.
45+ * Move to workspace 1.
46+ * Focus the gedit window on monitor 1.
47+
48+Expected Results:
49+ * Gedit launcher icon on monitor 1 must have:
50+ * A filled-in arrow on the left of the icon.
51+ * A filled-in arrow on the right of the icon.
52+ * Gedit launcher icon on monitor 2 must have:
53+ * Two pips on the left of the icon.
54+ * Nothing on the right of the icon.
55+
56+Actions:
57+ * Move to workspace 2.
58+ * Focus one of the two gedit windows on monitor 1.
59+
60+Expected Results:
61+ * Gedit launcher icon on monitor 1 must have:
62+ * Two pips on the left of the icon.
63+ * A filled-in arrow on the right of the icon.
64+ * Gedit launcher icon on monitor 2 must have:
65+ * An empty arrow on the left of the icon.
66+ * Nothing on the right of the icon.
67+
68+Actions:
69+ * Move to workspace 3.
70+ * Focus the gedit window on monitor 2.
71+
72+Expected Results:
73+ * Gedit launcher icon on monitor 1 must have:
74+ * An empty arrow on the left of the icon.
75+ * Nothing on the right of the icon.
76+ * Gedit launcher icon on monitor 2 must have:
77+ * A filled-in arrow on the left of the icon.
78+ * A filled-in arrow on the right of the icon.
79+
80+Actions:
81+ * Move to workspace 4.
82+
83+Expected Results:
84+ * Gedit launcher icon on monitor 1 must have:
85+ * An empty arrow on the left of the icon.
86+ * Nothing on the right of the icon.
87+ * Gedit launcher icon on monitor 2 must have:
88+ * An empty arrow on the left of the icon.
89+ * Nothing on the right of the icon.
90+
91+Test Single Launcher with Windows in Multiple Monitors
92+------------------------------------------------------
93+This test shows how the launcher should draw its icons when there are
94+application windows in multiple monitors.
95+
96+Setup:
97+ * Run CCSM and ensure that the unity option in "Experimental" ->
98+ "Launcher Monitors" is set to "Primary Desktop"
99+
100+Actions:
101+ * Open 2 Gedit windows on monitor 1, workspace 1.
102+ * Open 1 Gedit window on monitor 2, workspace 1.
103+ * Focus one of the two gedit windows on monitor 1.
104+
105+Expected Results:
106+ * The launcher is placed only on primary monitor
107+ * Gedit launcher icon must have:
108+ * Three pips on the left of the icon.
109+ * A filled-in arrow on the right of the icon.
110+
111+
112+Test Single Launcher with Windows in Multiple Monitors and Workspaces
113+---------------------------------------------------------------------
114+This test shows how the launcher should draw its icons when there are
115+application windows in multiple monitors spreaded in multiple workspaces.
116+
117+Setup:
118+ * Run CCSM and ensure that the unity option in "Experimental" ->
119+ "Launcher Monitors" is set to "Primary Desktop"
120+
121+Actions:
122+ * Open 1 Gedit window on monitor 1, workspace 1.
123+ * Open 2 Gedit windows on monitor 2, workspace 1.
124+ * Open 2 Gedit windows on monitor 1, workspace 2.
125+ * Open 1 Gedit window on monitor 2, workspace 3.
126+ * Move to workspace 1.
127+ * Focus the gedit window on monitor 1.
128+
129+Expected Results:
130+ * The launcher is shown only on primary monitor
131+ * Gedit launcher icon must have:
132+ * Three pips on the left of the icon.
133+ * A filled-in arrow on the right of the icon.
134+
135+Actions:
136+ * Move to workspace 2.
137+ * Focus one of the two gedit windows on monitor 1.
138+
139+Expected Results:
140+ * Gedit launcher icon on monitor 1 must have:
141+ * Two pips on the left of the icon.
142+ * A filled-in arrow on the right of the icon.
143+
144+Actions:
145+ * Move to workspace 3.
146+ * Focus the gedit window on monitor 2.
147+
148+Expected Results:
149+ * Gedit launcher icon on monitor 2 must have:
150+ * A filled-in arrow on the left of the icon.
151+ * A filled-in arrow on the right of the icon.
152+
153+Actions:
154+ * Move to workspace 4.
155+
156+Expected Results:
157+ * Gedit launcher icon on monitor 1 must have:
158+ * An empty arrow on the left of the icon.
159+ * Nothing on the right of the icon.
160+
161+
162 Panel appearance with overlays
163 ------------------------------
164 Setup:
165
166=== modified file 'plugins/unityshell/src/AbstractLauncherIcon.h'
167--- plugins/unityshell/src/AbstractLauncherIcon.h 2012-03-14 06:24:18 +0000
168+++ plugins/unityshell/src/AbstractLauncherIcon.h 2012-03-23 10:29:18 +0000
169@@ -147,7 +147,9 @@
170
171 virtual std::vector<Window> WindowsForMonitor(int monitor) = 0;
172
173- virtual std::string NameForWindow (Window window) = 0;
174+ virtual std::vector<Window> WindowsOnViewport() = 0;
175+
176+ virtual std::string NameForWindow(Window window) = 0;
177
178 virtual const bool WindowVisibleOnMonitor(int monitor) = 0;
179
180
181=== modified file 'plugins/unityshell/src/BamfLauncherIcon.cpp'
182--- plugins/unityshell/src/BamfLauncherIcon.cpp 2012-03-21 12:31:11 +0000
183+++ plugins/unityshell/src/BamfLauncherIcon.cpp 2012-03-23 10:29:18 +0000
184@@ -287,55 +287,71 @@
185 ubus_server_send_message(ubus_server_get_default(), UBUS_LAUNCHER_ACTION_DONE, nullptr);
186 }
187
188+std::vector<Window> BamfLauncherIcon::GetWindows(WindowFilterMask filter, int monitor)
189+{
190+ std::vector<Window> results;
191+ GList* children, *l;
192+ WindowManager *wm = WindowManager::Default();
193+
194+ monitor = (filter & WindowFilter::ON_ALL_MONITORS) ? -1 : monitor;
195+ bool mapped = (filter & WindowFilter::MAPPED);
196+ bool user_visible = (filter & WindowFilter::USER_VISIBLE);
197+ bool current_desktop = (filter & WindowFilter::ON_CURRENT_DESKTOP);
198+
199+ children = bamf_view_get_children(BAMF_VIEW(_bamf_app.RawPtr()));
200+ for (l = children; l; l = l->next)
201+ {
202+ if (!BAMF_IS_WINDOW(l->data))
203+ continue;
204+
205+ auto window = static_cast<BamfWindow*>(l->data);
206+ auto view = static_cast<BamfView*>(l->data);
207+
208+ if ((monitor >= 0 && bamf_window_get_monitor(window) == monitor) || monitor < 0)
209+ {
210+ if ((user_visible && bamf_view_user_visible(view)) || !user_visible)
211+ {
212+ guint32 xid = bamf_window_get_xid(window);
213+
214+ if ((mapped && wm->IsWindowMapped(xid)) || !mapped)
215+ {
216+ if ((current_desktop && wm->IsWindowOnCurrentDesktop(xid)) || !current_desktop)
217+ {
218+ results.push_back(xid);
219+ }
220+ }
221+ }
222+ }
223+ }
224+
225+ g_list_free(children);
226+ return results;
227+}
228+
229 std::vector<Window> BamfLauncherIcon::Windows()
230 {
231- std::vector<Window> results;
232- GList* children, *l;
233- WindowManager *wm = WindowManager::Default();
234-
235- children = bamf_view_get_children(BAMF_VIEW(_bamf_app.RawPtr()));
236- for (l = children; l; l = l->next)
237- {
238- if (!BAMF_IS_WINDOW(l->data))
239- continue;
240-
241- Window xid = bamf_window_get_xid(static_cast<BamfWindow*>(l->data));
242-
243- if (wm->IsWindowMapped(xid))
244- {
245- results.push_back(xid);
246- }
247- }
248-
249- g_list_free(children);
250- return results;
251+ return GetWindows(WindowFilter::MAPPED|WindowFilter::ON_ALL_MONITORS);
252+}
253+
254+std::vector<Window> BamfLauncherIcon::WindowsOnViewport()
255+{
256+ WindowFilterMask filter;
257+ filter |= WindowFilter::MAPPED;
258+ filter |= WindowFilter::USER_VISIBLE;
259+ filter |= WindowFilter::ON_CURRENT_DESKTOP;
260+ filter |= WindowFilter::ON_ALL_MONITORS;
261+
262+ return GetWindows(filter);
263 }
264
265 std::vector<Window> BamfLauncherIcon::WindowsForMonitor(int monitor)
266 {
267- std::vector<Window> results;
268- GList* children, *l;
269- WindowManager *wm = WindowManager::Default();
270-
271- children = bamf_view_get_children(BAMF_VIEW(_bamf_app.RawPtr()));
272- for (l = children; l; l = l->next)
273- {
274- if (!BAMF_IS_WINDOW(l->data))
275- continue;
276-
277- auto window = static_cast<BamfWindow*>(l->data);
278- if (bamf_window_get_monitor(window) == monitor)
279- {
280- guint32 xid = bamf_window_get_xid(window);
281- bool user_visible = bamf_view_user_visible(reinterpret_cast<BamfView*>(window));
282-
283- if (user_visible && wm->IsWindowMapped(xid) && wm->IsWindowOnCurrentDesktop(xid))
284- results.push_back(xid);
285- }
286- }
287-
288- g_list_free(children);
289- return results;
290+ WindowFilterMask filter;
291+ filter |= WindowFilter::MAPPED;
292+ filter |= WindowFilter::USER_VISIBLE;
293+ filter |= WindowFilter::ON_CURRENT_DESKTOP;
294+
295+ return GetWindows(filter, monitor);
296 }
297
298 std::string BamfLauncherIcon::NameForWindow(Window window)
299
300=== modified file 'plugins/unityshell/src/BamfLauncherIcon.h'
301--- plugins/unityshell/src/BamfLauncherIcon.h 2012-03-14 06:24:18 +0000
302+++ plugins/unityshell/src/BamfLauncherIcon.h 2012-03-23 10:29:18 +0000
303@@ -61,6 +61,7 @@
304 virtual unsigned long long SwitcherPriority();
305
306 std::vector<Window> Windows();
307+ std::vector<Window> WindowsOnViewport();
308 std::vector<Window> WindowsForMonitor(int monitor);
309 std::string NameForWindow(Window window);
310
311@@ -87,6 +88,15 @@
312 std::string GetName() const;
313
314 private:
315+ typedef unsigned long int WindowFilterMask;
316+ enum WindowFilter
317+ {
318+ MAPPED = (1 << 0),
319+ USER_VISIBLE = (1 << 1),
320+ ON_CURRENT_DESKTOP = (1 << 2),
321+ ON_ALL_MONITORS = (1 << 3),
322+ };
323+
324 void EnsureWindowState();
325 void EnsureMenuItemsReady();
326 void UpdateDesktopFile();
327@@ -103,6 +113,7 @@
328
329 bool OwnsWindow(Window w) const;
330
331+ std::vector<Window> GetWindows(WindowFilterMask filter, int monitor = -1);
332 const std::set<std::string>& GetSupportedTypes();
333
334
335
336=== modified file 'plugins/unityshell/src/Launcher.cpp'
337--- plugins/unityshell/src/Launcher.cpp 2012-03-23 02:22:04 +0000
338+++ plugins/unityshell/src/Launcher.cpp 2012-03-23 10:29:18 +0000
339@@ -939,7 +939,7 @@
340 else
341 {
342 if (options()->show_for_all)
343- arg.window_indicators = std::max<int> (icon->Windows().size(), 1);
344+ arg.window_indicators = std::max<int> (icon->WindowsOnViewport().size(), 1);
345 else
346 arg.window_indicators = std::max<int> (icon->WindowsForMonitor(monitor).size(), 1);
347 }
348
349=== modified file 'plugins/unityshell/src/LauncherIcon.h'
350--- plugins/unityshell/src/LauncherIcon.h 2012-03-14 06:24:18 +0000
351+++ plugins/unityshell/src/LauncherIcon.h 2012-03-23 10:29:18 +0000
352@@ -102,11 +102,13 @@
353
354 int SortPriority();
355
356- virtual std::vector<Window> Windows () { return std::vector<Window> (); }
357-
358- virtual std::vector<Window> WindowsForMonitor (int monitor) { return std::vector<Window> (); }
359-
360- virtual std::string NameForWindow (Window window) { return std::string(); }
361+ virtual std::vector<Window> Windows() { return std::vector<Window> (); }
362+
363+ virtual std::vector<Window> WindowsOnViewport() { return std::vector<Window> (); }
364+
365+ virtual std::vector<Window> WindowsForMonitor(int monitor) { return std::vector<Window> (); }
366+
367+ virtual std::string NameForWindow(Window window) { return std::string(); }
368
369 const bool WindowVisibleOnMonitor(int monitor);
370
371
372=== modified file 'plugins/unityshell/src/MockLauncherIcon.h'
373--- plugins/unityshell/src/MockLauncherIcon.h 2012-03-14 06:24:18 +0000
374+++ plugins/unityshell/src/MockLauncherIcon.h 2012-03-23 10:29:18 +0000
375@@ -81,6 +81,22 @@
376 return result;
377 }
378
379+ std::vector<Window> WindowsOnViewport ()
380+ {
381+ std::vector<Window> result;
382+
383+ result.push_back ((100 << 16) + 200);
384+ result.push_back ((500 << 16) + 200);
385+ result.push_back ((300 << 16) + 200);
386+ result.push_back ((200 << 16) + 200);
387+ result.push_back ((300 << 16) + 200);
388+ result.push_back ((100 << 16) + 200);
389+ result.push_back ((300 << 16) + 200);
390+ result.push_back ((600 << 16) + 200);
391+
392+ return result;
393+ }
394+
395 std::vector<Window> WindowsForMonitor (int monitor)
396 {
397 std::vector<Window> result;