Merge lp:~3v1n0/unity/switcher-first-selection-mode into lp:unity

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Christopher Townsend
Approved revision: no longer in the source branch.
Merged at revision: 3950
Proposed branch: lp:~3v1n0/unity/switcher-first-selection-mode
Merge into: lp:unity
Diff against target: 265 lines (+43/-54)
6 files modified
launcher/SwitcherController.cpp (+15/-26)
launcher/SwitcherController.h (+8/-8)
plugins/unityshell/src/unityshell.cpp (+12/-14)
plugins/unityshell/unityshell.xml.in (+6/-0)
tests/MockSwitcherController.h (+0/-2)
tests/test_switcher_controller.cpp (+2/-4)
To merge this branch: bzr merge lp:~3v1n0/unity/switcher-first-selection-mode
Reviewer Review Type Date Requested Status
Christopher Townsend Approve
PS Jenkins bot (community) continuous-integration Approve
Gerry Boland (community) Approve
Marco Trevisan (Treviño) Pending
Review via email: mp+255195@code.launchpad.net

This proposal supersedes a proposal from 2015-02-04.

Commit message

SwitcherController: add first selection mode property, to decide what to select at first

Add option to have Switcher strictly between applications, and not select the previously focused window as first selection (even if that window part of the same application)

Description of the change

Add option to have Switcher strictly between applications, and not select the previously focused window as first selection (even if that window part of the same application)

To post a comment you must log in.
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote : Posted in a previous version of this proposal

Ok, looks good.
Thanks ;)

review: Approve
Revision history for this message
Gerry Boland (gerboland) wrote : Posted in a previous version of this proposal

Hmm, it not working right. /me shouldn't code in bed.

Revision history for this message
Gerry Boland (gerboland) wrote :

Works well for me! Code looks fine to me, but I'm not an expert in this codebase

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Christopher Townsend (townsend) wrote :

Ok, code looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'launcher/SwitcherController.cpp'
2--- launcher/SwitcherController.cpp 2014-03-26 03:09:23 +0000
3+++ launcher/SwitcherController.cpp 2015-04-03 15:46:57 +0000
4@@ -73,14 +73,15 @@
5 : detail([this] { return impl_->model_ && impl_->model_->detail_selection(); },
6 [this] (bool d) { if (impl_->model_) { impl_->model_->detail_selection = d; } return false; })
7 , detail_mode([this] { return detail_mode_; })
8+ , first_selection_mode(FirstSelectionMode::LAST_ACTIVE_VIEW)
9+ , show_desktop_disabled(false)
10+ , mouse_disabled(false)
11 , timeout_length(0)
12 , detail_on_timeout(true)
13 , detail_timeout_length(500)
14 , initial_detail_timeout_length(1500)
15 , visible_(false)
16 , monitor_(0)
17- , show_desktop_disabled_(false)
18- , mouse_disabled_(false)
19 , detail_mode_(DetailMode::TAB_NEXT_WINDOW)
20 , impl_(new Controller::Impl(this, 20, create_window))
21 {}
22@@ -91,7 +92,7 @@
23
24 bool Controller::CanShowSwitcher(const std::vector<AbstractLauncherIcon::Ptr>& results) const
25 {
26- bool empty = (IsShowDesktopDisabled() ? results.empty() : results.size() == 1);
27+ bool empty = (show_desktop_disabled() ? results.empty() : results.size() == 1);
28 return (!empty && !WindowManager::Default().IsWallActive());
29 }
30
31@@ -202,29 +203,9 @@
32 return impl_->ExternalRenderTargets();
33 }
34
35-bool Controller::IsShowDesktopDisabled() const
36-{
37- return show_desktop_disabled_;
38-}
39-
40-void Controller::SetShowDesktopDisabled(bool disabled)
41-{
42- show_desktop_disabled_ = disabled;
43-}
44-
45-bool Controller::IsMouseDisabled() const
46-{
47- return mouse_disabled_;
48-}
49-
50-void Controller::SetMouseDisabled(bool disabled)
51-{
52- mouse_disabled_ = disabled;
53-}
54-
55 int Controller::StartIndex() const
56 {
57- return (IsShowDesktopDisabled() ? 0 : 1);
58+ return (show_desktop_disabled() ? 0 : 1);
59 }
60
61 Selection Controller::GetCurrentSelection() const
62@@ -265,8 +246,10 @@
63 .add("detail_timeout_length", detail_timeout_length())
64 .add("visible", visible_)
65 .add("monitor", monitor_)
66- .add("show_desktop_disabled", show_desktop_disabled_)
67- .add("detail_mode", static_cast<int>(detail_mode_));
68+ .add("show_desktop_disabled", show_desktop_disabled())
69+ .add("mouse_disabled", mouse_disabled())
70+ .add("detail_mode", static_cast<unsigned>(detail_mode_))
71+ .add("first_selection_mode", static_cast<unsigned>(first_selection_mode()));
72 }
73
74
75@@ -717,6 +700,12 @@
76 return;
77 }
78
79+ if (obj_->first_selection_mode == FirstSelectionMode::LAST_ACTIVE_APP)
80+ {
81+ model_->Select(second);
82+ return;
83+ }
84+
85 uint64_t first_highest = 0;
86 uint64_t first_second = 0; // first icons second highest active
87 uint64_t second_first = 0; // second icons first highest active
88
89=== modified file 'launcher/SwitcherController.h'
90--- launcher/SwitcherController.h 2014-03-04 00:42:49 +0000
91+++ launcher/SwitcherController.h 2015-04-03 15:46:57 +0000
92@@ -56,6 +56,11 @@
93 TAB_NEXT_TILE,
94 };
95
96+enum class FirstSelectionMode
97+{
98+ LAST_ACTIVE_VIEW,
99+ LAST_ACTIVE_APP
100+};
101
102 /**
103 * Represents a selected application+window to be switched to.
104@@ -109,12 +114,6 @@
105
106 ui::LayoutWindow::Vector const& ExternalRenderTargets() const;
107
108- bool IsShowDesktopDisabled() const;
109- void SetShowDesktopDisabled(bool disabled);
110-
111- bool IsMouseDisabled() const;
112- void SetMouseDisabled(bool disabled);
113-
114 int StartIndex() const;
115 double Opacity() const;
116
117@@ -128,6 +127,9 @@
118
119 nux::RWProperty<bool> detail;
120 nux::ROProperty<DetailMode> detail_mode;
121+ nux::Property<FirstSelectionMode> first_selection_mode;
122+ nux::Property<bool> show_desktop_disabled;
123+ nux::Property<bool> mouse_disabled;
124 nux::Property<int> timeout_length;
125 nux::Property<bool> detail_on_timeout;
126 nux::Property<int> detail_timeout_length;
127@@ -136,8 +138,6 @@
128 private:
129 bool visible_;
130 int monitor_;
131- bool show_desktop_disabled_;
132- bool mouse_disabled_;
133 DetailMode detail_mode_;
134
135 ImplPtr impl_;
136
137=== modified file 'plugins/unityshell/src/unityshell.cpp'
138--- plugins/unityshell/src/unityshell.cpp 2015-03-05 16:35:54 +0000
139+++ plugins/unityshell/src/unityshell.cpp 2015-04-03 15:46:57 +0000
140@@ -350,6 +350,7 @@
141 optionSetDashTapDurationNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));
142 optionSetAltTabTimeoutNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));
143 optionSetAltTabBiasViewportNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));
144+ optionSetSwitchStrictlyBetweenApplicationsNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));
145 optionSetDisableShowDesktopNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));
146 optionSetDisableMouseNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));
147
148@@ -359,10 +360,8 @@
149 optionSetAltTabForwardAllTerminate(boost::bind(&UnityScreen::altTabTerminateCommon, this, _1, _2, _3));
150 optionSetAltTabPrevAllInitiate(boost::bind(&UnityScreen::altTabPrevAllInitiate, this, _1, _2, _3));
151 optionSetAltTabPrevInitiate(boost::bind(&UnityScreen::altTabPrevInitiate, this, _1, _2, _3));
152-
153 optionSetAltTabNextWindowInitiate(boost::bind(&UnityScreen::altTabNextWindowInitiate, this, _1, _2, _3));
154 optionSetAltTabNextWindowTerminate(boost::bind(&UnityScreen::altTabTerminateCommon, this, _1, _2, _3));
155-
156 optionSetAltTabPrevWindowInitiate(boost::bind(&UnityScreen::altTabPrevWindowInitiate, this, _1, _2, _3));
157
158 optionSetLauncherSwitcherForwardInitiate(boost::bind(&UnityScreen::launcherSwitcherForwardInitiate, this, _1, _2, _3));
159@@ -1985,7 +1984,7 @@
160 if (event->type == MapRequest)
161 ShowdesktopHandler::AllowLeaveShowdesktopMode(event->xmaprequest.window);
162
163- if (switcher_controller_->IsMouseDisabled() && switcher_controller_->Visible() &&
164+ if (switcher_controller_->Visible() && switcher_controller_->mouse_disabled() &&
165 (event->type == MotionNotify || event->type == ButtonPress || event->type == ButtonRelease))
166 {
167 skip_other_plugins = true;
168@@ -2231,14 +2230,8 @@
169 {
170 if (!grab_index_)
171 {
172- if (switcher_controller_->IsMouseDisabled())
173- {
174- grab_index_ = screen->pushGrab (screen->invisibleCursor(), "unity-switcher");
175- }
176- else
177- {
178- grab_index_ = screen->pushGrab (screen->normalCursor(), "unity-switcher");
179- }
180+ auto cursor = switcher_controller_->mouse_disabled() ? screen->invisibleCursor() : screen->normalCursor();
181+ grab_index_ = screen->pushGrab(cursor, "unity-switcher");
182 }
183
184 launcher_controller_->ClearTooltips();
185@@ -2270,7 +2263,7 @@
186 }
187
188 auto results = launcher_controller_->GetAltTabIcons(show_mode == switcher::ShowMode::CURRENT_VIEWPORT,
189- switcher_controller_->IsShowDesktopDisabled());
190+ switcher_controller_->show_desktop_disabled());
191
192 if (switcher_controller_->CanShowSwitcher(results))
193 switcher_controller_->Show(show_mode, switcher::SortMode::FOCUS_ORDER, results);
194@@ -3575,11 +3568,16 @@
195 case UnityshellOptions::AltTabBiasViewport:
196 PluginAdapter::Default().bias_active_to_viewport = optionGetAltTabBiasViewport();
197 break;
198+ case UnityshellOptions::SwitchStrictlyBetweenApplications:
199+ switcher_controller_->first_selection_mode = optionGetSwitchStrictlyBetweenApplications() ?
200+ switcher::FirstSelectionMode::LAST_ACTIVE_APP :
201+ switcher::FirstSelectionMode::LAST_ACTIVE_VIEW;
202+ break;
203 case UnityshellOptions::DisableShowDesktop:
204- switcher_controller_->SetShowDesktopDisabled(optionGetDisableShowDesktop());
205+ switcher_controller_->show_desktop_disabled = optionGetDisableShowDesktop();
206 break;
207 case UnityshellOptions::DisableMouse:
208- switcher_controller_->SetMouseDisabled(optionGetDisableMouse());
209+ switcher_controller_->mouse_disabled = optionGetDisableMouse();
210 break;
211 case UnityshellOptions::ShowMinimizedWindows:
212 compiz::CompizMinimizedWindowHandler<UnityScreen, UnityWindow>::setFunctions (optionGetShowMinimizedWindows ());
213
214=== modified file 'plugins/unityshell/unityshell.xml.in'
215--- plugins/unityshell/unityshell.xml.in 2014-04-07 03:21:46 +0000
216+++ plugins/unityshell/unityshell.xml.in 2015-04-03 15:46:57 +0000
217@@ -565,6 +565,12 @@
218 <passive_grab>false</passive_grab>
219 </option>
220
221+ <option name="switch_strictly_between_applications" type="bool">
222+ <_short>Switcher strictly changes between applications</_short>
223+ <_long>Disables the last focused window being the first entry in the Switcher, so Switcher strictly switches between applications</_long>
224+ <default>false</default>
225+ </option>
226+
227 <option name="show_minimized_windows" type="bool">
228 <_short>Show live previews of windows in the Switcher</_short>
229 <_long>Enables miniature live window previews in the Switcher.</_long>
230
231=== modified file 'tests/MockSwitcherController.h'
232--- tests/MockSwitcherController.h 2014-03-04 00:42:49 +0000
233+++ tests/MockSwitcherController.h 2015-04-03 15:46:57 +0000
234@@ -52,8 +52,6 @@
235 MOCK_METHOD0(SelectFirstItem, void());
236 MOCK_METHOD2(SetWorkspace, void(nux::Geometry, int));
237 MOCK_CONST_METHOD0(ExternalRenderTargets, unity::ui::LayoutWindow::Vector const&());
238- MOCK_CONST_METHOD0(IsShowDesktopDisabled, bool());
239- MOCK_METHOD1(SetShowDesktopDisabled, void(bool));
240 MOCK_CONST_METHOD0(StartIndex, int());
241 };
242 }
243
244=== modified file 'tests/test_switcher_controller.cpp'
245--- tests/test_switcher_controller.cpp 2014-03-03 22:49:48 +0000
246+++ tests/test_switcher_controller.cpp 2015-04-03 15:46:57 +0000
247@@ -171,9 +171,7 @@
248 {
249 EXPECT_CALL(*mock_window_, ShowWindow(true, _)).Times(AtLeast(1));
250
251- controller_->SetShowDesktopDisabled(true);
252- ASSERT_TRUE(controller_->IsShowDesktopDisabled());
253-
254+ controller_->show_desktop_disabled = true;
255 controller_->Show(ShowMode::ALL, SortMode::LAUNCHER_ORDER, icons_);
256 Utils::WaitUntilMSec([this] { return controller_->Visible(); });
257 ASSERT_TRUE(controller_->StartIndex() == 0);
258@@ -187,7 +185,7 @@
259
260 TEST_F(TestSwitcherController, ShowSwitcherNoResults)
261 {
262- controller_->SetShowDesktopDisabled(true);
263+ controller_->show_desktop_disabled = true;
264 std::vector<unity::launcher::AbstractLauncherIcon::Ptr> results;
265 EXPECT_CALL(*mock_window_, ShowWindow(true, _)).Times(0);
266