From e1683ef06f734fbd231f000c72fa15176d5dd998 Mon Sep 17 00:00:00 2001 From: Lucas Murray Date: Fri, 25 Jul 2008 10:19:28 +0000 Subject: [PATCH] Snap to window corners. BUG: 130452 svn path=/trunk/KDE/kdebase/workspace/; revision=837640 --- geometry.cpp | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/geometry.cpp b/geometry.cpp index 570be0ab5c..845d5841c6 100644 --- a/geometry.cpp +++ b/geometry.cpp @@ -394,6 +394,34 @@ QPoint Workspace::adjustClientPosition( Client* c, QPoint pos, bool unrestricted ny = ly - ch; } } + + // Corner snapping + if( nx == lrx || nx+cw == lx ) + { + if ((sOWO?(ry>lry):true) && (qAbs(lry-ry)lrx):true) && (qAbs(lrx-rx)lry):true) \ + && (newcx == lrx || newrx == lx) \ + && qAbs(lry-newry) < deltaY ) { \ + deltaY = qAbs( lry - newry ); \ + newry=lry; \ + } + +#define SNAP_WINDOW_C_LEFT if ( (sOWO?(newcxlrx):true) \ + && (newcy == lry || newry == ly) \ + && qAbs(lrx-newrx) < deltaX ) { \ + deltaX = qAbs( lrx - newrx ); \ + newrx=lrx; \ + } + switch ( mode ) { case PositionBottomRight: SNAP_WINDOW_BOTTOM SNAP_WINDOW_RIGHT + SNAP_WINDOW_C_BOTTOM + SNAP_WINDOW_C_RIGHT break; case PositionRight: SNAP_WINDOW_RIGHT + SNAP_WINDOW_C_RIGHT break; case PositionBottom: SNAP_WINDOW_BOTTOM + SNAP_WINDOW_C_BOTTOM break; case PositionTopLeft: SNAP_WINDOW_TOP SNAP_WINDOW_LEFT + SNAP_WINDOW_C_TOP + SNAP_WINDOW_C_LEFT break; case PositionLeft: SNAP_WINDOW_LEFT + SNAP_WINDOW_C_LEFT break; case PositionTop: SNAP_WINDOW_TOP + SNAP_WINDOW_C_TOP break; case PositionTopRight: SNAP_WINDOW_TOP SNAP_WINDOW_RIGHT + SNAP_WINDOW_C_TOP + SNAP_WINDOW_C_RIGHT break; case PositionBottomLeft: SNAP_WINDOW_BOTTOM SNAP_WINDOW_LEFT + SNAP_WINDOW_C_BOTTOM + SNAP_WINDOW_C_LEFT break; default: assert( false );