Merge lp:~brandontschaefer/unity/switcher-detail-mode-fix-last-active into lp:unity

Proposed by Brandon Schaefer
Status: Merged
Approved by: Brandon Schaefer
Approved revision: no longer in the source branch.
Merged at revision: 2524
Proposed branch: lp:~brandontschaefer/unity/switcher-detail-mode-fix-last-active
Merge into: lp:unity
Diff against target: 66 lines (+19/-2)
3 files modified
launcher/SwitcherModel.cpp (+3/-1)
launcher/SwitcherModel.h (+2/-0)
tests/autopilot/unity/tests/test_switcher.py (+14/-1)
To merge this branch: bzr merge lp:~brandontschaefer/unity/switcher-detail-mode-fix-last-active
Reviewer Review Type Date Requested Status
Christopher Lee (community) Approve
Review via email: mp+116792@code.launchpad.net

Commit message

The switcher in detail mode will now focus the last active window, instead of the current one. If the current focus window activated the switcher.

Description of the change

=== Problem ===
When going into detail mode the switcher would focus its own window. This means Detail mode would no longer know if the window was currently active. So it would not swap the current window with the last active window.

This also cause detail mode to all of a sudden swap the first and second icon (very annoying)

=== Fix ===
Save the currently active icon type, so when we check if we need to swap icons we know which one it was.

=== Test ===
There is an AP test.

To post a comment you must log in.
Revision history for this message
Christopher Lee (veebers) :
review: Approve
Revision history for this message
Unity Merger (unity-merger) wrote :
Revision history for this message
Unity Merger (unity-merger) wrote :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'launcher/SwitcherModel.cpp'
2--- launcher/SwitcherModel.cpp 2012-06-26 02:22:44 +0000
3+++ launcher/SwitcherModel.cpp 2012-07-26 02:08:21 +0000
4@@ -42,6 +42,8 @@
5 for (auto icon : _inner)
6 {
7 AddChild(icon.GetPointer());
8+ if (icon->GetQuirk(AbstractLauncherIcon::QUIRK_ACTIVE))
9+ _last_active_icon = icon;
10 }
11 }
12
13@@ -157,7 +159,7 @@
14 std::sort (results.begin (), results.end (), &CompareWindowsByActive);
15
16 // swap so we focus the last focused window first
17- if (Selection()->GetQuirk (AbstractLauncherIcon::QUIRK_ACTIVE) && results.size () > 1)
18+ if (Selection() == _last_active_icon && results.size () > 1)
19 std::swap (results[0], results[1]);
20
21 return results;
22
23=== modified file 'launcher/SwitcherModel.h'
24--- launcher/SwitcherModel.h 2012-05-31 10:19:43 +0000
25+++ launcher/SwitcherModel.h 2012-07-26 02:08:21 +0000
26@@ -97,6 +97,8 @@
27 Base _inner;
28 unsigned int _index;
29 unsigned int _last_index;
30+
31+ launcher::AbstractLauncherIcon::Ptr _last_active_icon;
32 };
33
34 }
35
36=== modified file 'tests/autopilot/unity/tests/test_switcher.py'
37--- tests/autopilot/unity/tests/test_switcher.py 2012-07-11 16:37:21 +0000
38+++ tests/autopilot/unity/tests/test_switcher.py 2012-07-26 02:08:21 +0000
39@@ -308,6 +308,20 @@
40 self.switcher.next_icon()
41 self.assertThat(self.switcher.selection_index, Eventually(Equals(0)))
42
43+ def test_detail_mode_selects_last_active_window(self):
44+ """The active selection in detail mode must be the last focused window.
45+ If it was the currently active application type.
46+ """
47+ calc_win1, calc_win2 = self.start_applications("Calculator", "Calculator")
48+ self.assertVisibleWindowStack([calc_win2, calc_win1])
49+
50+ self.switcher.initiate()
51+ self.keyboard.press_and_release(self.initiate_keycode)
52+ sleep(0.5)
53+ self.switcher.select()
54+
55+ self.assertProperty(calc_win1, is_focused=True)
56+
57
58 class SwitcherWorkspaceTests(SwitcherTestCase):
59 """Test Switcher behavior with respect to multiple workspaces."""
60@@ -339,7 +353,6 @@
61 self.workspace.switch_to(2)
62 char_map = self.start_app("Character Map")
63
64-
65 self.switcher.initiate(SwitcherMode.ALL)
66 self.addCleanup(self.switcher.terminate)
67