diff options
Diffstat (limited to 'src/gui/kernel/qguiapplication.cpp')
-rw-r--r-- | src/gui/kernel/qguiapplication.cpp | 48 |
1 files changed, 46 insertions, 2 deletions
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 42ce3745de..26690c78cf 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -696,6 +696,8 @@ void QGuiApplicationPrivate::init() // trigger registering of QVariant's GUI types qRegisterGuiVariant(); + QWindowSystemInterfacePrivate::eventTime.start(); + is_app_running = true; init_plugins(pluginList); QWindowSystemInterface::sendWindowSystemEvents(QCoreApplicationPrivate::eventDispatcher, QEventLoop::AllEvents); @@ -753,7 +755,17 @@ static QClipboard *clipboard(); #endif /*! - Returns the currently held keyboard modifiers. + Returns the current state of the modifier keys on the keyboard. The current + state is updated sychronously as the event queue is emptied of events that + will spontaneously change the keyboard state (QEvent::KeyPress and + QEvent::KeyRelease events). + + It should be noted this may not reflect the actual keys held on the input + device at the time of calling but rather the modifiers as last reported in + one of the above events. If no keys are being held Qt::NoModifier is + returned. + + \sa mouseButtons(), queryKeyboardModifiers() */ Qt::KeyboardModifiers QGuiApplication::keyboardModifiers() { @@ -761,7 +773,39 @@ Qt::KeyboardModifiers QGuiApplication::keyboardModifiers() } /*! - Returns the currently held mouse buttons. + \fn Qt::KeyboardModifiers QApplication::queryKeyboardModifiers() + + Queries and returns the state of the modifier keys on the keyboard. + Unlike keyboardModifiers, this method returns the actual keys held + on the input device at the time of calling the method. + + It does not rely on the keypress events having been received by this + process, which makes it possible to check the modifiers while moving + a window, for instance. Note that in most cases, you should use + keyboardModifiers(), which is faster and more accurate since it contains + the state of the modifiers as they were when the currently processed + event was received. + + \sa keyboardModifiers() +*/ +Qt::KeyboardModifiers QGuiApplication::queryKeyboardModifiers() +{ + QPlatformIntegration *pi = QGuiApplicationPrivate::platformIntegration(); + return pi->queryKeyboardModifiers(); +} + +/*! + Returns the current state of the buttons on the mouse. The current state is + updated syncronously as the event queue is emptied of events that will + spontaneously change the mouse state (QEvent::MouseButtonPress and + QEvent::MouseButtonRelease events). + + It should be noted this may not reflect the actual buttons held on the + input device at the time of calling but rather the mouse buttons as last + reported in one of the above events. If no mouse buttons are being held + Qt::NoButton is returned. + + \sa keyboardModifiers() */ Qt::MouseButtons QGuiApplication::mouseButtons() { |