Remove desktop argument in AbstractClient::electricBorderMaximizeGeometry()

With the new virtual desktop model, we have an issue where the old
code that uses desktop() needs to be ported to desktops().

However, using no desktop() is better as we don't need to deal with
cases where a window can be on several desktops, which can be annoying
sometimes.

This change removes the desktop arg in electricBorderMaximizeGeometry()
and ports it to a Workspace::clientArea() overload that requires no
desktop.

Under the hood, Workspace::clientArea() still uses desktop(), but it
could also use a different strategy to compute the client area if the
window is on several virtual desktops, e.g. intersect client area on
every virtual desktop.
This commit is contained in:
Vlad Zahorodnii 2021-08-27 16:42:28 +03:00
parent e5f6039a68
commit 1dc749333e
2 changed files with 8 additions and 8 deletions

View file

@ -3053,22 +3053,22 @@ void AbstractClient::setElectricBorderMaximizing(bool maximizing)
{
m_electricMaximizing = maximizing;
if (maximizing)
outline()->show(electricBorderMaximizeGeometry(Cursors::self()->mouse()->pos(), desktop()), moveResizeGeometry());
outline()->show(electricBorderMaximizeGeometry(Cursors::self()->mouse()->pos()), moveResizeGeometry());
else
outline()->hide();
elevate(maximizing);
}
QRect AbstractClient::electricBorderMaximizeGeometry(QPoint pos, int desktop)
QRect AbstractClient::electricBorderMaximizeGeometry(const QPoint &pos) const
{
if (electricBorderMode() == QuickTileMode(QuickTileFlag::Maximize)) {
if (maximizeMode() == MaximizeFull)
return geometryRestore();
else
return workspace()->clientArea(MaximizeArea, pos, desktop);
return workspace()->clientArea(MaximizeArea, this, pos);
}
QRect ret = workspace()->clientArea(MaximizeArea, pos, desktop);
QRect ret = workspace()->clientArea(MaximizeArea, this, pos);
if (electricBorderMode() & QuickTileFlag::Left)
ret.setRight(ret.left()+ret.width()/2 - 1);
else if (electricBorderMode() & QuickTileFlag::Right)
@ -3129,7 +3129,7 @@ void AbstractClient::setQuickTileMode(QuickTileMode mode, bool keyboard)
setMaximize(false, false);
moveResize(electricBorderMaximizeGeometry(keyboard ? moveResizeGeometry().center() : Cursors::self()->mouse()->pos(), desktop()));
moveResize(electricBorderMaximizeGeometry(keyboard ? moveResizeGeometry().center() : Cursors::self()->mouse()->pos()));
// Store the mode change
m_quickTileMode = mode;
} else {
@ -3198,7 +3198,7 @@ void AbstractClient::setQuickTileMode(QuickTileMode mode, bool keyboard)
m_quickTileMode = mode;
// Temporary, so the maximize code doesn't get all confused
m_quickTileMode = int(QuickTileFlag::None);
moveResize(electricBorderMaximizeGeometry(whichScreen, desktop()));
moveResize(electricBorderMaximizeGeometry(whichScreen));
}
// Store the mode change
@ -3349,7 +3349,7 @@ void AbstractClient::checkWorkspacePosition(QRect oldGeometry, QRect oldClientGe
}
if (quickTileMode() != QuickTileMode(QuickTileFlag::None)) {
moveResize(electricBorderMaximizeGeometry(moveResizeGeometry().center(), desktop()));
moveResize(electricBorderMaximizeGeometry(moveResizeGeometry().center()));
return;
}

View file

@ -1054,7 +1054,7 @@ protected:
bool isElectricBorderMaximizing() const {
return m_electricMaximizing;
}
QRect electricBorderMaximizeGeometry(QPoint pos, int desktop);
QRect electricBorderMaximizeGeometry(const QPoint &pos) const;
void updateQuickTileMode(QuickTileMode newMode) {
m_quickTileMode = newMode;
}