Compute tile geometry without relying on electric border mode
Quick tiling allows you tile a window so it covers one half or a quarter of the screen. Electric border is basically interactive flavor of quick tiling, i.e. it allows you to drag a window to the top screen edge to maximize it. Currently, it's confusing that tile geometry is computed based on the electric border mode. This change converts electricBorderMaximizeGeometry() in a helper that's used to compute the tile geometry given the desired mode and output containing the specified QPoint. With that, setQuickTileMode() won't need to set electric border anymore, which makes tiling code more comprehensible, but by not a lot unfortunately.
This commit is contained in:
parent
5cfa4bae77
commit
6e26494b4e
2 changed files with 13 additions and 21 deletions
|
@ -3026,15 +3026,15 @@ void AbstractClient::setElectricBorderMaximizing(bool maximizing)
|
|||
{
|
||||
m_electricMaximizing = maximizing;
|
||||
if (maximizing)
|
||||
outline()->show(electricBorderMaximizeGeometry(Cursors::self()->mouse()->pos()), moveResizeGeometry());
|
||||
outline()->show(quickTileGeometry(electricBorderMode(), Cursors::self()->mouse()->pos()), moveResizeGeometry());
|
||||
else
|
||||
outline()->hide();
|
||||
elevate(maximizing);
|
||||
}
|
||||
|
||||
QRect AbstractClient::electricBorderMaximizeGeometry(const QPoint &pos) const
|
||||
QRect AbstractClient::quickTileGeometry(QuickTileMode mode, const QPoint &pos) const
|
||||
{
|
||||
if (electricBorderMode() == QuickTileMode(QuickTileFlag::Maximize)) {
|
||||
if (mode == QuickTileMode(QuickTileFlag::Maximize)) {
|
||||
if (maximizeMode() == MaximizeFull)
|
||||
return geometryRestore();
|
||||
else
|
||||
|
@ -3042,13 +3042,13 @@ QRect AbstractClient::electricBorderMaximizeGeometry(const QPoint &pos) const
|
|||
}
|
||||
|
||||
QRect ret = workspace()->clientArea(MaximizeArea, this, pos);
|
||||
if (electricBorderMode() & QuickTileFlag::Left)
|
||||
if (mode & QuickTileFlag::Left)
|
||||
ret.setRight(ret.left()+ret.width()/2 - 1);
|
||||
else if (electricBorderMode() & QuickTileFlag::Right)
|
||||
else if (mode & QuickTileFlag::Right)
|
||||
ret.setLeft(ret.right()-(ret.width()-ret.width()/2) + 1);
|
||||
if (electricBorderMode() & QuickTileFlag::Top)
|
||||
if (mode & QuickTileFlag::Top)
|
||||
ret.setBottom(ret.top()+ret.height()/2 - 1);
|
||||
else if (electricBorderMode() & QuickTileFlag::Bottom)
|
||||
else if (mode & QuickTileFlag::Bottom)
|
||||
ret.setTop(ret.bottom()-(ret.height()-ret.height()/2) + 1);
|
||||
|
||||
return ret;
|
||||
|
@ -3115,8 +3115,6 @@ void AbstractClient::setQuickTileMode(QuickTileMode mode, bool keyboard)
|
|||
if ((mode & QuickTileFlag::Vertical) == QuickTileMode(QuickTileFlag::Vertical))
|
||||
mode &= ~QuickTileMode(QuickTileFlag::Vertical);
|
||||
|
||||
setElectricBorderMode(mode); // used by ::electricBorderMaximizeGeometry(.)
|
||||
|
||||
// restore from maximized so that it is possible to tile maximized windows with one hit or by dragging
|
||||
if (maximizeMode() != MaximizeRestore) {
|
||||
|
||||
|
@ -3125,7 +3123,7 @@ void AbstractClient::setQuickTileMode(QuickTileMode mode, bool keyboard)
|
|||
|
||||
setMaximize(false, false);
|
||||
|
||||
moveResize(electricBorderMaximizeGeometry(keyboard ? moveResizeGeometry().center() : Cursors::self()->mouse()->pos()));
|
||||
moveResize(quickTileGeometry(mode, keyboard ? moveResizeGeometry().center() : Cursors::self()->mouse()->pos()));
|
||||
// Store the mode change
|
||||
m_quickTileMode = mode;
|
||||
} else {
|
||||
|
@ -3187,22 +3185,16 @@ void AbstractClient::setQuickTileMode(QuickTileMode mode, bool keyboard)
|
|||
mode = (~mode & QuickTileFlag::Horizontal) | (mode & QuickTileFlag::Vertical);
|
||||
}
|
||||
}
|
||||
setElectricBorderMode(mode); // used by ::electricBorderMaximizeGeometry(.)
|
||||
} else if (quickTileMode() == QuickTileMode(QuickTileFlag::None)) {
|
||||
// Not coming out of an existing tile, not shifting monitors, we're setting a brand new tile.
|
||||
// Store geometry first, so we can go out of this tile later.
|
||||
setGeometryRestore(quickTileGeometryRestore());
|
||||
}
|
||||
|
||||
m_quickTileMode = mode;
|
||||
if (mode != QuickTileMode(QuickTileFlag::None)) {
|
||||
m_quickTileMode = mode;
|
||||
// Temporary, so the maximize code doesn't get all confused
|
||||
m_quickTileMode = int(QuickTileFlag::None);
|
||||
moveResize(electricBorderMaximizeGeometry(whichScreen));
|
||||
moveResize(quickTileGeometry(mode, whichScreen));
|
||||
}
|
||||
|
||||
// Store the mode change
|
||||
m_quickTileMode = mode;
|
||||
}
|
||||
|
||||
if (mode == QuickTileMode(QuickTileFlag::None)) {
|
||||
|
@ -3350,7 +3342,7 @@ void AbstractClient::checkWorkspacePosition(QRect oldGeometry, const VirtualDesk
|
|||
}
|
||||
|
||||
if (quickTileMode() != QuickTileMode(QuickTileFlag::None)) {
|
||||
moveResize(electricBorderMaximizeGeometry(moveResizeGeometry().center()));
|
||||
moveResize(quickTileGeometry(quickTileMode(), moveResizeGeometry().center()));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -1029,9 +1029,9 @@ protected:
|
|||
bool isElectricBorderMaximizing() const {
|
||||
return m_electricMaximizing;
|
||||
}
|
||||
QRect electricBorderMaximizeGeometry(const QPoint &pos) const;
|
||||
void updateElectricGeometryRestore();
|
||||
QRect quickTileGeometryRestore() const;
|
||||
QRect quickTileGeometry(QuickTileMode mode, const QPoint &pos) const;
|
||||
void updateQuickTileMode(QuickTileMode newMode) {
|
||||
m_quickTileMode = newMode;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue