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

Proposed by Christopher Townsend
Status: Merged
Approved by: Brandon Schaefer
Approved revision: no longer in the source branch.
Merged at revision: 3711
Proposed branch: lp:~townsend/unity/fix-lp1286784
Merge into: lp:unity
Diff against target: 96 lines (+21/-16)
3 files modified
launcher/ApplicationLauncherIcon.cpp (+13/-13)
launcher/ApplicationLauncherIcon.h (+0/-1)
tests/test_application_launcher_icon.cpp (+8/-2)
To merge this branch: bzr merge lp:~townsend/unity/fix-lp1286784
Reviewer Review Type Date Requested Status
Brandon Schaefer (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+210683@code.launchpad.net

Commit message

Fix the inconsistent z ordering of windows when using the mouse to scroll the Launcher icon of the active application.

Description of the change

A user (asmoore82) described the current behavior of scrolling over the Launcher icon to focus windows as "inconsistent" and he gave a very detailed explanation as to why (see bug #1286784).

I spoke with John Lea about this and he agreed that the scrolling behavior should be more in line with what asmorre82 describes. asmoore82 attached a patch to the bug, so this MP is incorporating that patch plus fixing some things like removing an unused variable and fixing up a test based on the new behavior.

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
Brandon Schaefer (brandontschaefer) wrote :

Nice. LGTM

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-02-13 10:14:20 +0000
3+++ launcher/ApplicationLauncherIcon.cpp 2014-03-12 20:07:49 +0000
4@@ -68,7 +68,6 @@
5 : SimpleLauncherIcon(IconType::APPLICATION)
6 , _startup_notification_timestamp(0)
7 , _last_scroll_timestamp(0)
8- , _last_scroll_direction(ScrollDirection::DOWN)
9 , _progressive_scroll(0)
10 , use_custom_bg_color_(false)
11 , bg_color_(nux::color::White)
12@@ -1276,19 +1275,17 @@
13
14 void PerformScrollUp(WindowList const& windows, unsigned int progressive_scroll)
15 {
16- if (!progressive_scroll)
17- {
18- windows.at(1)->Focus();
19- return;
20- }
21- else if (progressive_scroll == 1)
22- {
23+ if (progressive_scroll == windows.size() - 1)
24+ {
25+ //RestackAbove to preserve Global Stacking Order
26+ WindowManager::Default().RestackBelow(windows.at(0)->window_id(), windows.at(1)->window_id());
27+ WindowManager::Default().RestackBelow(windows.at(1)->window_id(), windows.at(0)->window_id());
28 windows.back()->Focus();
29 return;
30 }
31
32- WindowManager::Default().RestackBelow(windows.at(0)->window_id(), windows.at(windows.size() - progressive_scroll + 1)->window_id());
33- windows.at(windows.size() - progressive_scroll + 1)->Focus();
34+ WindowManager::Default().RestackBelow(windows.at(0)->window_id(), windows.at(progressive_scroll + 1)->window_id());
35+ windows.at(progressive_scroll + 1)->Focus();
36 }
37
38 void PerformScrollDown(WindowList const& windows, unsigned int progressive_scroll)
39@@ -1308,18 +1305,21 @@
40 {
41 if (timestamp - _last_scroll_timestamp < 150)
42 return;
43- else if (timestamp - _last_scroll_timestamp > 1500 || direction != _last_scroll_direction)
44+ else if (timestamp - _last_scroll_timestamp > 1500)
45 _progressive_scroll = 0;
46
47 _last_scroll_timestamp = timestamp;
48- _last_scroll_direction = direction;
49
50 auto const& windows = GetWindowsOnCurrentDesktopInStackingOrder();
51
52 if (!IsActive() || windows.size() <= 1)
53 return;
54
55- ++_progressive_scroll;
56+ if (direction == ScrollDirection::DOWN)
57+ ++_progressive_scroll;
58+ else
59+ //--_progressive_scroll; but roll to the top of windows
60+ _progressive_scroll += windows.size() - 1;
61 _progressive_scroll %= windows.size();
62
63 switch(direction)
64
65=== modified file 'launcher/ApplicationLauncherIcon.h'
66--- launcher/ApplicationLauncherIcon.h 2013-11-14 00:17:19 +0000
67+++ launcher/ApplicationLauncherIcon.h 2014-03-12 20:07:49 +0000
68@@ -139,7 +139,6 @@
69 std::string _remote_uri;
70 Time _startup_notification_timestamp;
71 Time _last_scroll_timestamp;
72- ScrollDirection _last_scroll_direction;
73 unsigned int _progressive_scroll;
74 std::set<std::string> _supported_types;
75 std::vector<glib::Object<DbusmenuMenuitem>> _menu_items;
76
77=== modified file 'tests/test_application_launcher_icon.cpp'
78--- tests/test_application_launcher_icon.cpp 2014-01-15 14:51:10 +0000
79+++ tests/test_application_launcher_icon.cpp 2014-03-12 20:07:49 +0000
80@@ -668,8 +668,14 @@
81 mock_icon->PerformScroll(AbstractLauncherIcon::ScrollDirection::DOWN, 200);
82 EXPECT_THAT(WM->GetWindowsInStackingOrder(), testing::ElementsAre(7, 6, 5, 4, 3, 1, 2));
83
84- mock_icon->PerformScroll(AbstractLauncherIcon::ScrollDirection::UP, 400);
85- EXPECT_THAT(WM->GetWindowsInStackingOrder(), testing::ElementsAre(7, 6, 4, 3, 1, 2, 5));
86+ mock_icon->PerformScroll(AbstractLauncherIcon::ScrollDirection::DOWN, 400);
87+ EXPECT_THAT(WM->GetWindowsInStackingOrder(), testing::ElementsAre(7, 6, 5, 4, 2, 1, 3));
88+
89+ mock_icon->PerformScroll(AbstractLauncherIcon::ScrollDirection::UP, 600);
90+ EXPECT_THAT(WM->GetWindowsInStackingOrder(), testing::ElementsAre(7, 6, 5, 4, 3, 1, 2));
91+
92+ mock_icon->PerformScroll(AbstractLauncherIcon::ScrollDirection::UP, 800);
93+ EXPECT_THAT(WM->GetWindowsInStackingOrder(), testing::ElementsAre(7, 6, 5, 4, 3, 2, 1));
94 }
95
96 TEST_F(TestApplicationLauncherIcon, PerformScrollNoWindows)