Port Workspace::switchWindow() to VirtualDesktop
If a window is on several virtual desktops, Workspace::switchWindow() will not work as expected because AbstractClient::desktop() returns the id of the last virtual desktop. Since the active window is most likely on the current virtual desktop, we can use that for filtering out irrelevant windows.
This commit is contained in:
parent
7937aa78ef
commit
b85edc08d2
2 changed files with 6 additions and 6 deletions
|
@ -1586,12 +1586,12 @@ void Workspace::switchWindow(Direction direction)
|
|||
if (!active_client)
|
||||
return;
|
||||
AbstractClient *c = active_client;
|
||||
int desktopNumber = c->isOnAllDesktops() ? VirtualDesktopManager::self()->current() : c->desktop();
|
||||
VirtualDesktop *desktop = VirtualDesktopManager::self()->currentDesktop();
|
||||
|
||||
// Centre of the active window
|
||||
QPoint curPos(c->x() + c->width() / 2, c->y() + c->height() / 2);
|
||||
|
||||
if (!switchWindow(c, direction, curPos, desktopNumber)) {
|
||||
if (!switchWindow(c, direction, curPos, desktop)) {
|
||||
auto opposite = [&] {
|
||||
switch(direction) {
|
||||
case DirectionNorth:
|
||||
|
@ -1607,11 +1607,11 @@ void Workspace::switchWindow(Direction direction)
|
|||
}
|
||||
};
|
||||
|
||||
switchWindow(c, direction, opposite(), desktopNumber);
|
||||
switchWindow(c, direction, opposite(), desktop);
|
||||
}
|
||||
}
|
||||
|
||||
bool Workspace::switchWindow(AbstractClient *c, Direction direction, QPoint curPos, int d)
|
||||
bool Workspace::switchWindow(AbstractClient *c, Direction direction, QPoint curPos, VirtualDesktop *desktop)
|
||||
{
|
||||
AbstractClient *switchTo = nullptr;
|
||||
int bestScore = 0;
|
||||
|
@ -1623,7 +1623,7 @@ bool Workspace::switchWindow(AbstractClient *c, Direction direction, QPoint curP
|
|||
continue;
|
||||
}
|
||||
if (client->wantsTabFocus() && *i != c &&
|
||||
client->isOnDesktop(d) && !client->isMinimized() && (*i)->isOnCurrentActivity()) {
|
||||
client->isOnDesktop(desktop) && !client->isMinimized() && (*i)->isOnCurrentActivity()) {
|
||||
// Centre of the other window
|
||||
const QPoint other(client->x() + client->width() / 2, client->y() + client->height() / 2);
|
||||
|
||||
|
|
|
@ -531,7 +531,7 @@ private:
|
|||
template <typename T, typename Slot>
|
||||
void initShortcut(const QString &actionName, const QString &description, const QKeySequence &shortcut, T *receiver, Slot slot, const QVariant &data = QVariant());
|
||||
void setupWindowShortcut(AbstractClient* c);
|
||||
bool switchWindow(AbstractClient *c, Direction direction, QPoint curPos, int desktop);
|
||||
bool switchWindow(AbstractClient *c, Direction direction, QPoint curPos, VirtualDesktop *desktop);
|
||||
|
||||
void propagateClients(bool propagate_new_clients); // Called only from updateStackingOrder
|
||||
QList<Toplevel *> constrainedStackingOrder();
|
||||
|
|
Loading…
Reference in a new issue