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
=== modified file 'launcher/SwitcherController.cpp'
--- launcher/SwitcherController.cpp 2014-03-26 03:09:23 +0000
+++ launcher/SwitcherController.cpp 2015-04-03 15:46:57 +0000
@@ -73,14 +73,15 @@
73 : detail([this] { return impl_->model_ && impl_->model_->detail_selection(); },73 : detail([this] { return impl_->model_ && impl_->model_->detail_selection(); },
74 [this] (bool d) { if (impl_->model_) { impl_->model_->detail_selection = d; } return false; })74 [this] (bool d) { if (impl_->model_) { impl_->model_->detail_selection = d; } return false; })
75 , detail_mode([this] { return detail_mode_; })75 , detail_mode([this] { return detail_mode_; })
76 , first_selection_mode(FirstSelectionMode::LAST_ACTIVE_VIEW)
77 , show_desktop_disabled(false)
78 , mouse_disabled(false)
76 , timeout_length(0)79 , timeout_length(0)
77 , detail_on_timeout(true)80 , detail_on_timeout(true)
78 , detail_timeout_length(500)81 , detail_timeout_length(500)
79 , initial_detail_timeout_length(1500)82 , initial_detail_timeout_length(1500)
80 , visible_(false)83 , visible_(false)
81 , monitor_(0)84 , monitor_(0)
82 , show_desktop_disabled_(false)
83 , mouse_disabled_(false)
84 , detail_mode_(DetailMode::TAB_NEXT_WINDOW)85 , detail_mode_(DetailMode::TAB_NEXT_WINDOW)
85 , impl_(new Controller::Impl(this, 20, create_window))86 , impl_(new Controller::Impl(this, 20, create_window))
86{}87{}
@@ -91,7 +92,7 @@
9192
92bool Controller::CanShowSwitcher(const std::vector<AbstractLauncherIcon::Ptr>& results) const93bool Controller::CanShowSwitcher(const std::vector<AbstractLauncherIcon::Ptr>& results) const
93{94{
94 bool empty = (IsShowDesktopDisabled() ? results.empty() : results.size() == 1);95 bool empty = (show_desktop_disabled() ? results.empty() : results.size() == 1);
95 return (!empty && !WindowManager::Default().IsWallActive());96 return (!empty && !WindowManager::Default().IsWallActive());
96}97}
9798
@@ -202,29 +203,9 @@
202 return impl_->ExternalRenderTargets();203 return impl_->ExternalRenderTargets();
203}204}
204205
205bool Controller::IsShowDesktopDisabled() const
206{
207 return show_desktop_disabled_;
208}
209
210void Controller::SetShowDesktopDisabled(bool disabled)
211{
212 show_desktop_disabled_ = disabled;
213}
214
215bool Controller::IsMouseDisabled() const
216{
217 return mouse_disabled_;
218}
219
220void Controller::SetMouseDisabled(bool disabled)
221{
222 mouse_disabled_ = disabled;
223}
224
225int Controller::StartIndex() const206int Controller::StartIndex() const
226{207{
227 return (IsShowDesktopDisabled() ? 0 : 1);208 return (show_desktop_disabled() ? 0 : 1);
228}209}
229210
230Selection Controller::GetCurrentSelection() const211Selection Controller::GetCurrentSelection() const
@@ -265,8 +246,10 @@
265 .add("detail_timeout_length", detail_timeout_length())246 .add("detail_timeout_length", detail_timeout_length())
266 .add("visible", visible_)247 .add("visible", visible_)
267 .add("monitor", monitor_)248 .add("monitor", monitor_)
268 .add("show_desktop_disabled", show_desktop_disabled_)249 .add("show_desktop_disabled", show_desktop_disabled())
269 .add("detail_mode", static_cast<int>(detail_mode_));250 .add("mouse_disabled", mouse_disabled())
251 .add("detail_mode", static_cast<unsigned>(detail_mode_))
252 .add("first_selection_mode", static_cast<unsigned>(first_selection_mode()));
270}253}
271254
272255
@@ -717,6 +700,12 @@
717 return;700 return;
718 }701 }
719702
703 if (obj_->first_selection_mode == FirstSelectionMode::LAST_ACTIVE_APP)
704 {
705 model_->Select(second);
706 return;
707 }
708
720 uint64_t first_highest = 0;709 uint64_t first_highest = 0;
721 uint64_t first_second = 0; // first icons second highest active710 uint64_t first_second = 0; // first icons second highest active
722 uint64_t second_first = 0; // second icons first highest active711 uint64_t second_first = 0; // second icons first highest active
723712
=== modified file 'launcher/SwitcherController.h'
--- launcher/SwitcherController.h 2014-03-04 00:42:49 +0000
+++ launcher/SwitcherController.h 2015-04-03 15:46:57 +0000
@@ -56,6 +56,11 @@
56 TAB_NEXT_TILE,56 TAB_NEXT_TILE,
57};57};
5858
59enum class FirstSelectionMode
60{
61 LAST_ACTIVE_VIEW,
62 LAST_ACTIVE_APP
63};
5964
60/**65/**
61 * Represents a selected application+window to be switched to.66 * Represents a selected application+window to be switched to.
@@ -109,12 +114,6 @@
109114
110 ui::LayoutWindow::Vector const& ExternalRenderTargets() const;115 ui::LayoutWindow::Vector const& ExternalRenderTargets() const;
111116
112 bool IsShowDesktopDisabled() const;
113 void SetShowDesktopDisabled(bool disabled);
114
115 bool IsMouseDisabled() const;
116 void SetMouseDisabled(bool disabled);
117
118 int StartIndex() const;117 int StartIndex() const;
119 double Opacity() const;118 double Opacity() const;
120119
@@ -128,6 +127,9 @@
128127
129 nux::RWProperty<bool> detail;128 nux::RWProperty<bool> detail;
130 nux::ROProperty<DetailMode> detail_mode;129 nux::ROProperty<DetailMode> detail_mode;
130 nux::Property<FirstSelectionMode> first_selection_mode;
131 nux::Property<bool> show_desktop_disabled;
132 nux::Property<bool> mouse_disabled;
131 nux::Property<int> timeout_length;133 nux::Property<int> timeout_length;
132 nux::Property<bool> detail_on_timeout;134 nux::Property<bool> detail_on_timeout;
133 nux::Property<int> detail_timeout_length;135 nux::Property<int> detail_timeout_length;
@@ -136,8 +138,6 @@
136private:138private:
137 bool visible_;139 bool visible_;
138 int monitor_;140 int monitor_;
139 bool show_desktop_disabled_;
140 bool mouse_disabled_;
141 DetailMode detail_mode_;141 DetailMode detail_mode_;
142142
143 ImplPtr impl_;143 ImplPtr impl_;
144144
=== modified file 'plugins/unityshell/src/unityshell.cpp'
--- plugins/unityshell/src/unityshell.cpp 2015-03-05 16:35:54 +0000
+++ plugins/unityshell/src/unityshell.cpp 2015-04-03 15:46:57 +0000
@@ -350,6 +350,7 @@
350 optionSetDashTapDurationNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));350 optionSetDashTapDurationNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));
351 optionSetAltTabTimeoutNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));351 optionSetAltTabTimeoutNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));
352 optionSetAltTabBiasViewportNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));352 optionSetAltTabBiasViewportNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));
353 optionSetSwitchStrictlyBetweenApplicationsNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));
353 optionSetDisableShowDesktopNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));354 optionSetDisableShowDesktopNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));
354 optionSetDisableMouseNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));355 optionSetDisableMouseNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));
355356
@@ -359,10 +360,8 @@
359 optionSetAltTabForwardAllTerminate(boost::bind(&UnityScreen::altTabTerminateCommon, this, _1, _2, _3));360 optionSetAltTabForwardAllTerminate(boost::bind(&UnityScreen::altTabTerminateCommon, this, _1, _2, _3));
360 optionSetAltTabPrevAllInitiate(boost::bind(&UnityScreen::altTabPrevAllInitiate, this, _1, _2, _3));361 optionSetAltTabPrevAllInitiate(boost::bind(&UnityScreen::altTabPrevAllInitiate, this, _1, _2, _3));
361 optionSetAltTabPrevInitiate(boost::bind(&UnityScreen::altTabPrevInitiate, this, _1, _2, _3));362 optionSetAltTabPrevInitiate(boost::bind(&UnityScreen::altTabPrevInitiate, this, _1, _2, _3));
362
363 optionSetAltTabNextWindowInitiate(boost::bind(&UnityScreen::altTabNextWindowInitiate, this, _1, _2, _3));363 optionSetAltTabNextWindowInitiate(boost::bind(&UnityScreen::altTabNextWindowInitiate, this, _1, _2, _3));
364 optionSetAltTabNextWindowTerminate(boost::bind(&UnityScreen::altTabTerminateCommon, this, _1, _2, _3));364 optionSetAltTabNextWindowTerminate(boost::bind(&UnityScreen::altTabTerminateCommon, this, _1, _2, _3));
365
366 optionSetAltTabPrevWindowInitiate(boost::bind(&UnityScreen::altTabPrevWindowInitiate, this, _1, _2, _3));365 optionSetAltTabPrevWindowInitiate(boost::bind(&UnityScreen::altTabPrevWindowInitiate, this, _1, _2, _3));
367366
368 optionSetLauncherSwitcherForwardInitiate(boost::bind(&UnityScreen::launcherSwitcherForwardInitiate, this, _1, _2, _3));367 optionSetLauncherSwitcherForwardInitiate(boost::bind(&UnityScreen::launcherSwitcherForwardInitiate, this, _1, _2, _3));
@@ -1985,7 +1984,7 @@
1985 if (event->type == MapRequest)1984 if (event->type == MapRequest)
1986 ShowdesktopHandler::AllowLeaveShowdesktopMode(event->xmaprequest.window);1985 ShowdesktopHandler::AllowLeaveShowdesktopMode(event->xmaprequest.window);
19871986
1988 if (switcher_controller_->IsMouseDisabled() && switcher_controller_->Visible() &&1987 if (switcher_controller_->Visible() && switcher_controller_->mouse_disabled() &&
1989 (event->type == MotionNotify || event->type == ButtonPress || event->type == ButtonRelease))1988 (event->type == MotionNotify || event->type == ButtonPress || event->type == ButtonRelease))
1990 {1989 {
1991 skip_other_plugins = true;1990 skip_other_plugins = true;
@@ -2231,14 +2230,8 @@
2231{2230{
2232 if (!grab_index_)2231 if (!grab_index_)
2233 {2232 {
2234 if (switcher_controller_->IsMouseDisabled())2233 auto cursor = switcher_controller_->mouse_disabled() ? screen->invisibleCursor() : screen->normalCursor();
2235 {2234 grab_index_ = screen->pushGrab(cursor, "unity-switcher");
2236 grab_index_ = screen->pushGrab (screen->invisibleCursor(), "unity-switcher");
2237 }
2238 else
2239 {
2240 grab_index_ = screen->pushGrab (screen->normalCursor(), "unity-switcher");
2241 }
2242 }2235 }
22432236
2244 launcher_controller_->ClearTooltips();2237 launcher_controller_->ClearTooltips();
@@ -2270,7 +2263,7 @@
2270 }2263 }
22712264
2272 auto results = launcher_controller_->GetAltTabIcons(show_mode == switcher::ShowMode::CURRENT_VIEWPORT,2265 auto results = launcher_controller_->GetAltTabIcons(show_mode == switcher::ShowMode::CURRENT_VIEWPORT,
2273 switcher_controller_->IsShowDesktopDisabled());2266 switcher_controller_->show_desktop_disabled());
22742267
2275 if (switcher_controller_->CanShowSwitcher(results))2268 if (switcher_controller_->CanShowSwitcher(results))
2276 switcher_controller_->Show(show_mode, switcher::SortMode::FOCUS_ORDER, results);2269 switcher_controller_->Show(show_mode, switcher::SortMode::FOCUS_ORDER, results);
@@ -3575,11 +3568,16 @@
3575 case UnityshellOptions::AltTabBiasViewport:3568 case UnityshellOptions::AltTabBiasViewport:
3576 PluginAdapter::Default().bias_active_to_viewport = optionGetAltTabBiasViewport();3569 PluginAdapter::Default().bias_active_to_viewport = optionGetAltTabBiasViewport();
3577 break;3570 break;
3571 case UnityshellOptions::SwitchStrictlyBetweenApplications:
3572 switcher_controller_->first_selection_mode = optionGetSwitchStrictlyBetweenApplications() ?
3573 switcher::FirstSelectionMode::LAST_ACTIVE_APP :
3574 switcher::FirstSelectionMode::LAST_ACTIVE_VIEW;
3575 break;
3578 case UnityshellOptions::DisableShowDesktop:3576 case UnityshellOptions::DisableShowDesktop:
3579 switcher_controller_->SetShowDesktopDisabled(optionGetDisableShowDesktop());3577 switcher_controller_->show_desktop_disabled = optionGetDisableShowDesktop();
3580 break;3578 break;
3581 case UnityshellOptions::DisableMouse:3579 case UnityshellOptions::DisableMouse:
3582 switcher_controller_->SetMouseDisabled(optionGetDisableMouse());3580 switcher_controller_->mouse_disabled = optionGetDisableMouse();
3583 break;3581 break;
3584 case UnityshellOptions::ShowMinimizedWindows:3582 case UnityshellOptions::ShowMinimizedWindows:
3585 compiz::CompizMinimizedWindowHandler<UnityScreen, UnityWindow>::setFunctions (optionGetShowMinimizedWindows ());3583 compiz::CompizMinimizedWindowHandler<UnityScreen, UnityWindow>::setFunctions (optionGetShowMinimizedWindows ());
35863584
=== modified file 'plugins/unityshell/unityshell.xml.in'
--- plugins/unityshell/unityshell.xml.in 2014-04-07 03:21:46 +0000
+++ plugins/unityshell/unityshell.xml.in 2015-04-03 15:46:57 +0000
@@ -565,6 +565,12 @@
565 <passive_grab>false</passive_grab>565 <passive_grab>false</passive_grab>
566 </option>566 </option>
567567
568 <option name="switch_strictly_between_applications" type="bool">
569 <_short>Switcher strictly changes between applications</_short>
570 <_long>Disables the last focused window being the first entry in the Switcher, so Switcher strictly switches between applications</_long>
571 <default>false</default>
572 </option>
573
568 <option name="show_minimized_windows" type="bool">574 <option name="show_minimized_windows" type="bool">
569 <_short>Show live previews of windows in the Switcher</_short>575 <_short>Show live previews of windows in the Switcher</_short>
570 <_long>Enables miniature live window previews in the Switcher.</_long>576 <_long>Enables miniature live window previews in the Switcher.</_long>
571577
=== modified file 'tests/MockSwitcherController.h'
--- tests/MockSwitcherController.h 2014-03-04 00:42:49 +0000
+++ tests/MockSwitcherController.h 2015-04-03 15:46:57 +0000
@@ -52,8 +52,6 @@
52 MOCK_METHOD0(SelectFirstItem, void());52 MOCK_METHOD0(SelectFirstItem, void());
53 MOCK_METHOD2(SetWorkspace, void(nux::Geometry, int));53 MOCK_METHOD2(SetWorkspace, void(nux::Geometry, int));
54 MOCK_CONST_METHOD0(ExternalRenderTargets, unity::ui::LayoutWindow::Vector const&());54 MOCK_CONST_METHOD0(ExternalRenderTargets, unity::ui::LayoutWindow::Vector const&());
55 MOCK_CONST_METHOD0(IsShowDesktopDisabled, bool());
56 MOCK_METHOD1(SetShowDesktopDisabled, void(bool));
57 MOCK_CONST_METHOD0(StartIndex, int());55 MOCK_CONST_METHOD0(StartIndex, int());
58};56};
59}57}
6058
=== modified file 'tests/test_switcher_controller.cpp'
--- tests/test_switcher_controller.cpp 2014-03-03 22:49:48 +0000
+++ tests/test_switcher_controller.cpp 2015-04-03 15:46:57 +0000
@@ -171,9 +171,7 @@
171{171{
172 EXPECT_CALL(*mock_window_, ShowWindow(true, _)).Times(AtLeast(1));172 EXPECT_CALL(*mock_window_, ShowWindow(true, _)).Times(AtLeast(1));
173173
174 controller_->SetShowDesktopDisabled(true);174 controller_->show_desktop_disabled = true;
175 ASSERT_TRUE(controller_->IsShowDesktopDisabled());
176
177 controller_->Show(ShowMode::ALL, SortMode::LAUNCHER_ORDER, icons_);175 controller_->Show(ShowMode::ALL, SortMode::LAUNCHER_ORDER, icons_);
178 Utils::WaitUntilMSec([this] { return controller_->Visible(); });176 Utils::WaitUntilMSec([this] { return controller_->Visible(); });
179 ASSERT_TRUE(controller_->StartIndex() == 0);177 ASSERT_TRUE(controller_->StartIndex() == 0);
@@ -187,7 +185,7 @@
187185
188TEST_F(TestSwitcherController, ShowSwitcherNoResults)186TEST_F(TestSwitcherController, ShowSwitcherNoResults)
189{187{
190 controller_->SetShowDesktopDisabled(true);188 controller_->show_desktop_disabled = true;
191 std::vector<unity::launcher::AbstractLauncherIcon::Ptr> results;189 std::vector<unity::launcher::AbstractLauncherIcon::Ptr> results;
192 EXPECT_CALL(*mock_window_, ShowWindow(true, _)).Times(0);190 EXPECT_CALL(*mock_window_, ShowWindow(true, _)).Times(0);
193191