Merge lp:~timo-jyrinki/unity/alt-grave-ordering-fix-6.0 into lp:unity/6.0

Proposed by Timo Jyrinki
Status: Merged
Approved by: Brandon Schaefer
Approved revision: no longer in the source branch.
Merged at revision: 2778
Proposed branch: lp:~timo-jyrinki/unity/alt-grave-ordering-fix-6.0
Merge into: lp:unity/6.0
Diff against target: 85 lines (+52/-2)
3 files modified
launcher/SwitcherModel.cpp (+6/-2)
tests/autopilot/unity/tests/test_switcher.py (+13/-0)
tests/test_switcher_model.cpp (+33/-0)
To merge this branch: bzr merge lp:~timo-jyrinki/unity/alt-grave-ordering-fix-6.0
Reviewer Review Type Date Requested Status
Brandon Schaefer (community) Approve
Review via email: mp+129422@code.launchpad.net

Commit message

Changes the swapping order of the detail mode. Now the currently active window gets moved to the end, instead of getting swapped with the last used window. (LP: #1061229)

Description of the change

(from https://code.launchpad.net/~brandontschaefer/unity/alt-grave-ordering-fix/+merge/128823)

=== Problem ===
When pressing Alt+grave twice it would focus the active window going into detail mode. It should focus the third window, not the first.

=== Fix ===
Instead of swapping the first and second window, move the first all the way to the end (it being a vector means moving everything over one left)

=== Test ===
AP test

So with this change:

Window order, where 1 is the current focused window:
1,2,3,4,5,6

Pressing Alt+`

Desired result order:
2,3,4,5,6,1

Current result order:
2,1,3,4,5,6

To post a comment you must log in.
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

Looks good.

review: Approve

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-08-02 11:30:02 +0000
+++ launcher/SwitcherModel.cpp 2012-10-12 13:02:20 +0000
@@ -158,9 +158,13 @@
158158
159 std::sort (results.begin (), results.end (), &CompareWindowsByActive);159 std::sort (results.begin (), results.end (), &CompareWindowsByActive);
160160
161 // swap so we focus the last focused window first
162 if (Selection() == _last_active_icon && results.size () > 1)161 if (Selection() == _last_active_icon && results.size () > 1)
163 std::swap (results[0], results[1]);162 {
163 for (unsigned int i = 0; i < results.size()-1; i++)
164 {
165 std::swap (results[i], results[i+1]);
166 }
167 }
164168
165 return results;169 return results;
166}170}
167171
=== modified file 'tests/autopilot/unity/tests/test_switcher.py'
--- tests/autopilot/unity/tests/test_switcher.py 2012-09-17 10:37:02 +0000
+++ tests/autopilot/unity/tests/test_switcher.py 2012-10-12 13:02:20 +0000
@@ -350,6 +350,19 @@
350350
351 self.assertProperty(char_win1, is_focused=True)351 self.assertProperty(char_win1, is_focused=True)
352352
353 def test_detail_mode_selects_third_window(self):
354 """Pressing Alt+` twice must select the third last used window.
355 LP:1061229
356 """
357 char_win1, char_win2, char_win3 = self.start_applications("Character Map", "Character Map", "Character Map")
358 self.assertVisibleWindowStack([char_win3, char_win2, char_win1])
359
360 self.switcher.initiate(SwitcherMode.DETAIL)
361 self.switcher.next_detail()
362
363 self.switcher.select()
364 self.assertVisibleWindowStack([char_win1, char_win3, char_win2])
365
353366
354class SwitcherWorkspaceTests(SwitcherTestCase):367class SwitcherWorkspaceTests(SwitcherTestCase):
355 """Test Switcher behavior with respect to multiple workspaces."""368 """Test Switcher behavior with respect to multiple workspaces."""
356369
=== modified file 'tests/test_switcher_model.cpp'
--- tests/test_switcher_model.cpp 2012-03-14 06:24:18 +0000
+++ tests/test_switcher_model.cpp 2012-10-12 13:02:20 +0000
@@ -100,4 +100,37 @@
100 EXPECT_EQ(model->LastSelection(), third);100 EXPECT_EQ(model->LastSelection(), third);
101}101}
102102
103TEST(TestSwitcherModel, TestActiveDetailWindowSort)
104{
105 std::vector<AbstractLauncherIcon::Ptr> detail_icons;
106 AbstractLauncherIcon::Ptr detail(new MockLauncherIcon());
107 detail->SetQuirk(AbstractLauncherIcon::Quirk::ACTIVE, true);
108 detail_icons.push_back(detail);
109
110 // Set up a list with out an active icon, so we can assert
111 // the first detail icon == to the last xid of detailed list
112 std::vector<AbstractLauncherIcon::Ptr> icons;
113 AbstractLauncherIcon::Ptr normal(new MockLauncherIcon());
114 icons.push_back(normal);
115
116 SwitcherModel::Ptr model_detail_active(new SwitcherModel(detail_icons));
117 model_detail_active->detail_selection = true;
118
119 SwitcherModel::Ptr model_detail(new SwitcherModel(icons));
120 model_detail->detail_selection = true;
121
122 EXPECT_TRUE(model_detail_active->DetailXids().size() > 2);
123 EXPECT_TRUE(model_detail_active->DetailSelectionWindow() != model_detail->DetailSelectionWindow());
124
125 // Move to the last detailed window
126 for (unsigned int i = 0; i < model_detail_active->DetailXids().size() - 1; i++)
127 model_detail_active->NextDetail();
128
129 Window sorted, unsorted;
130 sorted = model_detail_active->DetailSelectionWindow();
131 unsorted = model_detail->DetailSelectionWindow();
132
133 EXPECT_EQ(sorted, unsorted);
134}
135
103}136}

Subscribers

People subscribed via source and target branches