From 8e367689cd6414f25cb761791c4d2d29ae862056 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubo=C5=A1=20Lu=C5=88=C3=A1k?= Date: Thu, 25 Sep 2003 09:29:18 +0000 Subject: [PATCH] Rework restricted move/resize to be readable, and as a side effect make it finally work correctly. svn path=/trunk/kdebase/kwin/; revision=253801 --- events.cpp | 4 ++-- geometry.cpp | 34 ++++++++++++++++++++++++++-------- 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/events.cpp b/events.cpp index 78cf40ae0d..b12c0e67f5 100644 --- a/events.cpp +++ b/events.cpp @@ -1239,8 +1239,8 @@ bool Client::buttonReleaseEvent( Window w, int /*button*/, int state, int x, int finishMoveResize( false ); // mouse position is still relative to old Client position, adjust it QPoint mousepos( x_root - x, y_root - y ); - mode = mousePosition( mousepos ); - setCursor( mode ); + mode = mousePosition( mousepos ); + setCursor( mode ); } } return true; diff --git a/geometry.cpp b/geometry.cpp index bac395359e..d467a33c36 100644 --- a/geometry.cpp +++ b/geometry.cpp @@ -1273,15 +1273,33 @@ void Client::handleMoveResize( int x, int y, int x_root, int y_root ) if( !unrestrictedMoveResize ) { - int left_overlap = width() - border_left - 100; - int right_overlap = width() - border_right - 100; - int top_overlap = 0; - int bottom_overlap = height() - border_top; + // width/height change with opaque resizing, use the initial ones + int init_width = initialMoveResizeGeom.width(); + int init_height = initialMoveResizeGeom.height(); + // how much must remain visible when moved away in that direction + const int left_limit = 100 + border_right; + const int right_limit = 100 + border_left; + const int top_limit = init_height; + const int bottom_limit = border_top; + int left_overlap = KMAX( init_width - left_limit, 0 ); + int right_overlap = KMAX( init_width - right_limit, 0 ); + int top_overlap = KMAX( init_height - top_limit, 0 ); + int bottom_overlap = KMAX( init_height - bottom_limit, 0 ); // 'pp' is top left corner, 'p' is bottom right corner - pp.setX( QMIN( desktopArea.right() + right_overlap - width(), QMAX( desktopArea.left() - left_overlap, pp.x()))); - pp.setY( QMIN( desktopArea.bottom() + bottom_overlap - height(), QMAX( desktopArea.top() - top_overlap, pp.y()))); - p.setX( QMIN( desktopArea.right() + right_overlap, QMAX( desktopArea.left() - left_overlap + width(), p.x()))); - p.setY( QMIN( desktopArea.bottom() + bottom_overlap, QMAX( desktopArea.top() - top_overlap + height(), p.y()))); + if( mode == Center ) // moving + { + pp.setX( KMIN( desktopArea.right() + right_overlap - init_width, + KMAX( desktopArea.left() - left_overlap, pp.x()))); + pp.setY( KMIN( desktopArea.bottom() + bottom_overlap - init_height, + KMAX( desktopArea.top() - top_overlap, pp.y()))); + } + else + { // resizing + pp.setX( KMAX( desktopArea.left() - left_overlap, pp.x())); + pp.setY( KMAX( desktopArea.top() - top_overlap, pp.y())); + p.setX( KMIN( desktopArea.right() + right_overlap, p.x())); + p.setY( KMIN( desktopArea.bottom() + bottom_overlap, p.y())); + } } QSize mpsize( geometry().right() - pp.x() + 1, geometry().bottom() - pp.y() + 1 );