From 0f57c9407a68ccfee6f9d23632f0aabbedf0b143 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20L=C3=BCbking?= Date: Thu, 18 Jul 2013 16:22:34 +0200 Subject: [PATCH] depend titlebar protection dir pref on cap dir when visualPixels is not 0, this means the titlebar does not touch an upper/lower border, thus moving that direction is ok and protection should be sought horizontally BUG: 322507 FIXED-IN: 4.11 REVIEW: 111573 --- geometry.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) 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 }