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
=== modified file 'manual-tests/Launcher.txt'
--- manual-tests/Launcher.txt 2012-03-23 02:34:18 +0000
+++ manual-tests/Launcher.txt 2012-03-23 10:29:18 +0000
@@ -190,6 +190,160 @@
190 from gnome-control-center -> Monitor should update the launcher position.190 from gnome-control-center -> Monitor should update the launcher position.
191191
192192
193Test Multiple Launchers with Windows in Multiple Monitors
194---------------------------------------------------------
195This test shows how the launchers should draw their icons when there are
196application windows in multiple monitors.
197
198Setup:
199 * Run CCSM and ensure that the unity option in "Experimental" ->
200 "Launcher Monitors" is set to "All Desktops"
201
202Actions:
203 * Open 2 Gedit windows on monitor 1, workspace 1.
204 * Open 1 Gedit window on monitor 2, workspace 1.
205 * Focus one of the two gedit windows on monitor 1.
206
207Expected Results:
208 * Gedit launcher icon on monitor 1 must have:
209 * Two pips on the left of the icon.
210 * A filled-in arrow on the right of the icon.
211 * Gedit launcher icon on monitor 2 must have:
212 * One empty arrow on the left of the icon.
213 * Nothing on the right of the icon.
214
215
216Test Multiple Launchers with Windows in Multiple Monitors and Workspaces
217------------------------------------------------------------------------
218This test shows how the launchers should draw their icons when there are
219application windows in multiple monitors spreaded in multiple workspaces.
220
221Setup:
222 * Run CCSM and ensure that the unity option in "Experimental" ->
223 "Launcher Monitors" is set to "All Desktops"
224
225Actions:
226 * Open 1 Gedit window on monitor 1, workspace 1.
227 * Open 2 Gedit windows on monitor 2, workspace 1.
228 * Open 2 Gedit windows on monitor 1, workspace 2.
229 * Open 1 Gedit window on monitor 2, workspace 3.
230 * Move to workspace 1.
231 * Focus the gedit window on monitor 1.
232
233Expected Results:
234 * Gedit launcher icon on monitor 1 must have:
235 * A filled-in arrow on the left of the icon.
236 * A filled-in arrow on the right of the icon.
237 * Gedit launcher icon on monitor 2 must have:
238 * Two pips on the left of the icon.
239 * Nothing on the right of the icon.
240
241Actions:
242 * Move to workspace 2.
243 * Focus one of the two gedit windows on monitor 1.
244
245Expected Results:
246 * Gedit launcher icon on monitor 1 must have:
247 * Two pips on the left of the icon.
248 * A filled-in arrow on the right of the icon.
249 * Gedit launcher icon on monitor 2 must have:
250 * An empty arrow on the left of the icon.
251 * Nothing on the right of the icon.
252
253Actions:
254 * Move to workspace 3.
255 * Focus the gedit window on monitor 2.
256
257Expected Results:
258 * Gedit launcher icon on monitor 1 must have:
259 * An empty arrow on the left of the icon.
260 * Nothing on the right of the icon.
261 * Gedit launcher icon on monitor 2 must have:
262 * A filled-in arrow on the left of the icon.
263 * A filled-in arrow on the right of the icon.
264
265Actions:
266 * Move to workspace 4.
267
268Expected Results:
269 * Gedit launcher icon on monitor 1 must have:
270 * An empty arrow on the left of the icon.
271 * Nothing on the right of the icon.
272 * Gedit launcher icon on monitor 2 must have:
273 * An empty arrow on the left of the icon.
274 * Nothing on the right of the icon.
275
276Test Single Launcher with Windows in Multiple Monitors
277------------------------------------------------------
278This test shows how the launcher should draw its icons when there are
279application windows in multiple monitors.
280
281Setup:
282 * Run CCSM and ensure that the unity option in "Experimental" ->
283 "Launcher Monitors" is set to "Primary Desktop"
284
285Actions:
286 * Open 2 Gedit windows on monitor 1, workspace 1.
287 * Open 1 Gedit window on monitor 2, workspace 1.
288 * Focus one of the two gedit windows on monitor 1.
289
290Expected Results:
291 * The launcher is placed only on primary monitor
292 * Gedit launcher icon must have:
293 * Three pips on the left of the icon.
294 * A filled-in arrow on the right of the icon.
295
296
297Test Single Launcher with Windows in Multiple Monitors and Workspaces
298---------------------------------------------------------------------
299This test shows how the launcher should draw its icons when there are
300application windows in multiple monitors spreaded in multiple workspaces.
301
302Setup:
303 * Run CCSM and ensure that the unity option in "Experimental" ->
304 "Launcher Monitors" is set to "Primary Desktop"
305
306Actions:
307 * Open 1 Gedit window on monitor 1, workspace 1.
308 * Open 2 Gedit windows on monitor 2, workspace 1.
309 * Open 2 Gedit windows on monitor 1, workspace 2.
310 * Open 1 Gedit window on monitor 2, workspace 3.
311 * Move to workspace 1.
312 * Focus the gedit window on monitor 1.
313
314Expected Results:
315 * The launcher is shown only on primary monitor
316 * Gedit launcher icon must have:
317 * Three pips on the left of the icon.
318 * A filled-in arrow on the right of the icon.
319
320Actions:
321 * Move to workspace 2.
322 * Focus one of the two gedit windows on monitor 1.
323
324Expected Results:
325 * Gedit launcher icon on monitor 1 must have:
326 * Two pips on the left of the icon.
327 * A filled-in arrow on the right of the icon.
328
329Actions:
330 * Move to workspace 3.
331 * Focus the gedit window on monitor 2.
332
333Expected Results:
334 * Gedit launcher icon on monitor 2 must have:
335 * A filled-in arrow on the left of the icon.
336 * A filled-in arrow on the right of the icon.
337
338Actions:
339 * Move to workspace 4.
340
341Expected Results:
342 * Gedit launcher icon on monitor 1 must have:
343 * An empty arrow on the left of the icon.
344 * Nothing on the right of the icon.
345
346
193Panel appearance with overlays347Panel appearance with overlays
194------------------------------348------------------------------
195Setup:349Setup:
196350
=== modified file 'plugins/unityshell/src/AbstractLauncherIcon.h'
--- plugins/unityshell/src/AbstractLauncherIcon.h 2012-03-14 06:24:18 +0000
+++ plugins/unityshell/src/AbstractLauncherIcon.h 2012-03-23 10:29:18 +0000
@@ -147,7 +147,9 @@
147147
148 virtual std::vector<Window> WindowsForMonitor(int monitor) = 0;148 virtual std::vector<Window> WindowsForMonitor(int monitor) = 0;
149149
150 virtual std::string NameForWindow (Window window) = 0;150 virtual std::vector<Window> WindowsOnViewport() = 0;
151
152 virtual std::string NameForWindow(Window window) = 0;
151153
152 virtual const bool WindowVisibleOnMonitor(int monitor) = 0;154 virtual const bool WindowVisibleOnMonitor(int monitor) = 0;
153155
154156
=== modified file 'plugins/unityshell/src/BamfLauncherIcon.cpp'
--- plugins/unityshell/src/BamfLauncherIcon.cpp 2012-03-21 12:31:11 +0000
+++ plugins/unityshell/src/BamfLauncherIcon.cpp 2012-03-23 10:29:18 +0000
@@ -287,55 +287,71 @@
287 ubus_server_send_message(ubus_server_get_default(), UBUS_LAUNCHER_ACTION_DONE, nullptr);287 ubus_server_send_message(ubus_server_get_default(), UBUS_LAUNCHER_ACTION_DONE, nullptr);
288}288}
289289
290std::vector<Window> BamfLauncherIcon::GetWindows(WindowFilterMask filter, int monitor)
291{
292 std::vector<Window> results;
293 GList* children, *l;
294 WindowManager *wm = WindowManager::Default();
295
296 monitor = (filter & WindowFilter::ON_ALL_MONITORS) ? -1 : monitor;
297 bool mapped = (filter & WindowFilter::MAPPED);
298 bool user_visible = (filter & WindowFilter::USER_VISIBLE);
299 bool current_desktop = (filter & WindowFilter::ON_CURRENT_DESKTOP);
300
301 children = bamf_view_get_children(BAMF_VIEW(_bamf_app.RawPtr()));
302 for (l = children; l; l = l->next)
303 {
304 if (!BAMF_IS_WINDOW(l->data))
305 continue;
306
307 auto window = static_cast<BamfWindow*>(l->data);
308 auto view = static_cast<BamfView*>(l->data);
309
310 if ((monitor >= 0 && bamf_window_get_monitor(window) == monitor) || monitor < 0)
311 {
312 if ((user_visible && bamf_view_user_visible(view)) || !user_visible)
313 {
314 guint32 xid = bamf_window_get_xid(window);
315
316 if ((mapped && wm->IsWindowMapped(xid)) || !mapped)
317 {
318 if ((current_desktop && wm->IsWindowOnCurrentDesktop(xid)) || !current_desktop)
319 {
320 results.push_back(xid);
321 }
322 }
323 }
324 }
325 }
326
327 g_list_free(children);
328 return results;
329}
330
290std::vector<Window> BamfLauncherIcon::Windows()331std::vector<Window> BamfLauncherIcon::Windows()
291{332{
292 std::vector<Window> results;333 return GetWindows(WindowFilter::MAPPED|WindowFilter::ON_ALL_MONITORS);
293 GList* children, *l;334}
294 WindowManager *wm = WindowManager::Default();335
295336std::vector<Window> BamfLauncherIcon::WindowsOnViewport()
296 children = bamf_view_get_children(BAMF_VIEW(_bamf_app.RawPtr()));337{
297 for (l = children; l; l = l->next)338 WindowFilterMask filter;
298 {339 filter |= WindowFilter::MAPPED;
299 if (!BAMF_IS_WINDOW(l->data))340 filter |= WindowFilter::USER_VISIBLE;
300 continue;341 filter |= WindowFilter::ON_CURRENT_DESKTOP;
301342 filter |= WindowFilter::ON_ALL_MONITORS;
302 Window xid = bamf_window_get_xid(static_cast<BamfWindow*>(l->data));343
303344 return GetWindows(filter);
304 if (wm->IsWindowMapped(xid))
305 {
306 results.push_back(xid);
307 }
308 }
309
310 g_list_free(children);
311 return results;
312}345}
313346
314std::vector<Window> BamfLauncherIcon::WindowsForMonitor(int monitor)347std::vector<Window> BamfLauncherIcon::WindowsForMonitor(int monitor)
315{348{
316 std::vector<Window> results;349 WindowFilterMask filter;
317 GList* children, *l;350 filter |= WindowFilter::MAPPED;
318 WindowManager *wm = WindowManager::Default();351 filter |= WindowFilter::USER_VISIBLE;
319352 filter |= WindowFilter::ON_CURRENT_DESKTOP;
320 children = bamf_view_get_children(BAMF_VIEW(_bamf_app.RawPtr()));353
321 for (l = children; l; l = l->next)354 return GetWindows(filter, monitor);
322 {
323 if (!BAMF_IS_WINDOW(l->data))
324 continue;
325
326 auto window = static_cast<BamfWindow*>(l->data);
327 if (bamf_window_get_monitor(window) == monitor)
328 {
329 guint32 xid = bamf_window_get_xid(window);
330 bool user_visible = bamf_view_user_visible(reinterpret_cast<BamfView*>(window));
331
332 if (user_visible && wm->IsWindowMapped(xid) && wm->IsWindowOnCurrentDesktop(xid))
333 results.push_back(xid);
334 }
335 }
336
337 g_list_free(children);
338 return results;
339}355}
340356
341std::string BamfLauncherIcon::NameForWindow(Window window)357std::string BamfLauncherIcon::NameForWindow(Window window)
342358
=== modified file 'plugins/unityshell/src/BamfLauncherIcon.h'
--- plugins/unityshell/src/BamfLauncherIcon.h 2012-03-14 06:24:18 +0000
+++ plugins/unityshell/src/BamfLauncherIcon.h 2012-03-23 10:29:18 +0000
@@ -61,6 +61,7 @@
61 virtual unsigned long long SwitcherPriority();61 virtual unsigned long long SwitcherPriority();
6262
63 std::vector<Window> Windows();63 std::vector<Window> Windows();
64 std::vector<Window> WindowsOnViewport();
64 std::vector<Window> WindowsForMonitor(int monitor);65 std::vector<Window> WindowsForMonitor(int monitor);
65 std::string NameForWindow(Window window);66 std::string NameForWindow(Window window);
6667
@@ -87,6 +88,15 @@
87 std::string GetName() const;88 std::string GetName() const;
8889
89private:90private:
91 typedef unsigned long int WindowFilterMask;
92 enum WindowFilter
93 {
94 MAPPED = (1 << 0),
95 USER_VISIBLE = (1 << 1),
96 ON_CURRENT_DESKTOP = (1 << 2),
97 ON_ALL_MONITORS = (1 << 3),
98 };
99
90 void EnsureWindowState();100 void EnsureWindowState();
91 void EnsureMenuItemsReady();101 void EnsureMenuItemsReady();
92 void UpdateDesktopFile();102 void UpdateDesktopFile();
@@ -103,6 +113,7 @@
103113
104 bool OwnsWindow(Window w) const;114 bool OwnsWindow(Window w) const;
105115
116 std::vector<Window> GetWindows(WindowFilterMask filter, int monitor = -1);
106 const std::set<std::string>& GetSupportedTypes();117 const std::set<std::string>& GetSupportedTypes();
107118
108119
109120
=== modified file 'plugins/unityshell/src/Launcher.cpp'
--- plugins/unityshell/src/Launcher.cpp 2012-03-23 02:22:04 +0000
+++ plugins/unityshell/src/Launcher.cpp 2012-03-23 10:29:18 +0000
@@ -939,7 +939,7 @@
939 else939 else
940 {940 {
941 if (options()->show_for_all)941 if (options()->show_for_all)
942 arg.window_indicators = std::max<int> (icon->Windows().size(), 1);942 arg.window_indicators = std::max<int> (icon->WindowsOnViewport().size(), 1);
943 else943 else
944 arg.window_indicators = std::max<int> (icon->WindowsForMonitor(monitor).size(), 1);944 arg.window_indicators = std::max<int> (icon->WindowsForMonitor(monitor).size(), 1);
945 }945 }
946946
=== modified file 'plugins/unityshell/src/LauncherIcon.h'
--- plugins/unityshell/src/LauncherIcon.h 2012-03-14 06:24:18 +0000
+++ plugins/unityshell/src/LauncherIcon.h 2012-03-23 10:29:18 +0000
@@ -102,11 +102,13 @@
102102
103 int SortPriority();103 int SortPriority();
104104
105 virtual std::vector<Window> Windows () { return std::vector<Window> (); }105 virtual std::vector<Window> Windows() { return std::vector<Window> (); }
106106
107 virtual std::vector<Window> WindowsForMonitor (int monitor) { return std::vector<Window> (); }107 virtual std::vector<Window> WindowsOnViewport() { return std::vector<Window> (); }
108108
109 virtual std::string NameForWindow (Window window) { return std::string(); }109 virtual std::vector<Window> WindowsForMonitor(int monitor) { return std::vector<Window> (); }
110
111 virtual std::string NameForWindow(Window window) { return std::string(); }
110112
111 const bool WindowVisibleOnMonitor(int monitor);113 const bool WindowVisibleOnMonitor(int monitor);
112114
113115
=== modified file 'plugins/unityshell/src/MockLauncherIcon.h'
--- plugins/unityshell/src/MockLauncherIcon.h 2012-03-14 06:24:18 +0000
+++ plugins/unityshell/src/MockLauncherIcon.h 2012-03-23 10:29:18 +0000
@@ -81,6 +81,22 @@
81 return result;81 return result;
82 }82 }
8383
84 std::vector<Window> WindowsOnViewport ()
85 {
86 std::vector<Window> result;
87
88 result.push_back ((100 << 16) + 200);
89 result.push_back ((500 << 16) + 200);
90 result.push_back ((300 << 16) + 200);
91 result.push_back ((200 << 16) + 200);
92 result.push_back ((300 << 16) + 200);
93 result.push_back ((100 << 16) + 200);
94 result.push_back ((300 << 16) + 200);
95 result.push_back ((600 << 16) + 200);
96
97 return result;
98 }
99
84 std::vector<Window> WindowsForMonitor (int monitor)100 std::vector<Window> WindowsForMonitor (int monitor)
85 {101 {
86 std::vector<Window> result;102 std::vector<Window> result;