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>
master
Michele Calgaro 4 years ago committed by Slávek Banko
parent 1c53644408
commit bc1b1fed7d
No known key found for this signature in database
GPG Key ID: 608F5293A04BE668

@ -1487,8 +1487,10 @@ void QWidget::grabMouse()
void QWidget::grabMouse( const QCursor &cursor ) void QWidget::grabMouse( const QCursor &cursor )
{ {
if ( !qt_nograb() ) { if ( !qt_nograb() ) {
if ( mouseGrb ) if ( mouseGrb != this ) {
if ( mouseGrb ) {
mouseGrb->releaseMouse(); mouseGrb->releaseMouse();
}
#if defined(QT_CHECK_STATE) #if defined(QT_CHECK_STATE)
int status = int status =
#endif #endif
@ -1511,6 +1513,7 @@ void QWidget::grabMouse( const QCursor &cursor )
mouseGrb = this; mouseGrb = this;
} }
} }
}
/*! /*!
Releases the mouse grab. Releases the mouse grab.
@ -1548,13 +1551,15 @@ void QWidget::releaseMouse()
void QWidget::grabKeyboard() void QWidget::grabKeyboard()
{ {
if ( !qt_nograb() ) { if ( !qt_nograb() ) {
if ( keyboardGrb ) if ( keyboardGrb != this ) {
if ( keyboardGrb ) {
keyboardGrb->releaseKeyboard(); keyboardGrb->releaseKeyboard();
XGrabKeyboard( x11Display(), winid, False, GrabModeAsync, GrabModeAsync, }
qt_x_time ); XGrabKeyboard( x11Display(), winid, False, GrabModeAsync, GrabModeAsync, qt_x_time );
keyboardGrb = this; keyboardGrb = this;
} }
} }
}
/*! /*!
Releases the keyboard grab. Releases the keyboard grab.

Loading…
Cancel
Save