diff --git a/geometry.cpp b/geometry.cpp index d17513f30e..9adcb98776 100644 --- a/geometry.cpp +++ b/geometry.cpp @@ -56,6 +56,10 @@ along with this program. If not, see . namespace KWin { +static inline int sign(int v) { + return (v > 0) - (v < 0); +} + //******************************************** // Workspace //******************************************** @@ -3009,13 +3013,16 @@ void Client::handleMoveResize(int x, int y, int x_root, int y_root) } } - // Move it (Favour vertically) - if (previousMoveResizeGeom.y() != moveResizeGeom.y()) - moveResizeGeom.translate(0, - previousMoveResizeGeom.y() > moveResizeGeom.y() ? 1 : -1); - else - moveResizeGeom.translate(previousMoveResizeGeom.x() > moveResizeGeom.x() ? 1 : -1, - 0); + int dx = sign(previousMoveResizeGeom.x() - moveResizeGeom.x()), + dy = sign(previousMoveResizeGeom.y() - moveResizeGeom.y()); + if (visiblePixels && dx) // means there's no full width cap -> favor horizontally + dy = 0; + else if (dy) + dx = 0; + + // Move it back + moveResizeGeom.translate(dx, dy); + if (moveResizeGeom == previousMoveResizeGeom) { break; // Prevent lockup }