diff options
| -rw-r--r-- | launcher/AbstractLauncherIcon.cpp | 3 | ||||
| -rw-r--r-- | launcher/AbstractLauncherIcon.h | 1 | ||||
| -rw-r--r-- | launcher/ApplicationLauncherIcon.cpp | 14 | ||||
| -rw-r--r-- | launcher/Launcher.cpp | 6 | ||||
| -rw-r--r-- | launcher/Launcher.h | 2 | ||||
| -rw-r--r-- | launcher/LauncherOptions.cpp | 2 | ||||
| -rw-r--r-- | launcher/LauncherOptions.h | 1 | ||||
| -rw-r--r-- | plugins/unityshell/src/unityshell.cpp | 7 | ||||
| -rw-r--r-- | plugins/unityshell/unityshell.xml.in | 6 | ||||
| -rw-r--r-- | tests/test_application_launcher_icon.cpp | 8 |
10 files changed, 44 insertions, 6 deletions
diff --git a/launcher/AbstractLauncherIcon.cpp b/launcher/AbstractLauncherIcon.cpp index ae3ebd042..55c398c18 100644 --- a/launcher/AbstractLauncherIcon.cpp +++ b/launcher/AbstractLauncherIcon.cpp @@ -22,8 +22,9 @@ namespace unity { namespace launcher { nux::Property<unsigned> AbstractLauncherIcon::icon_size(48); + nux::Property<bool> AbstractLauncherIcon::scroll_inactive_icons(true); // needed for ungodly stupid reasons NUX_IMPLEMENT_OBJECT_TYPE(AbstractLauncherIcon); } -} \ No newline at end of file +} diff --git a/launcher/AbstractLauncherIcon.h b/launcher/AbstractLauncherIcon.h index e745c94b7..6cf92b458 100644 --- a/launcher/AbstractLauncherIcon.h +++ b/launcher/AbstractLauncherIcon.h @@ -134,6 +134,7 @@ public: virtual ~AbstractLauncherIcon() = default; static nux::Property<unsigned> icon_size; + static nux::Property<bool> scroll_inactive_icons; nux::Property<std::string> tooltip_text; nux::Property<bool> tooltip_enabled; nux::Property<Position> position; diff --git a/launcher/ApplicationLauncherIcon.cpp b/launcher/ApplicationLauncherIcon.cpp index 48ebdb218..2e835dd6c 100644 --- a/launcher/ApplicationLauncherIcon.cpp +++ b/launcher/ApplicationLauncherIcon.cpp @@ -1316,7 +1316,19 @@ void ApplicationLauncherIcon::PerformScroll(ScrollDirection direction, Time time auto const& windows = GetWindowsOnCurrentDesktopInStackingOrder(); - if (!IsActive() || windows.size() <= 1) + if (windows.empty()) + return; + + if (scroll_inactive_icons && !IsActive()) + { + windows.at(0)->Focus(); + return; + } + + if (!scroll_inactive_icons && !IsActive()) + return; + + if (windows.size() <= 1) return; ++_progressive_scroll; diff --git a/launcher/Launcher.cpp b/launcher/Launcher.cpp index f61b7354e..1eafa63a0 100644 --- a/launcher/Launcher.cpp +++ b/launcher/Launcher.cpp @@ -1210,6 +1210,7 @@ void Launcher::UpdateOptions(Options::Ptr options) { SetIconSize(options->tile_size, options->icon_size); SetHideMode(options->hide_mode); + SetScrollInactiveIcons(options->scroll_inactive_icons); if (model_) { @@ -1486,6 +1487,11 @@ bool Launcher::OnUrgentTimeout() return false; } +void Launcher::SetScrollInactiveIcons(bool scroll) +{ + AbstractLauncherIcon::scroll_inactive_icons = scroll; +} + void Launcher::SetIconSize(int tile_size, int icon_size) { ui::IconRenderer::DestroyShortcutTextures(); diff --git a/launcher/Launcher.h b/launcher/Launcher.h index 2e998b648..fd3be6c41 100644 --- a/launcher/Launcher.h +++ b/launcher/Launcher.h @@ -79,6 +79,8 @@ public: AbstractLauncherIcon::Ptr GetSelectedMenuIcon() const; + void SetScrollInactiveIcons(bool scroll); + void SetIconSize(int tile_size, int icon_size); int GetIconSize() const; diff --git a/launcher/LauncherOptions.cpp b/launcher/LauncherOptions.cpp index b6e213e12..20ef3b303 100644 --- a/launcher/LauncherOptions.cpp +++ b/launcher/LauncherOptions.cpp @@ -46,6 +46,7 @@ Options::Options() , edge_passed_disabled_ms(1000) , edge_resist(true) , show_for_all(false) + , scroll_inactive_icons(false) { auto changed_lambda = [this] { changed_idle_.reset(new glib::Idle(glib::Source::Priority::HIGH)); @@ -70,6 +71,7 @@ Options::Options() super_tap_duration.changed.connect(sigc::hide(changed_lambda)); urgent_animation.changed.connect(sigc::hide(changed_lambda)); edge_resist.changed.connect(sigc::hide(changed_lambda)); + scroll_inactive_icons.changed.connect(sigc::hide(changed_lambda)); } } diff --git a/launcher/LauncherOptions.h b/launcher/LauncherOptions.h index c6f460c3a..7339f7188 100644 --- a/launcher/LauncherOptions.h +++ b/launcher/LauncherOptions.h @@ -102,6 +102,7 @@ public: nux::Property<unsigned> edge_passed_disabled_ms; nux::Property<bool> edge_resist; nux::Property<bool> show_for_all; + nux::Property<bool> scroll_inactive_icons; sigc::signal<void> option_changed; diff --git a/plugins/unityshell/src/unityshell.cpp b/plugins/unityshell/src/unityshell.cpp index f6cbdefaf..4ec6286ec 100644 --- a/plugins/unityshell/src/unityshell.cpp +++ b/plugins/unityshell/src/unityshell.cpp @@ -374,6 +374,8 @@ UnityScreen::UnityScreen(CompScreen* screen) optionSetNumLaunchersNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2)); optionSetLauncherCaptureMouseNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2)); + optionSetScrollInactiveIconsNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2)); + ubus_manager_.RegisterInterest(UBUS_LAUNCHER_START_KEY_NAV, sigc::mem_fun(this, &UnityScreen::OnLauncherStartKeyNav)); @@ -3367,6 +3369,9 @@ void UnityScreen::optionChanged(CompOption* opt, UnityshellOptions::Options num) case UnityshellOptions::LauncherCaptureMouse: launcher_options->edge_resist = optionGetLauncherCaptureMouse(); break; + case UnityshellOptions::ScrollInactiveIcons: + launcher_options->scroll_inactive_icons = optionGetScrollInactiveIcons(); + break; case UnityshellOptions::BackgroundColor: { auto override_color = NuxColorFromCompizColor(optionGetBackgroundColor()); @@ -3703,6 +3708,8 @@ void UnityScreen::initLauncher() on_launcher_size_changed(launcher.GetPointer(), launcher->GetWidth(), launcher->GetHeight()); }); + launcher_controller_->options()->scroll_inactive_icons = optionGetScrollInactiveIcons(); + ScheduleRelayout(0); } diff --git a/plugins/unityshell/unityshell.xml.in b/plugins/unityshell/unityshell.xml.in index fd7e4ec6f..cefb87537 100644 --- a/plugins/unityshell/unityshell.xml.in +++ b/plugins/unityshell/unityshell.xml.in @@ -356,6 +356,12 @@ <default>true</default> </option> + <option name="scroll_inactive_icons" type="bool"> + <_short>Scroll Inactive Icon to Focus Application</_short> + <_long>Allows using the mouse scrollwheel to focus an application if the icon is inactive.</_long> + <default>true</default> + </option> + <option name="edge_responsiveness" type="float"> <_short>Launcher Reveal Edge Responsiveness</_short> <_long>A conglomerate setting that modifies the overall responsiveness of the Launcher reveal.</_long> diff --git a/tests/test_application_launcher_icon.cpp b/tests/test_application_launcher_icon.cpp index 407a9d1f7..1c7735783 100644 --- a/tests/test_application_launcher_icon.cpp +++ b/tests/test_application_launcher_icon.cpp @@ -718,8 +718,8 @@ TEST_F(TestApplicationLauncherIcon, PerformScrollInitiallyUnfocusedWindow) ASSERT_EQ(WM->GetActiveWindow(), 8); mock_icon->PerformScroll(AbstractLauncherIcon::ScrollDirection::DOWN, 200); - EXPECT_THAT(WM->GetWindowsInStackingOrder(), testing::ElementsAre(7, 6, 5, 4, 3, 2, 1, 8)); - ASSERT_EQ(WM->GetActiveWindow(), 8); + EXPECT_THAT(WM->GetWindowsInStackingOrder(), testing::ElementsAre(7, 6, 5, 4, 3, 2, 8, 1)); + ASSERT_EQ(WM->GetActiveWindow(), 1); } TEST_F(TestApplicationLauncherIcon, PerformScrollSingleUnfocusedWindow) @@ -735,8 +735,8 @@ TEST_F(TestApplicationLauncherIcon, PerformScrollSingleUnfocusedWindow) mock_icon->PerformScroll(AbstractLauncherIcon::ScrollDirection::DOWN, 200); - EXPECT_THAT(WM->GetWindowsInStackingOrder(), testing::ElementsAre(1, 2)); - ASSERT_EQ(WM->GetActiveWindow(), 2); + EXPECT_THAT(WM->GetWindowsInStackingOrder(), testing::ElementsAre(2, 1)); + ASSERT_EQ(WM->GetActiveWindow(), 1); } TEST_F(TestApplicationLauncherIcon, ActiveQuirkWMCrossCheck) |
