Avoid changing geometry when finishing interactive move resize

When finishing interactive resize operation, the move resize geometry is
already good and the client should have sent the corresponding configure
event. So, this moveResize() call is redundant.

This change moves code that is responsible for quitting maximized
horizontally or vertically mode to the start of the interactive resize
operation. It makes handling of MaximizeFull mode consistent, and it
kills one moveResize() call at the end of the interactive resize
operation, which is good because it makes simpler handling of resizing
aspect ratio aware windows on wayland.

However, in order to make resizing of aspect ratio aware windows good
for real, we will need to augment configure events with gravity info.
This commit is contained in:
Vlad Zahorodnii 2021-12-23 22:43:21 +02:00
parent dbee0573c4
commit d85ab218ee

View file

@ -944,20 +944,51 @@ bool AbstractClient::startInteractiveMoveResize()
setInteractiveMoveResize(true); setInteractiveMoveResize(true);
workspace()->setMoveResizeClient(this); workspace()->setMoveResizeClient(this);
const Position mode = interactiveMoveResizePointerMode(); if (maximizeMode() != MaximizeRestore) {
if (mode != PositionCenter) { // means "isResize()" but moveResizeMode = true is set below switch (interactiveMoveResizePointerMode()) {
if (maximizeMode() == MaximizeFull) { // partial is cond. reset in finishMoveResize case PositionLeft:
setGeometryRestore(moveResizeGeometry()); // "restore" to current geometry case PositionRight:
setMaximize(false, false); // Quit maximized horizontally state if the window is resized horizontally.
if (maximizeMode() & MaximizeHorizontal) {
QRect originalGeometry = geometryRestore();
originalGeometry.setX(moveResizeGeometry().x());
originalGeometry.setWidth(moveResizeGeometry().width());
setGeometryRestore(originalGeometry);
maximize(maximizeMode() ^ MaximizeHorizontal);
}
break;
case PositionTop:
case PositionBottom:
// Quit maximized vertically state if the window is resized vertically.
if (maximizeMode() & MaximizeVertical) {
QRect originalGeometry = geometryRestore();
originalGeometry.setY(moveResizeGeometry().y());
originalGeometry.setHeight(moveResizeGeometry().height());
setGeometryRestore(originalGeometry);
maximize(maximizeMode() ^ MaximizeVertical);
}
break;
case PositionTopLeft:
case PositionBottomLeft:
case PositionTopRight:
case PositionBottomRight:
// Quit the maximized mode if the window is resized by dragging one of its corners.
setGeometryRestore(moveResizeGeometry());
maximize(MaximizeRestore);
break;
default:
break;
} }
} }
if (quickTileMode() != QuickTileMode(QuickTileFlag::None) && mode != PositionCenter) { // Cannot use isResize() yet if (quickTileMode() != QuickTileMode(QuickTileFlag::None)) {
// Exit quick tile mode when the user attempts to resize a tiled window if (interactiveMoveResizePointerMode() != PositionCenter) { // Cannot use isResize() yet
updateQuickTileMode(QuickTileFlag::None); // Do so without restoring original geometry // Exit quick tile mode when the user attempts to resize a tiled window
setGeometryRestore(moveResizeGeometry()); updateQuickTileMode(QuickTileFlag::None); // Do so without restoring original geometry
doSetQuickTileMode(); setGeometryRestore(moveResizeGeometry());
Q_EMIT quickTileModeChanged(); doSetQuickTileMode();
Q_EMIT quickTileModeChanged();
}
} }
updateHaveResizeEffect(); updateHaveResizeEffect();
@ -972,25 +1003,12 @@ bool AbstractClient::startInteractiveMoveResize()
void AbstractClient::finishInteractiveMoveResize(bool cancel) void AbstractClient::finishInteractiveMoveResize(bool cancel)
{ {
GeometryUpdatesBlocker blocker(this); GeometryUpdatesBlocker blocker(this);
const bool wasResize = isInteractiveResize(); // store across leaveMoveResize
leaveInteractiveMoveResize(); leaveInteractiveMoveResize();
doFinishInteractiveMoveResize(); doFinishInteractiveMoveResize();
if (cancel) if (cancel) {
moveResize(initialInteractiveMoveResizeGeometry()); moveResize(initialInteractiveMoveResizeGeometry());
else {
const QRect &moveResizeGeom = moveResizeGeometry();
if (wasResize) {
const bool restoreH = maximizeMode() == MaximizeHorizontal &&
moveResizeGeom.width() != initialInteractiveMoveResizeGeometry().width();
const bool restoreV = maximizeMode() == MaximizeVertical &&
moveResizeGeom.height() != initialInteractiveMoveResizeGeometry().height();
if (restoreH || restoreV) {
changeMaximize(restoreH, restoreV, false);
}
}
moveResize(moveResizeGeom);
} }
checkOutput(); // needs to be done because clientFinishUserMovedResized has not yet re-activated online alignment checkOutput(); // needs to be done because clientFinishUserMovedResized has not yet re-activated online alignment
if (output() != interactiveMoveResizeStartOutput()) { if (output() != interactiveMoveResizeStartOutput()) {