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>
(cherry picked from commit bc1b1fed7d)
r14.0.x
Michele Calgaro 5 years ago committed by Slávek Banko
parent e9d6b1eb3d
commit 5a19653cb5
No known key found for this signature in database
GPG Key ID: 608F5293A04BE668

@ -1487,28 +1487,31 @@ void QWidget::grabMouse()
void QWidget::grabMouse( const QCursor &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(), qt_x_time );
XGrabPointer( x11Display(), winId(), False,
(uint)(ButtonPressMask | ButtonReleaseMask |
PointerMotionMask | EnterWindowMask | LeaveWindowMask),
GrabModeAsync, GrabModeAsync,
None, cursor.handle(), qt_x_time );
#if defined(QT_CHECK_STATE)
if ( status ) {
const char *s =
status == GrabNotViewable ? "\"GrabNotViewable\"" :
status == AlreadyGrabbed ? "\"AlreadyGrabbed\"" :
status == GrabFrozen ? "\"GrabFrozen\"" :
status == GrabInvalidTime ? "\"GrabInvalidTime\"" :
"<?>";
qWarning( "Grabbing the mouse failed with %s", s );
}
if ( status ) {
const char *s =
status == GrabNotViewable ? "\"GrabNotViewable\"" :
status == AlreadyGrabbed ? "\"AlreadyGrabbed\"" :
status == GrabFrozen ? "\"GrabFrozen\"" :
status == GrabInvalidTime ? "\"GrabInvalidTime\"" :
"<?>";
qWarning( "Grabbing the mouse failed with %s", s );
}
#endif
mouseGrb = this;
mouseGrb = this;
}
}
}
@ -1548,11 +1551,13 @@ void QWidget::releaseMouse()
void QWidget::grabKeyboard()
{
if ( !qt_nograb() ) {
if ( keyboardGrb )
keyboardGrb->releaseKeyboard();
XGrabKeyboard( x11Display(), winid, False, GrabModeAsync, GrabModeAsync,
qt_x_time );
keyboardGrb = this;
if ( keyboardGrb != this ) {
if ( keyboardGrb ) {
keyboardGrb->releaseKeyboard();
}
XGrabKeyboard( x11Display(), winid, False, GrabModeAsync, GrabModeAsync, qt_x_time );
keyboardGrb = this;
}
}
}

Loading…
Cancel
Save