diff options
author | Miikka Heikkinen <miikka.heikkinen@digia.com> | 2012-10-22 14:43:38 +0300 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-10-25 10:08:04 +0200 |
commit | 9fc7fcb4c90f9fdc5bb3581609a1d5b01cfb7076 (patch) | |
tree | 205dd5103662563949f9bea6ca7c85aea905a33c /src/plugins | |
parent | 8e002f1c0e0e0605d6cdfb90cdf909035eb643c8 (diff) |
Add ContextMenu event to QWindowSystemInterface
Context menu key wasn't working, as QPA had no handling for it.
Added ContextMenu event to QWindowSystemInterface and proper handling
to QGuiApplication and QWidgetWindow.
Also provide Windows implementation.
Task-number: QTBUG-27648
Change-Id: I7ce71ec4b5cdcc7be758e67f9faf6d863f7b19be
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Reviewed-by: Samuel Rødal <samuel.rodal@digia.com>
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/platforms/windows/qtwindowsglobal.h | 5 | ||||
-rw-r--r-- | src/plugins/platforms/windows/qwindowscontext.cpp | 23 | ||||
-rw-r--r-- | src/plugins/platforms/windows/qwindowscontext.h | 3 |
3 files changed, 31 insertions, 0 deletions
diff --git a/src/plugins/platforms/windows/qtwindowsglobal.h b/src/plugins/platforms/windows/qtwindowsglobal.h index 73f963b6b8..7ff8edb588 100644 --- a/src/plugins/platforms/windows/qtwindowsglobal.h +++ b/src/plugins/platforms/windows/qtwindowsglobal.h @@ -105,6 +105,7 @@ enum WindowsEventType // Simplify event types ThemeChanged = ThemingEventFlag + 1, DisplayChangedEvent = 437, SettingChangedEvent = DisplayChangedEvent + 1, + ContextMenu = 123, UnknownEvent = 542 }; @@ -194,6 +195,10 @@ inline QtWindows::WindowsEventType windowsEventType(UINT message, WPARAM wParamI return QtWindows::DisplayChangedEvent; case WM_THEMECHANGED: return QtWindows::ThemeChanged; +#ifndef QT_NO_CONTEXTMENU + case WM_CONTEXTMENU: + return QtWindows::ContextMenu; +#endif default: break; } diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp index 3d4871d7a2..42db58ae6c 100644 --- a/src/plugins/platforms/windows/qwindowscontext.cpp +++ b/src/plugins/platforms/windows/qwindowscontext.cpp @@ -869,6 +869,11 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message, QWindowsWindow::baseWindowOf(modalWindow)->alertWindow(); break; #endif +#ifndef QT_NO_CONTEXTMENU + case QtWindows::ContextMenu: + handleContextMenuEvent(platformWindow->window(), msg); + return true; +#endif default: break; } @@ -900,6 +905,24 @@ void QWindowsContext::handleFocusEvent(QtWindows::WindowsEventType et, } } +#ifndef QT_NO_CONTEXTMENU +void QWindowsContext::handleContextMenuEvent(QWindow *window, const MSG &msg) +{ + bool mouseTriggered = false; + QPoint globalPos; + QPoint pos; + if (msg.lParam != (int)0xffffffff) { + mouseTriggered = true; + globalPos.setX(msg.pt.x); + globalPos.setY(msg.pt.y); + pos = QWindowsGeometryHint::mapFromGlobal(msg.hwnd, globalPos); + } + + QWindowSystemInterface::handleContextMenuEvent(window, mouseTriggered, pos, globalPos, + QWindowsKeyMapper::queryKeyboardModifiers()); +} +#endif + /*! \brief Windows functions for actual windows. diff --git a/src/plugins/platforms/windows/qwindowscontext.h b/src/plugins/platforms/windows/qwindowscontext.h index dcc636bfc0..ef48a52e07 100644 --- a/src/plugins/platforms/windows/qwindowscontext.h +++ b/src/plugins/platforms/windows/qwindowscontext.h @@ -187,6 +187,9 @@ public: private: void handleFocusEvent(QtWindows::WindowsEventType et, QWindowsWindow *w); +#ifndef QT_NO_CONTEXTMENU + void handleContextMenuEvent(QWindow *window, const MSG &msg); +#endif void unregisterWindowClasses(); QScopedPointer<QWindowsContextPrivate> d; |