Merge lp:~townsend/unity/fix-lp1283775 into lp:unity

Proposed by Christopher Townsend
Status: Merged
Approved by: Marco Trevisan (Treviño)
Approved revision: no longer in the source branch.
Merged at revision: 3820
Proposed branch: lp:~townsend/unity/fix-lp1283775
Merge into: lp:unity
Diff against target: 87 lines (+14/-9)
3 files modified
launcher/ApplicationLauncherIcon.cpp (+5/-5)
launcher/LauncherIcon.cpp (+7/-3)
launcher/LauncherIcon.h (+2/-1)
To merge this branch: bzr merge lp:~townsend/unity/fix-lp1283775
Reviewer Review Type Date Requested Status
Marco Trevisan (Treviño) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+220964@code.launchpad.net

Commit message

Fix issue where the number of Launcher icon pips are not always properly updated when a new window of an already running application is opened.

Description of the change

Fix issue where the number of Launcher icon pips are not always properly updated when a new window of an already running application is opened.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) :
review: Approve
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

Ouch, I still need a case where this might make no effect: if no new window is opened/closed, but there are multiple opened across monitors, and one is moved to another monitor, it's not guaranteed that the redraw is emitted.

So, while the proper solution would just be to keep around the number of windows per monitor we have, we might just emit a redraw in any case... It's still something that won't really cost much.

review: Abstain
Revision history for this message
Christopher Townsend (townsend) wrote :

@Marco,

Hmm, I would think the call to SetWindowVisibleOnMonitor() would take care of the redraw in the case of moving a window to a different monitor. Could you explain why this doesn't force a redraw in the case you point out?

Revision history for this message
Christopher Townsend (townsend) wrote :

@ Marco,

Thinking more about your scenario you point out, I think I understand what you mean. Since there are already multiple windows opened of the same app across different monitors, then moving one of those windows to another monitor will cause SetWindowVisibleOnMonitor() to just return since there are already open windows of that app on that monitor.

So yeah, either keeping a vector of app windows for each monitor (most efficient) or just calling EmitNeedsRedraw() (easiest to implement) is correct.

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'launcher/ApplicationLauncherIcon.cpp'
2--- launcher/ApplicationLauncherIcon.cpp 2014-04-21 15:04:09 +0000
3+++ launcher/ApplicationLauncherIcon.cpp 2014-05-28 12:16:36 +0000
4@@ -723,7 +723,7 @@
5
6 void ApplicationLauncherIcon::EnsureWindowState()
7 {
8- std::bitset<monitors::MAX> monitors;
9+ std::vector<int> number_of_windows_on_monitor(monitors::MAX);
10
11 for (auto& window: app_->GetWindows())
12 {
13@@ -735,18 +735,18 @@
14 // If monitor is -1 (or negative), show on all monitors.
15 if (monitor < 0)
16 {
17- monitors.set();
18- break;
19+ for (unsigned j; j < monitors::MAX; j++)
20+ ++number_of_windows_on_monitor[j];
21 }
22 else
23 {
24- monitors[monitor] = true;
25+ ++number_of_windows_on_monitor[monitor];
26 }
27 }
28 }
29
30 for (unsigned i = 0; i < monitors::MAX; i++)
31- SetWindowVisibleOnMonitor(monitors[i], i);
32+ SetNumberOfWindowsVisibleOnMonitor(number_of_windows_on_monitor[i], i);
33
34 WindowsChanged.emit();
35 }
36
37=== modified file 'launcher/LauncherIcon.cpp'
38--- launcher/LauncherIcon.cpp 2014-03-11 09:16:10 +0000
39+++ launcher/LauncherIcon.cpp 2014-05-28 12:16:36 +0000
40@@ -80,6 +80,7 @@
41 , _shortcut(0)
42 , _allow_quicklist_to_show(true)
43 , _center(monitors::MAX)
44+ , _number_of_visible_windows(monitors::MAX)
45 , _quirks(monitors::MAX)
46 , _quirk_animations(monitors::MAX, decltype(_quirk_animations)::value_type(unsigned(Quirk::LAST)))
47 , _last_stable(monitors::MAX)
48@@ -732,12 +733,15 @@
49 return {-1, nux::Point3()};
50 }
51
52-void LauncherIcon::SetWindowVisibleOnMonitor(bool val, int monitor)
53+void LauncherIcon::SetNumberOfWindowsVisibleOnMonitor(int number_of_windows, int monitor)
54 {
55- if (_has_visible_window[monitor] == val)
56+ if (_number_of_visible_windows[monitor] == number_of_windows)
57 return;
58
59- _has_visible_window[monitor] = val;
60+ _has_visible_window[monitor] = (number_of_windows > 0);
61+
62+ _number_of_visible_windows[monitor] = number_of_windows;
63+
64 EmitNeedsRedraw(monitor);
65 }
66
67
68=== modified file 'launcher/LauncherIcon.h'
69--- launcher/LauncherIcon.h 2014-03-11 09:16:10 +0000
70+++ launcher/LauncherIcon.h 2014-05-28 12:16:36 +0000
71@@ -226,7 +226,7 @@
72
73 void SetProgress(float progress);
74
75- void SetWindowVisibleOnMonitor(bool val, int monitor);
76+ void SetNumberOfWindowsVisibleOnMonitor(int number_of_windows, int monitor);
77
78 void Present(float urgency, int length, int monitor = -1);
79
80@@ -338,6 +338,7 @@
81
82 std::vector<nux::Point3> _center;
83 std::bitset<monitors::MAX> _has_visible_window;
84+ std::vector<int> _number_of_visible_windows;
85 std::vector<std::bitset<std::size_t(Quirk::LAST)>> _quirks;
86 std::vector<std::vector<std::shared_ptr<Animation>>> _quirk_animations;
87 std::vector<nux::Point3> _last_stable;