Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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
4#ifndef QWINDOWSKEYMAPPER_H
5#define QWINDOWSKEYMAPPER_H
6
7#include <QtCore/qt_windows.h>
8
9#include <QtCore/qlocale.h>
10
11#include <qpa/qplatformkeymapper.h>
12
14
15class QKeyEvent;
16class QWindow;
17
18/*
19 \internal
20 A Windows KeyboardLayoutItem has 8 possible states:
21 1. Unmodified
22 2. Shift
23 3. Control
24 4. Control + Shift
25 5. Alt
26 6. Alt + Shift
27 7. Alt + Control
28 8. Alt + Control + Shift
29*/
32 uint exists : 1; // whether this item has been initialized (by updatePossibleKeyCodes)
34 static const size_t NumQtKeys = 9;
35 quint32 qtKey[NumQtKeys]; // Can by any Qt::Key_<foo>, or unicode character
36};
37
39{
40 Q_DISABLE_COPY_MOVE(QWindowsKeyMapper)
41public:
42 explicit QWindowsKeyMapper();
44
45 void changeKeyboard();
46
47 void setUseRTLExtensions(bool e) { m_useRTLExtensions = e; }
48 bool useRTLExtensions() const { return m_useRTLExtensions; }
49
50 void setDetectAltGrModifier(bool a) { m_detectAltGrModifier = a; }
51 bool detectAltGrModifier() const { return m_detectAltGrModifier; }
52
53 bool translateKeyEvent(QWindow *widget, HWND hwnd, const MSG &msg, LRESULT *result);
54
55 QWindow *keyGrabber() const { return m_keyGrabber; }
56 void setKeyGrabber(QWindow *w) { m_keyGrabber = w; }
57
58 Qt::KeyboardModifiers queryKeyboardModifiers() const override;
59 QList<QKeyCombination> possibleKeyCombinations(const QKeyEvent *e) const override;
60
61private:
62 bool translateKeyEventInternal(QWindow *receiver, MSG msg, bool grab, LRESULT *lResult);
63 bool translateMultimediaKeyEventInternal(QWindow *receiver, const MSG &msg);
64 void updateKeyMap(const MSG &msg);
65
66 bool m_useRTLExtensions;
67
68 QLocale keyboardInputLocale;
69 Qt::LayoutDirection keyboardInputDirection;
70
71 void updatePossibleKeyCodes(unsigned char *kbdBuffer, quint32 scancode, quint32 vk_key);
72 void deleteLayouts();
73
74 QWindow *m_keyGrabber;
75 QChar m_lastHighSurrogate;
76 static const size_t NumKeyboardLayoutItems = 256;
77 KeyboardLayoutItem keyLayout[NumKeyboardLayoutItems];
78 bool m_detectAltGrModifier = false;
79 bool m_seenAltGr = false;
80
81};
82
84 ShiftLeft = 0x00000001,
85 ControlLeft = 0x00000002,
86 AltLeft = 0x00000004,
87 MetaLeft = 0x00000008,
88 ShiftRight = 0x00000010,
89 ControlRight = 0x00000020,
90 AltRight = 0x00000040,
91 MetaRight = 0x00000080,
92 CapsLock = 0x00000100,
93 NumLock = 0x00000200,
94 ScrollLock = 0x00000400,
95 ExtendedKey = 0x01000000,
96
97 // Convenience mappings
98 ShiftAny = 0x00000011,
99 ControlAny = 0x00000022,
100 AltAny = 0x00000044,
101 MetaAny = 0x00000088,
102 LockAny = 0x00000700
104
106
107#endif // QWINDOWSKEYMAPPER_H
\inmodule QtCore
The QKeyEvent class describes a key event.
Definition qevent.h:424
\inmodule QtGui
Definition qwindow.h:63
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
QOpenGLWidget * widget
[1]
Combined button and popup list for selecting options.
LayoutDirection
GLfloat GLfloat GLfloat w
[0]
GLboolean GLboolean GLboolean GLboolean a
[7]
GLuint64EXT * result
[6]
unsigned int quint32
Definition qtypes.h:50
unsigned int uint
Definition qtypes.h:34
unsigned char quint8
Definition qtypes.h:46
struct tagMSG MSG
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