diff options
author | Michele Calgaro <michele.calgaro@yahoo.it> | 2020-04-29 00:10:33 +0900 |
---|---|---|
committer | Michele Calgaro <michele.calgaro@yahoo.it> | 2020-04-29 00:15:46 +0900 |
commit | f0869718763cd6d04c9b225db8966df08ddaef44 (patch) | |
tree | c6799fe65af5d633e84a89590fb35e36d2cef9dd /src | |
parent | 8520b59ce9d56978ff0d9e5242375cc33b4d5bf1 (diff) | |
download | tqt3-f0869718763cd6d04c9b225db8966df08ddaef44.tar.gz tqt3-f0869718763cd6d04c9b225db8966df08ddaef44.zip |
Improved code for keyboard and mouse grabbing and releasing to avoid
unnecessary actions. This relates loosely to bug 2955.
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
Diffstat (limited to 'src')
-rw-r--r-- | src/kernel/qwidget_x11.cpp | 51 |
1 files changed, 28 insertions, 23 deletions
diff --git a/src/kernel/qwidget_x11.cpp b/src/kernel/qwidget_x11.cpp index f842595d5..31185921a 100644 --- a/src/kernel/qwidget_x11.cpp +++ b/src/kernel/qwidget_x11.cpp @@ -1487,28 +1487,31 @@ void TQWidget::grabMouse() void TQWidget::grabMouse( const TQCursor &cursor ) { if ( !qt_nograb() ) { - if ( mouseGrb ) - mouseGrb->releaseMouse(); + if ( mouseGrb != this ) { + if ( mouseGrb ) { + mouseGrb->releaseMouse(); + } #if defined(QT_CHECK_STATE) - int status = + int status = #endif - XGrabPointer( x11Display(), winId(), False, - (uint)(ButtonPressMask | ButtonReleaseMask | - PointerMotionMask | EnterWindowMask | LeaveWindowMask), - GrabModeAsync, GrabModeAsync, - None, cursor.handle(), tqt_x_time ); + XGrabPointer( x11Display(), winId(), False, + (uint)(ButtonPressMask | ButtonReleaseMask | + PointerMotionMask | EnterWindowMask | LeaveWindowMask), + GrabModeAsync, GrabModeAsync, + None, cursor.handle(), tqt_x_time ); #if defined(QT_CHECK_STATE) - if ( status ) { - const char *s = - status == GrabNotViewable ? "\"GrabNotViewable\"" : - status == AlreadyGrabbed ? "\"AlreadyGrabbed\"" : - status == GrabFrozen ? "\"GrabFrozen\"" : - status == GrabInvalidTime ? "\"GrabInvalidTime\"" : - "<?>"; - tqWarning( "Grabbing the mouse failed with %s", s ); - } + if ( status ) { + const char *s = + status == GrabNotViewable ? "\"GrabNotViewable\"" : + status == AlreadyGrabbed ? "\"AlreadyGrabbed\"" : + status == GrabFrozen ? "\"GrabFrozen\"" : + status == GrabInvalidTime ? "\"GrabInvalidTime\"" : + "<?>"; + tqWarning( "Grabbing the mouse failed with %s", s ); + } #endif - mouseGrb = this; + mouseGrb = this; + } } } @@ -1548,11 +1551,13 @@ void TQWidget::releaseMouse() void TQWidget::grabKeyboard() { if ( !qt_nograb() ) { - if ( keyboardGrb ) - keyboardGrb->releaseKeyboard(); - XGrabKeyboard( x11Display(), winid, False, GrabModeAsync, GrabModeAsync, - tqt_x_time ); - keyboardGrb = this; + if ( keyboardGrb != this ) { + if ( keyboardGrb ) { + keyboardGrb->releaseKeyboard(); + } + XGrabKeyboard( x11Display(), winid, False, GrabModeAsync, GrabModeAsync, tqt_x_time ); + keyboardGrb = this; + } } } |