From 7d3517060f89040e36a6eeea1c8c64fae1c48541 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Fl=C3=B6ser?= Date: Thu, 20 Jul 2017 06:58:35 +0200 Subject: [PATCH] Drop the Workspace::slotSwitchWindowFoo methods Summary: They were only delegating into switchWindow(Direction), so let's do the same through std::bind in kwinbindings and delegate to it directly in scripting's WorkspaceWrapper. Test Plan: Not yet, want to add test case for Workspace::switchWindow Reviewers: #kwin, #plasma Subscribers: plasma-devel Tags: #plasma Differential Revision: https://phabricator.kde.org/D6791 --- kwinbindings.cpp | 16 ++++++++-------- scripting/workspace_wrapper.cpp | 17 ++++++++++++----- useractions.cpp | 32 -------------------------------- workspace.h | 20 ++++++++------------ 4 files changed, 28 insertions(+), 57 deletions(-) diff --git a/kwinbindings.cpp b/kwinbindings.cpp index 7924414e8c..4448f7680f 100644 --- a/kwinbindings.cpp +++ b/kwinbindings.cpp @@ -112,14 +112,14 @@ DEF4("Window Quick Tile Top Right", I18N_NOOP("Quick Tile Window to the Top Righ 0, std::bind(&Workspace::quickTileWindow, this, QuickTileFlag::Top | QuickTileFlag::Right)); DEF4("Window Quick Tile Bottom Right", I18N_NOOP("Quick Tile Window to the Bottom Right"), 0, std::bind(&Workspace::quickTileWindow, this, QuickTileFlag::Bottom | QuickTileFlag::Right)); -DEF2("Switch Window Up", I18N_NOOP("Switch to Window Above"), - Qt::META + Qt::ALT + Qt::Key_Up, slotSwitchWindowUp); -DEF2("Switch Window Down", I18N_NOOP("Switch to Window Below"), - Qt::META + Qt::ALT + Qt::Key_Down, slotSwitchWindowDown); -DEF2("Switch Window Right", I18N_NOOP("Switch to Window to the Right"), - Qt::META + Qt::ALT + Qt::Key_Right, slotSwitchWindowRight); -DEF2("Switch Window Left", I18N_NOOP("Switch to Window to the Left"), - Qt::META + Qt::ALT + Qt::Key_Left, slotSwitchWindowLeft); +DEF4("Switch Window Up", I18N_NOOP("Switch to Window Above"), + Qt::META + Qt::ALT + Qt::Key_Up, std::bind(static_cast(&Workspace::switchWindow), this, DirectionNorth)); +DEF4("Switch Window Down", I18N_NOOP("Switch to Window Below"), + Qt::META + Qt::ALT + Qt::Key_Down, std::bind(static_cast(&Workspace::switchWindow), this, DirectionSouth)); +DEF4("Switch Window Right", I18N_NOOP("Switch to Window to the Right"), + Qt::META + Qt::ALT + Qt::Key_Right, std::bind(static_cast(&Workspace::switchWindow), this, DirectionEast)); +DEF4("Switch Window Left", I18N_NOOP("Switch to Window to the Left"), + Qt::META + Qt::ALT + Qt::Key_Left, std::bind(static_cast(&Workspace::switchWindow), this, DirectionWest)); DEF2("Increase Opacity", I18N_NOOP("Increase Opacity of Active Window by 5 %"), 0, slotIncreaseWindowOpacity); DEF2("Decrease Opacity", I18N_NOOP("Decrease Opacity of Active Window by 5 %"), diff --git a/scripting/workspace_wrapper.cpp b/scripting/workspace_wrapper.cpp index ac29a7116a..ad7d1dfbe0 100644 --- a/scripting/workspace_wrapper.cpp +++ b/scripting/workspace_wrapper.cpp @@ -150,11 +150,6 @@ SLOTWRAPPER(slotWindowGrowVertical) SLOTWRAPPER(slotWindowShrinkHorizontal) SLOTWRAPPER(slotWindowShrinkVertical) -SLOTWRAPPER(slotSwitchWindowUp) -SLOTWRAPPER(slotSwitchWindowDown) -SLOTWRAPPER(slotSwitchWindowRight) -SLOTWRAPPER(slotSwitchWindowLeft) - SLOTWRAPPER(slotIncreaseWindowOpacity) SLOTWRAPPER(slotLowerWindowOpacity) @@ -193,6 +188,18 @@ SLOTWRAPPER(slotWindowQuickTileBottomRight, QuickTileFlag::Bottom | QuickTileFla #undef SLOTWRAPPER +#define SLOTWRAPPER(name,direction) \ +void WorkspaceWrapper::name() { \ + Workspace::self()->switchWindow(Workspace::direction); \ +} + +SLOTWRAPPER(slotSwitchWindowUp, DirectionNorth) +SLOTWRAPPER(slotSwitchWindowDown, DirectionSouth) +SLOTWRAPPER(slotSwitchWindowRight, DirectionEast) +SLOTWRAPPER(slotSwitchWindowLeft, DirectionWest) + +#undef SLOTWRAPPER + #define SLOTWRAPPER(name,direction) \ void WorkspaceWrapper::name( ) { \ VirtualDesktopManager::self()->moveTo(options->isRollOverDesktops()); \ diff --git a/useractions.cpp b/useractions.cpp index c6c8643d90..850d826237 100644 --- a/useractions.cpp +++ b/useractions.cpp @@ -1657,38 +1657,6 @@ bool Workspace::switchWindow(AbstractClient *c, Direction direction, QPoint curP return switchTo; } -/*! - Switches to upper window - */ -void Workspace::slotSwitchWindowUp() -{ - switchWindow(DirectionNorth); -} - -/*! - Switches to lower window - */ -void Workspace::slotSwitchWindowDown() -{ - switchWindow(DirectionSouth); -} - -/*! - Switches to window on the right - */ -void Workspace::slotSwitchWindowRight() -{ - switchWindow(DirectionEast); -} - -/*! - Switches to window on the left - */ -void Workspace::slotSwitchWindowLeft() -{ - switchWindow(DirectionWest); -} - /*! Shows the window operations popup menu for the activeClient() */ diff --git a/workspace.h b/workspace.h index 4314ad8278..0b3ac42d89 100644 --- a/workspace.h +++ b/workspace.h @@ -371,6 +371,14 @@ public: void quickTileWindow(QuickTileMode mode); + enum Direction { + DirectionNorth, + DirectionEast, + DirectionSouth, + DirectionWest + }; + void switchWindow(Direction direction); + public Q_SLOTS: void performWindowOperation(KWin::AbstractClient* c, Options::WindowOperation op); // Keybindings @@ -404,11 +412,6 @@ public Q_SLOTS: void slotWindowShrinkHorizontal(); void slotWindowShrinkVertical(); - void slotSwitchWindowUp(); - void slotSwitchWindowDown(); - void slotSwitchWindowRight(); - void slotSwitchWindowLeft(); - void slotIncreaseWindowOpacity(); void slotLowerWindowOpacity(); @@ -496,13 +499,6 @@ private: void initShortcut(const QString &actionName, const QString &description, const QKeySequence &shortcut, Slot slot, const QVariant &data = QVariant()); void setupWindowShortcut(AbstractClient* c); - enum Direction { - DirectionNorth, - DirectionEast, - DirectionSouth, - DirectionWest - }; - void switchWindow(Direction direction); bool switchWindow(AbstractClient *c, Direction direction, QPoint curPos, int desktop); void propagateClients(bool propagate_new_clients); // Called only from updateStackingOrder