Fix center snap zone to account for available space

This commit is contained in:
Kristen McWilliam 2021-10-01 14:55:12 +00:00 committed by David Edmundson
parent d55011ae86
commit cc06f62749

View file

@ -2472,10 +2472,12 @@ QPoint Workspace::adjustClientPosition(AbstractClient* c, QPoint pos, bool unres
if (options->windowSnapZone() || !borderSnapZone.isNull() || options->centerSnapZone()) { if (options->windowSnapZone() || !borderSnapZone.isNull() || options->centerSnapZone()) {
const bool snappingToCenter = (options->centerSnapZone() * snapAdjust);
const bool sOWO = options->isSnapOnlyWhenOverlapping(); const bool sOWO = options->isSnapOnlyWhenOverlapping();
const AbstractOutput *output = kwinApp()->platform()->outputAt(pos + c->rect().center()); const AbstractOutput *output = kwinApp()->platform()->outputAt(pos + c->rect().center());
if (maxRect.isNull()) if (maxRect.isNull()) {
maxRect = clientArea(MovementArea, c, output); maxRect = clientArea(MaximizeArea, c, output);
}
const int xmin = maxRect.left(); const int xmin = maxRect.left();
const int xmax = maxRect.right() + 1; //desk size const int xmax = maxRect.right() + 1; //desk size
const int ymin = maxRect.top(); const int ymin = maxRect.top();
@ -2611,8 +2613,7 @@ QPoint Workspace::adjustClientPosition(AbstractClient* c, QPoint pos, bool unres
} }
// center snap // center snap
snap = options->centerSnapZone() * snapAdjust; //snap trigger if (snappingToCenter) { //snap trigger
if (snap) {
int diffX = qAbs((xmin + xmax) / 2 - (cx + cw / 2)); int diffX = qAbs((xmin + xmax) / 2 - (cx + cw / 2));
int diffY = qAbs((ymin + ymax) / 2 - (cy + ch / 2)); int diffY = qAbs((ymin + ymax) / 2 - (cy + ch / 2));
if (diffX < snap && diffY < snap && diffX < deltaX && diffY < deltaY) { if (diffX < snap && diffY < snap && diffX < deltaX && diffY < deltaY) {