Implemented _NET_WM_MOVERESIZE.
Fixed some minor bugs with resizing. svn path=/trunk/kdebase/kwin/; revision=165071
This commit is contained in:
parent
ffff5455b4
commit
6d7f113304
3 changed files with 44 additions and 35 deletions
62
client.cpp
62
client.cpp
|
@ -114,8 +114,6 @@ static int nullErrorHandler(Display *, XErrorEvent *)
|
|||
|
||||
using namespace KWinInternal;
|
||||
|
||||
static bool resizeHorizontalDirectionFixed = FALSE;
|
||||
static bool resizeVerticalDirectionFixed = FALSE;
|
||||
static bool blockAnimation = FALSE;
|
||||
|
||||
static QRect* visible_bound = 0;
|
||||
|
@ -1571,8 +1569,10 @@ void Client::resizeEvent( QResizeEvent * e)
|
|||
void Client::mouseMoveEvent( QMouseEvent * e)
|
||||
{
|
||||
if ( !buttonDown ) {
|
||||
mode = mousePosition( e->pos() );
|
||||
setMouseCursor( mode );
|
||||
MousePosition newmode = mousePosition( e->pos() );
|
||||
if( newmode != mode )
|
||||
setMouseCursor( newmode );
|
||||
mode = newmode;
|
||||
geom = geometry();
|
||||
return;
|
||||
}
|
||||
|
@ -1601,7 +1601,6 @@ void Client::mouseMoveEvent( QMouseEvent * e)
|
|||
|
||||
QPoint globalPos = e->globalPos(); // pos() + geometry().topLeft();
|
||||
|
||||
|
||||
QPoint p = globalPos + invertedMoveOffset;
|
||||
|
||||
QPoint pp = globalPos - moveOffset;
|
||||
|
@ -2643,6 +2642,7 @@ bool Client::performMouseCommand( Options::MouseCommand command, QPoint globalPo
|
|||
buttonDown = TRUE;
|
||||
moveOffset = mapFromGlobal( globalPos );
|
||||
invertedMoveOffset = rect().bottomRight() - moveOffset;
|
||||
setMouseCursor( mode );
|
||||
startMoveResize();
|
||||
break;
|
||||
case Options::MouseResize: {
|
||||
|
@ -2672,8 +2672,6 @@ bool Client::performMouseCommand( Options::MouseCommand command, QPoint globalPo
|
|||
invertedMoveOffset = rect().bottomRight() - moveOffset;
|
||||
setMouseCursor( mode );
|
||||
startMoveResize();
|
||||
resizeHorizontalDirectionFixed = FALSE;
|
||||
resizeVerticalDirectionFixed = FALSE;
|
||||
} break;
|
||||
case Options::MouseNothing:
|
||||
// fall through
|
||||
|
@ -2684,6 +2682,32 @@ bool Client::performMouseCommand( Options::MouseCommand command, QPoint globalPo
|
|||
return replay;
|
||||
}
|
||||
|
||||
// performs _NET_WM_MOVERESIZE
|
||||
void Client::NETMoveResize( int x_root, int y_root, NET::Direction direction )
|
||||
{
|
||||
if( direction == NET::Move )
|
||||
performMouseCommand( Options::MouseMove, QPoint( x_root, y_root ));
|
||||
else if( direction >= NET::TopLeft && direction <= NET::Left ) {
|
||||
static const MousePosition convert[] = { TopLeft, Top, TopRight, Right, BottomRight, Bottom,
|
||||
BottomLeft, Left };
|
||||
if (!isMovable())
|
||||
return;
|
||||
geom=geometry();
|
||||
if ( isMaximized() ) {
|
||||
// in case we were maximized, reset state
|
||||
max_mode = MaximizeRestore;
|
||||
maximizeChange(FALSE );
|
||||
Events::raise( Events::UnMaximize );
|
||||
info->setState( 0, NET::Max );
|
||||
}
|
||||
buttonDown = TRUE;
|
||||
moveOffset = mapFromGlobal( QPoint( x_root, y_root ));
|
||||
invertedMoveOffset = rect().bottomRight() - moveOffset;
|
||||
mode = convert[ direction ];
|
||||
setMouseCursor( mode );
|
||||
startMoveResize();
|
||||
}
|
||||
}
|
||||
|
||||
void Client::keyPressEvent( uint key_code )
|
||||
{
|
||||
|
@ -2696,39 +2720,15 @@ void Client::keyPressEvent( uint key_code )
|
|||
switch ( key_code ) {
|
||||
case Key_Left:
|
||||
pos.rx() -= delta;
|
||||
if ( isResize() && !resizeHorizontalDirectionFixed ) {
|
||||
resizeHorizontalDirectionFixed = TRUE;
|
||||
resizeVerticalDirectionFixed = FALSE;
|
||||
mode = Right;
|
||||
setMouseCursor( mode );
|
||||
}
|
||||
break;
|
||||
case Key_Right:
|
||||
pos.rx() += delta;
|
||||
if ( isResize() && !resizeHorizontalDirectionFixed ) {
|
||||
resizeHorizontalDirectionFixed = TRUE;
|
||||
resizeVerticalDirectionFixed = FALSE;
|
||||
mode = Right;
|
||||
setMouseCursor( mode );
|
||||
}
|
||||
break;
|
||||
case Key_Up:
|
||||
pos.ry() -= delta;
|
||||
if ( isResize() && !resizeVerticalDirectionFixed ) {
|
||||
resizeVerticalDirectionFixed = TRUE;
|
||||
resizeHorizontalDirectionFixed = FALSE;
|
||||
mode = Bottom;
|
||||
setMouseCursor( mode );
|
||||
}
|
||||
break;
|
||||
case Key_Down:
|
||||
pos.ry() += delta;
|
||||
if ( isResize() && !resizeVerticalDirectionFixed ) {
|
||||
resizeVerticalDirectionFixed = TRUE;
|
||||
resizeHorizontalDirectionFixed = FALSE;
|
||||
mode = Bottom;
|
||||
setMouseCursor( mode );
|
||||
}
|
||||
break;
|
||||
case Key_Space:
|
||||
case Key_Return:
|
||||
|
|
4
client.h
4
client.h
|
@ -212,7 +212,9 @@ public:
|
|||
|
||||
void updateUserTime();
|
||||
|
||||
const QPoint gravitate( bool invert ) const;
|
||||
const QPoint gravitate( bool invert ) const;
|
||||
|
||||
void NETMoveResize( int x_root, int y_root, NET::Direction direction );
|
||||
|
||||
public slots:
|
||||
void iconify();
|
||||
|
|
|
@ -86,7 +86,12 @@ public:
|
|||
c->closeWindow();
|
||||
}
|
||||
}
|
||||
void moveResize(Window, int, int, unsigned long) { }
|
||||
void moveResize(Window w, int x_root, int y_root, unsigned long direction) {
|
||||
KWinInternal::Client* c = workspace->findClient( (WId) w );
|
||||
if ( c ) {
|
||||
c->NETMoveResize( x_root, y_root, (Direction)direction);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
KWinInternal::Workspace* workspace;
|
||||
|
@ -379,6 +384,7 @@ void Workspace::init()
|
|||
NET::WMIconGeometry |
|
||||
NET::WMIcon |
|
||||
NET::WMPid |
|
||||
NET::WMMoveResize |
|
||||
NET::WMKDESystemTrayWinFor |
|
||||
NET::WMKDEFrameStrut
|
||||
;
|
||||
|
@ -1671,9 +1677,10 @@ void Workspace::performWindowOperation( Client* c, Options::WindowOperation op )
|
|||
if ( !c )
|
||||
return;
|
||||
|
||||
if (op == Options::MoveOp || op == Options::ResizeOp) {
|
||||
if (op == Options::MoveOp)
|
||||
QCursor::setPos( c->geometry().center() );
|
||||
}
|
||||
if (op == Options::ResizeOp)
|
||||
QCursor::setPos( c->geometry().bottomRight());
|
||||
switch ( op ) {
|
||||
case Options::MoveOp:
|
||||
c->performMouseCommand( Options::MouseMove, QCursor::pos() );
|
||||
|
|
Loading…
Reference in a new issue