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
This commit is contained in:
Martin Flöser 2017-07-20 06:58:35 +02:00
parent 64da6c8d1e
commit 7d3517060f
4 changed files with 28 additions and 57 deletions

View file

@ -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<void (Workspace::*)(Direction)>(&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<void (Workspace::*)(Direction)>(&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<void (Workspace::*)(Direction)>(&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<void (Workspace::*)(Direction)>(&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 %"),

View file

@ -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<direction>(options->isRollOverDesktops()); \

View file

@ -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()
*/

View file

@ -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