Rework restricted move/resize to be readable, and as a side effect make
it finally work correctly. svn path=/trunk/kdebase/kwin/; revision=253801
This commit is contained in:
parent
b1fe242be0
commit
8e367689cd
2 changed files with 28 additions and 10 deletions
|
@ -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;
|
||||
|
|
34
geometry.cpp
34
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 );
|
||||
|
|
Loading…
Reference in a new issue