Cycle between windows of the same desktop on switch
Summary: When switching virtual desktops using shortcuts, the behavior is to switch to a virtual desktop in the opposite direction if the current one is on the edges of the layout. For example, in a one row layout with 4 virtual desktops, "Switch One Desktop to the Left" while in virtual desktop # 1 will send the user to virtual desktop # 4. Likewise, in a 3 rows layout with 9 virtual desktops, "Switch One Desktop Down" while in virtual desktop # 8 will lead the user to desktop # 2. This patch uses the same behavior whilst changing windows using "Switch to Window Above|Below|to the Right|to the Left". For example, in a 3 display set-up (my set-up), the user would go from an application in the rightmost position to an application in the leftmost position using just one key combination: "Switch to Window to the Right". Currently, the shortcuts are no-op in these cases (ie, trying "Switch to Window to the Left" from the leftmost window has no outcome, which is mostly accurate with the shortcut semantics but totally useless in behavior). Reviewers: #vdg, #kwin, graesslin Reviewed By: #kwin, graesslin Subscribers: luebking, subdiff, colomar, graesslin, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D3602
This commit is contained in:
parent
2c3bbb9783
commit
8e32dd4fdc
2 changed files with 30 additions and 3 deletions
|
@ -1568,13 +1568,37 @@ void Workspace::switchWindow(Direction direction)
|
||||||
if (!active_client)
|
if (!active_client)
|
||||||
return;
|
return;
|
||||||
AbstractClient *c = active_client;
|
AbstractClient *c = active_client;
|
||||||
Client *switchTo = 0;
|
int desktopNumber = c->isOnAllDesktops() ? VirtualDesktopManager::self()->current() : c->desktop();
|
||||||
int bestScore = 0;
|
|
||||||
int d = c->isOnAllDesktops() ? VirtualDesktopManager::self()->current() : c->desktop();
|
|
||||||
// Centre of the active window
|
// Centre of the active window
|
||||||
QPoint curPos(c->pos().x() + c->geometry().width() / 2,
|
QPoint curPos(c->pos().x() + c->geometry().width() / 2,
|
||||||
c->pos().y() + c->geometry().height() / 2);
|
c->pos().y() + c->geometry().height() / 2);
|
||||||
|
|
||||||
|
if (!switchWindow(c, direction, curPos, desktopNumber)) {
|
||||||
|
auto opposite = [&] {
|
||||||
|
switch(direction) {
|
||||||
|
case DirectionNorth:
|
||||||
|
return QPoint(curPos.x(), screens()->geometry().height());
|
||||||
|
case DirectionSouth:
|
||||||
|
return QPoint(curPos.x(), 0);
|
||||||
|
case DirectionEast:
|
||||||
|
return QPoint(0, curPos.y());
|
||||||
|
case DirectionWest:
|
||||||
|
return QPoint(screens()->geometry().width(), curPos.y());
|
||||||
|
default:
|
||||||
|
Q_UNREACHABLE();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
switchWindow(c, direction, opposite(), desktopNumber);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Workspace::switchWindow(AbstractClient *c, Direction direction, QPoint curPos, int d)
|
||||||
|
{
|
||||||
|
Client *switchTo = nullptr;
|
||||||
|
int bestScore = 0;
|
||||||
|
|
||||||
ToplevelList clist = stackingOrder();
|
ToplevelList clist = stackingOrder();
|
||||||
for (ToplevelList::Iterator i = clist.begin(); i != clist.end(); ++i) {
|
for (ToplevelList::Iterator i = clist.begin(); i != clist.end(); ++i) {
|
||||||
Client *client = qobject_cast<Client*>(*i);
|
Client *client = qobject_cast<Client*>(*i);
|
||||||
|
@ -1626,6 +1650,8 @@ void Workspace::switchWindow(Direction direction)
|
||||||
switchTo = switchTo->tabGroup()->current();
|
switchTo = switchTo->tabGroup()->current();
|
||||||
activateClient(switchTo);
|
activateClient(switchTo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return switchTo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|
|
@ -503,6 +503,7 @@ private:
|
||||||
DirectionWest
|
DirectionWest
|
||||||
};
|
};
|
||||||
void switchWindow(Direction direction);
|
void switchWindow(Direction direction);
|
||||||
|
bool switchWindow(AbstractClient *c, Direction direction, QPoint curPos, int desktop);
|
||||||
|
|
||||||
void propagateClients(bool propagate_new_clients); // Called only from updateStackingOrder
|
void propagateClients(bool propagate_new_clients); // Called only from updateStackingOrder
|
||||||
ToplevelList constrainedStackingOrder();
|
ToplevelList constrainedStackingOrder();
|
||||||
|
|
Loading…
Reference in a new issue