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
=== modified file 'launcher/SwitcherModel.cpp'
--- launcher/SwitcherModel.cpp 2012-06-26 02:22:44 +0000
+++ launcher/SwitcherModel.cpp 2012-07-26 02:08:21 +0000
@@ -42,6 +42,8 @@
42 for (auto icon : _inner)42 for (auto icon : _inner)
43 {43 {
44 AddChild(icon.GetPointer());44 AddChild(icon.GetPointer());
45 if (icon->GetQuirk(AbstractLauncherIcon::QUIRK_ACTIVE))
46 _last_active_icon = icon;
45 }47 }
46}48}
4749
@@ -157,7 +159,7 @@
157 std::sort (results.begin (), results.end (), &CompareWindowsByActive);159 std::sort (results.begin (), results.end (), &CompareWindowsByActive);
158160
159 // swap so we focus the last focused window first161 // swap so we focus the last focused window first
160 if (Selection()->GetQuirk (AbstractLauncherIcon::QUIRK_ACTIVE) && results.size () > 1)162 if (Selection() == _last_active_icon && results.size () > 1)
161 std::swap (results[0], results[1]);163 std::swap (results[0], results[1]);
162164
163 return results;165 return results;
164166
=== modified file 'launcher/SwitcherModel.h'
--- launcher/SwitcherModel.h 2012-05-31 10:19:43 +0000
+++ launcher/SwitcherModel.h 2012-07-26 02:08:21 +0000
@@ -97,6 +97,8 @@
97 Base _inner;97 Base _inner;
98 unsigned int _index;98 unsigned int _index;
99 unsigned int _last_index;99 unsigned int _last_index;
100
101 launcher::AbstractLauncherIcon::Ptr _last_active_icon;
100};102};
101103
102}104}
103105
=== modified file 'tests/autopilot/unity/tests/test_switcher.py'
--- tests/autopilot/unity/tests/test_switcher.py 2012-07-11 16:37:21 +0000
+++ tests/autopilot/unity/tests/test_switcher.py 2012-07-26 02:08:21 +0000
@@ -308,6 +308,20 @@
308 self.switcher.next_icon()308 self.switcher.next_icon()
309 self.assertThat(self.switcher.selection_index, Eventually(Equals(0)))309 self.assertThat(self.switcher.selection_index, Eventually(Equals(0)))
310310
311 def test_detail_mode_selects_last_active_window(self):
312 """The active selection in detail mode must be the last focused window.
313 If it was the currently active application type.
314 """
315 calc_win1, calc_win2 = self.start_applications("Calculator", "Calculator")
316 self.assertVisibleWindowStack([calc_win2, calc_win1])
317
318 self.switcher.initiate()
319 self.keyboard.press_and_release(self.initiate_keycode)
320 sleep(0.5)
321 self.switcher.select()
322
323 self.assertProperty(calc_win1, is_focused=True)
324
311325
312class SwitcherWorkspaceTests(SwitcherTestCase):326class SwitcherWorkspaceTests(SwitcherTestCase):
313 """Test Switcher behavior with respect to multiple workspaces."""327 """Test Switcher behavior with respect to multiple workspaces."""
@@ -339,7 +353,6 @@
339 self.workspace.switch_to(2)353 self.workspace.switch_to(2)
340 char_map = self.start_app("Character Map")354 char_map = self.start_app("Character Map")
341355
342
343 self.switcher.initiate(SwitcherMode.ALL)356 self.switcher.initiate(SwitcherMode.ALL)
344 self.addCleanup(self.switcher.terminate)357 self.addCleanup(self.switcher.terminate)
345358