1 | /* |
2 | Copyright (C) 2001 Ellis Whitehead <ellis@kde.org> |
3 | |
4 | Win32 port: |
5 | Copyright (C) 2004 Jarosław Staniek <staniek@kde.org> |
6 | |
7 | This library is free software; you can redistribute it and/or |
8 | modify it under the terms of the GNU Library General Public |
9 | License as published by the Free Software Foundation; either |
10 | version 2 of the License, or (at your option) any later version. |
11 | |
12 | This library is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 | Library General Public License for more details. |
16 | |
17 | You should have received a copy of the GNU Library General Public License |
18 | along with this library; see the file COPYING.LIB. If not, write to |
19 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
20 | Boston, MA 02110-1301, USA. |
21 | */ |
22 | |
23 | #ifndef _KKEYSERVER_X11_H |
24 | #define _KKEYSERVER_X11_H |
25 | |
26 | #include "kshortcut.h" |
27 | #include <X11/Xlib.h> |
28 | #include <fixx11h.h> |
29 | |
30 | namespace KKeyServer |
31 | { |
32 | static const int MODE_SWITCH = 0x2000; |
33 | |
34 | /** |
35 | * Initialises the values to return for the mod*() functions below. |
36 | * Called automatically by those functions if not already initialized. |
37 | */ |
38 | KDEUI_EXPORT bool initializeMods(); |
39 | |
40 | /** |
41 | * Returns true if the current keyboard layout supports the Meta key. |
42 | * Specifically, whether the Super or Meta keys are assigned to an X modifier. |
43 | * @return true if the keyboard has a Meta key |
44 | * @see modXMeta() |
45 | */ |
46 | KDEUI_EXPORT bool keyboardHasMetaKey(); |
47 | |
48 | /** |
49 | * Returns the X11 Shift modifier mask/flag. |
50 | * @return the X11 Shift modifier mask/flag. |
51 | * @see accelModMaskX() |
52 | */ |
53 | KDEUI_EXPORT uint modXShift(); |
54 | |
55 | /** |
56 | * Returns the X11 Lock modifier mask/flag. |
57 | * @return the X11 Lock modifier mask/flag. |
58 | * @see accelModMaskX() |
59 | */ |
60 | KDEUI_EXPORT uint modXLock(); |
61 | |
62 | /** |
63 | * Returns the X11 Ctrl modifier mask/flag. |
64 | * @return the X11 Ctrl modifier mask/flag. |
65 | * @see accelModMaskX() |
66 | */ |
67 | KDEUI_EXPORT uint modXCtrl(); |
68 | |
69 | /** |
70 | * Returns the X11 Alt (Mod1) modifier mask/flag. |
71 | * @return the X11 Alt (Mod1) modifier mask/flag. |
72 | * @see accelModMaskX() |
73 | */ |
74 | KDEUI_EXPORT uint modXAlt(); |
75 | |
76 | /** |
77 | * Returns the X11 Win (Mod3) modifier mask/flag. |
78 | * @return the X11 Win (Mod3) modifier mask/flag. |
79 | * @see keyboardHasWinKey() |
80 | * @see accelModMaskX() |
81 | */ |
82 | KDEUI_EXPORT uint modXMeta(); |
83 | |
84 | /** |
85 | * Returns the X11 NumLock modifier mask/flag. |
86 | * @return the X11 NumLock modifier mask/flag. |
87 | * @see accelModMaskX() |
88 | */ |
89 | KDEUI_EXPORT uint modXNumLock(); |
90 | |
91 | /** |
92 | * Returns the X11 ScrollLock modifier mask/flag. |
93 | * @return the X11 ScrollLock modifier mask/flag. |
94 | * @see accelModMaskX() |
95 | */ |
96 | KDEUI_EXPORT uint modXScrollLock(); |
97 | |
98 | /** |
99 | * Returns the X11 Mode_switch modifier mask/flag. |
100 | * @return the X11 Mode_switch modifier mask/flag. |
101 | * @see accelModMaskX() |
102 | */ |
103 | KDEUI_EXPORT uint modXModeSwitch(); |
104 | |
105 | /** |
106 | * Returns bitwise OR'ed mask containing Shift, Ctrl, Alt, and |
107 | * Win (if available). |
108 | * @see modXShift() |
109 | * @see modXLock() |
110 | * @see modXCtrl() |
111 | * @see modXAlt() |
112 | * @see modXNumLock() |
113 | * @see modXWin() |
114 | * @see modXScrollLock() |
115 | */ |
116 | KDEUI_EXPORT uint accelModMaskX(); |
117 | |
118 | /** |
119 | * Extracts the symbol from the given Qt key and |
120 | * converts it to an X11 symbol + modifiers. |
121 | * @param keyQt the qt key code |
122 | * @param sym if successful, the symbol will be written here |
123 | * @return true if successful, false otherwise |
124 | */ |
125 | KDEUI_EXPORT bool keyQtToSymX( int keyQt, int* sym ); |
126 | |
127 | /** |
128 | * Extracts the code from the given Qt key. |
129 | * @param keyQt the qt key code |
130 | * @param keyCode if successful, the symbol will be written here |
131 | * @return true if successful, false otherwise |
132 | */ |
133 | KDEUI_EXPORT bool keyQtToCodeX( int keyQt, int* keyCode ); |
134 | |
135 | /** |
136 | * Extracts the modifiers from the given Qt key and |
137 | * converts them in a mask of X11 modifiers. |
138 | * @param keyQt the qt key code |
139 | * @param mod if successful, the modifiers will be written here |
140 | * @return true if successful, false otherwise |
141 | */ |
142 | KDEUI_EXPORT bool keyQtToModX( int keyQt, uint* mod ); |
143 | |
144 | /** |
145 | * Converts the given symbol to a Qt key code. |
146 | * @param sym the symbol |
147 | * @param keyQt if successful, the qt key code will be written here |
148 | * @return true if successful, false otherwise |
149 | */ |
150 | KDEUI_EXPORT bool symXToKeyQt( uint sym, int* keyQt ); |
151 | |
152 | /** |
153 | * Converts the mask of ORed X11 modifiers to |
154 | * a mask of ORed Qt key code modifiers. |
155 | * @param modX the mask of X11 modifiers |
156 | * @param modQt the mask of Qt key code modifiers will be written here |
157 | * if successful |
158 | * @return true if successful, false otherwise |
159 | */ |
160 | KDEUI_EXPORT bool modXToQt( uint modX, int* modQt ); |
161 | |
162 | /** |
163 | * Converts an X keypress event into a Qt key + modifier code |
164 | * @param e the X11 keypress event |
165 | * @param keyModQt the Qt keycode and mask of Qt key code modifiers will be written here |
166 | * if successful |
167 | * @return true if successful, false otherwise |
168 | */ |
169 | KDEUI_EXPORT bool xEventToQt( XEvent* e, int* keyModQt ); |
170 | } |
171 | |
172 | #endif // !_KKEYSERVER_X11_H |
173 | |