From 1f456b4cbb93e3fea699878d117900b703146213 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Fri, 3 Jun 2011 11:30:23 +0200 Subject: Add support for mouse and keyboard grab. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Samuel Rødal --- src/widgets/kernel/qwidget_qpa.cpp | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) (limited to 'src/widgets/kernel/qwidget_qpa.cpp') diff --git a/src/widgets/kernel/qwidget_qpa.cpp b/src/widgets/kernel/qwidget_qpa.cpp index b8a7cb5463..8764f633f1 100644 --- a/src/widgets/kernel/qwidget_qpa.cpp +++ b/src/widgets/kernel/qwidget_qpa.cpp @@ -338,8 +338,8 @@ void QWidget::grabMouse() if (qt_mouseGrb) qt_mouseGrb->releaseMouse(); - // XXX - //qwsDisplay()->grabMouse(this,true); + if (windowHandle()) + windowHandle()->setMouseGrabEnabled(true); qt_mouseGrb = this; qt_pressGrab = 0; @@ -353,19 +353,27 @@ void QWidget::grabMouse(const QCursor &cursor) if (qt_mouseGrb) qt_mouseGrb->releaseMouse(); - // XXX - //qwsDisplay()->grabMouse(this,true); - //qwsDisplay()->selectCursor(this, cursor.handle()); + if (windowHandle()) + windowHandle()->setMouseGrabEnabled(true); + qt_mouseGrb = this; qt_pressGrab = 0; } #endif +bool QWidgetPrivate::stealMouseGrab(bool grab) +{ + // This is like a combination of grab/releaseMouse() but with error checking + // and it has no effect on the result of mouseGrabber(). + Q_Q(QWidget); + return q->windowHandle() ? q->windowHandle()->setMouseGrabEnabled(grab) : false; +} + void QWidget::releaseMouse() { if (qt_mouseGrb == this) { - // XXX - //qwsDisplay()->grabMouse(this,false); + if (windowHandle()) + windowHandle()->setMouseGrabEnabled(false); qt_mouseGrb = 0; } } @@ -374,16 +382,24 @@ void QWidget::grabKeyboard() { if (keyboardGrb) keyboardGrb->releaseKeyboard(); - // XXX - //qwsDisplay()->grabKeyboard(this, true); + if (windowHandle()) + windowHandle()->setKeyboardGrabEnabled(true); keyboardGrb = this; } +bool QWidgetPrivate::stealKeyboardGrab(bool grab) +{ + // This is like a combination of grab/releaseKeyboard() but with error + // checking and it has no effect on the result of keyboardGrabber(). + Q_Q(QWidget); + return q->windowHandle() ? q->windowHandle()->setKeyboardGrabEnabled(grab) : false; +} + void QWidget::releaseKeyboard() { if (keyboardGrb == this) { - // XXX - //qwsDisplay()->grabKeyboard(this, false); + if (windowHandle()) + windowHandle()->setKeyboardGrabEnabled(false); keyboardGrb = 0; } } -- cgit v1.2.3