KWindowSystem

kkeyserver_x11.h
1 /*
2  SPDX-FileCopyrightText: 2001 Ellis Whitehead <[email protected]>
3 
4  Win32 port:
5  SPDX-FileCopyrightText: 2004 JarosÅ‚aw Staniek <[email protected]>
6 
7  SPDX-License-Identifier: LGPL-2.1-or-later
8 */
9 
10 #ifndef _KKEYSERVER_X11_H
11 #define _KKEYSERVER_X11_H
12 
13 #include <X11/Xlib.h>
14 #include <fixx11h.h>
15 #include <kwindowsystem_export.h>
16 #include <xcb/xcb.h>
17 
18 namespace KKeyServer
19 {
20 static const int MODE_SWITCH = 0x2000;
21 
22 /**
23  * Initialises the values to return for the mod*() functions below.
24  * Called automatically by those functions if not already initialized.
25  */
26 KWINDOWSYSTEM_EXPORT bool initializeMods();
27 
28 /**
29  * Returns true if the current keyboard layout supports the Meta key.
30  * Specifically, whether the Super or Meta keys are assigned to an X modifier.
31  * @return true if the keyboard has a Meta key
32  * @see modXMeta()
33  */
34 KWINDOWSYSTEM_EXPORT bool keyboardHasMetaKey();
35 
36 /**
37  * Returns the X11 Shift modifier mask/flag.
38  * @return the X11 Shift modifier mask/flag.
39  * @see accelModMaskX()
40  */
41 KWINDOWSYSTEM_EXPORT uint modXShift();
42 
43 /**
44  * Returns the X11 Lock modifier mask/flag.
45  * @return the X11 Lock modifier mask/flag.
46  * @see accelModMaskX()
47  */
48 KWINDOWSYSTEM_EXPORT uint modXLock();
49 
50 /**
51  * Returns the X11 Ctrl modifier mask/flag.
52  * @return the X11 Ctrl modifier mask/flag.
53  * @see accelModMaskX()
54  */
55 KWINDOWSYSTEM_EXPORT uint modXCtrl();
56 
57 /**
58  * Returns the X11 Alt (Mod1) modifier mask/flag.
59  * @return the X11 Alt (Mod1) modifier mask/flag.
60  * @see accelModMaskX()
61  */
62 KWINDOWSYSTEM_EXPORT uint modXAlt();
63 
64 /**
65  * Returns the X11 Win (Mod3) modifier mask/flag.
66  * @return the X11 Win (Mod3) modifier mask/flag.
67  * @see keyboardHasWinKey()
68  * @see accelModMaskX()
69  */
70 KWINDOWSYSTEM_EXPORT uint modXMeta();
71 
72 /**
73  * Returns the X11 NumLock modifier mask/flag.
74  * @return the X11 NumLock modifier mask/flag.
75  * @see accelModMaskX()
76  */
77 KWINDOWSYSTEM_EXPORT uint modXNumLock();
78 
79 /**
80  * Returns the X11 ScrollLock modifier mask/flag.
81  * @return the X11 ScrollLock modifier mask/flag.
82  * @see accelModMaskX()
83  */
84 KWINDOWSYSTEM_EXPORT uint modXScrollLock();
85 
86 /**
87  * Returns the X11 Mode_switch modifier mask/flag.
88  * @return the X11 Mode_switch modifier mask/flag.
89  * @see accelModMaskX()
90  */
91 KWINDOWSYSTEM_EXPORT uint modXModeSwitch();
92 
93 /**
94  * Returns bitwise OR'ed mask containing Shift, Ctrl, Alt, and
95  * Win (if available).
96  * @see modXShift()
97  * @see modXLock()
98  * @see modXCtrl()
99  * @see modXAlt()
100  * @see modXNumLock()
101  * @see modXWin()
102  * @see modXScrollLock()
103  */
104 KWINDOWSYSTEM_EXPORT uint accelModMaskX();
105 
106 /**
107  * Extracts the symbol from the given Qt key and
108  * converts it to an X11 symbol + modifiers.
109  * @param keyQt the qt key code
110  * @param sym if successful, the symbol will be written here
111  * @return true if successful, false otherwise
112  */
113 KWINDOWSYSTEM_EXPORT bool keyQtToSymX(int keyQt, int *sym);
114 
115 /**
116  * Extracts the code from the given Qt key.
117  * @param keyQt the qt key code
118  * @param keyCode if successful, the symbol will be written here
119  * @return true if successful, false otherwise
120  */
121 KWINDOWSYSTEM_EXPORT bool keyQtToCodeX(int keyQt, int *keyCode);
122 
123 /**
124  * Extracts the modifiers from the given Qt key and
125  * converts them in a mask of X11 modifiers.
126  * @param keyQt the qt key code
127  * @param mod if successful, the modifiers will be written here
128  * @return true if successful, false otherwise
129  */
130 KWINDOWSYSTEM_EXPORT bool keyQtToModX(int keyQt, uint *mod);
131 
132 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 38)
133 /**
134  * Converts the given symbol to a Qt key code.
135  * @param sym the symbol
136  * @param keyQt if successful, the qt key code will be written here
137  * @return true if successful, false otherwise
138  * @deprecated since 5.38, use symXModXToKeyQt in order to support numeric keypad keys too
139  */
140 KWINDOWSYSTEM_EXPORT
141 KWINDOWSYSTEM_DEPRECATED_VERSION(5, 38, "Use KKeyServer::symXModXToKeyQt(uint32_t, uint16_t, int *)")
142 bool symXToKeyQt(uint sym, int *keyQt);
143 #endif
144 
145 /**
146  * Converts the given symbol and modifier combination to a Qt key code.
147  * @param keySym the X key symbol
148  * @param modX the mask of X11 modifiers
149  * @param keyQt if successful, the qt key code will be written here
150  * @return true if successful, false otherwise
151  */
152 KWINDOWSYSTEM_EXPORT bool symXModXToKeyQt(uint32_t keySym, uint16_t modX, int *keyQt);
153 
154 /**
155  * Converts the mask of ORed X11 modifiers to
156  * a mask of ORed Qt key code modifiers.
157  * @param modX the mask of X11 modifiers
158  * @param modQt the mask of Qt key code modifiers will be written here
159  * if successful
160  * @return true if successful, false otherwise
161  */
162 KWINDOWSYSTEM_EXPORT bool modXToQt(uint modX, int *modQt);
163 
164 /**
165  * Converts an X keypress event into a Qt key + modifier code
166  * @param e the X11 keypress event
167  * @param keyModQt the Qt keycode and mask of Qt key code modifiers will be written here
168  * if successful
169  * @return true if successful, false otherwise
170  */
171 KWINDOWSYSTEM_EXPORT bool xEventToQt(XEvent *e, int *keyModQt);
172 
173 /**
174  * Converts an XCB keypress event into a Qt key + modifier code
175  * @param e the XCB keypress event
176  * @param keyModQt the Qt keycode and mask of Qt key code modifiers will be written here
177  * if successful
178  * @return true if successful, false otherwise
179  */
180 KWINDOWSYSTEM_EXPORT bool xcbKeyPressEventToQt(xcb_generic_event_t *e, int *keyModQt);
181 /**
182  * Overloaded method for convenience.
183  */
184 KWINDOWSYSTEM_EXPORT bool xcbKeyPressEventToQt(xcb_key_press_event_t *e, int *keyModQt);
185 
186 }
187 
188 #endif // !_KKEYSERVER_X11_H
uint modXShift()
Returns the X11 Shift modifier mask/flag.
bool keyQtToSymX(int keyQt, int *keySym)
Extracts the symbol from the given Qt key and converts it to an X11 symbol + modifiers.
A collection of functions for the conversion of key presses and their modifiers from the window syste...
Definition: kkeyserver.cpp:14
bool initializeMods()
Initialises the values to return for the mod*() functions below.
uint modXAlt()
Returns the X11 Alt (Mod1) modifier mask/flag.
uint accelModMaskX()
Returns bitwise OR&#39;ed mask containing Shift, Ctrl, Alt, and Win (if available).
uint modXCtrl()
Returns the X11 Ctrl modifier mask/flag.
bool keyQtToCodeX(int keyQt, int *keyCode)
Extracts the code from the given Qt key.
bool symXModXToKeyQt(uint32_t keySym, uint16_t modX, int *keyQt)
Converts the given symbol and modifier combination to a Qt key code.
bool symXToKeyQt(uint keySym, int *keyQt)
Converts the given symbol to a Qt key code.
bool keyQtToModX(int modQt, uint *modX)
Extracts the modifiers from the given Qt key and converts them in a mask of X11 modifiers.
uint modXLock()
Returns the X11 Lock modifier mask/flag.
bool xcbKeyPressEventToQt(xcb_generic_event_t *e, int *keyQt)
Converts an XCB keypress event into a Qt key + modifier code.
uint modXScrollLock()
Returns the X11 ScrollLock modifier mask/flag.
bool keyboardHasMetaKey()
Returns true if the current keyboard layout supports the Meta key.
uint modXNumLock()
Returns the X11 NumLock modifier mask/flag.
uint modXMeta()
Returns the X11 Win (Mod3) modifier mask/flag.
bool modXToQt(uint modX, int *modQt)
Converts the mask of ORed X11 modifiers to a mask of ORed Qt key code modifiers.
uint modXModeSwitch()
Returns the X11 Mode_switch modifier mask/flag.
bool xEventToQt(XEvent *e, int *keyQt)
Converts an X keypress event into a Qt key + modifier code.
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Fri Oct 15 2021 22:41:49 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.