Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qwindowskeymapper.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5#ifndef QWINDOWSKEYMAPPER_H
6#define QWINDOWSKEYMAPPER_H
7
8#include <QtCore/qt_windows.h>
9
10#include <QtCore/qlocale.h>
11
12#include <qpa/qplatformkeymapper.h>
13
14QT_BEGIN_NAMESPACE
15
16class QKeyEvent;
17class QWindow;
18
19/*
20 \internal
21 A Windows KeyboardLayoutItem has 8 possible states:
22 1. Unmodified
23 2. Shift
24 3. Control
25 4. Control + Shift
26 5. Alt
27 6. Alt + Shift
28 7. Alt + Control
29 8. Alt + Control + Shift
30*/
33 uint exists : 1; // whether this item has been initialized (by updatePossibleKeyCodes)
35 static const size_t NumQtKeys = 9;
36 quint32 qtKey[NumQtKeys]; // Can by any Qt::Key_<foo>, or unicode character
37};
38
40{
42public:
43 explicit QWindowsKeyMapper();
45
46 void changeKeyboard();
47
48 void setUseRTLExtensions(bool e) { m_useRTLExtensions = e; }
49 bool useRTLExtensions() const { return m_useRTLExtensions; }
50
51 void setDetectAltGrModifier(bool a) { m_detectAltGrModifier = a; }
52 bool detectAltGrModifier() const { return m_detectAltGrModifier; }
53
54 bool translateKeyEvent(QWindow *widget, HWND hwnd, const MSG &msg, LRESULT *result);
55
56 QWindow *keyGrabber() const { return m_keyGrabber; }
57 void setKeyGrabber(QWindow *w) { m_keyGrabber = w; }
58
60 QList<QKeyCombination> possibleKeyCombinations(const QKeyEvent *e) const override;
61
62private:
63 bool translateKeyEventInternal(QWindow *receiver, MSG msg, bool grab, LRESULT *lResult);
64 bool translateMultimediaKeyEventInternal(QWindow *receiver, const MSG &msg);
65 void updateKeyMap(const MSG &msg);
66
67 bool m_useRTLExtensions;
68
69 QLocale keyboardInputLocale;
70 Qt::LayoutDirection keyboardInputDirection;
71
72 void updatePossibleKeyCodes(unsigned char *kbdBuffer, quint32 scancode, quint32 vk_key);
73 void deleteLayouts();
74
75 QWindow *m_keyGrabber;
76 QChar m_lastHighSurrogate;
77 static const size_t NumKeyboardLayoutItems = 256;
78 KeyboardLayoutItem keyLayout[NumKeyboardLayoutItems];
79 bool m_detectAltGrModifier = false;
80 bool m_seenAltGr = false;
81
82};
83
85 ShiftLeft = 0x00000001,
86 ControlLeft = 0x00000002,
87 AltLeft = 0x00000004,
88 MetaLeft = 0x00000008,
89 ShiftRight = 0x00000010,
90 ControlRight = 0x00000020,
91 AltRight = 0x00000040,
92 MetaRight = 0x00000080,
93 CapsLock = 0x00000100,
94 NumLock = 0x00000200,
95 ScrollLock = 0x00000400,
96 ExtendedKey = 0x01000000,
97
98 // Convenience mappings
99 ShiftAny = 0x00000011,
100 ControlAny = 0x00000022,
101 AltAny = 0x00000044,
102 MetaAny = 0x00000088,
103 LockAny = 0x00000700
104};
105
106QT_END_NAMESPACE
107
108#endif // QWINDOWSKEYMAPPER_H
\inmodule QtCore\reentrant
Definition qpoint.h:30
Singleton container for all relevant information.
QSharedPointer< QWindowCreationContext > windowCreationContext() const
QWindowsScreenManager & screenManager()
QWindowsWindow * findClosestPlatformWindow(HWND) const
QWindow * findWindow(HWND) const
bool asyncExpose() const
void addWindow(HWND, QWindowsWindow *w)
static bool systemParametersInfoForScreen(unsigned action, unsigned param, void *out, const QPlatformScreen *screen=nullptr)
static bool setProcessDpiAwareness(QtWindows::DpiAwareness dpiAwareness)
HDC displayContext() const
QWindowsTabletSupport * tabletSupport() const
static bool systemParametersInfoForWindow(unsigned action, unsigned param, void *out, const QPlatformWindow *win=nullptr)
static void setTabletAbsoluteRange(int a)
QWindowsWindow * findPlatformWindowAt(HWND parent, const QPoint &screenPoint, unsigned cwex_flags) const
bool initTouch(unsigned integrationOptions)
HWND createDummyWindow(const QString &classNameIn, const wchar_t *windowName, WNDPROC wndProc=nullptr, DWORD style=WS_OVERLAPPED)
Convenience to create a non-visible, message-only dummy window for example used as clipboard watcher ...
void setAsyncExpose(bool value)
QSharedPointer< QWindowCreationContext > setWindowCreationContext(const QSharedPointer< QWindowCreationContext > &ctx)
bool windowsProc(HWND hwnd, UINT message, QtWindows::WindowsEventType et, WPARAM wParam, LPARAM lParam, LRESULT *result, QWindowsWindow **platformWindowPtr)
Main windows procedure registered for windows.
unsigned systemInfo() const
static QtWindows::DpiAwareness processDpiAwareness()
QWindowsWindow * findPlatformWindow(HWND) const
QWindow * keyGrabber() const
QWindowsWindow * findPlatformWindow(const QWindowsMenuBar *mb) const
QWindow * windowUnderMouse() const
QPlatformKeyMapper * keyMapper() const
bool useRTLExtensions() const
static bool systemParametersInfo(unsigned action, unsigned param, void *out, unsigned dpi=0)
QWindowsMimeRegistry & mimeConverter() const
static bool isSessionLocked()
int screenDepth() const
bool initPowerNotificationHandler()
HandleBaseWindowHash & windows()
static QWindowsContext * instance()
void setDetectAltGrModifier(bool a)
Platform cursor implementation.
static bool hasOverrideCursor()
static void enforceOverrideCursor()
Windows Input context implementation.
static void setWindowsImeEnabled(QWindowsWindow *platformWindow, bool enabled)
static QWindowsIntegration * instance()
Translates Windows keys to QWindowSystemInterface events.
bool translateKeyEvent(QWindow *widget, HWND hwnd, const MSG &msg, LRESULT *result)
To be called from the window procedure.
bool detectAltGrModifier() const
void setUseRTLExtensions(bool e)
QWindow * keyGrabber() const
Qt::KeyboardModifiers queryKeyboardModifiers() const override
bool useRTLExtensions() const
void setKeyGrabber(QWindow *w)
void setDetectAltGrModifier(bool a)
QList< QKeyCombination > possibleKeyCombinations(const QKeyEvent *e) const override
Windows native menu bar.
Manages the list of QWindowsMimeConverter instances.
Manages a list of QWindowsScreen.
Tablet support for Windows.
static QWindowsTheme * instance()
Raster or OpenGL Window.
void alertWindow(int durationMs=0)
bool testFlag(unsigned f) const
void setFlag(unsigned f) const
void clearFlag(unsigned f) const
static void settingsChanged()
static const char * embeddedNativeParentHandleProperty
QWindowsMenuBar * menuBar() const
bool frameStrutEventsEnabled() const override
Reimplement this method to return whether frame strut events are enabled.
@ WithinSetParent
Automatic mouse capture on button press.
void handleCompositionSettingsChanged()
WindowsEventType
Enumerations for WM_XX events.
@ PointerActivateWindowEvent
@ InputMethodEndCompositionEvent
@ ShowEventOnParentRestoring
@ InputMethodCompositionEvent
@ InputMethodOpenCandidateWindowEvent
@ MouseActivateWindowEvent
@ DpiChangedAfterParentEvent
@ InputMethodStartCompositionEvent
@ CompositionSettingsChanged
@ InputMethodCloseCandidateWindowEvent
@ AccessibleObjectFromWindowRequest
Q_LOGGING_CATEGORY(lcEventDispatcher, "qt.eventdispatcher")
#define WM_TOUCH
#define DPI_AWARENESS_CONTEXT_UNAWARE
#define DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE
#define DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2
#define DPI_AWARENESS_CONTEXT_SYSTEM_AWARE
#define DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED
static bool isTopLevel(HWND hwnd)
#define LANG_SYRIAC
static RECT rectFromNcCalcSize(UINT message, WPARAM wParam, LPARAM lParam, int n)
static bool enableNonClientDpiScaling(HWND hwnd)
static bool isInputMessage(UINT m)
static DPI_AWARENESS_CONTEXT qtDpiAwarenessToDpiAwarenessContext(QtWindows::DpiAwareness dpiAwareness)
static bool isMinimized(HWND hwnd)
static QMargins marginsFromRects(const RECT &frame, const RECT &client)
static bool useRTL_Extensions()
static bool sessionManagerInteractionBlocked()
static QWindowsInputContext * windowsInputContext()
static QtWindows::DpiAwareness dpiAwarenessContextToQtDpiAwareness(DPI_AWARENESS_CONTEXT context)
static QByteArray nativeEventType()
static bool isEmptyRect(const RECT &rect)
static bool findPlatformWindowHelper(const POINT &screenPoint, unsigned cwexFlags, const QWindowsContext *context, HWND *hwnd, QWindowsWindow **result)
Find a child window at a screen point.
WindowsNativeModifiers
@ ScrollLock
@ ExtendedKey
@ ShiftRight
@ LockAny
@ AltLeft
@ ShiftLeft
@ MetaRight
@ MetaLeft
@ MetaAny
@ AltRight
@ ControlLeft
@ ControlRight
@ CapsLock
@ NumLock
@ ShiftAny
@ ControlAny
quint32 qtKey[NumQtKeys]
static const size_t NumQtKeys
const HRESULT m_oleInitializeResult
QWindowsKeyMapper m_keyMapper
QWindowsWindowClassRegistry m_windowClassRegistry
QWindowsPointerHandler m_pointerHandler
QUniqueHDCHandle m_displayContext
QWindowsScreenManager m_screenManager
QWindowsMimeRegistry m_mimeConverter
QWindowsContext::HandleBaseWindowHash m_windows
QSharedPointer< QWindowCreationContext > m_creationContext