diff --git a/client.cpp b/client.cpp index dafdbdd85f..f58d83e6a8 100644 --- a/client.cpp +++ b/client.cpp @@ -83,7 +83,6 @@ Client::Client( Workspace *ws ) ping_timer( NULL ), process_killer( NULL ), user_time( CurrentTime ), // not known yet - input_grabbed( false ), allowed_actions( 0 ), block_geometry( 0 ), shade_geometry_change( false ), @@ -399,33 +398,6 @@ void Client::setUserNoBorder( bool set ) updateDecoration( true, false ); } -bool Client::grabInput() - { - assert( !input_grabbed ); - assert( QWidget::keyboardGrabber() == NULL ); - assert( QWidget::mouseGrabber() == NULL ); - if( XGrabPointer( qt_xdisplay(), frameId(), False, ButtonPressMask | ButtonReleaseMask | PointerMotionMask, - GrabModeAsync, GrabModeAsync, None, cursor.handle(), qt_x_time ) != Success ) - return false; - if( XGrabKeyboard( qt_xdisplay(), frameId(), False, GrabModeAsync, GrabModeAsync, qt_x_time ) != Success ) - { - XUngrabPointer( qt_xdisplay(), qt_x_time ); - return false; - } - input_grabbed = true; - return true; - } - -void Client::ungrabInput() - { - assert( input_grabbed ); - assert( QWidget::keyboardGrabber() == NULL ); - assert( QWidget::mouseGrabber() == NULL ); - XUngrabKeyboard( qt_xdisplay(), qt_x_time ); - XUngrabPointer( qt_xdisplay(), qt_x_time ); - input_grabbed = false; - } - void Client::updateShape() { if ( shape() ) diff --git a/client.h b/client.h index e75f2c3464..4046b3bc0f 100644 --- a/client.h +++ b/client.h @@ -337,8 +337,6 @@ class Client : public QObject, public KDecorationDefines void leaveMoveResize(); void handleMoveResize( int x, int y, int x_root, int y_root ); void positionGeometryTip(); - bool grabInput(); - void ungrabInput(); void updateMouseGrab(); void grabButton( int mod ); void ungrabButton( int mod ); @@ -458,7 +456,6 @@ class Client : public QObject, public KDecorationDefines KProcess* process_killer; Time ping_timestamp; Time user_time; - bool input_grabbed; unsigned long allowed_actions; QRect frame_geometry; QSize client_size; diff --git a/geometry.cpp b/geometry.cpp index 862cf1726a..08ac206172 100644 --- a/geometry.cpp +++ b/geometry.cpp @@ -1441,11 +1441,20 @@ class EatAllPaintEvents static EatAllPaintEvents* eater = 0; -// TODO kontrolovat navratovou hodnotu bool Client::startMoveResize() { assert( !moveResizeMode ); - if( !grabInput()) + assert( QWidget::keyboardGrabber() == NULL ); + assert( QWidget::mouseGrabber() == NULL ); + if( QApplication::activePopupWidget() != NULL ) + return false; // popups have grab + bool has_grab = false; + if( XGrabPointer( qt_xdisplay(), frameId(), False, ButtonPressMask | ButtonReleaseMask | PointerMotionMask, + GrabModeAsync, GrabModeAsync, None, cursor.handle(), qt_x_time ) == Success ) + has_grab = true; + if( XGrabKeyboard( qt_xdisplay(), frameId(), False, GrabModeAsync, GrabModeAsync, qt_x_time ) == Success ) + has_grab = true; + if( !has_grab ) // at least one grab is necessary in order to be able to finish move/resize return false; if( mode == Center ) setCursor( sizeAllCursor ); // change from arrow cursor if moving @@ -1494,7 +1503,8 @@ void Client::leaveMoveResize() if ( ( isMove() && options->moveMode != Options::Opaque ) || ( isResize() && options->resizeMode != Options::Opaque ) ) XUngrabServer( qt_xdisplay() ); - ungrabInput(); + XUngrabKeyboard( qt_xdisplay(), qt_x_time ); + XUngrabPointer( qt_xdisplay(), qt_x_time ); workspace()->setClientIsMoving(0); if( move_faked_activity ) workspace()->unfakeActivity( this );