File: | var/lib/jenkins/workspace/firefox-scan-build/widget/gtk/nsGtkKeyUtils.cpp |
Warning: | line 1487, column 5 Value stored to 'handlingState' is never read |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 | /* vim:expandtab:shiftwidth=4:tabstop=4: |
3 | */ |
4 | /* This Source Code Form is subject to the terms of the Mozilla Public |
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
7 | |
8 | #include "mozilla/Logging.h" |
9 | |
10 | #include "nsGtkKeyUtils.h" |
11 | |
12 | #include <gdk/gdkkeysyms.h> |
13 | #include <algorithm> |
14 | #include <gdk/gdk.h> |
15 | #include <dlfcn.h> |
16 | #include <gdk/gdkkeysyms-compat.h> |
17 | #ifdef MOZ_X111 |
18 | # include <gdk/gdkx.h> |
19 | # include <X11/XKBlib.h> |
20 | # include "X11UndefineNone.h" |
21 | #endif |
22 | #include "IMContextWrapper.h" |
23 | #include "WidgetUtils.h" |
24 | #include "WidgetUtilsGtk.h" |
25 | #include "x11/keysym2ucs.h" |
26 | #include "nsContentUtils.h" |
27 | #include "nsGtkUtils.h" |
28 | #include "nsIBidiKeyboard.h" |
29 | #include "nsPrintfCString.h" |
30 | #include "nsReadableUtils.h" |
31 | #include "nsServiceManagerUtils.h" |
32 | #include "nsWindow.h" |
33 | |
34 | #include "mozilla/ArrayUtils.h" |
35 | #include "mozilla/Maybe.h" |
36 | #include "mozilla/MouseEvents.h" |
37 | #include "mozilla/StaticPrefs_dom.h" |
38 | #include "mozilla/TextEventDispatcher.h" |
39 | #include "mozilla/TextEvents.h" |
40 | |
41 | #ifdef MOZ_WAYLAND1 |
42 | # include <sys/mman.h> |
43 | # include "nsWaylandDisplay.h" |
44 | #endif |
45 | |
46 | // For collecting other people's log, tell them `MOZ_LOG=KeyboardHandler:4,sync` |
47 | // rather than `MOZ_LOG=KeyboardHandler:5,sync` since using `5` may create too |
48 | // big file. |
49 | // Therefore you shouldn't use `LogLevel::Verbose` for logging usual behavior. |
50 | mozilla::LazyLogModule gKeyLog("KeyboardHandler"); |
51 | |
52 | namespace mozilla { |
53 | namespace widget { |
54 | |
55 | #define IS_ASCII_ALPHABETICAL(key)((('a' <= key) && (key <= 'z')) || (('A' <= key ) && (key <= 'Z'))) \ |
56 | ((('a' <= key) && (key <= 'z')) || (('A' <= key) && (key <= 'Z'))) |
57 | |
58 | #define MOZ_MODIFIER_KEYS"MozKeymapWrapper" "MozKeymapWrapper" |
59 | |
60 | KeymapWrapper* KeymapWrapper::sInstance = nullptr; |
61 | guint KeymapWrapper::sLastRepeatableHardwareKeyCode = 0; |
62 | #ifdef MOZ_X111 |
63 | Time KeymapWrapper::sLastRepeatableKeyTime = 0; |
64 | #endif |
65 | KeymapWrapper::RepeatState KeymapWrapper::sRepeatState = |
66 | KeymapWrapper::NOT_PRESSED; |
67 | |
68 | static const char* GetBoolName(bool aBool) { return aBool ? "TRUE" : "FALSE"; } |
69 | |
70 | static const char* GetStatusName(nsEventStatus aStatus) { |
71 | switch (aStatus) { |
72 | case nsEventStatus_eConsumeDoDefault: |
73 | return "nsEventStatus_eConsumeDoDefault"; |
74 | case nsEventStatus_eConsumeNoDefault: |
75 | return "nsEventStatus_eConsumeNoDefault"; |
76 | case nsEventStatus_eIgnore: |
77 | return "nsEventStatus_eIgnore"; |
78 | case nsEventStatus_eSentinel: |
79 | return "nsEventStatus_eSentinel"; |
80 | default: |
81 | return "Illegal value"; |
82 | } |
83 | } |
84 | |
85 | static const nsCString GetKeyLocationName(uint32_t aLocation) { |
86 | switch (aLocation) { |
87 | case eKeyLocationLeft: |
88 | return "KEY_LOCATION_LEFT"_ns; |
89 | case eKeyLocationRight: |
90 | return "KEY_LOCATION_RIGHT"_ns; |
91 | case eKeyLocationStandard: |
92 | return "KEY_LOCATION_STANDARD"_ns; |
93 | case eKeyLocationNumpad: |
94 | return "KEY_LOCATION_NUMPAD"_ns; |
95 | default: |
96 | return nsPrintfCString("Unknown (0x%04X)", aLocation); |
97 | } |
98 | } |
99 | |
100 | static const nsCString GetCharacterCodeName(char16_t aChar) { |
101 | switch (aChar) { |
102 | case 0x0000: |
103 | return "NULL (0x0000)"_ns; |
104 | case 0x0008: |
105 | return "BACKSPACE (0x0008)"_ns; |
106 | case 0x0009: |
107 | return "CHARACTER TABULATION (0x0009)"_ns; |
108 | case 0x000A: |
109 | return "LINE FEED (0x000A)"_ns; |
110 | case 0x000B: |
111 | return "LINE TABULATION (0x000B)"_ns; |
112 | case 0x000C: |
113 | return "FORM FEED (0x000C)"_ns; |
114 | case 0x000D: |
115 | return "CARRIAGE RETURN (0x000D)"_ns; |
116 | case 0x0018: |
117 | return "CANCEL (0x0018)"_ns; |
118 | case 0x001B: |
119 | return "ESCAPE (0x001B)"_ns; |
120 | case 0x0020: |
121 | return "SPACE (0x0020)"_ns; |
122 | case 0x007F: |
123 | return "DELETE (0x007F)"_ns; |
124 | case 0x00A0: |
125 | return "NO-BREAK SPACE (0x00A0)"_ns; |
126 | case 0x00AD: |
127 | return "SOFT HYPHEN (0x00AD)"_ns; |
128 | case 0x2000: |
129 | return "EN QUAD (0x2000)"_ns; |
130 | case 0x2001: |
131 | return "EM QUAD (0x2001)"_ns; |
132 | case 0x2002: |
133 | return "EN SPACE (0x2002)"_ns; |
134 | case 0x2003: |
135 | return "EM SPACE (0x2003)"_ns; |
136 | case 0x2004: |
137 | return "THREE-PER-EM SPACE (0x2004)"_ns; |
138 | case 0x2005: |
139 | return "FOUR-PER-EM SPACE (0x2005)"_ns; |
140 | case 0x2006: |
141 | return "SIX-PER-EM SPACE (0x2006)"_ns; |
142 | case 0x2007: |
143 | return "FIGURE SPACE (0x2007)"_ns; |
144 | case 0x2008: |
145 | return "PUNCTUATION SPACE (0x2008)"_ns; |
146 | case 0x2009: |
147 | return "THIN SPACE (0x2009)"_ns; |
148 | case 0x200A: |
149 | return "HAIR SPACE (0x200A)"_ns; |
150 | case 0x200B: |
151 | return "ZERO WIDTH SPACE (0x200B)"_ns; |
152 | case 0x200C: |
153 | return "ZERO WIDTH NON-JOINER (0x200C)"_ns; |
154 | case 0x200D: |
155 | return "ZERO WIDTH JOINER (0x200D)"_ns; |
156 | case 0x200E: |
157 | return "LEFT-TO-RIGHT MARK (0x200E)"_ns; |
158 | case 0x200F: |
159 | return "RIGHT-TO-LEFT MARK (0x200F)"_ns; |
160 | case 0x2029: |
161 | return "PARAGRAPH SEPARATOR (0x2029)"_ns; |
162 | case 0x202A: |
163 | return "LEFT-TO-RIGHT EMBEDDING (0x202A)"_ns; |
164 | case 0x202B: |
165 | return "RIGHT-TO-LEFT EMBEDDING (0x202B)"_ns; |
166 | case 0x202D: |
167 | return "LEFT-TO-RIGHT OVERRIDE (0x202D)"_ns; |
168 | case 0x202E: |
169 | return "RIGHT-TO-LEFT OVERRIDE (0x202E)"_ns; |
170 | case 0x202F: |
171 | return "NARROW NO-BREAK SPACE (0x202F)"_ns; |
172 | case 0x205F: |
173 | return "MEDIUM MATHEMATICAL SPACE (0x205F)"_ns; |
174 | case 0x2060: |
175 | return "WORD JOINER (0x2060)"_ns; |
176 | case 0x2066: |
177 | return "LEFT-TO-RIGHT ISOLATE (0x2066)"_ns; |
178 | case 0x2067: |
179 | return "RIGHT-TO-LEFT ISOLATE (0x2067)"_ns; |
180 | case 0x3000: |
181 | return "IDEOGRAPHIC SPACE (0x3000)"_ns; |
182 | case 0xFEFF: |
183 | return "ZERO WIDTH NO-BREAK SPACE (0xFEFF)"_ns; |
184 | default: { |
185 | if (aChar < ' ' || (aChar >= 0x80 && aChar < 0xA0)) { |
186 | return nsPrintfCString("control (0x%04X)", aChar); |
187 | } |
188 | if (NS_IS_HIGH_SURROGATE(aChar)((uint32_t(aChar) & 0xFFFFFC00) == 0xD800)) { |
189 | return nsPrintfCString("high surrogate (0x%04X)", aChar); |
190 | } |
191 | if (NS_IS_LOW_SURROGATE(aChar)((uint32_t(aChar) & 0xFFFFFC00) == 0xDC00)) { |
192 | return nsPrintfCString("low surrogate (0x%04X)", aChar); |
193 | } |
194 | return nsPrintfCString("'%s' (0x%04X)", |
195 | NS_ConvertUTF16toUTF8(nsAutoString(aChar)).get(), |
196 | aChar); |
197 | } |
198 | } |
199 | } |
200 | |
201 | static const nsCString GetCharacterCodeNames(const char16_t* aChars, |
202 | uint32_t aLength) { |
203 | if (!aLength) { |
204 | return "\"\""_ns; |
205 | } |
206 | nsCString result; |
207 | result.AssignLiteral("\""); |
208 | StringJoinAppend(result, ", "_ns, Span{aChars, aLength}, |
209 | [](nsACString& dest, const char16_t charValue) { |
210 | dest.Append(GetCharacterCodeName(charValue)); |
211 | }); |
212 | result.AppendLiteral("\""); |
213 | return result; |
214 | } |
215 | |
216 | static const nsCString GetCharacterCodeNames(const nsAString& aString) { |
217 | return GetCharacterCodeNames(aString.BeginReading(), aString.Length()); |
218 | } |
219 | |
220 | /* static */ |
221 | const char* KeymapWrapper::GetModifierName(MappedModifier aModifier) { |
222 | switch (aModifier) { |
223 | case CAPS_LOCK: |
224 | return "CapsLock"; |
225 | case NUM_LOCK: |
226 | return "NumLock"; |
227 | case SCROLL_LOCK: |
228 | return "ScrollLock"; |
229 | case SHIFT: |
230 | return "Shift"; |
231 | case CTRL: |
232 | return "Ctrl"; |
233 | case ALT: |
234 | return "Alt"; |
235 | case SUPER: |
236 | return "Super"; |
237 | case HYPER: |
238 | return "Hyper"; |
239 | case META: |
240 | return "Meta"; |
241 | case LEVEL3: |
242 | return "Level3"; |
243 | case LEVEL5: |
244 | return "Level5"; |
245 | case NOT_MODIFIER: |
246 | return "NotModifier"; |
247 | default: |
248 | return "InvalidValue"; |
249 | } |
250 | } |
251 | |
252 | /* static */ |
253 | KeymapWrapper::MappedModifier KeymapWrapper::GetModifierForGDKKeyval( |
254 | guint aGdkKeyval) { |
255 | switch (aGdkKeyval) { |
256 | case GDK_Caps_Lock0xffe5: |
257 | return CAPS_LOCK; |
258 | case GDK_Num_Lock0xff7f: |
259 | return NUM_LOCK; |
260 | case GDK_Scroll_Lock0xff14: |
261 | return SCROLL_LOCK; |
262 | case GDK_Shift_Lock0xffe6: |
263 | case GDK_Shift_L0xffe1: |
264 | case GDK_Shift_R0xffe2: |
265 | return SHIFT; |
266 | case GDK_Control_L0xffe3: |
267 | case GDK_Control_R0xffe4: |
268 | return CTRL; |
269 | case GDK_Alt_L0xffe9: |
270 | case GDK_Alt_R0xffea: |
271 | return ALT; |
272 | case GDK_Super_L0xffeb: |
273 | case GDK_Super_R0xffec: |
274 | return SUPER; |
275 | case GDK_Hyper_L0xffed: |
276 | case GDK_Hyper_R0xffee: |
277 | return HYPER; |
278 | case GDK_Meta_L0xffe7: |
279 | case GDK_Meta_R0xffe8: |
280 | return META; |
281 | case GDK_ISO_Level3_Shift0xfe03: |
282 | case GDK_Mode_switch0xff7e: |
283 | return LEVEL3; |
284 | case GDK_ISO_Level5_Shift0xfe11: |
285 | return LEVEL5; |
286 | default: |
287 | return NOT_MODIFIER; |
288 | } |
289 | } |
290 | |
291 | guint KeymapWrapper::GetGdkModifierMask(MappedModifier aModifier) const { |
292 | switch (aModifier) { |
293 | case CAPS_LOCK: |
294 | return GDK_LOCK_MASK; |
295 | case NUM_LOCK: |
296 | return mModifierMasks[INDEX_NUM_LOCK]; |
297 | case SCROLL_LOCK: |
298 | return mModifierMasks[INDEX_SCROLL_LOCK]; |
299 | case SHIFT: |
300 | return GDK_SHIFT_MASK; |
301 | case CTRL: |
302 | return GDK_CONTROL_MASK; |
303 | case ALT: |
304 | return mModifierMasks[INDEX_ALT]; |
305 | case SUPER: |
306 | return GDK_SUPER_MASK; |
307 | case HYPER: |
308 | return mModifierMasks[INDEX_HYPER]; |
309 | case META: |
310 | return mModifierMasks[INDEX_META]; |
311 | case LEVEL3: |
312 | return mModifierMasks[INDEX_LEVEL3]; |
313 | case LEVEL5: |
314 | return mModifierMasks[INDEX_LEVEL5]; |
315 | default: |
316 | return 0; |
317 | } |
318 | } |
319 | |
320 | KeymapWrapper::ModifierKey* KeymapWrapper::GetModifierKey( |
321 | guint aHardwareKeycode) { |
322 | for (uint32_t i = 0; i < mModifierKeys.Length(); i++) { |
323 | ModifierKey& key = mModifierKeys[i]; |
324 | if (key.mHardwareKeycode == aHardwareKeycode) { |
325 | return &key; |
326 | } |
327 | } |
328 | return nullptr; |
329 | } |
330 | |
331 | /* static */ |
332 | KeymapWrapper* KeymapWrapper::GetInstance() { |
333 | if (!sInstance) { |
334 | sInstance = new KeymapWrapper(); |
335 | sInstance->Init(); |
336 | } |
337 | return sInstance; |
338 | } |
339 | |
340 | #ifdef MOZ_WAYLAND1 |
341 | void KeymapWrapper::EnsureInstance() { (void)GetInstance(); } |
342 | |
343 | void KeymapWrapper::InitBySystemSettingsWayland() { |
344 | MOZ_UNUSED(WaylandDisplayGet())do { if (WaylandDisplayGet()) { (void)0; } } while (0); |
345 | } |
346 | #endif |
347 | |
348 | /* static */ |
349 | void KeymapWrapper::Shutdown() { |
350 | if (sInstance) { |
351 | delete sInstance; |
352 | sInstance = nullptr; |
353 | } |
354 | } |
355 | |
356 | KeymapWrapper::KeymapWrapper() |
357 | : mInitialized(false), |
358 | mGdkKeymap(gdk_keymap_get_default()), |
359 | mXKBBaseEventCode(0), |
360 | mOnKeysChangedSignalHandle(0), |
361 | mOnDirectionChangedSignalHandle(0) { |
362 | MOZ_LOG(gKeyLog, LogLevel::Info,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p Constructor, mGdkKeymap=%p", this, mGdkKeymap ); } } while (0) |
363 | ("%p Constructor, mGdkKeymap=%p", this, mGdkKeymap))do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p Constructor, mGdkKeymap=%p", this, mGdkKeymap ); } } while (0); |
364 | |
365 | g_object_ref(mGdkKeymap); |
366 | |
367 | #ifdef MOZ_X111 |
368 | if (GdkIsX11Display()) { |
369 | InitXKBExtension(); |
370 | } |
371 | #endif |
372 | } |
373 | |
374 | void KeymapWrapper::Init() { |
375 | if (mInitialized) { |
376 | return; |
377 | } |
378 | mInitialized = true; |
379 | |
380 | MOZ_LOG(gKeyLog, LogLevel::Info,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p Init, mGdkKeymap=%p", this, mGdkKeymap) ; } } while (0) |
381 | ("%p Init, mGdkKeymap=%p", this, mGdkKeymap))do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p Init, mGdkKeymap=%p", this, mGdkKeymap) ; } } while (0); |
382 | |
383 | mModifierKeys.Clear(); |
384 | memset(mModifierMasks, 0, sizeof(mModifierMasks)); |
385 | |
386 | #ifdef MOZ_X111 |
387 | if (GdkIsX11Display()) { |
388 | InitBySystemSettingsX11(); |
389 | } |
390 | #endif |
391 | #ifdef MOZ_WAYLAND1 |
392 | if (GdkIsWaylandDisplay()) { |
393 | InitBySystemSettingsWayland(); |
394 | } |
395 | #endif |
396 | |
397 | #ifdef MOZ_X111 |
398 | gdk_window_add_filter(nullptr, FilterEvents, this); |
399 | #endif |
400 | |
401 | MOZ_LOG(gKeyLog, LogLevel::Info,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p Init, CapsLock=0x%X, NumLock=0x%X, " "ScrollLock=0x%X, Level3=0x%X, Level5=0x%X, " "Shift=0x%X, Ctrl=0x%X, Alt=0x%X, Meta=0x%X, Super=0x%X, Hyper=0x%X" , this, GetGdkModifierMask(CAPS_LOCK), GetGdkModifierMask(NUM_LOCK ), GetGdkModifierMask(SCROLL_LOCK), GetGdkModifierMask(LEVEL3 ), GetGdkModifierMask(LEVEL5), GetGdkModifierMask(SHIFT), GetGdkModifierMask (CTRL), GetGdkModifierMask(ALT), GetGdkModifierMask(META), GetGdkModifierMask (SUPER), GetGdkModifierMask(HYPER)); } } while (0) |
402 | ("%p Init, CapsLock=0x%X, NumLock=0x%X, "do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p Init, CapsLock=0x%X, NumLock=0x%X, " "ScrollLock=0x%X, Level3=0x%X, Level5=0x%X, " "Shift=0x%X, Ctrl=0x%X, Alt=0x%X, Meta=0x%X, Super=0x%X, Hyper=0x%X" , this, GetGdkModifierMask(CAPS_LOCK), GetGdkModifierMask(NUM_LOCK ), GetGdkModifierMask(SCROLL_LOCK), GetGdkModifierMask(LEVEL3 ), GetGdkModifierMask(LEVEL5), GetGdkModifierMask(SHIFT), GetGdkModifierMask (CTRL), GetGdkModifierMask(ALT), GetGdkModifierMask(META), GetGdkModifierMask (SUPER), GetGdkModifierMask(HYPER)); } } while (0) |
403 | "ScrollLock=0x%X, Level3=0x%X, Level5=0x%X, "do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p Init, CapsLock=0x%X, NumLock=0x%X, " "ScrollLock=0x%X, Level3=0x%X, Level5=0x%X, " "Shift=0x%X, Ctrl=0x%X, Alt=0x%X, Meta=0x%X, Super=0x%X, Hyper=0x%X" , this, GetGdkModifierMask(CAPS_LOCK), GetGdkModifierMask(NUM_LOCK ), GetGdkModifierMask(SCROLL_LOCK), GetGdkModifierMask(LEVEL3 ), GetGdkModifierMask(LEVEL5), GetGdkModifierMask(SHIFT), GetGdkModifierMask (CTRL), GetGdkModifierMask(ALT), GetGdkModifierMask(META), GetGdkModifierMask (SUPER), GetGdkModifierMask(HYPER)); } } while (0) |
404 | "Shift=0x%X, Ctrl=0x%X, Alt=0x%X, Meta=0x%X, Super=0x%X, Hyper=0x%X",do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p Init, CapsLock=0x%X, NumLock=0x%X, " "ScrollLock=0x%X, Level3=0x%X, Level5=0x%X, " "Shift=0x%X, Ctrl=0x%X, Alt=0x%X, Meta=0x%X, Super=0x%X, Hyper=0x%X" , this, GetGdkModifierMask(CAPS_LOCK), GetGdkModifierMask(NUM_LOCK ), GetGdkModifierMask(SCROLL_LOCK), GetGdkModifierMask(LEVEL3 ), GetGdkModifierMask(LEVEL5), GetGdkModifierMask(SHIFT), GetGdkModifierMask (CTRL), GetGdkModifierMask(ALT), GetGdkModifierMask(META), GetGdkModifierMask (SUPER), GetGdkModifierMask(HYPER)); } } while (0) |
405 | this, GetGdkModifierMask(CAPS_LOCK), GetGdkModifierMask(NUM_LOCK),do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p Init, CapsLock=0x%X, NumLock=0x%X, " "ScrollLock=0x%X, Level3=0x%X, Level5=0x%X, " "Shift=0x%X, Ctrl=0x%X, Alt=0x%X, Meta=0x%X, Super=0x%X, Hyper=0x%X" , this, GetGdkModifierMask(CAPS_LOCK), GetGdkModifierMask(NUM_LOCK ), GetGdkModifierMask(SCROLL_LOCK), GetGdkModifierMask(LEVEL3 ), GetGdkModifierMask(LEVEL5), GetGdkModifierMask(SHIFT), GetGdkModifierMask (CTRL), GetGdkModifierMask(ALT), GetGdkModifierMask(META), GetGdkModifierMask (SUPER), GetGdkModifierMask(HYPER)); } } while (0) |
406 | GetGdkModifierMask(SCROLL_LOCK), GetGdkModifierMask(LEVEL3),do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p Init, CapsLock=0x%X, NumLock=0x%X, " "ScrollLock=0x%X, Level3=0x%X, Level5=0x%X, " "Shift=0x%X, Ctrl=0x%X, Alt=0x%X, Meta=0x%X, Super=0x%X, Hyper=0x%X" , this, GetGdkModifierMask(CAPS_LOCK), GetGdkModifierMask(NUM_LOCK ), GetGdkModifierMask(SCROLL_LOCK), GetGdkModifierMask(LEVEL3 ), GetGdkModifierMask(LEVEL5), GetGdkModifierMask(SHIFT), GetGdkModifierMask (CTRL), GetGdkModifierMask(ALT), GetGdkModifierMask(META), GetGdkModifierMask (SUPER), GetGdkModifierMask(HYPER)); } } while (0) |
407 | GetGdkModifierMask(LEVEL5), GetGdkModifierMask(SHIFT),do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p Init, CapsLock=0x%X, NumLock=0x%X, " "ScrollLock=0x%X, Level3=0x%X, Level5=0x%X, " "Shift=0x%X, Ctrl=0x%X, Alt=0x%X, Meta=0x%X, Super=0x%X, Hyper=0x%X" , this, GetGdkModifierMask(CAPS_LOCK), GetGdkModifierMask(NUM_LOCK ), GetGdkModifierMask(SCROLL_LOCK), GetGdkModifierMask(LEVEL3 ), GetGdkModifierMask(LEVEL5), GetGdkModifierMask(SHIFT), GetGdkModifierMask (CTRL), GetGdkModifierMask(ALT), GetGdkModifierMask(META), GetGdkModifierMask (SUPER), GetGdkModifierMask(HYPER)); } } while (0) |
408 | GetGdkModifierMask(CTRL), GetGdkModifierMask(ALT),do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p Init, CapsLock=0x%X, NumLock=0x%X, " "ScrollLock=0x%X, Level3=0x%X, Level5=0x%X, " "Shift=0x%X, Ctrl=0x%X, Alt=0x%X, Meta=0x%X, Super=0x%X, Hyper=0x%X" , this, GetGdkModifierMask(CAPS_LOCK), GetGdkModifierMask(NUM_LOCK ), GetGdkModifierMask(SCROLL_LOCK), GetGdkModifierMask(LEVEL3 ), GetGdkModifierMask(LEVEL5), GetGdkModifierMask(SHIFT), GetGdkModifierMask (CTRL), GetGdkModifierMask(ALT), GetGdkModifierMask(META), GetGdkModifierMask (SUPER), GetGdkModifierMask(HYPER)); } } while (0) |
409 | GetGdkModifierMask(META), GetGdkModifierMask(SUPER),do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p Init, CapsLock=0x%X, NumLock=0x%X, " "ScrollLock=0x%X, Level3=0x%X, Level5=0x%X, " "Shift=0x%X, Ctrl=0x%X, Alt=0x%X, Meta=0x%X, Super=0x%X, Hyper=0x%X" , this, GetGdkModifierMask(CAPS_LOCK), GetGdkModifierMask(NUM_LOCK ), GetGdkModifierMask(SCROLL_LOCK), GetGdkModifierMask(LEVEL3 ), GetGdkModifierMask(LEVEL5), GetGdkModifierMask(SHIFT), GetGdkModifierMask (CTRL), GetGdkModifierMask(ALT), GetGdkModifierMask(META), GetGdkModifierMask (SUPER), GetGdkModifierMask(HYPER)); } } while (0) |
410 | GetGdkModifierMask(HYPER)))do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p Init, CapsLock=0x%X, NumLock=0x%X, " "ScrollLock=0x%X, Level3=0x%X, Level5=0x%X, " "Shift=0x%X, Ctrl=0x%X, Alt=0x%X, Meta=0x%X, Super=0x%X, Hyper=0x%X" , this, GetGdkModifierMask(CAPS_LOCK), GetGdkModifierMask(NUM_LOCK ), GetGdkModifierMask(SCROLL_LOCK), GetGdkModifierMask(LEVEL3 ), GetGdkModifierMask(LEVEL5), GetGdkModifierMask(SHIFT), GetGdkModifierMask (CTRL), GetGdkModifierMask(ALT), GetGdkModifierMask(META), GetGdkModifierMask (SUPER), GetGdkModifierMask(HYPER)); } } while (0); |
411 | } |
412 | |
413 | #ifdef MOZ_X111 |
414 | void KeymapWrapper::InitXKBExtension() { |
415 | PodZero(&mKeyboardState); |
416 | |
417 | int xkbMajorVer = XkbMajorVersion1; |
418 | int xkbMinorVer = XkbMinorVersion0; |
419 | if (!XkbLibraryVersion(&xkbMajorVer, &xkbMinorVer)) { |
420 | MOZ_LOG(gKeyLog, LogLevel::Info,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p InitXKBExtension failed due to failure of " "XkbLibraryVersion()", this); } } while (0) |
421 | ("%p InitXKBExtension failed due to failure of "do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p InitXKBExtension failed due to failure of " "XkbLibraryVersion()", this); } } while (0) |
422 | "XkbLibraryVersion()",do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p InitXKBExtension failed due to failure of " "XkbLibraryVersion()", this); } } while (0) |
423 | this))do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p InitXKBExtension failed due to failure of " "XkbLibraryVersion()", this); } } while (0); |
424 | return; |
425 | } |
426 | |
427 | Display* display = gdk_x11_display_get_xdisplay(gdk_display_get_default()); |
428 | |
429 | // XkbLibraryVersion() set xkbMajorVer and xkbMinorVer to that of the |
430 | // library, which may be newer than what is required of the server in |
431 | // XkbQueryExtension(), so these variables should be reset to |
432 | // XkbMajorVersion and XkbMinorVersion before the XkbQueryExtension call. |
433 | xkbMajorVer = XkbMajorVersion1; |
434 | xkbMinorVer = XkbMinorVersion0; |
435 | int opcode, baseErrorCode; |
436 | if (!XkbQueryExtension(display, &opcode, &mXKBBaseEventCode, &baseErrorCode, |
437 | &xkbMajorVer, &xkbMinorVer)) { |
438 | MOZ_LOG(gKeyLog, LogLevel::Info,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p InitXKBExtension failed due to failure of " "XkbQueryExtension(), display=0x%p", this, display); } } while (0) |
439 | ("%p InitXKBExtension failed due to failure of "do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p InitXKBExtension failed due to failure of " "XkbQueryExtension(), display=0x%p", this, display); } } while (0) |
440 | "XkbQueryExtension(), display=0x%p",do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p InitXKBExtension failed due to failure of " "XkbQueryExtension(), display=0x%p", this, display); } } while (0) |
441 | this, display))do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p InitXKBExtension failed due to failure of " "XkbQueryExtension(), display=0x%p", this, display); } } while (0); |
442 | return; |
443 | } |
444 | |
445 | if (!XkbSelectEventDetails(display, XkbUseCoreKbd0x0100, XkbStateNotify2, |
446 | XkbModifierStateMask(1L << 0), XkbModifierStateMask(1L << 0))) { |
447 | MOZ_LOG(gKeyLog, LogLevel::Info,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p InitXKBExtension failed due to failure of " "XkbSelectEventDetails() for XModifierStateMask, display=0x%p" , this, display); } } while (0) |
448 | ("%p InitXKBExtension failed due to failure of "do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p InitXKBExtension failed due to failure of " "XkbSelectEventDetails() for XModifierStateMask, display=0x%p" , this, display); } } while (0) |
449 | "XkbSelectEventDetails() for XModifierStateMask, display=0x%p",do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p InitXKBExtension failed due to failure of " "XkbSelectEventDetails() for XModifierStateMask, display=0x%p" , this, display); } } while (0) |
450 | this, display))do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p InitXKBExtension failed due to failure of " "XkbSelectEventDetails() for XModifierStateMask, display=0x%p" , this, display); } } while (0); |
451 | return; |
452 | } |
453 | |
454 | if (!XkbSelectEventDetails(display, XkbUseCoreKbd0x0100, XkbControlsNotify3, |
455 | XkbPerKeyRepeatMask(1L << 30), XkbPerKeyRepeatMask(1L << 30))) { |
456 | MOZ_LOG(gKeyLog, LogLevel::Info,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p InitXKBExtension failed due to failure of " "XkbSelectEventDetails() for XkbControlsNotify, display=0x%p" , this, display); } } while (0) |
457 | ("%p InitXKBExtension failed due to failure of "do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p InitXKBExtension failed due to failure of " "XkbSelectEventDetails() for XkbControlsNotify, display=0x%p" , this, display); } } while (0) |
458 | "XkbSelectEventDetails() for XkbControlsNotify, display=0x%p",do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p InitXKBExtension failed due to failure of " "XkbSelectEventDetails() for XkbControlsNotify, display=0x%p" , this, display); } } while (0) |
459 | this, display))do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p InitXKBExtension failed due to failure of " "XkbSelectEventDetails() for XkbControlsNotify, display=0x%p" , this, display); } } while (0); |
460 | return; |
461 | } |
462 | |
463 | if (!XGetKeyboardControl(display, &mKeyboardState)) { |
464 | MOZ_LOG(gKeyLog, LogLevel::Info,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p InitXKBExtension failed due to failure of " "XGetKeyboardControl(), display=0x%p", this, display); } } while (0) |
465 | ("%p InitXKBExtension failed due to failure of "do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p InitXKBExtension failed due to failure of " "XGetKeyboardControl(), display=0x%p", this, display); } } while (0) |
466 | "XGetKeyboardControl(), display=0x%p",do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p InitXKBExtension failed due to failure of " "XGetKeyboardControl(), display=0x%p", this, display); } } while (0) |
467 | this, display))do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p InitXKBExtension failed due to failure of " "XGetKeyboardControl(), display=0x%p", this, display); } } while (0); |
468 | return; |
469 | } |
470 | |
471 | MOZ_LOG(gKeyLog, LogLevel::Info, ("%p InitXKBExtension, Succeeded", this))do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p InitXKBExtension, Succeeded", this); } } while (0); |
472 | } |
473 | |
474 | void KeymapWrapper::InitBySystemSettingsX11() { |
475 | MOZ_LOG(gKeyLog, LogLevel::Info,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p InitBySystemSettingsX11, mGdkKeymap=%p" , this, mGdkKeymap); } } while (0) |
476 | ("%p InitBySystemSettingsX11, mGdkKeymap=%p", this, mGdkKeymap))do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p InitBySystemSettingsX11, mGdkKeymap=%p" , this, mGdkKeymap); } } while (0); |
477 | |
478 | if (!mOnKeysChangedSignalHandle) { |
479 | mOnKeysChangedSignalHandle = g_signal_connect(g_signal_connect_data ((mGdkKeymap), ("keys-changed"), ((GCallback )OnKeysChanged), (this), __null, (GConnectFlags) 0) |
480 | mGdkKeymap, "keys-changed", (GCallback)OnKeysChanged, this)g_signal_connect_data ((mGdkKeymap), ("keys-changed"), ((GCallback )OnKeysChanged), (this), __null, (GConnectFlags) 0); |
481 | } |
482 | if (!mOnDirectionChangedSignalHandle) { |
483 | mOnDirectionChangedSignalHandle = g_signal_connect(g_signal_connect_data ((mGdkKeymap), ("direction-changed"), ( (GCallback)OnDirectionChanged), (this), __null, (GConnectFlags ) 0) |
484 | mGdkKeymap, "direction-changed", (GCallback)OnDirectionChanged, this)g_signal_connect_data ((mGdkKeymap), ("direction-changed"), ( (GCallback)OnDirectionChanged), (this), __null, (GConnectFlags ) 0); |
485 | } |
486 | |
487 | Display* display = gdk_x11_display_get_xdisplay(gdk_display_get_default()); |
488 | |
489 | int min_keycode = 0; |
490 | int max_keycode = 0; |
491 | XDisplayKeycodes(display, &min_keycode, &max_keycode); |
492 | |
493 | int keysyms_per_keycode = 0; |
494 | KeySym* xkeymap = |
495 | XGetKeyboardMapping(display, min_keycode, max_keycode - min_keycode + 1, |
496 | &keysyms_per_keycode); |
497 | if (!xkeymap) { |
498 | MOZ_LOG(gKeyLog, LogLevel::Info,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p InitBySystemSettings, " "Failed due to null xkeymap" , this); } } while (0) |
499 | ("%p InitBySystemSettings, "do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p InitBySystemSettings, " "Failed due to null xkeymap" , this); } } while (0) |
500 | "Failed due to null xkeymap",do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p InitBySystemSettings, " "Failed due to null xkeymap" , this); } } while (0) |
501 | this))do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p InitBySystemSettings, " "Failed due to null xkeymap" , this); } } while (0); |
502 | return; |
503 | } |
504 | |
505 | XModifierKeymap* xmodmap = XGetModifierMapping(display); |
506 | if (!xmodmap) { |
507 | MOZ_LOG(gKeyLog, LogLevel::Info,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p InitBySystemSettings, " "Failed due to null xmodmap" , this); } } while (0) |
508 | ("%p InitBySystemSettings, "do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p InitBySystemSettings, " "Failed due to null xmodmap" , this); } } while (0) |
509 | "Failed due to null xmodmap",do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p InitBySystemSettings, " "Failed due to null xmodmap" , this); } } while (0) |
510 | this))do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p InitBySystemSettings, " "Failed due to null xmodmap" , this); } } while (0); |
511 | XFree(xkeymap); |
512 | return; |
513 | } |
514 | MOZ_LOG(gKeyLog, LogLevel::Info,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p InitBySystemSettings, min_keycode=%d, " "max_keycode=%d, keysyms_per_keycode=%d, max_keypermod=%d", this , min_keycode, max_keycode, keysyms_per_keycode, xmodmap-> max_keypermod); } } while (0) |
515 | ("%p InitBySystemSettings, min_keycode=%d, "do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p InitBySystemSettings, min_keycode=%d, " "max_keycode=%d, keysyms_per_keycode=%d, max_keypermod=%d", this , min_keycode, max_keycode, keysyms_per_keycode, xmodmap-> max_keypermod); } } while (0) |
516 | "max_keycode=%d, keysyms_per_keycode=%d, max_keypermod=%d",do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p InitBySystemSettings, min_keycode=%d, " "max_keycode=%d, keysyms_per_keycode=%d, max_keypermod=%d", this , min_keycode, max_keycode, keysyms_per_keycode, xmodmap-> max_keypermod); } } while (0) |
517 | this, min_keycode, max_keycode, keysyms_per_keycode,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p InitBySystemSettings, min_keycode=%d, " "max_keycode=%d, keysyms_per_keycode=%d, max_keypermod=%d", this , min_keycode, max_keycode, keysyms_per_keycode, xmodmap-> max_keypermod); } } while (0) |
518 | xmodmap->max_keypermod))do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p InitBySystemSettings, min_keycode=%d, " "max_keycode=%d, keysyms_per_keycode=%d, max_keypermod=%d", this , min_keycode, max_keycode, keysyms_per_keycode, xmodmap-> max_keypermod); } } while (0); |
519 | |
520 | // The modifiermap member of the XModifierKeymap structure contains 8 sets |
521 | // of max_keypermod KeyCodes, one for each modifier in the order Shift, |
522 | // Lock, Control, Mod1, Mod2, Mod3, Mod4, and Mod5. |
523 | // Only nonzero KeyCodes have meaning in each set, and zero KeyCodes are |
524 | // ignored. |
525 | |
526 | // Note that two or more modifiers may use one modifier flag. E.g., |
527 | // on Ubuntu 10.10, Alt and Meta share the Mod1 in default settings. |
528 | // And also Super and Hyper share the Mod4. In such cases, we need to |
529 | // decide which modifier flag means one of DOM modifiers. |
530 | |
531 | // mod[0] is Modifier introduced by Mod1. |
532 | MappedModifier mod[5]; |
533 | int32_t foundLevel[5]; |
534 | for (uint32_t i = 0; i < ArrayLength(mod); i++) { |
535 | mod[i] = NOT_MODIFIER; |
536 | foundLevel[i] = INT32_MAX(2147483647); |
537 | } |
538 | const uint32_t map_size = 8 * xmodmap->max_keypermod; |
539 | for (uint32_t i = 0; i < map_size; i++) { |
540 | KeyCode keycode = xmodmap->modifiermap[i]; |
541 | MOZ_LOG(gKeyLog, LogLevel::Info,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p InitBySystemSettings, " " i=%d, keycode=0x%08X" , this, i, keycode); } } while (0) |
542 | ("%p InitBySystemSettings, "do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p InitBySystemSettings, " " i=%d, keycode=0x%08X" , this, i, keycode); } } while (0) |
543 | " i=%d, keycode=0x%08X",do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p InitBySystemSettings, " " i=%d, keycode=0x%08X" , this, i, keycode); } } while (0) |
544 | this, i, keycode))do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p InitBySystemSettings, " " i=%d, keycode=0x%08X" , this, i, keycode); } } while (0); |
545 | if (!keycode || keycode < min_keycode || keycode > max_keycode) { |
546 | continue; |
547 | } |
548 | |
549 | ModifierKey* modifierKey = GetModifierKey(keycode); |
550 | if (!modifierKey) { |
551 | modifierKey = mModifierKeys.AppendElement(ModifierKey(keycode)); |
552 | } |
553 | |
554 | const KeySym* syms = |
555 | xkeymap + (keycode - min_keycode) * keysyms_per_keycode; |
556 | const uint32_t bit = i / xmodmap->max_keypermod; |
557 | modifierKey->mMask |= 1 << bit; |
558 | |
559 | // We need to know the meaning of Mod1, Mod2, Mod3, Mod4 and Mod5. |
560 | // Let's skip if current map is for others. |
561 | if (bit < 3) { |
562 | continue; |
563 | } |
564 | |
565 | const int32_t modIndex = bit - 3; |
566 | for (int32_t j = 0; j < keysyms_per_keycode; j++) { |
567 | MappedModifier modifier = GetModifierForGDKKeyval(syms[j]); |
568 | MOZ_LOG(gKeyLog, LogLevel::Info,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p InitBySystemSettings, " " Mod%d, j=%d, syms[j]=%s(0x%lX), modifier=%s" , this, modIndex + 1, j, gdk_keyval_name(syms[j]), syms[j], GetModifierName (modifier)); } } while (0) |
569 | ("%p InitBySystemSettings, "do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p InitBySystemSettings, " " Mod%d, j=%d, syms[j]=%s(0x%lX), modifier=%s" , this, modIndex + 1, j, gdk_keyval_name(syms[j]), syms[j], GetModifierName (modifier)); } } while (0) |
570 | " Mod%d, j=%d, syms[j]=%s(0x%lX), modifier=%s",do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p InitBySystemSettings, " " Mod%d, j=%d, syms[j]=%s(0x%lX), modifier=%s" , this, modIndex + 1, j, gdk_keyval_name(syms[j]), syms[j], GetModifierName (modifier)); } } while (0) |
571 | this, modIndex + 1, j, gdk_keyval_name(syms[j]), syms[j],do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p InitBySystemSettings, " " Mod%d, j=%d, syms[j]=%s(0x%lX), modifier=%s" , this, modIndex + 1, j, gdk_keyval_name(syms[j]), syms[j], GetModifierName (modifier)); } } while (0) |
572 | GetModifierName(modifier)))do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p InitBySystemSettings, " " Mod%d, j=%d, syms[j]=%s(0x%lX), modifier=%s" , this, modIndex + 1, j, gdk_keyval_name(syms[j]), syms[j], GetModifierName (modifier)); } } while (0); |
573 | |
574 | switch (modifier) { |
575 | case NOT_MODIFIER: |
576 | // Don't overwrite the stored information with |
577 | // NOT_MODIFIER. |
578 | break; |
579 | case CAPS_LOCK: |
580 | case SHIFT: |
581 | case CTRL: |
582 | case SUPER: |
583 | // Ignore the modifiers defined in GDK spec. They shouldn't |
584 | // be mapped to Mod1-5 because they must not work on native |
585 | // GTK applications. |
586 | break; |
587 | default: |
588 | // If new modifier is found in higher level than stored |
589 | // value, we don't need to overwrite it. |
590 | if (j > foundLevel[modIndex]) { |
591 | break; |
592 | } |
593 | // If new modifier is more important than stored value, |
594 | // we should overwrite it with new modifier. |
595 | if (j == foundLevel[modIndex]) { |
596 | mod[modIndex] = std::min(modifier, mod[modIndex]); |
597 | break; |
598 | } |
599 | foundLevel[modIndex] = j; |
600 | mod[modIndex] = modifier; |
601 | break; |
602 | } |
603 | } |
604 | } |
605 | |
606 | for (uint32_t i = 0; i < COUNT_OF_MODIFIER_INDEX; i++) { |
607 | MappedModifier modifier; |
608 | switch (i) { |
609 | case INDEX_NUM_LOCK: |
610 | modifier = NUM_LOCK; |
611 | break; |
612 | case INDEX_SCROLL_LOCK: |
613 | modifier = SCROLL_LOCK; |
614 | break; |
615 | case INDEX_ALT: |
616 | modifier = ALT; |
617 | break; |
618 | case INDEX_META: |
619 | modifier = META; |
620 | break; |
621 | case INDEX_HYPER: |
622 | modifier = HYPER; |
623 | break; |
624 | case INDEX_LEVEL3: |
625 | modifier = LEVEL3; |
626 | break; |
627 | case INDEX_LEVEL5: |
628 | modifier = LEVEL5; |
629 | break; |
630 | default: |
631 | MOZ_CRASH("All indexes must be handled here")do { do { } while (false); MOZ_ReportCrash("" "All indexes must be handled here" , "/var/lib/jenkins/workspace/firefox-scan-build/widget/gtk/nsGtkKeyUtils.cpp" , 631); AnnotateMozCrashReason("MOZ_CRASH(" "All indexes must be handled here" ")"); do { *((volatile int*)__null) = 631; __attribute__((nomerge )) ::abort(); } while (false); } while (false); |
632 | } |
633 | for (uint32_t j = 0; j < ArrayLength(mod); j++) { |
634 | if (modifier == mod[j]) { |
635 | mModifierMasks[i] |= 1 << (j + 3); |
636 | } |
637 | } |
638 | } |
639 | |
640 | XFreeModifiermap(xmodmap); |
641 | XFree(xkeymap); |
642 | } |
643 | #endif |
644 | |
645 | #ifdef MOZ_WAYLAND1 |
646 | void KeymapWrapper::SetModifierMask(xkb_keymap* aKeymap, |
647 | ModifierIndex aModifierIndex, |
648 | const char* aModifierName) { |
649 | xkb_mod_index_t index = xkb_keymap_mod_get_index(aKeymap, aModifierName); |
650 | if (index != XKB_MOD_INVALID(0xffffffff)) { |
651 | mModifierMasks[aModifierIndex] = (1 << index); |
652 | } |
653 | } |
654 | |
655 | void KeymapWrapper::SetModifierMasks(xkb_keymap* aKeymap) { |
656 | KeymapWrapper* keymapWrapper = GetInstance(); |
657 | |
658 | // This mapping is derived from get_xkb_modifiers() at gdkkeys-wayland.c |
659 | keymapWrapper->SetModifierMask(aKeymap, INDEX_NUM_LOCK, XKB_MOD_NAME_NUM"Mod2"); |
660 | keymapWrapper->SetModifierMask(aKeymap, INDEX_ALT, XKB_MOD_NAME_ALT"Mod1"); |
661 | keymapWrapper->SetModifierMask(aKeymap, INDEX_META, "Meta"); |
662 | keymapWrapper->SetModifierMask(aKeymap, INDEX_HYPER, "Hyper"); |
663 | |
664 | keymapWrapper->SetModifierMask(aKeymap, INDEX_SCROLL_LOCK, "ScrollLock"); |
665 | keymapWrapper->SetModifierMask(aKeymap, INDEX_LEVEL3, "Level3"); |
666 | keymapWrapper->SetModifierMask(aKeymap, INDEX_LEVEL5, "Level5"); |
667 | |
668 | MOZ_LOG(gKeyLog, LogLevel::Info,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p KeymapWrapper::SetModifierMasks, CapsLock=0x%X, NumLock=0x%X, " "ScrollLock=0x%X, Level3=0x%X, Level5=0x%X, " "Shift=0x%X, Ctrl=0x%X, Alt=0x%X, Meta=0x%X, Super=0x%X, Hyper=0x%X" , keymapWrapper, keymapWrapper->GetGdkModifierMask(CAPS_LOCK ), keymapWrapper->GetGdkModifierMask(NUM_LOCK), keymapWrapper ->GetGdkModifierMask(SCROLL_LOCK), keymapWrapper->GetGdkModifierMask (LEVEL3), keymapWrapper->GetGdkModifierMask(LEVEL5), keymapWrapper ->GetGdkModifierMask(SHIFT), keymapWrapper->GetGdkModifierMask (CTRL), keymapWrapper->GetGdkModifierMask(ALT), keymapWrapper ->GetGdkModifierMask(META), keymapWrapper->GetGdkModifierMask (SUPER), keymapWrapper->GetGdkModifierMask(HYPER)); } } while (0) |
669 | ("%p KeymapWrapper::SetModifierMasks, CapsLock=0x%X, NumLock=0x%X, "do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p KeymapWrapper::SetModifierMasks, CapsLock=0x%X, NumLock=0x%X, " "ScrollLock=0x%X, Level3=0x%X, Level5=0x%X, " "Shift=0x%X, Ctrl=0x%X, Alt=0x%X, Meta=0x%X, Super=0x%X, Hyper=0x%X" , keymapWrapper, keymapWrapper->GetGdkModifierMask(CAPS_LOCK ), keymapWrapper->GetGdkModifierMask(NUM_LOCK), keymapWrapper ->GetGdkModifierMask(SCROLL_LOCK), keymapWrapper->GetGdkModifierMask (LEVEL3), keymapWrapper->GetGdkModifierMask(LEVEL5), keymapWrapper ->GetGdkModifierMask(SHIFT), keymapWrapper->GetGdkModifierMask (CTRL), keymapWrapper->GetGdkModifierMask(ALT), keymapWrapper ->GetGdkModifierMask(META), keymapWrapper->GetGdkModifierMask (SUPER), keymapWrapper->GetGdkModifierMask(HYPER)); } } while (0) |
670 | "ScrollLock=0x%X, Level3=0x%X, Level5=0x%X, "do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p KeymapWrapper::SetModifierMasks, CapsLock=0x%X, NumLock=0x%X, " "ScrollLock=0x%X, Level3=0x%X, Level5=0x%X, " "Shift=0x%X, Ctrl=0x%X, Alt=0x%X, Meta=0x%X, Super=0x%X, Hyper=0x%X" , keymapWrapper, keymapWrapper->GetGdkModifierMask(CAPS_LOCK ), keymapWrapper->GetGdkModifierMask(NUM_LOCK), keymapWrapper ->GetGdkModifierMask(SCROLL_LOCK), keymapWrapper->GetGdkModifierMask (LEVEL3), keymapWrapper->GetGdkModifierMask(LEVEL5), keymapWrapper ->GetGdkModifierMask(SHIFT), keymapWrapper->GetGdkModifierMask (CTRL), keymapWrapper->GetGdkModifierMask(ALT), keymapWrapper ->GetGdkModifierMask(META), keymapWrapper->GetGdkModifierMask (SUPER), keymapWrapper->GetGdkModifierMask(HYPER)); } } while (0) |
671 | "Shift=0x%X, Ctrl=0x%X, Alt=0x%X, Meta=0x%X, Super=0x%X, Hyper=0x%X",do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p KeymapWrapper::SetModifierMasks, CapsLock=0x%X, NumLock=0x%X, " "ScrollLock=0x%X, Level3=0x%X, Level5=0x%X, " "Shift=0x%X, Ctrl=0x%X, Alt=0x%X, Meta=0x%X, Super=0x%X, Hyper=0x%X" , keymapWrapper, keymapWrapper->GetGdkModifierMask(CAPS_LOCK ), keymapWrapper->GetGdkModifierMask(NUM_LOCK), keymapWrapper ->GetGdkModifierMask(SCROLL_LOCK), keymapWrapper->GetGdkModifierMask (LEVEL3), keymapWrapper->GetGdkModifierMask(LEVEL5), keymapWrapper ->GetGdkModifierMask(SHIFT), keymapWrapper->GetGdkModifierMask (CTRL), keymapWrapper->GetGdkModifierMask(ALT), keymapWrapper ->GetGdkModifierMask(META), keymapWrapper->GetGdkModifierMask (SUPER), keymapWrapper->GetGdkModifierMask(HYPER)); } } while (0) |
672 | keymapWrapper, keymapWrapper->GetGdkModifierMask(CAPS_LOCK),do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p KeymapWrapper::SetModifierMasks, CapsLock=0x%X, NumLock=0x%X, " "ScrollLock=0x%X, Level3=0x%X, Level5=0x%X, " "Shift=0x%X, Ctrl=0x%X, Alt=0x%X, Meta=0x%X, Super=0x%X, Hyper=0x%X" , keymapWrapper, keymapWrapper->GetGdkModifierMask(CAPS_LOCK ), keymapWrapper->GetGdkModifierMask(NUM_LOCK), keymapWrapper ->GetGdkModifierMask(SCROLL_LOCK), keymapWrapper->GetGdkModifierMask (LEVEL3), keymapWrapper->GetGdkModifierMask(LEVEL5), keymapWrapper ->GetGdkModifierMask(SHIFT), keymapWrapper->GetGdkModifierMask (CTRL), keymapWrapper->GetGdkModifierMask(ALT), keymapWrapper ->GetGdkModifierMask(META), keymapWrapper->GetGdkModifierMask (SUPER), keymapWrapper->GetGdkModifierMask(HYPER)); } } while (0) |
673 | keymapWrapper->GetGdkModifierMask(NUM_LOCK),do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p KeymapWrapper::SetModifierMasks, CapsLock=0x%X, NumLock=0x%X, " "ScrollLock=0x%X, Level3=0x%X, Level5=0x%X, " "Shift=0x%X, Ctrl=0x%X, Alt=0x%X, Meta=0x%X, Super=0x%X, Hyper=0x%X" , keymapWrapper, keymapWrapper->GetGdkModifierMask(CAPS_LOCK ), keymapWrapper->GetGdkModifierMask(NUM_LOCK), keymapWrapper ->GetGdkModifierMask(SCROLL_LOCK), keymapWrapper->GetGdkModifierMask (LEVEL3), keymapWrapper->GetGdkModifierMask(LEVEL5), keymapWrapper ->GetGdkModifierMask(SHIFT), keymapWrapper->GetGdkModifierMask (CTRL), keymapWrapper->GetGdkModifierMask(ALT), keymapWrapper ->GetGdkModifierMask(META), keymapWrapper->GetGdkModifierMask (SUPER), keymapWrapper->GetGdkModifierMask(HYPER)); } } while (0) |
674 | keymapWrapper->GetGdkModifierMask(SCROLL_LOCK),do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p KeymapWrapper::SetModifierMasks, CapsLock=0x%X, NumLock=0x%X, " "ScrollLock=0x%X, Level3=0x%X, Level5=0x%X, " "Shift=0x%X, Ctrl=0x%X, Alt=0x%X, Meta=0x%X, Super=0x%X, Hyper=0x%X" , keymapWrapper, keymapWrapper->GetGdkModifierMask(CAPS_LOCK ), keymapWrapper->GetGdkModifierMask(NUM_LOCK), keymapWrapper ->GetGdkModifierMask(SCROLL_LOCK), keymapWrapper->GetGdkModifierMask (LEVEL3), keymapWrapper->GetGdkModifierMask(LEVEL5), keymapWrapper ->GetGdkModifierMask(SHIFT), keymapWrapper->GetGdkModifierMask (CTRL), keymapWrapper->GetGdkModifierMask(ALT), keymapWrapper ->GetGdkModifierMask(META), keymapWrapper->GetGdkModifierMask (SUPER), keymapWrapper->GetGdkModifierMask(HYPER)); } } while (0) |
675 | keymapWrapper->GetGdkModifierMask(LEVEL3),do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p KeymapWrapper::SetModifierMasks, CapsLock=0x%X, NumLock=0x%X, " "ScrollLock=0x%X, Level3=0x%X, Level5=0x%X, " "Shift=0x%X, Ctrl=0x%X, Alt=0x%X, Meta=0x%X, Super=0x%X, Hyper=0x%X" , keymapWrapper, keymapWrapper->GetGdkModifierMask(CAPS_LOCK ), keymapWrapper->GetGdkModifierMask(NUM_LOCK), keymapWrapper ->GetGdkModifierMask(SCROLL_LOCK), keymapWrapper->GetGdkModifierMask (LEVEL3), keymapWrapper->GetGdkModifierMask(LEVEL5), keymapWrapper ->GetGdkModifierMask(SHIFT), keymapWrapper->GetGdkModifierMask (CTRL), keymapWrapper->GetGdkModifierMask(ALT), keymapWrapper ->GetGdkModifierMask(META), keymapWrapper->GetGdkModifierMask (SUPER), keymapWrapper->GetGdkModifierMask(HYPER)); } } while (0) |
676 | keymapWrapper->GetGdkModifierMask(LEVEL5),do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p KeymapWrapper::SetModifierMasks, CapsLock=0x%X, NumLock=0x%X, " "ScrollLock=0x%X, Level3=0x%X, Level5=0x%X, " "Shift=0x%X, Ctrl=0x%X, Alt=0x%X, Meta=0x%X, Super=0x%X, Hyper=0x%X" , keymapWrapper, keymapWrapper->GetGdkModifierMask(CAPS_LOCK ), keymapWrapper->GetGdkModifierMask(NUM_LOCK), keymapWrapper ->GetGdkModifierMask(SCROLL_LOCK), keymapWrapper->GetGdkModifierMask (LEVEL3), keymapWrapper->GetGdkModifierMask(LEVEL5), keymapWrapper ->GetGdkModifierMask(SHIFT), keymapWrapper->GetGdkModifierMask (CTRL), keymapWrapper->GetGdkModifierMask(ALT), keymapWrapper ->GetGdkModifierMask(META), keymapWrapper->GetGdkModifierMask (SUPER), keymapWrapper->GetGdkModifierMask(HYPER)); } } while (0) |
677 | keymapWrapper->GetGdkModifierMask(SHIFT),do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p KeymapWrapper::SetModifierMasks, CapsLock=0x%X, NumLock=0x%X, " "ScrollLock=0x%X, Level3=0x%X, Level5=0x%X, " "Shift=0x%X, Ctrl=0x%X, Alt=0x%X, Meta=0x%X, Super=0x%X, Hyper=0x%X" , keymapWrapper, keymapWrapper->GetGdkModifierMask(CAPS_LOCK ), keymapWrapper->GetGdkModifierMask(NUM_LOCK), keymapWrapper ->GetGdkModifierMask(SCROLL_LOCK), keymapWrapper->GetGdkModifierMask (LEVEL3), keymapWrapper->GetGdkModifierMask(LEVEL5), keymapWrapper ->GetGdkModifierMask(SHIFT), keymapWrapper->GetGdkModifierMask (CTRL), keymapWrapper->GetGdkModifierMask(ALT), keymapWrapper ->GetGdkModifierMask(META), keymapWrapper->GetGdkModifierMask (SUPER), keymapWrapper->GetGdkModifierMask(HYPER)); } } while (0) |
678 | keymapWrapper->GetGdkModifierMask(CTRL),do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p KeymapWrapper::SetModifierMasks, CapsLock=0x%X, NumLock=0x%X, " "ScrollLock=0x%X, Level3=0x%X, Level5=0x%X, " "Shift=0x%X, Ctrl=0x%X, Alt=0x%X, Meta=0x%X, Super=0x%X, Hyper=0x%X" , keymapWrapper, keymapWrapper->GetGdkModifierMask(CAPS_LOCK ), keymapWrapper->GetGdkModifierMask(NUM_LOCK), keymapWrapper ->GetGdkModifierMask(SCROLL_LOCK), keymapWrapper->GetGdkModifierMask (LEVEL3), keymapWrapper->GetGdkModifierMask(LEVEL5), keymapWrapper ->GetGdkModifierMask(SHIFT), keymapWrapper->GetGdkModifierMask (CTRL), keymapWrapper->GetGdkModifierMask(ALT), keymapWrapper ->GetGdkModifierMask(META), keymapWrapper->GetGdkModifierMask (SUPER), keymapWrapper->GetGdkModifierMask(HYPER)); } } while (0) |
679 | keymapWrapper->GetGdkModifierMask(ALT),do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p KeymapWrapper::SetModifierMasks, CapsLock=0x%X, NumLock=0x%X, " "ScrollLock=0x%X, Level3=0x%X, Level5=0x%X, " "Shift=0x%X, Ctrl=0x%X, Alt=0x%X, Meta=0x%X, Super=0x%X, Hyper=0x%X" , keymapWrapper, keymapWrapper->GetGdkModifierMask(CAPS_LOCK ), keymapWrapper->GetGdkModifierMask(NUM_LOCK), keymapWrapper ->GetGdkModifierMask(SCROLL_LOCK), keymapWrapper->GetGdkModifierMask (LEVEL3), keymapWrapper->GetGdkModifierMask(LEVEL5), keymapWrapper ->GetGdkModifierMask(SHIFT), keymapWrapper->GetGdkModifierMask (CTRL), keymapWrapper->GetGdkModifierMask(ALT), keymapWrapper ->GetGdkModifierMask(META), keymapWrapper->GetGdkModifierMask (SUPER), keymapWrapper->GetGdkModifierMask(HYPER)); } } while (0) |
680 | keymapWrapper->GetGdkModifierMask(META),do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p KeymapWrapper::SetModifierMasks, CapsLock=0x%X, NumLock=0x%X, " "ScrollLock=0x%X, Level3=0x%X, Level5=0x%X, " "Shift=0x%X, Ctrl=0x%X, Alt=0x%X, Meta=0x%X, Super=0x%X, Hyper=0x%X" , keymapWrapper, keymapWrapper->GetGdkModifierMask(CAPS_LOCK ), keymapWrapper->GetGdkModifierMask(NUM_LOCK), keymapWrapper ->GetGdkModifierMask(SCROLL_LOCK), keymapWrapper->GetGdkModifierMask (LEVEL3), keymapWrapper->GetGdkModifierMask(LEVEL5), keymapWrapper ->GetGdkModifierMask(SHIFT), keymapWrapper->GetGdkModifierMask (CTRL), keymapWrapper->GetGdkModifierMask(ALT), keymapWrapper ->GetGdkModifierMask(META), keymapWrapper->GetGdkModifierMask (SUPER), keymapWrapper->GetGdkModifierMask(HYPER)); } } while (0) |
681 | keymapWrapper->GetGdkModifierMask(SUPER),do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p KeymapWrapper::SetModifierMasks, CapsLock=0x%X, NumLock=0x%X, " "ScrollLock=0x%X, Level3=0x%X, Level5=0x%X, " "Shift=0x%X, Ctrl=0x%X, Alt=0x%X, Meta=0x%X, Super=0x%X, Hyper=0x%X" , keymapWrapper, keymapWrapper->GetGdkModifierMask(CAPS_LOCK ), keymapWrapper->GetGdkModifierMask(NUM_LOCK), keymapWrapper ->GetGdkModifierMask(SCROLL_LOCK), keymapWrapper->GetGdkModifierMask (LEVEL3), keymapWrapper->GetGdkModifierMask(LEVEL5), keymapWrapper ->GetGdkModifierMask(SHIFT), keymapWrapper->GetGdkModifierMask (CTRL), keymapWrapper->GetGdkModifierMask(ALT), keymapWrapper ->GetGdkModifierMask(META), keymapWrapper->GetGdkModifierMask (SUPER), keymapWrapper->GetGdkModifierMask(HYPER)); } } while (0) |
682 | keymapWrapper->GetGdkModifierMask(HYPER)))do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p KeymapWrapper::SetModifierMasks, CapsLock=0x%X, NumLock=0x%X, " "ScrollLock=0x%X, Level3=0x%X, Level5=0x%X, " "Shift=0x%X, Ctrl=0x%X, Alt=0x%X, Meta=0x%X, Super=0x%X, Hyper=0x%X" , keymapWrapper, keymapWrapper->GetGdkModifierMask(CAPS_LOCK ), keymapWrapper->GetGdkModifierMask(NUM_LOCK), keymapWrapper ->GetGdkModifierMask(SCROLL_LOCK), keymapWrapper->GetGdkModifierMask (LEVEL3), keymapWrapper->GetGdkModifierMask(LEVEL5), keymapWrapper ->GetGdkModifierMask(SHIFT), keymapWrapper->GetGdkModifierMask (CTRL), keymapWrapper->GetGdkModifierMask(ALT), keymapWrapper ->GetGdkModifierMask(META), keymapWrapper->GetGdkModifierMask (SUPER), keymapWrapper->GetGdkModifierMask(HYPER)); } } while (0); |
683 | } |
684 | |
685 | /* This keymap routine is derived from weston-2.0.0/clients/simple-im.c |
686 | */ |
687 | void KeymapWrapper::HandleKeymap(uint32_t format, int fd, uint32_t size) { |
688 | KeymapWrapper::ResetKeyboard(); |
689 | |
690 | if (format != WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1) { |
691 | close(fd); |
692 | return; |
693 | } |
694 | |
695 | char* mapString = (char*)mmap(NULL__null, size, PROT_READ0x1, MAP_SHARED0x01, fd, 0); |
696 | if (mapString == MAP_FAILED((void *) -1)) { |
697 | close(fd); |
698 | return; |
699 | } |
700 | |
701 | struct xkb_context* xkb_context = xkb_context_new(XKB_CONTEXT_NO_FLAGS); |
702 | struct xkb_keymap* keymap = xkb_keymap_new_from_string( |
703 | xkb_context, mapString, XKB_KEYMAP_FORMAT_TEXT_V1, |
704 | XKB_KEYMAP_COMPILE_NO_FLAGS); |
705 | |
706 | munmap(mapString, size); |
707 | close(fd); |
708 | |
709 | if (!keymap) { |
710 | NS_WARNING("keyboard_handle_keymap(): Failed to compile keymap!\n")NS_DebugBreak(NS_DEBUG_WARNING, "keyboard_handle_keymap(): Failed to compile keymap!\n" , nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/widget/gtk/nsGtkKeyUtils.cpp" , 710); |
711 | return; |
712 | } |
713 | |
714 | KeymapWrapper::SetModifierMasks(keymap); |
715 | |
716 | xkb_keymap_unref(keymap); |
717 | |
718 | xkb_context_unref(xkb_context); |
719 | } |
720 | #endif |
721 | |
722 | KeymapWrapper::~KeymapWrapper() { |
723 | #ifdef MOZ_X111 |
724 | gdk_window_remove_filter(nullptr, FilterEvents, this); |
725 | #endif |
726 | if (mOnKeysChangedSignalHandle) { |
727 | g_signal_handler_disconnect(mGdkKeymap, mOnKeysChangedSignalHandle); |
728 | } |
729 | if (mOnDirectionChangedSignalHandle) { |
730 | g_signal_handler_disconnect(mGdkKeymap, mOnDirectionChangedSignalHandle); |
731 | } |
732 | g_object_unref(mGdkKeymap); |
733 | MOZ_LOG(gKeyLog, LogLevel::Info, ("%p Destructor", this))do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p Destructor", this); } } while (0); |
734 | } |
735 | |
736 | #ifdef MOZ_X111 |
737 | /* static */ |
738 | GdkFilterReturn KeymapWrapper::FilterEvents(GdkXEvent* aXEvent, |
739 | GdkEvent* aGdkEvent, |
740 | gpointer aData) { |
741 | XEvent* xEvent = static_cast<XEvent*>(aXEvent); |
742 | switch (xEvent->type) { |
743 | case KeyPress2: { |
744 | // If the key doesn't support auto repeat, ignore the event because |
745 | // even if such key (e.g., Shift) is pressed during auto repeat of |
746 | // anoter key, it doesn't stop the auto repeat. |
747 | KeymapWrapper* self = static_cast<KeymapWrapper*>(aData); |
748 | if (!self->IsAutoRepeatableKey(xEvent->xkey.keycode)) { |
749 | break; |
750 | } |
751 | if (sRepeatState == NOT_PRESSED) { |
752 | sRepeatState = FIRST_PRESS; |
753 | MOZ_LOG(gKeyLog, LogLevel::Info,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "FilterEvents(aXEvent={ type=KeyPress, " "xkey={ keycode=0x%08X, state=0x%08X, time=%lu } }, " "aGdkEvent={ state=0x%08X }), " "detected first keypress", xEvent ->xkey.keycode, xEvent->xkey.state, xEvent->xkey.time , reinterpret_cast<GdkEventKey*>(aGdkEvent)->state); } } while (0) |
754 | ("FilterEvents(aXEvent={ type=KeyPress, "do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "FilterEvents(aXEvent={ type=KeyPress, " "xkey={ keycode=0x%08X, state=0x%08X, time=%lu } }, " "aGdkEvent={ state=0x%08X }), " "detected first keypress", xEvent ->xkey.keycode, xEvent->xkey.state, xEvent->xkey.time , reinterpret_cast<GdkEventKey*>(aGdkEvent)->state); } } while (0) |
755 | "xkey={ keycode=0x%08X, state=0x%08X, time=%lu } }, "do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "FilterEvents(aXEvent={ type=KeyPress, " "xkey={ keycode=0x%08X, state=0x%08X, time=%lu } }, " "aGdkEvent={ state=0x%08X }), " "detected first keypress", xEvent ->xkey.keycode, xEvent->xkey.state, xEvent->xkey.time , reinterpret_cast<GdkEventKey*>(aGdkEvent)->state); } } while (0) |
756 | "aGdkEvent={ state=0x%08X }), "do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "FilterEvents(aXEvent={ type=KeyPress, " "xkey={ keycode=0x%08X, state=0x%08X, time=%lu } }, " "aGdkEvent={ state=0x%08X }), " "detected first keypress", xEvent ->xkey.keycode, xEvent->xkey.state, xEvent->xkey.time , reinterpret_cast<GdkEventKey*>(aGdkEvent)->state); } } while (0) |
757 | "detected first keypress",do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "FilterEvents(aXEvent={ type=KeyPress, " "xkey={ keycode=0x%08X, state=0x%08X, time=%lu } }, " "aGdkEvent={ state=0x%08X }), " "detected first keypress", xEvent ->xkey.keycode, xEvent->xkey.state, xEvent->xkey.time , reinterpret_cast<GdkEventKey*>(aGdkEvent)->state); } } while (0) |
758 | xEvent->xkey.keycode, xEvent->xkey.state, xEvent->xkey.time,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "FilterEvents(aXEvent={ type=KeyPress, " "xkey={ keycode=0x%08X, state=0x%08X, time=%lu } }, " "aGdkEvent={ state=0x%08X }), " "detected first keypress", xEvent ->xkey.keycode, xEvent->xkey.state, xEvent->xkey.time , reinterpret_cast<GdkEventKey*>(aGdkEvent)->state); } } while (0) |
759 | reinterpret_cast<GdkEventKey*>(aGdkEvent)->state))do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "FilterEvents(aXEvent={ type=KeyPress, " "xkey={ keycode=0x%08X, state=0x%08X, time=%lu } }, " "aGdkEvent={ state=0x%08X }), " "detected first keypress", xEvent ->xkey.keycode, xEvent->xkey.state, xEvent->xkey.time , reinterpret_cast<GdkEventKey*>(aGdkEvent)->state); } } while (0); |
760 | } else if (sLastRepeatableHardwareKeyCode == xEvent->xkey.keycode) { |
761 | if (sLastRepeatableKeyTime == xEvent->xkey.time && |
762 | sLastRepeatableHardwareKeyCode == |
763 | IMContextWrapper:: |
764 | GetWaitingSynthesizedKeyPressHardwareKeyCode()) { |
765 | // On some environment, IM may generate duplicated KeyPress event |
766 | // without any special state flags. In such case, we shouldn't |
767 | // treat the event as "repeated". |
768 | MOZ_LOG(gKeyLog, LogLevel::Info,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "FilterEvents(aXEvent={ type=KeyPress, " "xkey={ keycode=0x%08X, state=0x%08X, time=%lu } }, " "aGdkEvent={ state=0x%08X }), " "igored keypress since it must be synthesized by IME" , xEvent->xkey.keycode, xEvent->xkey.state, xEvent-> xkey.time, reinterpret_cast<GdkEventKey*>(aGdkEvent)-> state); } } while (0) |
769 | ("FilterEvents(aXEvent={ type=KeyPress, "do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "FilterEvents(aXEvent={ type=KeyPress, " "xkey={ keycode=0x%08X, state=0x%08X, time=%lu } }, " "aGdkEvent={ state=0x%08X }), " "igored keypress since it must be synthesized by IME" , xEvent->xkey.keycode, xEvent->xkey.state, xEvent-> xkey.time, reinterpret_cast<GdkEventKey*>(aGdkEvent)-> state); } } while (0) |
770 | "xkey={ keycode=0x%08X, state=0x%08X, time=%lu } }, "do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "FilterEvents(aXEvent={ type=KeyPress, " "xkey={ keycode=0x%08X, state=0x%08X, time=%lu } }, " "aGdkEvent={ state=0x%08X }), " "igored keypress since it must be synthesized by IME" , xEvent->xkey.keycode, xEvent->xkey.state, xEvent-> xkey.time, reinterpret_cast<GdkEventKey*>(aGdkEvent)-> state); } } while (0) |
771 | "aGdkEvent={ state=0x%08X }), "do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "FilterEvents(aXEvent={ type=KeyPress, " "xkey={ keycode=0x%08X, state=0x%08X, time=%lu } }, " "aGdkEvent={ state=0x%08X }), " "igored keypress since it must be synthesized by IME" , xEvent->xkey.keycode, xEvent->xkey.state, xEvent-> xkey.time, reinterpret_cast<GdkEventKey*>(aGdkEvent)-> state); } } while (0) |
772 | "igored keypress since it must be synthesized by IME",do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "FilterEvents(aXEvent={ type=KeyPress, " "xkey={ keycode=0x%08X, state=0x%08X, time=%lu } }, " "aGdkEvent={ state=0x%08X }), " "igored keypress since it must be synthesized by IME" , xEvent->xkey.keycode, xEvent->xkey.state, xEvent-> xkey.time, reinterpret_cast<GdkEventKey*>(aGdkEvent)-> state); } } while (0) |
773 | xEvent->xkey.keycode, xEvent->xkey.state, xEvent->xkey.time,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "FilterEvents(aXEvent={ type=KeyPress, " "xkey={ keycode=0x%08X, state=0x%08X, time=%lu } }, " "aGdkEvent={ state=0x%08X }), " "igored keypress since it must be synthesized by IME" , xEvent->xkey.keycode, xEvent->xkey.state, xEvent-> xkey.time, reinterpret_cast<GdkEventKey*>(aGdkEvent)-> state); } } while (0) |
774 | reinterpret_cast<GdkEventKey*>(aGdkEvent)->state))do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "FilterEvents(aXEvent={ type=KeyPress, " "xkey={ keycode=0x%08X, state=0x%08X, time=%lu } }, " "aGdkEvent={ state=0x%08X }), " "igored keypress since it must be synthesized by IME" , xEvent->xkey.keycode, xEvent->xkey.state, xEvent-> xkey.time, reinterpret_cast<GdkEventKey*>(aGdkEvent)-> state); } } while (0); |
775 | break; |
776 | } |
777 | sRepeatState = REPEATING; |
778 | MOZ_LOG(gKeyLog, LogLevel::Info,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "FilterEvents(aXEvent={ type=KeyPress, " "xkey={ keycode=0x%08X, state=0x%08X, time=%lu } }, " "aGdkEvent={ state=0x%08X }), " "detected repeating keypress" , xEvent->xkey.keycode, xEvent->xkey.state, xEvent-> xkey.time, reinterpret_cast<GdkEventKey*>(aGdkEvent)-> state); } } while (0) |
779 | ("FilterEvents(aXEvent={ type=KeyPress, "do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "FilterEvents(aXEvent={ type=KeyPress, " "xkey={ keycode=0x%08X, state=0x%08X, time=%lu } }, " "aGdkEvent={ state=0x%08X }), " "detected repeating keypress" , xEvent->xkey.keycode, xEvent->xkey.state, xEvent-> xkey.time, reinterpret_cast<GdkEventKey*>(aGdkEvent)-> state); } } while (0) |
780 | "xkey={ keycode=0x%08X, state=0x%08X, time=%lu } }, "do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "FilterEvents(aXEvent={ type=KeyPress, " "xkey={ keycode=0x%08X, state=0x%08X, time=%lu } }, " "aGdkEvent={ state=0x%08X }), " "detected repeating keypress" , xEvent->xkey.keycode, xEvent->xkey.state, xEvent-> xkey.time, reinterpret_cast<GdkEventKey*>(aGdkEvent)-> state); } } while (0) |
781 | "aGdkEvent={ state=0x%08X }), "do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "FilterEvents(aXEvent={ type=KeyPress, " "xkey={ keycode=0x%08X, state=0x%08X, time=%lu } }, " "aGdkEvent={ state=0x%08X }), " "detected repeating keypress" , xEvent->xkey.keycode, xEvent->xkey.state, xEvent-> xkey.time, reinterpret_cast<GdkEventKey*>(aGdkEvent)-> state); } } while (0) |
782 | "detected repeating keypress",do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "FilterEvents(aXEvent={ type=KeyPress, " "xkey={ keycode=0x%08X, state=0x%08X, time=%lu } }, " "aGdkEvent={ state=0x%08X }), " "detected repeating keypress" , xEvent->xkey.keycode, xEvent->xkey.state, xEvent-> xkey.time, reinterpret_cast<GdkEventKey*>(aGdkEvent)-> state); } } while (0) |
783 | xEvent->xkey.keycode, xEvent->xkey.state, xEvent->xkey.time,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "FilterEvents(aXEvent={ type=KeyPress, " "xkey={ keycode=0x%08X, state=0x%08X, time=%lu } }, " "aGdkEvent={ state=0x%08X }), " "detected repeating keypress" , xEvent->xkey.keycode, xEvent->xkey.state, xEvent-> xkey.time, reinterpret_cast<GdkEventKey*>(aGdkEvent)-> state); } } while (0) |
784 | reinterpret_cast<GdkEventKey*>(aGdkEvent)->state))do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "FilterEvents(aXEvent={ type=KeyPress, " "xkey={ keycode=0x%08X, state=0x%08X, time=%lu } }, " "aGdkEvent={ state=0x%08X }), " "detected repeating keypress" , xEvent->xkey.keycode, xEvent->xkey.state, xEvent-> xkey.time, reinterpret_cast<GdkEventKey*>(aGdkEvent)-> state); } } while (0); |
785 | } else { |
786 | // If a different key is pressed while another key is pressed, |
787 | // auto repeat system repeats only the last pressed key. |
788 | // So, setting new keycode and setting repeat state as first key |
789 | // press should work fine. |
790 | sRepeatState = FIRST_PRESS; |
791 | MOZ_LOG(gKeyLog, LogLevel::Info,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "FilterEvents(aXEvent={ type=KeyPress, " "xkey={ keycode=0x%08X, state=0x%08X, time=%lu } }, " "aGdkEvent={ state=0x%08X }), " "detected different keypress" , xEvent->xkey.keycode, xEvent->xkey.state, xEvent-> xkey.time, reinterpret_cast<GdkEventKey*>(aGdkEvent)-> state); } } while (0) |
792 | ("FilterEvents(aXEvent={ type=KeyPress, "do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "FilterEvents(aXEvent={ type=KeyPress, " "xkey={ keycode=0x%08X, state=0x%08X, time=%lu } }, " "aGdkEvent={ state=0x%08X }), " "detected different keypress" , xEvent->xkey.keycode, xEvent->xkey.state, xEvent-> xkey.time, reinterpret_cast<GdkEventKey*>(aGdkEvent)-> state); } } while (0) |
793 | "xkey={ keycode=0x%08X, state=0x%08X, time=%lu } }, "do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "FilterEvents(aXEvent={ type=KeyPress, " "xkey={ keycode=0x%08X, state=0x%08X, time=%lu } }, " "aGdkEvent={ state=0x%08X }), " "detected different keypress" , xEvent->xkey.keycode, xEvent->xkey.state, xEvent-> xkey.time, reinterpret_cast<GdkEventKey*>(aGdkEvent)-> state); } } while (0) |
794 | "aGdkEvent={ state=0x%08X }), "do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "FilterEvents(aXEvent={ type=KeyPress, " "xkey={ keycode=0x%08X, state=0x%08X, time=%lu } }, " "aGdkEvent={ state=0x%08X }), " "detected different keypress" , xEvent->xkey.keycode, xEvent->xkey.state, xEvent-> xkey.time, reinterpret_cast<GdkEventKey*>(aGdkEvent)-> state); } } while (0) |
795 | "detected different keypress",do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "FilterEvents(aXEvent={ type=KeyPress, " "xkey={ keycode=0x%08X, state=0x%08X, time=%lu } }, " "aGdkEvent={ state=0x%08X }), " "detected different keypress" , xEvent->xkey.keycode, xEvent->xkey.state, xEvent-> xkey.time, reinterpret_cast<GdkEventKey*>(aGdkEvent)-> state); } } while (0) |
796 | xEvent->xkey.keycode, xEvent->xkey.state, xEvent->xkey.time,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "FilterEvents(aXEvent={ type=KeyPress, " "xkey={ keycode=0x%08X, state=0x%08X, time=%lu } }, " "aGdkEvent={ state=0x%08X }), " "detected different keypress" , xEvent->xkey.keycode, xEvent->xkey.state, xEvent-> xkey.time, reinterpret_cast<GdkEventKey*>(aGdkEvent)-> state); } } while (0) |
797 | reinterpret_cast<GdkEventKey*>(aGdkEvent)->state))do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "FilterEvents(aXEvent={ type=KeyPress, " "xkey={ keycode=0x%08X, state=0x%08X, time=%lu } }, " "aGdkEvent={ state=0x%08X }), " "detected different keypress" , xEvent->xkey.keycode, xEvent->xkey.state, xEvent-> xkey.time, reinterpret_cast<GdkEventKey*>(aGdkEvent)-> state); } } while (0); |
798 | } |
799 | sLastRepeatableHardwareKeyCode = xEvent->xkey.keycode; |
800 | sLastRepeatableKeyTime = xEvent->xkey.time; |
801 | break; |
802 | } |
803 | case KeyRelease3: { |
804 | if (sLastRepeatableHardwareKeyCode != xEvent->xkey.keycode) { |
805 | // This case means the key release event is caused by |
806 | // a non-repeatable key such as Shift or a repeatable key that |
807 | // was pressed before sLastRepeatableHardwareKeyCode was |
808 | // pressed. |
809 | break; |
810 | } |
811 | sRepeatState = NOT_PRESSED; |
812 | MOZ_LOG(gKeyLog, LogLevel::Info,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "FilterEvents(aXEvent={ type=KeyRelease, " "xkey={ keycode=0x%08X, state=0x%08X, time=%lu } }, " "aGdkEvent={ state=0x%08X }), " "detected key release", xEvent ->xkey.keycode, xEvent->xkey.state, xEvent->xkey.time , reinterpret_cast<GdkEventKey*>(aGdkEvent)->state); } } while (0) |
813 | ("FilterEvents(aXEvent={ type=KeyRelease, "do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "FilterEvents(aXEvent={ type=KeyRelease, " "xkey={ keycode=0x%08X, state=0x%08X, time=%lu } }, " "aGdkEvent={ state=0x%08X }), " "detected key release", xEvent ->xkey.keycode, xEvent->xkey.state, xEvent->xkey.time , reinterpret_cast<GdkEventKey*>(aGdkEvent)->state); } } while (0) |
814 | "xkey={ keycode=0x%08X, state=0x%08X, time=%lu } }, "do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "FilterEvents(aXEvent={ type=KeyRelease, " "xkey={ keycode=0x%08X, state=0x%08X, time=%lu } }, " "aGdkEvent={ state=0x%08X }), " "detected key release", xEvent ->xkey.keycode, xEvent->xkey.state, xEvent->xkey.time , reinterpret_cast<GdkEventKey*>(aGdkEvent)->state); } } while (0) |
815 | "aGdkEvent={ state=0x%08X }), "do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "FilterEvents(aXEvent={ type=KeyRelease, " "xkey={ keycode=0x%08X, state=0x%08X, time=%lu } }, " "aGdkEvent={ state=0x%08X }), " "detected key release", xEvent ->xkey.keycode, xEvent->xkey.state, xEvent->xkey.time , reinterpret_cast<GdkEventKey*>(aGdkEvent)->state); } } while (0) |
816 | "detected key release",do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "FilterEvents(aXEvent={ type=KeyRelease, " "xkey={ keycode=0x%08X, state=0x%08X, time=%lu } }, " "aGdkEvent={ state=0x%08X }), " "detected key release", xEvent ->xkey.keycode, xEvent->xkey.state, xEvent->xkey.time , reinterpret_cast<GdkEventKey*>(aGdkEvent)->state); } } while (0) |
817 | xEvent->xkey.keycode, xEvent->xkey.state, xEvent->xkey.time,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "FilterEvents(aXEvent={ type=KeyRelease, " "xkey={ keycode=0x%08X, state=0x%08X, time=%lu } }, " "aGdkEvent={ state=0x%08X }), " "detected key release", xEvent ->xkey.keycode, xEvent->xkey.state, xEvent->xkey.time , reinterpret_cast<GdkEventKey*>(aGdkEvent)->state); } } while (0) |
818 | reinterpret_cast<GdkEventKey*>(aGdkEvent)->state))do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "FilterEvents(aXEvent={ type=KeyRelease, " "xkey={ keycode=0x%08X, state=0x%08X, time=%lu } }, " "aGdkEvent={ state=0x%08X }), " "detected key release", xEvent ->xkey.keycode, xEvent->xkey.state, xEvent->xkey.time , reinterpret_cast<GdkEventKey*>(aGdkEvent)->state); } } while (0); |
819 | break; |
820 | } |
821 | case FocusOut10: { |
822 | // At moving focus, we should reset keyboard repeat state. |
823 | // Strictly, this causes incorrect behavior. However, this |
824 | // correctness must be enough for web applications. |
825 | sRepeatState = NOT_PRESSED; |
826 | break; |
827 | } |
828 | default: { |
829 | KeymapWrapper* self = static_cast<KeymapWrapper*>(aData); |
830 | if (xEvent->type != self->mXKBBaseEventCode) { |
831 | break; |
832 | } |
833 | XkbEvent* xkbEvent = (XkbEvent*)xEvent; |
834 | if (xkbEvent->any.xkb_type != XkbControlsNotify3 || |
835 | !(xkbEvent->ctrls.changed_ctrls & XkbPerKeyRepeatMask(1L << 30))) { |
836 | break; |
837 | } |
838 | if (!XGetKeyboardControl(xkbEvent->any.display, &self->mKeyboardState)) { |
839 | MOZ_LOG(gKeyLog, LogLevel::Info,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p FilterEvents failed due to failure " "of XGetKeyboardControl(), display=0x%p" , self, xkbEvent->any.display); } } while (0) |
840 | ("%p FilterEvents failed due to failure "do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p FilterEvents failed due to failure " "of XGetKeyboardControl(), display=0x%p" , self, xkbEvent->any.display); } } while (0) |
841 | "of XGetKeyboardControl(), display=0x%p",do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p FilterEvents failed due to failure " "of XGetKeyboardControl(), display=0x%p" , self, xkbEvent->any.display); } } while (0) |
842 | self, xkbEvent->any.display))do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p FilterEvents failed due to failure " "of XGetKeyboardControl(), display=0x%p" , self, xkbEvent->any.display); } } while (0); |
843 | } |
844 | break; |
845 | } |
846 | } |
847 | |
848 | return GDK_FILTER_CONTINUE; |
849 | } |
850 | #endif |
851 | |
852 | static void ResetBidiKeyboard() { |
853 | // Reset the bidi keyboard settings for the new GdkKeymap |
854 | nsCOMPtr<nsIBidiKeyboard> bidiKeyboard = nsContentUtils::GetBidiKeyboard(); |
855 | if (bidiKeyboard) { |
856 | bidiKeyboard->Reset(); |
857 | } |
858 | WidgetUtils::SendBidiKeyboardInfoToContent(); |
859 | } |
860 | |
861 | /* static */ |
862 | void KeymapWrapper::ResetKeyboard() { |
863 | if (sInstance) { |
864 | sInstance->mInitialized = false; |
865 | ResetBidiKeyboard(); |
866 | } |
867 | } |
868 | |
869 | /* static */ |
870 | void KeymapWrapper::OnKeysChanged(GdkKeymap* aGdkKeymap, |
871 | KeymapWrapper* aKeymapWrapper) { |
872 | MOZ_LOG(gKeyLog, LogLevel::Info,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "OnKeysChanged, aGdkKeymap=%p, aKeymapWrapper=%p" , aGdkKeymap, aKeymapWrapper); } } while (0) |
873 | ("OnKeysChanged, aGdkKeymap=%p, aKeymapWrapper=%p", aGdkKeymap,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "OnKeysChanged, aGdkKeymap=%p, aKeymapWrapper=%p" , aGdkKeymap, aKeymapWrapper); } } while (0) |
874 | aKeymapWrapper))do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "OnKeysChanged, aGdkKeymap=%p, aKeymapWrapper=%p" , aGdkKeymap, aKeymapWrapper); } } while (0); |
875 | |
876 | MOZ_ASSERT(sInstance == aKeymapWrapper,do { static_assert( mozilla::detail::AssertionConditionType< decltype(sInstance == aKeymapWrapper)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(sInstance == aKeymapWrapper) )), 0))) { do { } while (false); MOZ_ReportAssertionFailure("sInstance == aKeymapWrapper" " (" "This instance must be the singleton instance" ")", "/var/lib/jenkins/workspace/firefox-scan-build/widget/gtk/nsGtkKeyUtils.cpp" , 877); AnnotateMozCrashReason("MOZ_ASSERT" "(" "sInstance == aKeymapWrapper" ") (" "This instance must be the singleton instance" ")"); do { *((volatile int*)__null) = 877; __attribute__((nomerge)) :: abort(); } while (false); } } while (false) |
877 | "This instance must be the singleton instance")do { static_assert( mozilla::detail::AssertionConditionType< decltype(sInstance == aKeymapWrapper)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(sInstance == aKeymapWrapper) )), 0))) { do { } while (false); MOZ_ReportAssertionFailure("sInstance == aKeymapWrapper" " (" "This instance must be the singleton instance" ")", "/var/lib/jenkins/workspace/firefox-scan-build/widget/gtk/nsGtkKeyUtils.cpp" , 877); AnnotateMozCrashReason("MOZ_ASSERT" "(" "sInstance == aKeymapWrapper" ") (" "This instance must be the singleton instance" ")"); do { *((volatile int*)__null) = 877; __attribute__((nomerge)) :: abort(); } while (false); } } while (false); |
878 | |
879 | // We cannot reintialize here becasue we don't have GdkWindow which is using |
880 | // the GdkKeymap. We'll reinitialize it when next GetInstance() is called. |
881 | ResetKeyboard(); |
882 | } |
883 | |
884 | // static |
885 | void KeymapWrapper::OnDirectionChanged(GdkKeymap* aGdkKeymap, |
886 | KeymapWrapper* aKeymapWrapper) { |
887 | // XXX |
888 | // A lot of diretion-changed signal might be fired on switching bidi |
889 | // keyboard when using both ibus (with arabic layout) and fcitx (with IME). |
890 | // See https://github.com/fcitx/fcitx/issues/257 |
891 | // |
892 | // Also, when using ibus, switching to IM might not cause this signal. |
893 | // See https://github.com/ibus/ibus/issues/1848 |
894 | |
895 | MOZ_LOG(gKeyLog, LogLevel::Info,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "OnDirectionChanged, aGdkKeymap=%p, aKeymapWrapper=%p" , aGdkKeymap, aKeymapWrapper); } } while (0) |
896 | ("OnDirectionChanged, aGdkKeymap=%p, aKeymapWrapper=%p", aGdkKeymap,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "OnDirectionChanged, aGdkKeymap=%p, aKeymapWrapper=%p" , aGdkKeymap, aKeymapWrapper); } } while (0) |
897 | aKeymapWrapper))do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "OnDirectionChanged, aGdkKeymap=%p, aKeymapWrapper=%p" , aGdkKeymap, aKeymapWrapper); } } while (0); |
898 | |
899 | ResetBidiKeyboard(); |
900 | } |
901 | |
902 | /* static */ |
903 | guint KeymapWrapper::GetCurrentModifierState() { |
904 | GdkModifierType modifiers; |
905 | GdkDisplay* display = gdk_display_get_default(); |
906 | GdkScreen* screen = gdk_display_get_default_screen(display); |
907 | GdkWindow* window = gdk_screen_get_root_window(screen); |
908 | gdk_window_get_device_position(window, GdkGetPointer(), nullptr, nullptr, |
909 | &modifiers); |
910 | return static_cast<guint>(modifiers); |
911 | } |
912 | |
913 | /* static */ |
914 | bool KeymapWrapper::AreModifiersActive(MappedModifiers aModifiers, |
915 | guint aGdkModifierState) { |
916 | NS_ENSURE_TRUE(aModifiers, false)do { if ((__builtin_expect(!!(!(aModifiers)), 0))) { NS_DebugBreak (NS_DEBUG_WARNING, "NS_ENSURE_TRUE(" "aModifiers" ") failed", nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/widget/gtk/nsGtkKeyUtils.cpp" , 916); return false; } } while (false); |
917 | |
918 | KeymapWrapper* keymapWrapper = GetInstance(); |
919 | for (uint32_t i = 0; i < sizeof(MappedModifier) * 8 && aModifiers; i++) { |
920 | MappedModifier modifier = static_cast<MappedModifier>(1 << i); |
921 | // Is the binary position used by modifier? |
922 | if (!(aModifiers & modifier)) { |
923 | continue; |
924 | } |
925 | // Is the modifier active? |
926 | if (!(aGdkModifierState & keymapWrapper->GetGdkModifierMask(modifier))) { |
927 | return false; |
928 | } |
929 | aModifiers &= ~modifier; |
930 | } |
931 | return true; |
932 | } |
933 | |
934 | /* static */ |
935 | uint32_t KeymapWrapper::ComputeCurrentKeyModifiers() { |
936 | return ComputeKeyModifiers(GetCurrentModifierState()); |
937 | } |
938 | |
939 | /* static */ |
940 | uint32_t KeymapWrapper::ComputeKeyModifiers(guint aGdkModifierState) { |
941 | uint32_t keyModifiers = 0; |
942 | if (!aGdkModifierState) { |
943 | return keyModifiers; |
944 | } |
945 | |
946 | // DOM Meta key should be TRUE only on Mac. We need to discuss this |
947 | // issue later. |
948 | KeymapWrapper* keymapWrapper = GetInstance(); |
949 | if (keymapWrapper->AreModifiersActive(SHIFT, aGdkModifierState)) { |
950 | keyModifiers |= MODIFIER_SHIFT; |
951 | } |
952 | if (keymapWrapper->AreModifiersActive(CTRL, aGdkModifierState)) { |
953 | keyModifiers |= MODIFIER_CONTROL; |
954 | } |
955 | if (keymapWrapper->AreModifiersActive(ALT, aGdkModifierState)) { |
956 | keyModifiers |= MODIFIER_ALT; |
957 | } |
958 | if (keymapWrapper->AreModifiersActive(SUPER, aGdkModifierState) || |
959 | keymapWrapper->AreModifiersActive(HYPER, aGdkModifierState) || |
960 | // "Meta" state is typically mapped to `Alt` + `Shift`, but we ignore the |
961 | // state if `Alt` is mapped to "Alt" state. Additionally it's mapped to |
962 | // `Win` in Sun/Solaris keyboard layout. In this case, we want to treat |
963 | // them as DOM Meta modifier keys like "Super" state in the major Linux |
964 | // environments. |
965 | keymapWrapper->AreModifiersActive(META, aGdkModifierState)) { |
966 | keyModifiers |= MODIFIER_META; |
967 | } |
968 | if (keymapWrapper->AreModifiersActive(LEVEL3, aGdkModifierState) || |
969 | keymapWrapper->AreModifiersActive(LEVEL5, aGdkModifierState)) { |
970 | keyModifiers |= MODIFIER_ALTGRAPH; |
971 | } |
972 | if (keymapWrapper->AreModifiersActive(CAPS_LOCK, aGdkModifierState)) { |
973 | keyModifiers |= MODIFIER_CAPSLOCK; |
974 | } |
975 | if (keymapWrapper->AreModifiersActive(NUM_LOCK, aGdkModifierState)) { |
976 | keyModifiers |= MODIFIER_NUMLOCK; |
977 | } |
978 | if (keymapWrapper->AreModifiersActive(SCROLL_LOCK, aGdkModifierState)) { |
979 | keyModifiers |= MODIFIER_SCROLLLOCK; |
980 | } |
981 | return keyModifiers; |
982 | } |
983 | |
984 | /* static */ |
985 | guint KeymapWrapper::ConvertWidgetModifierToGdkState( |
986 | nsIWidget::Modifiers aNativeModifiers) { |
987 | if (!aNativeModifiers) { |
988 | return 0; |
989 | } |
990 | struct ModifierMapEntry { |
991 | nsIWidget::Modifiers mWidgetModifier; |
992 | MappedModifier mModifier; |
993 | }; |
994 | // TODO: Currently, we don't treat L/R of each modifier on Linux. |
995 | // TODO: No proper native modifier for Level5. |
996 | static constexpr ModifierMapEntry sModifierMap[] = { |
997 | {nsIWidget::CAPS_LOCK, MappedModifier::CAPS_LOCK}, |
998 | {nsIWidget::NUM_LOCK, MappedModifier::NUM_LOCK}, |
999 | {nsIWidget::SHIFT_L, MappedModifier::SHIFT}, |
1000 | {nsIWidget::SHIFT_R, MappedModifier::SHIFT}, |
1001 | {nsIWidget::CTRL_L, MappedModifier::CTRL}, |
1002 | {nsIWidget::CTRL_R, MappedModifier::CTRL}, |
1003 | {nsIWidget::ALT_L, MappedModifier::ALT}, |
1004 | {nsIWidget::ALT_R, MappedModifier::ALT}, |
1005 | {nsIWidget::ALTGRAPH, MappedModifier::LEVEL3}, |
1006 | {nsIWidget::COMMAND_L, MappedModifier::SUPER}, |
1007 | {nsIWidget::COMMAND_R, MappedModifier::SUPER}}; |
1008 | |
1009 | guint state = 0; |
1010 | KeymapWrapper* instance = GetInstance(); |
1011 | for (const ModifierMapEntry& entry : sModifierMap) { |
1012 | if (aNativeModifiers & entry.mWidgetModifier) { |
1013 | state |= instance->GetGdkModifierMask(entry.mModifier); |
1014 | } |
1015 | } |
1016 | return state; |
1017 | } |
1018 | |
1019 | /* static */ |
1020 | void KeymapWrapper::InitInputEvent(WidgetInputEvent& aInputEvent, |
1021 | guint aGdkModifierState) { |
1022 | KeymapWrapper* keymapWrapper = GetInstance(); |
1023 | |
1024 | aInputEvent.mModifiers = ComputeKeyModifiers(aGdkModifierState); |
1025 | |
1026 | // Don't log this method for non-important events because e.g., eMouseMove is |
1027 | // just noisy and there is no reason to log it. |
1028 | bool doLog = aInputEvent.mMessage != eMouseMove; |
1029 | if (doLog) { |
1030 | MOZ_LOG(gKeyLog, LogLevel::Debug,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Debug)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Debug, "%p InitInputEvent, aGdkModifierState=0x%08X, " "aInputEvent={ mMessage=%s, mModifiers=0x%04X (Shift: %s, " "Control: %s, Alt: %s, Meta: %s, AltGr: %s, " "CapsLock: %s, NumLock: %s, ScrollLock: %s })", keymapWrapper , aGdkModifierState, ToChar(aInputEvent.mMessage), aInputEvent .mModifiers, GetBoolName(aInputEvent.mModifiers & MODIFIER_SHIFT ), GetBoolName(aInputEvent.mModifiers & MODIFIER_CONTROL) , GetBoolName(aInputEvent.mModifiers & MODIFIER_ALT), GetBoolName (aInputEvent.mModifiers & MODIFIER_META), GetBoolName(aInputEvent .mModifiers & MODIFIER_ALTGRAPH), GetBoolName(aInputEvent .mModifiers & MODIFIER_CAPSLOCK), GetBoolName(aInputEvent .mModifiers & MODIFIER_NUMLOCK), GetBoolName(aInputEvent. mModifiers & MODIFIER_SCROLLLOCK)); } } while (0) |
1031 | ("%p InitInputEvent, aGdkModifierState=0x%08X, "do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Debug)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Debug, "%p InitInputEvent, aGdkModifierState=0x%08X, " "aInputEvent={ mMessage=%s, mModifiers=0x%04X (Shift: %s, " "Control: %s, Alt: %s, Meta: %s, AltGr: %s, " "CapsLock: %s, NumLock: %s, ScrollLock: %s })", keymapWrapper , aGdkModifierState, ToChar(aInputEvent.mMessage), aInputEvent .mModifiers, GetBoolName(aInputEvent.mModifiers & MODIFIER_SHIFT ), GetBoolName(aInputEvent.mModifiers & MODIFIER_CONTROL) , GetBoolName(aInputEvent.mModifiers & MODIFIER_ALT), GetBoolName (aInputEvent.mModifiers & MODIFIER_META), GetBoolName(aInputEvent .mModifiers & MODIFIER_ALTGRAPH), GetBoolName(aInputEvent .mModifiers & MODIFIER_CAPSLOCK), GetBoolName(aInputEvent .mModifiers & MODIFIER_NUMLOCK), GetBoolName(aInputEvent. mModifiers & MODIFIER_SCROLLLOCK)); } } while (0) |
1032 | "aInputEvent={ mMessage=%s, mModifiers=0x%04X (Shift: %s, "do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Debug)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Debug, "%p InitInputEvent, aGdkModifierState=0x%08X, " "aInputEvent={ mMessage=%s, mModifiers=0x%04X (Shift: %s, " "Control: %s, Alt: %s, Meta: %s, AltGr: %s, " "CapsLock: %s, NumLock: %s, ScrollLock: %s })", keymapWrapper , aGdkModifierState, ToChar(aInputEvent.mMessage), aInputEvent .mModifiers, GetBoolName(aInputEvent.mModifiers & MODIFIER_SHIFT ), GetBoolName(aInputEvent.mModifiers & MODIFIER_CONTROL) , GetBoolName(aInputEvent.mModifiers & MODIFIER_ALT), GetBoolName (aInputEvent.mModifiers & MODIFIER_META), GetBoolName(aInputEvent .mModifiers & MODIFIER_ALTGRAPH), GetBoolName(aInputEvent .mModifiers & MODIFIER_CAPSLOCK), GetBoolName(aInputEvent .mModifiers & MODIFIER_NUMLOCK), GetBoolName(aInputEvent. mModifiers & MODIFIER_SCROLLLOCK)); } } while (0) |
1033 | "Control: %s, Alt: %s, Meta: %s, AltGr: %s, "do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Debug)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Debug, "%p InitInputEvent, aGdkModifierState=0x%08X, " "aInputEvent={ mMessage=%s, mModifiers=0x%04X (Shift: %s, " "Control: %s, Alt: %s, Meta: %s, AltGr: %s, " "CapsLock: %s, NumLock: %s, ScrollLock: %s })", keymapWrapper , aGdkModifierState, ToChar(aInputEvent.mMessage), aInputEvent .mModifiers, GetBoolName(aInputEvent.mModifiers & MODIFIER_SHIFT ), GetBoolName(aInputEvent.mModifiers & MODIFIER_CONTROL) , GetBoolName(aInputEvent.mModifiers & MODIFIER_ALT), GetBoolName (aInputEvent.mModifiers & MODIFIER_META), GetBoolName(aInputEvent .mModifiers & MODIFIER_ALTGRAPH), GetBoolName(aInputEvent .mModifiers & MODIFIER_CAPSLOCK), GetBoolName(aInputEvent .mModifiers & MODIFIER_NUMLOCK), GetBoolName(aInputEvent. mModifiers & MODIFIER_SCROLLLOCK)); } } while (0) |
1034 | "CapsLock: %s, NumLock: %s, ScrollLock: %s })",do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Debug)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Debug, "%p InitInputEvent, aGdkModifierState=0x%08X, " "aInputEvent={ mMessage=%s, mModifiers=0x%04X (Shift: %s, " "Control: %s, Alt: %s, Meta: %s, AltGr: %s, " "CapsLock: %s, NumLock: %s, ScrollLock: %s })", keymapWrapper , aGdkModifierState, ToChar(aInputEvent.mMessage), aInputEvent .mModifiers, GetBoolName(aInputEvent.mModifiers & MODIFIER_SHIFT ), GetBoolName(aInputEvent.mModifiers & MODIFIER_CONTROL) , GetBoolName(aInputEvent.mModifiers & MODIFIER_ALT), GetBoolName (aInputEvent.mModifiers & MODIFIER_META), GetBoolName(aInputEvent .mModifiers & MODIFIER_ALTGRAPH), GetBoolName(aInputEvent .mModifiers & MODIFIER_CAPSLOCK), GetBoolName(aInputEvent .mModifiers & MODIFIER_NUMLOCK), GetBoolName(aInputEvent. mModifiers & MODIFIER_SCROLLLOCK)); } } while (0) |
1035 | keymapWrapper, aGdkModifierState, ToChar(aInputEvent.mMessage),do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Debug)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Debug, "%p InitInputEvent, aGdkModifierState=0x%08X, " "aInputEvent={ mMessage=%s, mModifiers=0x%04X (Shift: %s, " "Control: %s, Alt: %s, Meta: %s, AltGr: %s, " "CapsLock: %s, NumLock: %s, ScrollLock: %s })", keymapWrapper , aGdkModifierState, ToChar(aInputEvent.mMessage), aInputEvent .mModifiers, GetBoolName(aInputEvent.mModifiers & MODIFIER_SHIFT ), GetBoolName(aInputEvent.mModifiers & MODIFIER_CONTROL) , GetBoolName(aInputEvent.mModifiers & MODIFIER_ALT), GetBoolName (aInputEvent.mModifiers & MODIFIER_META), GetBoolName(aInputEvent .mModifiers & MODIFIER_ALTGRAPH), GetBoolName(aInputEvent .mModifiers & MODIFIER_CAPSLOCK), GetBoolName(aInputEvent .mModifiers & MODIFIER_NUMLOCK), GetBoolName(aInputEvent. mModifiers & MODIFIER_SCROLLLOCK)); } } while (0) |
1036 | aInputEvent.mModifiers,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Debug)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Debug, "%p InitInputEvent, aGdkModifierState=0x%08X, " "aInputEvent={ mMessage=%s, mModifiers=0x%04X (Shift: %s, " "Control: %s, Alt: %s, Meta: %s, AltGr: %s, " "CapsLock: %s, NumLock: %s, ScrollLock: %s })", keymapWrapper , aGdkModifierState, ToChar(aInputEvent.mMessage), aInputEvent .mModifiers, GetBoolName(aInputEvent.mModifiers & MODIFIER_SHIFT ), GetBoolName(aInputEvent.mModifiers & MODIFIER_CONTROL) , GetBoolName(aInputEvent.mModifiers & MODIFIER_ALT), GetBoolName (aInputEvent.mModifiers & MODIFIER_META), GetBoolName(aInputEvent .mModifiers & MODIFIER_ALTGRAPH), GetBoolName(aInputEvent .mModifiers & MODIFIER_CAPSLOCK), GetBoolName(aInputEvent .mModifiers & MODIFIER_NUMLOCK), GetBoolName(aInputEvent. mModifiers & MODIFIER_SCROLLLOCK)); } } while (0) |
1037 | GetBoolName(aInputEvent.mModifiers & MODIFIER_SHIFT),do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Debug)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Debug, "%p InitInputEvent, aGdkModifierState=0x%08X, " "aInputEvent={ mMessage=%s, mModifiers=0x%04X (Shift: %s, " "Control: %s, Alt: %s, Meta: %s, AltGr: %s, " "CapsLock: %s, NumLock: %s, ScrollLock: %s })", keymapWrapper , aGdkModifierState, ToChar(aInputEvent.mMessage), aInputEvent .mModifiers, GetBoolName(aInputEvent.mModifiers & MODIFIER_SHIFT ), GetBoolName(aInputEvent.mModifiers & MODIFIER_CONTROL) , GetBoolName(aInputEvent.mModifiers & MODIFIER_ALT), GetBoolName (aInputEvent.mModifiers & MODIFIER_META), GetBoolName(aInputEvent .mModifiers & MODIFIER_ALTGRAPH), GetBoolName(aInputEvent .mModifiers & MODIFIER_CAPSLOCK), GetBoolName(aInputEvent .mModifiers & MODIFIER_NUMLOCK), GetBoolName(aInputEvent. mModifiers & MODIFIER_SCROLLLOCK)); } } while (0) |
1038 | GetBoolName(aInputEvent.mModifiers & MODIFIER_CONTROL),do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Debug)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Debug, "%p InitInputEvent, aGdkModifierState=0x%08X, " "aInputEvent={ mMessage=%s, mModifiers=0x%04X (Shift: %s, " "Control: %s, Alt: %s, Meta: %s, AltGr: %s, " "CapsLock: %s, NumLock: %s, ScrollLock: %s })", keymapWrapper , aGdkModifierState, ToChar(aInputEvent.mMessage), aInputEvent .mModifiers, GetBoolName(aInputEvent.mModifiers & MODIFIER_SHIFT ), GetBoolName(aInputEvent.mModifiers & MODIFIER_CONTROL) , GetBoolName(aInputEvent.mModifiers & MODIFIER_ALT), GetBoolName (aInputEvent.mModifiers & MODIFIER_META), GetBoolName(aInputEvent .mModifiers & MODIFIER_ALTGRAPH), GetBoolName(aInputEvent .mModifiers & MODIFIER_CAPSLOCK), GetBoolName(aInputEvent .mModifiers & MODIFIER_NUMLOCK), GetBoolName(aInputEvent. mModifiers & MODIFIER_SCROLLLOCK)); } } while (0) |
1039 | GetBoolName(aInputEvent.mModifiers & MODIFIER_ALT),do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Debug)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Debug, "%p InitInputEvent, aGdkModifierState=0x%08X, " "aInputEvent={ mMessage=%s, mModifiers=0x%04X (Shift: %s, " "Control: %s, Alt: %s, Meta: %s, AltGr: %s, " "CapsLock: %s, NumLock: %s, ScrollLock: %s })", keymapWrapper , aGdkModifierState, ToChar(aInputEvent.mMessage), aInputEvent .mModifiers, GetBoolName(aInputEvent.mModifiers & MODIFIER_SHIFT ), GetBoolName(aInputEvent.mModifiers & MODIFIER_CONTROL) , GetBoolName(aInputEvent.mModifiers & MODIFIER_ALT), GetBoolName (aInputEvent.mModifiers & MODIFIER_META), GetBoolName(aInputEvent .mModifiers & MODIFIER_ALTGRAPH), GetBoolName(aInputEvent .mModifiers & MODIFIER_CAPSLOCK), GetBoolName(aInputEvent .mModifiers & MODIFIER_NUMLOCK), GetBoolName(aInputEvent. mModifiers & MODIFIER_SCROLLLOCK)); } } while (0) |
1040 | GetBoolName(aInputEvent.mModifiers & MODIFIER_META),do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Debug)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Debug, "%p InitInputEvent, aGdkModifierState=0x%08X, " "aInputEvent={ mMessage=%s, mModifiers=0x%04X (Shift: %s, " "Control: %s, Alt: %s, Meta: %s, AltGr: %s, " "CapsLock: %s, NumLock: %s, ScrollLock: %s })", keymapWrapper , aGdkModifierState, ToChar(aInputEvent.mMessage), aInputEvent .mModifiers, GetBoolName(aInputEvent.mModifiers & MODIFIER_SHIFT ), GetBoolName(aInputEvent.mModifiers & MODIFIER_CONTROL) , GetBoolName(aInputEvent.mModifiers & MODIFIER_ALT), GetBoolName (aInputEvent.mModifiers & MODIFIER_META), GetBoolName(aInputEvent .mModifiers & MODIFIER_ALTGRAPH), GetBoolName(aInputEvent .mModifiers & MODIFIER_CAPSLOCK), GetBoolName(aInputEvent .mModifiers & MODIFIER_NUMLOCK), GetBoolName(aInputEvent. mModifiers & MODIFIER_SCROLLLOCK)); } } while (0) |
1041 | GetBoolName(aInputEvent.mModifiers & MODIFIER_ALTGRAPH),do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Debug)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Debug, "%p InitInputEvent, aGdkModifierState=0x%08X, " "aInputEvent={ mMessage=%s, mModifiers=0x%04X (Shift: %s, " "Control: %s, Alt: %s, Meta: %s, AltGr: %s, " "CapsLock: %s, NumLock: %s, ScrollLock: %s })", keymapWrapper , aGdkModifierState, ToChar(aInputEvent.mMessage), aInputEvent .mModifiers, GetBoolName(aInputEvent.mModifiers & MODIFIER_SHIFT ), GetBoolName(aInputEvent.mModifiers & MODIFIER_CONTROL) , GetBoolName(aInputEvent.mModifiers & MODIFIER_ALT), GetBoolName (aInputEvent.mModifiers & MODIFIER_META), GetBoolName(aInputEvent .mModifiers & MODIFIER_ALTGRAPH), GetBoolName(aInputEvent .mModifiers & MODIFIER_CAPSLOCK), GetBoolName(aInputEvent .mModifiers & MODIFIER_NUMLOCK), GetBoolName(aInputEvent. mModifiers & MODIFIER_SCROLLLOCK)); } } while (0) |
1042 | GetBoolName(aInputEvent.mModifiers & MODIFIER_CAPSLOCK),do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Debug)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Debug, "%p InitInputEvent, aGdkModifierState=0x%08X, " "aInputEvent={ mMessage=%s, mModifiers=0x%04X (Shift: %s, " "Control: %s, Alt: %s, Meta: %s, AltGr: %s, " "CapsLock: %s, NumLock: %s, ScrollLock: %s })", keymapWrapper , aGdkModifierState, ToChar(aInputEvent.mMessage), aInputEvent .mModifiers, GetBoolName(aInputEvent.mModifiers & MODIFIER_SHIFT ), GetBoolName(aInputEvent.mModifiers & MODIFIER_CONTROL) , GetBoolName(aInputEvent.mModifiers & MODIFIER_ALT), GetBoolName (aInputEvent.mModifiers & MODIFIER_META), GetBoolName(aInputEvent .mModifiers & MODIFIER_ALTGRAPH), GetBoolName(aInputEvent .mModifiers & MODIFIER_CAPSLOCK), GetBoolName(aInputEvent .mModifiers & MODIFIER_NUMLOCK), GetBoolName(aInputEvent. mModifiers & MODIFIER_SCROLLLOCK)); } } while (0) |
1043 | GetBoolName(aInputEvent.mModifiers & MODIFIER_NUMLOCK),do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Debug)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Debug, "%p InitInputEvent, aGdkModifierState=0x%08X, " "aInputEvent={ mMessage=%s, mModifiers=0x%04X (Shift: %s, " "Control: %s, Alt: %s, Meta: %s, AltGr: %s, " "CapsLock: %s, NumLock: %s, ScrollLock: %s })", keymapWrapper , aGdkModifierState, ToChar(aInputEvent.mMessage), aInputEvent .mModifiers, GetBoolName(aInputEvent.mModifiers & MODIFIER_SHIFT ), GetBoolName(aInputEvent.mModifiers & MODIFIER_CONTROL) , GetBoolName(aInputEvent.mModifiers & MODIFIER_ALT), GetBoolName (aInputEvent.mModifiers & MODIFIER_META), GetBoolName(aInputEvent .mModifiers & MODIFIER_ALTGRAPH), GetBoolName(aInputEvent .mModifiers & MODIFIER_CAPSLOCK), GetBoolName(aInputEvent .mModifiers & MODIFIER_NUMLOCK), GetBoolName(aInputEvent. mModifiers & MODIFIER_SCROLLLOCK)); } } while (0) |
1044 | GetBoolName(aInputEvent.mModifiers & MODIFIER_SCROLLLOCK)))do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Debug)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Debug, "%p InitInputEvent, aGdkModifierState=0x%08X, " "aInputEvent={ mMessage=%s, mModifiers=0x%04X (Shift: %s, " "Control: %s, Alt: %s, Meta: %s, AltGr: %s, " "CapsLock: %s, NumLock: %s, ScrollLock: %s })", keymapWrapper , aGdkModifierState, ToChar(aInputEvent.mMessage), aInputEvent .mModifiers, GetBoolName(aInputEvent.mModifiers & MODIFIER_SHIFT ), GetBoolName(aInputEvent.mModifiers & MODIFIER_CONTROL) , GetBoolName(aInputEvent.mModifiers & MODIFIER_ALT), GetBoolName (aInputEvent.mModifiers & MODIFIER_META), GetBoolName(aInputEvent .mModifiers & MODIFIER_ALTGRAPH), GetBoolName(aInputEvent .mModifiers & MODIFIER_CAPSLOCK), GetBoolName(aInputEvent .mModifiers & MODIFIER_NUMLOCK), GetBoolName(aInputEvent. mModifiers & MODIFIER_SCROLLLOCK)); } } while (0); |
1045 | } |
1046 | |
1047 | switch (aInputEvent.mClass) { |
1048 | case eMouseEventClass: |
1049 | case ePointerEventClass: |
1050 | case eMouseScrollEventClass: |
1051 | case eWheelEventClass: |
1052 | case eDragEventClass: |
1053 | case eSimpleGestureEventClass: |
1054 | break; |
1055 | default: |
1056 | return; |
1057 | } |
1058 | |
1059 | WidgetMouseEventBase& mouseEvent = *aInputEvent.AsMouseEventBase(); |
1060 | mouseEvent.mButtons = 0; |
1061 | if (aGdkModifierState & GDK_BUTTON1_MASK) { |
1062 | mouseEvent.mButtons |= MouseButtonsFlag::ePrimaryFlag; |
1063 | } |
1064 | if (aGdkModifierState & GDK_BUTTON3_MASK) { |
1065 | mouseEvent.mButtons |= MouseButtonsFlag::eSecondaryFlag; |
1066 | } |
1067 | if (aGdkModifierState & GDK_BUTTON2_MASK) { |
1068 | mouseEvent.mButtons |= MouseButtonsFlag::eMiddleFlag; |
1069 | } |
1070 | |
1071 | if (doLog) { |
1072 | MOZ_LOG(do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Debug)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Debug, "%p InitInputEvent, aInputEvent has mButtons, " "aInputEvent.mButtons=0x%04X (Left: %s, Right: %s, Middle: %s, " "4th (BACK): %s, 5th (FORWARD): %s)", keymapWrapper, mouseEvent .mButtons, GetBoolName(mouseEvent.mButtons & MouseButtonsFlag ::ePrimaryFlag), GetBoolName(mouseEvent.mButtons & MouseButtonsFlag ::eSecondaryFlag), GetBoolName(mouseEvent.mButtons & MouseButtonsFlag ::eMiddleFlag), GetBoolName(mouseEvent.mButtons & MouseButtonsFlag ::e4thFlag), GetBoolName(mouseEvent.mButtons & MouseButtonsFlag ::e5thFlag)); } } while (0) |
1073 | gKeyLog, LogLevel::Debug,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Debug)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Debug, "%p InitInputEvent, aInputEvent has mButtons, " "aInputEvent.mButtons=0x%04X (Left: %s, Right: %s, Middle: %s, " "4th (BACK): %s, 5th (FORWARD): %s)", keymapWrapper, mouseEvent .mButtons, GetBoolName(mouseEvent.mButtons & MouseButtonsFlag ::ePrimaryFlag), GetBoolName(mouseEvent.mButtons & MouseButtonsFlag ::eSecondaryFlag), GetBoolName(mouseEvent.mButtons & MouseButtonsFlag ::eMiddleFlag), GetBoolName(mouseEvent.mButtons & MouseButtonsFlag ::e4thFlag), GetBoolName(mouseEvent.mButtons & MouseButtonsFlag ::e5thFlag)); } } while (0) |
1074 | ("%p InitInputEvent, aInputEvent has mButtons, "do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Debug)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Debug, "%p InitInputEvent, aInputEvent has mButtons, " "aInputEvent.mButtons=0x%04X (Left: %s, Right: %s, Middle: %s, " "4th (BACK): %s, 5th (FORWARD): %s)", keymapWrapper, mouseEvent .mButtons, GetBoolName(mouseEvent.mButtons & MouseButtonsFlag ::ePrimaryFlag), GetBoolName(mouseEvent.mButtons & MouseButtonsFlag ::eSecondaryFlag), GetBoolName(mouseEvent.mButtons & MouseButtonsFlag ::eMiddleFlag), GetBoolName(mouseEvent.mButtons & MouseButtonsFlag ::e4thFlag), GetBoolName(mouseEvent.mButtons & MouseButtonsFlag ::e5thFlag)); } } while (0) |
1075 | "aInputEvent.mButtons=0x%04X (Left: %s, Right: %s, Middle: %s, "do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Debug)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Debug, "%p InitInputEvent, aInputEvent has mButtons, " "aInputEvent.mButtons=0x%04X (Left: %s, Right: %s, Middle: %s, " "4th (BACK): %s, 5th (FORWARD): %s)", keymapWrapper, mouseEvent .mButtons, GetBoolName(mouseEvent.mButtons & MouseButtonsFlag ::ePrimaryFlag), GetBoolName(mouseEvent.mButtons & MouseButtonsFlag ::eSecondaryFlag), GetBoolName(mouseEvent.mButtons & MouseButtonsFlag ::eMiddleFlag), GetBoolName(mouseEvent.mButtons & MouseButtonsFlag ::e4thFlag), GetBoolName(mouseEvent.mButtons & MouseButtonsFlag ::e5thFlag)); } } while (0) |
1076 | "4th (BACK): %s, 5th (FORWARD): %s)",do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Debug)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Debug, "%p InitInputEvent, aInputEvent has mButtons, " "aInputEvent.mButtons=0x%04X (Left: %s, Right: %s, Middle: %s, " "4th (BACK): %s, 5th (FORWARD): %s)", keymapWrapper, mouseEvent .mButtons, GetBoolName(mouseEvent.mButtons & MouseButtonsFlag ::ePrimaryFlag), GetBoolName(mouseEvent.mButtons & MouseButtonsFlag ::eSecondaryFlag), GetBoolName(mouseEvent.mButtons & MouseButtonsFlag ::eMiddleFlag), GetBoolName(mouseEvent.mButtons & MouseButtonsFlag ::e4thFlag), GetBoolName(mouseEvent.mButtons & MouseButtonsFlag ::e5thFlag)); } } while (0) |
1077 | keymapWrapper, mouseEvent.mButtons,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Debug)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Debug, "%p InitInputEvent, aInputEvent has mButtons, " "aInputEvent.mButtons=0x%04X (Left: %s, Right: %s, Middle: %s, " "4th (BACK): %s, 5th (FORWARD): %s)", keymapWrapper, mouseEvent .mButtons, GetBoolName(mouseEvent.mButtons & MouseButtonsFlag ::ePrimaryFlag), GetBoolName(mouseEvent.mButtons & MouseButtonsFlag ::eSecondaryFlag), GetBoolName(mouseEvent.mButtons & MouseButtonsFlag ::eMiddleFlag), GetBoolName(mouseEvent.mButtons & MouseButtonsFlag ::e4thFlag), GetBoolName(mouseEvent.mButtons & MouseButtonsFlag ::e5thFlag)); } } while (0) |
1078 | GetBoolName(mouseEvent.mButtons & MouseButtonsFlag::ePrimaryFlag),do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Debug)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Debug, "%p InitInputEvent, aInputEvent has mButtons, " "aInputEvent.mButtons=0x%04X (Left: %s, Right: %s, Middle: %s, " "4th (BACK): %s, 5th (FORWARD): %s)", keymapWrapper, mouseEvent .mButtons, GetBoolName(mouseEvent.mButtons & MouseButtonsFlag ::ePrimaryFlag), GetBoolName(mouseEvent.mButtons & MouseButtonsFlag ::eSecondaryFlag), GetBoolName(mouseEvent.mButtons & MouseButtonsFlag ::eMiddleFlag), GetBoolName(mouseEvent.mButtons & MouseButtonsFlag ::e4thFlag), GetBoolName(mouseEvent.mButtons & MouseButtonsFlag ::e5thFlag)); } } while (0) |
1079 | GetBoolName(mouseEvent.mButtons & MouseButtonsFlag::eSecondaryFlag),do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Debug)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Debug, "%p InitInputEvent, aInputEvent has mButtons, " "aInputEvent.mButtons=0x%04X (Left: %s, Right: %s, Middle: %s, " "4th (BACK): %s, 5th (FORWARD): %s)", keymapWrapper, mouseEvent .mButtons, GetBoolName(mouseEvent.mButtons & MouseButtonsFlag ::ePrimaryFlag), GetBoolName(mouseEvent.mButtons & MouseButtonsFlag ::eSecondaryFlag), GetBoolName(mouseEvent.mButtons & MouseButtonsFlag ::eMiddleFlag), GetBoolName(mouseEvent.mButtons & MouseButtonsFlag ::e4thFlag), GetBoolName(mouseEvent.mButtons & MouseButtonsFlag ::e5thFlag)); } } while (0) |
1080 | GetBoolName(mouseEvent.mButtons & MouseButtonsFlag::eMiddleFlag),do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Debug)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Debug, "%p InitInputEvent, aInputEvent has mButtons, " "aInputEvent.mButtons=0x%04X (Left: %s, Right: %s, Middle: %s, " "4th (BACK): %s, 5th (FORWARD): %s)", keymapWrapper, mouseEvent .mButtons, GetBoolName(mouseEvent.mButtons & MouseButtonsFlag ::ePrimaryFlag), GetBoolName(mouseEvent.mButtons & MouseButtonsFlag ::eSecondaryFlag), GetBoolName(mouseEvent.mButtons & MouseButtonsFlag ::eMiddleFlag), GetBoolName(mouseEvent.mButtons & MouseButtonsFlag ::e4thFlag), GetBoolName(mouseEvent.mButtons & MouseButtonsFlag ::e5thFlag)); } } while (0) |
1081 | GetBoolName(mouseEvent.mButtons & MouseButtonsFlag::e4thFlag),do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Debug)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Debug, "%p InitInputEvent, aInputEvent has mButtons, " "aInputEvent.mButtons=0x%04X (Left: %s, Right: %s, Middle: %s, " "4th (BACK): %s, 5th (FORWARD): %s)", keymapWrapper, mouseEvent .mButtons, GetBoolName(mouseEvent.mButtons & MouseButtonsFlag ::ePrimaryFlag), GetBoolName(mouseEvent.mButtons & MouseButtonsFlag ::eSecondaryFlag), GetBoolName(mouseEvent.mButtons & MouseButtonsFlag ::eMiddleFlag), GetBoolName(mouseEvent.mButtons & MouseButtonsFlag ::e4thFlag), GetBoolName(mouseEvent.mButtons & MouseButtonsFlag ::e5thFlag)); } } while (0) |
1082 | GetBoolName(mouseEvent.mButtons & MouseButtonsFlag::e5thFlag)))do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Debug)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Debug, "%p InitInputEvent, aInputEvent has mButtons, " "aInputEvent.mButtons=0x%04X (Left: %s, Right: %s, Middle: %s, " "4th (BACK): %s, 5th (FORWARD): %s)", keymapWrapper, mouseEvent .mButtons, GetBoolName(mouseEvent.mButtons & MouseButtonsFlag ::ePrimaryFlag), GetBoolName(mouseEvent.mButtons & MouseButtonsFlag ::eSecondaryFlag), GetBoolName(mouseEvent.mButtons & MouseButtonsFlag ::eMiddleFlag), GetBoolName(mouseEvent.mButtons & MouseButtonsFlag ::e4thFlag), GetBoolName(mouseEvent.mButtons & MouseButtonsFlag ::e5thFlag)); } } while (0); |
1083 | } |
1084 | } |
1085 | |
1086 | /* static */ |
1087 | uint32_t KeymapWrapper::ComputeDOMKeyCode(const GdkEventKey* aGdkKeyEvent) { |
1088 | // If the keyval indicates it's a modifier key, we should use unshifted |
1089 | // key's modifier keyval. |
1090 | guint keyval = aGdkKeyEvent->keyval; |
1091 | if (GetModifierForGDKKeyval(keyval)) { |
1092 | // But if the keyval without modifiers isn't a modifier key, we |
1093 | // shouldn't use it. E.g., Japanese keyboard layout's |
1094 | // Shift + Eisu-Toggle key is CapsLock. This is an actual rare case, |
1095 | // Windows uses different keycode for a physical key for different |
1096 | // shift key state. |
1097 | guint keyvalWithoutModifier = GetGDKKeyvalWithoutModifier(aGdkKeyEvent); |
1098 | if (GetModifierForGDKKeyval(keyvalWithoutModifier)) { |
1099 | keyval = keyvalWithoutModifier; |
1100 | } |
1101 | // Note that the modifier keycode and activating or deactivating |
1102 | // modifier flag may be mismatched, but it's okay. If a DOM key |
1103 | // event handler is testing a keydown event, it's more likely being |
1104 | // used to test which key is being pressed than to test which |
1105 | // modifier will become active. So, if we computed DOM keycode |
1106 | // from modifier flag which were changing by the physical key, then |
1107 | // there would be no other way for the user to generate the original |
1108 | // keycode. |
1109 | uint32_t DOMKeyCode = GetDOMKeyCodeFromKeyPairs(keyval); |
1110 | NS_ASSERTION(DOMKeyCode, "All modifier keys must have a DOM keycode")do { if (!(DOMKeyCode)) { NS_DebugBreak(NS_DEBUG_ASSERTION, "All modifier keys must have a DOM keycode" , "DOMKeyCode", "/var/lib/jenkins/workspace/firefox-scan-build/widget/gtk/nsGtkKeyUtils.cpp" , 1110); MOZ_PretendNoReturn(); } } while (0); |
1111 | return DOMKeyCode; |
1112 | } |
1113 | |
1114 | // If the key isn't printable, let's look at the key pairs. |
1115 | uint32_t charCode = GetCharCodeFor(aGdkKeyEvent); |
1116 | if (!charCode) { |
1117 | // Note that any key may be a function key because of some unusual keyboard |
1118 | // layouts. I.e., even if the pressed key is a printable key of en-US |
1119 | // keyboard layout, we should expose the function key's keyCode value to |
1120 | // web apps because web apps should handle the keydown/keyup events as |
1121 | // inputted by usual keyboard layout. For example, Hatchak keyboard |
1122 | // maps Tab key to "Digit3" key and Level3 Shift makes it "Backspace". |
1123 | // In this case, we should expose DOM_VK_BACK_SPACE (8). |
1124 | uint32_t DOMKeyCode = GetDOMKeyCodeFromKeyPairs(keyval); |
1125 | if (DOMKeyCode) { |
1126 | // XXX If DOMKeyCode is a function key's keyCode value, it might be |
1127 | // better to consume necessary modifiers. For example, if there is |
1128 | // no Control Pad section on keyboard like notebook, Delete key is |
1129 | // available only with Level3 Shift+"Backspace" key if using Hatchak. |
1130 | // If web apps accept Delete key operation only when no modifiers are |
1131 | // active, such users cannot use Delete key to do it. However, |
1132 | // Chromium doesn't consume such necessary modifiers. So, our default |
1133 | // behavior should keep not touching modifiers for compatibility, but |
1134 | // it might be better to add a pref to consume necessary modifiers. |
1135 | return DOMKeyCode; |
1136 | } |
1137 | // If aGdkKeyEvent cannot be mapped to a DOM keyCode value, we should |
1138 | // refer keyCode value without modifiers because web apps should be |
1139 | // able to identify the key as far as possible. |
1140 | guint keyvalWithoutModifier = GetGDKKeyvalWithoutModifier(aGdkKeyEvent); |
1141 | return GetDOMKeyCodeFromKeyPairs(keyvalWithoutModifier); |
1142 | } |
1143 | |
1144 | // printable numpad keys should be resolved here. |
1145 | switch (keyval) { |
1146 | case GDK_KP_Multiply0xffaa: |
1147 | return NS_VK_MULTIPLY; |
1148 | case GDK_KP_Add0xffab: |
1149 | return NS_VK_ADD; |
1150 | case GDK_KP_Separator0xffac: |
1151 | return NS_VK_SEPARATOR; |
1152 | case GDK_KP_Subtract0xffad: |
1153 | return NS_VK_SUBTRACT; |
1154 | case GDK_KP_Decimal0xffae: |
1155 | return NS_VK_DECIMAL; |
1156 | case GDK_KP_Divide0xffaf: |
1157 | return NS_VK_DIVIDE; |
1158 | case GDK_KP_00xffb0: |
1159 | return NS_VK_NUMPAD0; |
1160 | case GDK_KP_10xffb1: |
1161 | return NS_VK_NUMPAD1; |
1162 | case GDK_KP_20xffb2: |
1163 | return NS_VK_NUMPAD2; |
1164 | case GDK_KP_30xffb3: |
1165 | return NS_VK_NUMPAD3; |
1166 | case GDK_KP_40xffb4: |
1167 | return NS_VK_NUMPAD4; |
1168 | case GDK_KP_50xffb5: |
1169 | return NS_VK_NUMPAD5; |
1170 | case GDK_KP_60xffb6: |
1171 | return NS_VK_NUMPAD6; |
1172 | case GDK_KP_70xffb7: |
1173 | return NS_VK_NUMPAD7; |
1174 | case GDK_KP_80xffb8: |
1175 | return NS_VK_NUMPAD8; |
1176 | case GDK_KP_90xffb9: |
1177 | return NS_VK_NUMPAD9; |
1178 | } |
1179 | |
1180 | KeymapWrapper* keymapWrapper = GetInstance(); |
1181 | |
1182 | // Ignore all modifier state except NumLock. |
1183 | guint baseState = |
1184 | (aGdkKeyEvent->state & keymapWrapper->GetGdkModifierMask(NUM_LOCK)); |
1185 | |
1186 | // Basically, we should use unmodified character for deciding our keyCode. |
1187 | uint32_t unmodifiedChar = keymapWrapper->GetCharCodeFor( |
1188 | aGdkKeyEvent, baseState, aGdkKeyEvent->group); |
1189 | if (IsBasicLatinLetterOrNumeral(unmodifiedChar)) { |
1190 | // If the unmodified character is an ASCII alphabet or an ASCII |
1191 | // numeric, it's the best hint for deciding our keyCode. |
1192 | return WidgetUtils::ComputeKeyCodeFromChar(unmodifiedChar); |
1193 | } |
1194 | |
1195 | // If the unmodified character is not an ASCII character, that means we |
1196 | // couldn't find the hint. We should reset it. |
1197 | if (!IsPrintableASCIICharacter(unmodifiedChar)) { |
1198 | unmodifiedChar = 0; |
1199 | } |
1200 | |
1201 | // Retry with shifted keycode. |
1202 | guint shiftState = (baseState | keymapWrapper->GetGdkModifierMask(SHIFT)); |
1203 | uint32_t shiftedChar = keymapWrapper->GetCharCodeFor(aGdkKeyEvent, shiftState, |
1204 | aGdkKeyEvent->group); |
1205 | if (IsBasicLatinLetterOrNumeral(shiftedChar)) { |
1206 | // A shifted character can be an ASCII alphabet on Hebrew keyboard |
1207 | // layout. And also shifted character can be an ASCII numeric on |
1208 | // AZERTY keyboad layout. Then, it's a good hint for deciding our |
1209 | // keyCode. |
1210 | return WidgetUtils::ComputeKeyCodeFromChar(shiftedChar); |
1211 | } |
1212 | |
1213 | // If the shifted unmodified character isn't an ASCII character, we should |
1214 | // discard it too. |
1215 | if (!IsPrintableASCIICharacter(shiftedChar)) { |
1216 | shiftedChar = 0; |
1217 | } |
1218 | |
1219 | // If current keyboard layout isn't ASCII alphabet inputtable layout, |
1220 | // look for ASCII alphabet inputtable keyboard layout. If the key |
1221 | // inputs an ASCII alphabet or an ASCII numeric, we should use it |
1222 | // for deciding our keyCode. |
1223 | uint32_t unmodCharLatin = 0; |
1224 | uint32_t shiftedCharLatin = 0; |
1225 | if (!keymapWrapper->IsLatinGroup(aGdkKeyEvent->group)) { |
1226 | gint minGroup = keymapWrapper->GetFirstLatinGroup(); |
1227 | if (minGroup >= 0) { |
1228 | unmodCharLatin = |
1229 | keymapWrapper->GetCharCodeFor(aGdkKeyEvent, baseState, minGroup); |
1230 | if (IsBasicLatinLetterOrNumeral(unmodCharLatin)) { |
1231 | // If the unmodified character is an ASCII alphabet or |
1232 | // an ASCII numeric, we should use it for the keyCode. |
1233 | return WidgetUtils::ComputeKeyCodeFromChar(unmodCharLatin); |
1234 | } |
1235 | // If the unmodified character in the alternative ASCII capable |
1236 | // keyboard layout isn't an ASCII character, that means we couldn't |
1237 | // find the hint. We should reset it. |
1238 | if (!IsPrintableASCIICharacter(unmodCharLatin)) { |
1239 | unmodCharLatin = 0; |
1240 | } |
1241 | shiftedCharLatin = |
1242 | keymapWrapper->GetCharCodeFor(aGdkKeyEvent, shiftState, minGroup); |
1243 | if (IsBasicLatinLetterOrNumeral(shiftedCharLatin)) { |
1244 | // If the shifted character is an ASCII alphabet or an ASCII |
1245 | // numeric, we should use it for the keyCode. |
1246 | return WidgetUtils::ComputeKeyCodeFromChar(shiftedCharLatin); |
1247 | } |
1248 | // If the shifted unmodified character in the alternative ASCII |
1249 | // capable keyboard layout isn't an ASCII character, we should |
1250 | // discard it too. |
1251 | if (!IsPrintableASCIICharacter(shiftedCharLatin)) { |
1252 | shiftedCharLatin = 0; |
1253 | } |
1254 | } |
1255 | } |
1256 | |
1257 | // If the key itself or with Shift state on active keyboard layout produces |
1258 | // an ASCII punctuation character, we should decide keyCode value with it. |
1259 | if (unmodifiedChar || shiftedChar) { |
1260 | return WidgetUtils::ComputeKeyCodeFromChar(unmodifiedChar ? unmodifiedChar |
1261 | : shiftedChar); |
1262 | } |
1263 | |
1264 | // If the key itself or with Shift state on alternative ASCII capable |
1265 | // keyboard layout produces an ASCII punctuation character, we should |
1266 | // decide keyCode value with it. Note that We've returned 0 for long |
1267 | // time if keyCode isn't for an alphabet keys or a numeric key even in |
1268 | // alternative ASCII capable keyboard layout because we decided that we |
1269 | // should avoid setting same keyCode value to 2 or more keys since active |
1270 | // keyboard layout may have a key to input the punctuation with different |
1271 | // key. However, setting keyCode to 0 makes some web applications which |
1272 | // are aware of neither KeyboardEvent.key nor KeyboardEvent.code not work |
1273 | // with Firefox when user selects non-ASCII capable keyboard layout such |
1274 | // as Russian and Thai. So, if alternative ASCII capable keyboard layout |
1275 | // has keyCode value for the key, we should use it. In other words, this |
1276 | // behavior means that non-ASCII capable keyboard layout overrides some |
1277 | // keys' keyCode value only if the key produces ASCII character by itself |
1278 | // or with Shift key. |
1279 | if (unmodCharLatin || shiftedCharLatin) { |
1280 | return WidgetUtils::ComputeKeyCodeFromChar( |
1281 | unmodCharLatin ? unmodCharLatin : shiftedCharLatin); |
1282 | } |
1283 | |
1284 | // Otherwise, let's decide keyCode value from the hardware_keycode |
1285 | // value on major keyboard layout. |
1286 | CodeNameIndex code = ComputeDOMCodeNameIndex(aGdkKeyEvent); |
1287 | return WidgetKeyboardEvent::GetFallbackKeyCodeOfPunctuationKey(code); |
1288 | } |
1289 | |
1290 | KeyNameIndex KeymapWrapper::ComputeDOMKeyNameIndex( |
1291 | const GdkEventKey* aGdkKeyEvent) { |
1292 | switch (aGdkKeyEvent->keyval) { |
1293 | #define NS_NATIVE_KEY_TO_DOM_KEY_NAME_INDEX(aNativeKey, aKeyNameIndex) \ |
1294 | case aNativeKey: \ |
1295 | return aKeyNameIndex; |
1296 | |
1297 | #include "NativeKeyToDOMKeyName.h" |
1298 | |
1299 | #undef NS_NATIVE_KEY_TO_DOM_KEY_NAME_INDEX |
1300 | |
1301 | default: |
1302 | break; |
1303 | } |
1304 | |
1305 | return KEY_NAME_INDEX_Unidentified; |
1306 | } |
1307 | |
1308 | /* static */ |
1309 | CodeNameIndex KeymapWrapper::ComputeDOMCodeNameIndex( |
1310 | const GdkEventKey* aGdkKeyEvent) { |
1311 | switch (aGdkKeyEvent->hardware_keycode) { |
1312 | #define NS_NATIVE_KEY_TO_DOM_CODE_NAME_INDEX(aNativeKey, aCodeNameIndex) \ |
1313 | case aNativeKey: \ |
1314 | return aCodeNameIndex; |
1315 | |
1316 | #include "NativeKeyToDOMCodeName.h" |
1317 | |
1318 | #undef NS_NATIVE_KEY_TO_DOM_CODE_NAME_INDEX |
1319 | |
1320 | default: |
1321 | break; |
1322 | } |
1323 | |
1324 | return CODE_NAME_INDEX_UNKNOWN; |
1325 | } |
1326 | |
1327 | /* static */ |
1328 | bool KeymapWrapper::DispatchKeyDownOrKeyUpEvent(nsWindow* aWindow, |
1329 | GdkEventKey* aGdkKeyEvent, |
1330 | bool aIsProcessedByIME, |
1331 | bool* aIsCancelled) { |
1332 | MOZ_ASSERT(aIsCancelled, "aIsCancelled must not be nullptr")do { static_assert( mozilla::detail::AssertionConditionType< decltype(aIsCancelled)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(aIsCancelled))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("aIsCancelled" " (" "aIsCancelled must not be nullptr" ")", "/var/lib/jenkins/workspace/firefox-scan-build/widget/gtk/nsGtkKeyUtils.cpp" , 1332); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aIsCancelled" ") (" "aIsCancelled must not be nullptr" ")"); do { *((volatile int*)__null) = 1332; __attribute__((nomerge)) ::abort(); } while (false); } } while (false); |
1333 | |
1334 | *aIsCancelled = false; |
1335 | |
1336 | if (aGdkKeyEvent->type == GDK_KEY_PRESS && aGdkKeyEvent->keyval == GDK_Tab0xff09 && |
1337 | AreModifiersActive(CTRL | ALT, aGdkKeyEvent->state)) { |
1338 | MOZ_LOG(gKeyLog, LogLevel::Info,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, " DispatchKeyDownOrKeyUpEvent(), didn't dispatch keyboard events " "because it's Ctrl + Alt + Tab"); } } while (0) |
1339 | (" DispatchKeyDownOrKeyUpEvent(), didn't dispatch keyboard events "do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, " DispatchKeyDownOrKeyUpEvent(), didn't dispatch keyboard events " "because it's Ctrl + Alt + Tab"); } } while (0) |
1340 | "because it's Ctrl + Alt + Tab"))do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, " DispatchKeyDownOrKeyUpEvent(), didn't dispatch keyboard events " "because it's Ctrl + Alt + Tab"); } } while (0); |
1341 | return false; |
1342 | } |
1343 | |
1344 | EventMessage message = |
1345 | aGdkKeyEvent->type == GDK_KEY_PRESS ? eKeyDown : eKeyUp; |
1346 | WidgetKeyboardEvent keyEvent(true, message, aWindow); |
1347 | KeymapWrapper::InitKeyEvent(keyEvent, aGdkKeyEvent, aIsProcessedByIME); |
1348 | return DispatchKeyDownOrKeyUpEvent(aWindow, keyEvent, aIsCancelled); |
1349 | } |
1350 | |
1351 | /* static */ |
1352 | bool KeymapWrapper::DispatchKeyDownOrKeyUpEvent( |
1353 | nsWindow* aWindow, WidgetKeyboardEvent& aKeyboardEvent, |
1354 | bool* aIsCancelled) { |
1355 | MOZ_ASSERT(aIsCancelled, "aIsCancelled must not be nullptr")do { static_assert( mozilla::detail::AssertionConditionType< decltype(aIsCancelled)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(aIsCancelled))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("aIsCancelled" " (" "aIsCancelled must not be nullptr" ")", "/var/lib/jenkins/workspace/firefox-scan-build/widget/gtk/nsGtkKeyUtils.cpp" , 1355); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aIsCancelled" ") (" "aIsCancelled must not be nullptr" ")"); do { *((volatile int*)__null) = 1355; __attribute__((nomerge)) ::abort(); } while (false); } } while (false); |
1356 | |
1357 | *aIsCancelled = false; |
1358 | |
1359 | RefPtr<TextEventDispatcher> dispatcher = aWindow->GetTextEventDispatcher(); |
1360 | nsresult rv = dispatcher->BeginNativeInputTransaction(); |
1361 | if (NS_WARN_IF(NS_FAILED(rv))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(rv )), 0))), "NS_FAILED(rv)", "/var/lib/jenkins/workspace/firefox-scan-build/widget/gtk/nsGtkKeyUtils.cpp" , 1361)) { |
1362 | MOZ_LOG(gKeyLog, LogLevel::Error,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Error)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Error, " DispatchKeyDownOrKeyUpEvent(), stopped dispatching %s event " "because of failed to initialize TextEventDispatcher", ToChar (aKeyboardEvent.mMessage)); } } while (0) |
1363 | (" DispatchKeyDownOrKeyUpEvent(), stopped dispatching %s event "do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Error)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Error, " DispatchKeyDownOrKeyUpEvent(), stopped dispatching %s event " "because of failed to initialize TextEventDispatcher", ToChar (aKeyboardEvent.mMessage)); } } while (0) |
1364 | "because of failed to initialize TextEventDispatcher",do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Error)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Error, " DispatchKeyDownOrKeyUpEvent(), stopped dispatching %s event " "because of failed to initialize TextEventDispatcher", ToChar (aKeyboardEvent.mMessage)); } } while (0) |
1365 | ToChar(aKeyboardEvent.mMessage)))do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Error)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Error, " DispatchKeyDownOrKeyUpEvent(), stopped dispatching %s event " "because of failed to initialize TextEventDispatcher", ToChar (aKeyboardEvent.mMessage)); } } while (0); |
1366 | return FALSE(0); |
1367 | } |
1368 | |
1369 | nsEventStatus status = nsEventStatus_eIgnore; |
1370 | bool dispatched = dispatcher->DispatchKeyboardEvent( |
1371 | aKeyboardEvent.mMessage, aKeyboardEvent, status, nullptr); |
1372 | *aIsCancelled = (status == nsEventStatus_eConsumeNoDefault); |
1373 | return dispatched; |
1374 | } |
1375 | |
1376 | /* static */ |
1377 | bool KeymapWrapper::MaybeDispatchContextMenuEvent(nsWindow* aWindow, |
1378 | const GdkEventKey* aEvent) { |
1379 | KeyNameIndex keyNameIndex = ComputeDOMKeyNameIndex(aEvent); |
1380 | |
1381 | // Shift+F10 and ContextMenu should cause eContextMenu event. |
1382 | if (keyNameIndex != KEY_NAME_INDEX_F10 && |
1383 | keyNameIndex != KEY_NAME_INDEX_ContextMenu) { |
1384 | return false; |
1385 | } |
1386 | |
1387 | WidgetPointerEvent contextMenuEvent(true, eContextMenu, aWindow, |
1388 | WidgetMouseEvent::eContextMenuKey); |
1389 | contextMenuEvent.mRefPoint = LayoutDeviceIntPoint(0, 0); |
1390 | contextMenuEvent.AssignEventTime(aWindow->GetWidgetEventTime(aEvent->time)); |
1391 | contextMenuEvent.mClickCount = 1; |
1392 | KeymapWrapper::InitInputEvent(contextMenuEvent, aEvent->state); |
1393 | |
1394 | if (contextMenuEvent.IsControl() || contextMenuEvent.IsMeta() || |
1395 | contextMenuEvent.IsAlt()) { |
1396 | return false; |
1397 | } |
1398 | |
1399 | // If the key is ContextMenu, then an eContextMenu mouse event is |
1400 | // dispatched regardless of the state of the Shift modifier. When it is |
1401 | // pressed without the Shift modifier, a web page can prevent the default |
1402 | // context menu action. When pressed with the Shift modifier, the web page |
1403 | // cannot prevent the default context menu action. |
1404 | // (PresShell::HandleEventInternal() sets mOnlyChromeDispatch to true.) |
1405 | |
1406 | // If the key is F10, it needs Shift state because Shift+F10 is well-known |
1407 | // shortcut key on Linux. However, eContextMenu with Shift state is |
1408 | // special. It won't fire "contextmenu" event in the web content for |
1409 | // blocking web page to prevent its default. Therefore, this combination |
1410 | // should work same as ContextMenu key. |
1411 | // XXX Should we allow to block web page to prevent its default with |
1412 | // Ctrl+Shift+F10 or Alt+Shift+F10 instead? |
1413 | if (keyNameIndex == KEY_NAME_INDEX_F10) { |
1414 | if (!contextMenuEvent.IsShift()) { |
1415 | return false; |
1416 | } |
1417 | contextMenuEvent.mModifiers &= ~MODIFIER_SHIFT; |
1418 | } |
1419 | |
1420 | aWindow->DispatchInputEvent(&contextMenuEvent); |
1421 | return true; |
1422 | } |
1423 | |
1424 | /* static*/ |
1425 | void KeymapWrapper::HandleKeyPressEvent(nsWindow* aWindow, |
1426 | GdkEventKey* aGdkKeyEvent) { |
1427 | MOZ_LOG(gKeyLog, LogLevel::Info,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "HandleKeyPressEvent(aWindow=%p, aGdkKeyEvent={ type=%s, " "keyval=%s(0x%X), state=0x%08X, hardware_keycode=0x%08X, " "time=%u, is_modifier=%s })" , aWindow, ((aGdkKeyEvent->type == GDK_KEY_PRESS) ? "GDK_KEY_PRESS" : "GDK_KEY_RELEASE"), gdk_keyval_name(aGdkKeyEvent->keyval ), aGdkKeyEvent->keyval, aGdkKeyEvent->state, aGdkKeyEvent ->hardware_keycode, aGdkKeyEvent->time, GetBoolName(aGdkKeyEvent ->is_modifier)); } } while (0) |
1428 | ("HandleKeyPressEvent(aWindow=%p, aGdkKeyEvent={ type=%s, "do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "HandleKeyPressEvent(aWindow=%p, aGdkKeyEvent={ type=%s, " "keyval=%s(0x%X), state=0x%08X, hardware_keycode=0x%08X, " "time=%u, is_modifier=%s })" , aWindow, ((aGdkKeyEvent->type == GDK_KEY_PRESS) ? "GDK_KEY_PRESS" : "GDK_KEY_RELEASE"), gdk_keyval_name(aGdkKeyEvent->keyval ), aGdkKeyEvent->keyval, aGdkKeyEvent->state, aGdkKeyEvent ->hardware_keycode, aGdkKeyEvent->time, GetBoolName(aGdkKeyEvent ->is_modifier)); } } while (0) |
1429 | "keyval=%s(0x%X), state=0x%08X, hardware_keycode=0x%08X, "do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "HandleKeyPressEvent(aWindow=%p, aGdkKeyEvent={ type=%s, " "keyval=%s(0x%X), state=0x%08X, hardware_keycode=0x%08X, " "time=%u, is_modifier=%s })" , aWindow, ((aGdkKeyEvent->type == GDK_KEY_PRESS) ? "GDK_KEY_PRESS" : "GDK_KEY_RELEASE"), gdk_keyval_name(aGdkKeyEvent->keyval ), aGdkKeyEvent->keyval, aGdkKeyEvent->state, aGdkKeyEvent ->hardware_keycode, aGdkKeyEvent->time, GetBoolName(aGdkKeyEvent ->is_modifier)); } } while (0) |
1430 | "time=%u, is_modifier=%s })",do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "HandleKeyPressEvent(aWindow=%p, aGdkKeyEvent={ type=%s, " "keyval=%s(0x%X), state=0x%08X, hardware_keycode=0x%08X, " "time=%u, is_modifier=%s })" , aWindow, ((aGdkKeyEvent->type == GDK_KEY_PRESS) ? "GDK_KEY_PRESS" : "GDK_KEY_RELEASE"), gdk_keyval_name(aGdkKeyEvent->keyval ), aGdkKeyEvent->keyval, aGdkKeyEvent->state, aGdkKeyEvent ->hardware_keycode, aGdkKeyEvent->time, GetBoolName(aGdkKeyEvent ->is_modifier)); } } while (0) |
1431 | aWindow,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "HandleKeyPressEvent(aWindow=%p, aGdkKeyEvent={ type=%s, " "keyval=%s(0x%X), state=0x%08X, hardware_keycode=0x%08X, " "time=%u, is_modifier=%s })" , aWindow, ((aGdkKeyEvent->type == GDK_KEY_PRESS) ? "GDK_KEY_PRESS" : "GDK_KEY_RELEASE"), gdk_keyval_name(aGdkKeyEvent->keyval ), aGdkKeyEvent->keyval, aGdkKeyEvent->state, aGdkKeyEvent ->hardware_keycode, aGdkKeyEvent->time, GetBoolName(aGdkKeyEvent ->is_modifier)); } } while (0) |
1432 | ((aGdkKeyEvent->type == GDK_KEY_PRESS) ? "GDK_KEY_PRESS"do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "HandleKeyPressEvent(aWindow=%p, aGdkKeyEvent={ type=%s, " "keyval=%s(0x%X), state=0x%08X, hardware_keycode=0x%08X, " "time=%u, is_modifier=%s })" , aWindow, ((aGdkKeyEvent->type == GDK_KEY_PRESS) ? "GDK_KEY_PRESS" : "GDK_KEY_RELEASE"), gdk_keyval_name(aGdkKeyEvent->keyval ), aGdkKeyEvent->keyval, aGdkKeyEvent->state, aGdkKeyEvent ->hardware_keycode, aGdkKeyEvent->time, GetBoolName(aGdkKeyEvent ->is_modifier)); } } while (0) |
1433 | : "GDK_KEY_RELEASE"),do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "HandleKeyPressEvent(aWindow=%p, aGdkKeyEvent={ type=%s, " "keyval=%s(0x%X), state=0x%08X, hardware_keycode=0x%08X, " "time=%u, is_modifier=%s })" , aWindow, ((aGdkKeyEvent->type == GDK_KEY_PRESS) ? "GDK_KEY_PRESS" : "GDK_KEY_RELEASE"), gdk_keyval_name(aGdkKeyEvent->keyval ), aGdkKeyEvent->keyval, aGdkKeyEvent->state, aGdkKeyEvent ->hardware_keycode, aGdkKeyEvent->time, GetBoolName(aGdkKeyEvent ->is_modifier)); } } while (0) |
1434 | gdk_keyval_name(aGdkKeyEvent->keyval), aGdkKeyEvent->keyval,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "HandleKeyPressEvent(aWindow=%p, aGdkKeyEvent={ type=%s, " "keyval=%s(0x%X), state=0x%08X, hardware_keycode=0x%08X, " "time=%u, is_modifier=%s })" , aWindow, ((aGdkKeyEvent->type == GDK_KEY_PRESS) ? "GDK_KEY_PRESS" : "GDK_KEY_RELEASE"), gdk_keyval_name(aGdkKeyEvent->keyval ), aGdkKeyEvent->keyval, aGdkKeyEvent->state, aGdkKeyEvent ->hardware_keycode, aGdkKeyEvent->time, GetBoolName(aGdkKeyEvent ->is_modifier)); } } while (0) |
1435 | aGdkKeyEvent->state, aGdkKeyEvent->hardware_keycode,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "HandleKeyPressEvent(aWindow=%p, aGdkKeyEvent={ type=%s, " "keyval=%s(0x%X), state=0x%08X, hardware_keycode=0x%08X, " "time=%u, is_modifier=%s })" , aWindow, ((aGdkKeyEvent->type == GDK_KEY_PRESS) ? "GDK_KEY_PRESS" : "GDK_KEY_RELEASE"), gdk_keyval_name(aGdkKeyEvent->keyval ), aGdkKeyEvent->keyval, aGdkKeyEvent->state, aGdkKeyEvent ->hardware_keycode, aGdkKeyEvent->time, GetBoolName(aGdkKeyEvent ->is_modifier)); } } while (0) |
1436 | aGdkKeyEvent->time, GetBoolName(aGdkKeyEvent->is_modifier)))do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "HandleKeyPressEvent(aWindow=%p, aGdkKeyEvent={ type=%s, " "keyval=%s(0x%X), state=0x%08X, hardware_keycode=0x%08X, " "time=%u, is_modifier=%s })" , aWindow, ((aGdkKeyEvent->type == GDK_KEY_PRESS) ? "GDK_KEY_PRESS" : "GDK_KEY_RELEASE"), gdk_keyval_name(aGdkKeyEvent->keyval ), aGdkKeyEvent->keyval, aGdkKeyEvent->state, aGdkKeyEvent ->hardware_keycode, aGdkKeyEvent->time, GetBoolName(aGdkKeyEvent ->is_modifier)); } } while (0); |
1437 | |
1438 | // if we are in the middle of composing text, XIM gets to see it |
1439 | // before mozilla does. |
1440 | // FYI: Don't dispatch keydown event before notifying IME of the event |
1441 | // because IME may send a key event synchronously and consume the |
1442 | // original event. |
1443 | bool IMEWasEnabled = false; |
1444 | KeyHandlingState handlingState = KeyHandlingState::eNotHandled; |
1445 | RefPtr<IMContextWrapper> imContext = aWindow->GetIMContext(); |
1446 | if (imContext) { |
1447 | IMEWasEnabled = imContext->IsEnabled(); |
1448 | handlingState = imContext->OnKeyEvent(aWindow, aGdkKeyEvent); |
1449 | if (handlingState == KeyHandlingState::eHandled) { |
1450 | MOZ_LOG(gKeyLog, LogLevel::Info,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, " HandleKeyPressEvent(), the event was handled by " "IMContextWrapper"); } } while (0) |
1451 | (" HandleKeyPressEvent(), the event was handled by "do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, " HandleKeyPressEvent(), the event was handled by " "IMContextWrapper"); } } while (0) |
1452 | "IMContextWrapper"))do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, " HandleKeyPressEvent(), the event was handled by " "IMContextWrapper"); } } while (0); |
1453 | return; |
1454 | } |
1455 | } |
1456 | |
1457 | // work around for annoying things. |
1458 | if (aGdkKeyEvent->keyval == GDK_Tab0xff09 && |
1459 | AreModifiersActive(CTRL | ALT, aGdkKeyEvent->state)) { |
1460 | MOZ_LOG(gKeyLog, LogLevel::Info,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, " HandleKeyPressEvent(), didn't dispatch keyboard events " "because it's Ctrl + Alt + Tab"); } } while (0) |
1461 | (" HandleKeyPressEvent(), didn't dispatch keyboard events "do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, " HandleKeyPressEvent(), didn't dispatch keyboard events " "because it's Ctrl + Alt + Tab"); } } while (0) |
1462 | "because it's Ctrl + Alt + Tab"))do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, " HandleKeyPressEvent(), didn't dispatch keyboard events " "because it's Ctrl + Alt + Tab"); } } while (0); |
1463 | return; |
1464 | } |
1465 | |
1466 | // Dispatch keydown event always. At auto repeating, we should send |
1467 | // KEYDOWN -> KEYPRESS -> KEYDOWN -> KEYPRESS ... -> KEYUP |
1468 | // However, old distributions (e.g., Ubuntu 9.10) sent native key |
1469 | // release event, so, on such platform, the DOM events will be: |
1470 | // KEYDOWN -> KEYPRESS -> KEYUP -> KEYDOWN -> KEYPRESS -> KEYUP... |
1471 | |
1472 | bool isKeyDownCancelled = false; |
1473 | if (handlingState == KeyHandlingState::eNotHandled) { |
1474 | if (DispatchKeyDownOrKeyUpEvent(aWindow, aGdkKeyEvent, false, |
1475 | &isKeyDownCancelled) && |
1476 | (MOZ_UNLIKELY(aWindow->IsDestroyed())(__builtin_expect(!!(aWindow->IsDestroyed()), 0)) || isKeyDownCancelled)) { |
1477 | MOZ_LOG(gKeyLog, LogLevel::Info,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, " HandleKeyPressEvent(), dispatched eKeyDown event and " "stopped handling the event because %s", aWindow->IsDestroyed () ? "the window has been destroyed" : "the event was consumed" ); } } while (0) |
1478 | (" HandleKeyPressEvent(), dispatched eKeyDown event and "do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, " HandleKeyPressEvent(), dispatched eKeyDown event and " "stopped handling the event because %s", aWindow->IsDestroyed () ? "the window has been destroyed" : "the event was consumed" ); } } while (0) |
1479 | "stopped handling the event because %s",do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, " HandleKeyPressEvent(), dispatched eKeyDown event and " "stopped handling the event because %s", aWindow->IsDestroyed () ? "the window has been destroyed" : "the event was consumed" ); } } while (0) |
1480 | aWindow->IsDestroyed() ? "the window has been destroyed"do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, " HandleKeyPressEvent(), dispatched eKeyDown event and " "stopped handling the event because %s", aWindow->IsDestroyed () ? "the window has been destroyed" : "the event was consumed" ); } } while (0) |
1481 | : "the event was consumed"))do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, " HandleKeyPressEvent(), dispatched eKeyDown event and " "stopped handling the event because %s", aWindow->IsDestroyed () ? "the window has been destroyed" : "the event was consumed" ); } } while (0); |
1482 | return; |
1483 | } |
1484 | MOZ_LOG(gKeyLog, LogLevel::Info,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, " HandleKeyPressEvent(), dispatched eKeyDown event and " "it wasn't consumed"); } } while (0) |
1485 | (" HandleKeyPressEvent(), dispatched eKeyDown event and "do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, " HandleKeyPressEvent(), dispatched eKeyDown event and " "it wasn't consumed"); } } while (0) |
1486 | "it wasn't consumed"))do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, " HandleKeyPressEvent(), dispatched eKeyDown event and " "it wasn't consumed"); } } while (0); |
1487 | handlingState = KeyHandlingState::eNotHandledButEventDispatched; |
Value stored to 'handlingState' is never read | |
1488 | } |
1489 | |
1490 | // If a keydown event handler causes to enable IME, i.e., it moves |
1491 | // focus from IME unusable content to IME usable editor, we should |
1492 | // send the native key event to IME for the first input on the editor. |
1493 | imContext = aWindow->GetIMContext(); |
1494 | if (!IMEWasEnabled && imContext && imContext->IsEnabled()) { |
1495 | // Notice our keydown event was already dispatched. This prevents |
1496 | // unnecessary DOM keydown event in the editor. |
1497 | handlingState = imContext->OnKeyEvent(aWindow, aGdkKeyEvent, true); |
1498 | if (handlingState == KeyHandlingState::eHandled) { |
1499 | MOZ_LOG(gKeyLog, LogLevel::Info,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, " HandleKeyPressEvent(), the event was handled by " "IMContextWrapper which was enabled by the preceding eKeyDown " "event"); } } while (0) |
1500 | (" HandleKeyPressEvent(), the event was handled by "do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, " HandleKeyPressEvent(), the event was handled by " "IMContextWrapper which was enabled by the preceding eKeyDown " "event"); } } while (0) |
1501 | "IMContextWrapper which was enabled by the preceding eKeyDown "do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, " HandleKeyPressEvent(), the event was handled by " "IMContextWrapper which was enabled by the preceding eKeyDown " "event"); } } while (0) |
1502 | "event"))do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, " HandleKeyPressEvent(), the event was handled by " "IMContextWrapper which was enabled by the preceding eKeyDown " "event"); } } while (0); |
1503 | return; |
1504 | } |
1505 | } |
1506 | |
1507 | // Look for specialized app-command keys |
1508 | switch (aGdkKeyEvent->keyval) { |
1509 | case GDK_Back0x1008ff26: |
1510 | aWindow->DispatchCommandEvent(nsGkAtoms::Back); |
1511 | MOZ_LOG(gKeyLog, LogLevel::Info,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, " HandleKeyPressEvent(), dispatched \"Back\" command event" ); } } while (0) |
1512 | (" HandleKeyPressEvent(), dispatched \"Back\" command event"))do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, " HandleKeyPressEvent(), dispatched \"Back\" command event" ); } } while (0); |
1513 | return; |
1514 | case GDK_Forward0x1008ff27: |
1515 | aWindow->DispatchCommandEvent(nsGkAtoms::Forward); |
1516 | MOZ_LOG(gKeyLog, LogLevel::Info,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, " HandleKeyPressEvent(), dispatched \"Forward\" command " "event"); } } while (0) |
1517 | (" HandleKeyPressEvent(), dispatched \"Forward\" command "do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, " HandleKeyPressEvent(), dispatched \"Forward\" command " "event"); } } while (0) |
1518 | "event"))do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, " HandleKeyPressEvent(), dispatched \"Forward\" command " "event"); } } while (0); |
1519 | return; |
1520 | case GDK_Reload0x1008ff73: |
1521 | case GDK_Refresh0x1008ff29: |
1522 | aWindow->DispatchCommandEvent(nsGkAtoms::Reload); |
1523 | return; |
1524 | case GDK_Stop0x1008ff28: |
1525 | aWindow->DispatchCommandEvent(nsGkAtoms::Stop); |
1526 | MOZ_LOG(gKeyLog, LogLevel::Info,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, " HandleKeyPressEvent(), dispatched \"Stop\" command event" ); } } while (0) |
1527 | (" HandleKeyPressEvent(), dispatched \"Stop\" command event"))do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, " HandleKeyPressEvent(), dispatched \"Stop\" command event" ); } } while (0); |
1528 | return; |
1529 | case GDK_Search0x1008ff1b: |
1530 | aWindow->DispatchCommandEvent(nsGkAtoms::Search); |
1531 | MOZ_LOG(gKeyLog, LogLevel::Info,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, " HandleKeyPressEvent(), dispatched \"Search\" command event" ); } } while (0) |
1532 | (" HandleKeyPressEvent(), dispatched \"Search\" command event"))do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, " HandleKeyPressEvent(), dispatched \"Search\" command event" ); } } while (0); |
1533 | return; |
1534 | case GDK_Favorites0x1008ff30: |
1535 | aWindow->DispatchCommandEvent(nsGkAtoms::Bookmarks); |
1536 | MOZ_LOG(gKeyLog, LogLevel::Info,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, " HandleKeyPressEvent(), dispatched \"Bookmarks\" command " "event"); } } while (0) |
1537 | (" HandleKeyPressEvent(), dispatched \"Bookmarks\" command "do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, " HandleKeyPressEvent(), dispatched \"Bookmarks\" command " "event"); } } while (0) |
1538 | "event"))do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, " HandleKeyPressEvent(), dispatched \"Bookmarks\" command " "event"); } } while (0); |
1539 | return; |
1540 | case GDK_HomePage0x1008ff18: |
1541 | aWindow->DispatchCommandEvent(nsGkAtoms::Home); |
1542 | return; |
1543 | case GDK_Copy0x1008ff57: |
1544 | case GDK_F160xffcd: // F16, F20, F18, F14 are old keysyms for Copy Cut Paste Undo |
1545 | aWindow->DispatchContentCommandEvent(eContentCommandCopy); |
1546 | MOZ_LOG(gKeyLog, LogLevel::Info,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, " HandleKeyPressEvent(), dispatched \"Copy\" content command " "event"); } } while (0) |
1547 | (" HandleKeyPressEvent(), dispatched \"Copy\" content command "do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, " HandleKeyPressEvent(), dispatched \"Copy\" content command " "event"); } } while (0) |
1548 | "event"))do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, " HandleKeyPressEvent(), dispatched \"Copy\" content command " "event"); } } while (0); |
1549 | return; |
1550 | case GDK_Cut0x1008ff58: |
1551 | case GDK_F200xffd1: |
1552 | aWindow->DispatchContentCommandEvent(eContentCommandCut); |
1553 | MOZ_LOG(gKeyLog, LogLevel::Info,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, " HandleKeyPressEvent(), dispatched \"Cut\" content command " "event"); } } while (0) |
1554 | (" HandleKeyPressEvent(), dispatched \"Cut\" content command "do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, " HandleKeyPressEvent(), dispatched \"Cut\" content command " "event"); } } while (0) |
1555 | "event"))do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, " HandleKeyPressEvent(), dispatched \"Cut\" content command " "event"); } } while (0); |
1556 | return; |
1557 | case GDK_Paste0x1008ff6d: |
1558 | case GDK_F180xffcf: |
1559 | aWindow->DispatchContentCommandEvent(eContentCommandPaste); |
1560 | MOZ_LOG(gKeyLog, LogLevel::Info,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, " HandleKeyPressEvent(), dispatched \"Paste\" content command " "event"); } } while (0) |
1561 | (" HandleKeyPressEvent(), dispatched \"Paste\" content command "do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, " HandleKeyPressEvent(), dispatched \"Paste\" content command " "event"); } } while (0) |
1562 | "event"))do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, " HandleKeyPressEvent(), dispatched \"Paste\" content command " "event"); } } while (0); |
1563 | return; |
1564 | case GDK_Redo0xff66: |
1565 | aWindow->DispatchContentCommandEvent(eContentCommandRedo); |
1566 | return; |
1567 | case GDK_Undo0xff65: |
1568 | case GDK_F140xffcb: |
1569 | aWindow->DispatchContentCommandEvent(eContentCommandUndo); |
1570 | MOZ_LOG(gKeyLog, LogLevel::Info,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, " HandleKeyPressEvent(), dispatched \"Undo\" content command " "event"); } } while (0) |
1571 | (" HandleKeyPressEvent(), dispatched \"Undo\" content command "do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, " HandleKeyPressEvent(), dispatched \"Undo\" content command " "event"); } } while (0) |
1572 | "event"))do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, " HandleKeyPressEvent(), dispatched \"Undo\" content command " "event"); } } while (0); |
1573 | return; |
1574 | default: |
1575 | break; |
1576 | } |
1577 | |
1578 | // before we dispatch a key, check if it's the context menu key. |
1579 | // If so, send a context menu key event instead. |
1580 | if (MaybeDispatchContextMenuEvent(aWindow, aGdkKeyEvent)) { |
1581 | MOZ_LOG(gKeyLog, LogLevel::Info,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, " HandleKeyPressEvent(), stopped dispatching eKeyPress event " "because eContextMenu event was dispatched"); } } while (0) |
1582 | (" HandleKeyPressEvent(), stopped dispatching eKeyPress event "do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, " HandleKeyPressEvent(), stopped dispatching eKeyPress event " "because eContextMenu event was dispatched"); } } while (0) |
1583 | "because eContextMenu event was dispatched"))do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, " HandleKeyPressEvent(), stopped dispatching eKeyPress event " "because eContextMenu event was dispatched"); } } while (0); |
1584 | return; |
1585 | } |
1586 | |
1587 | RefPtr<TextEventDispatcher> textEventDispatcher = |
1588 | aWindow->GetTextEventDispatcher(); |
1589 | nsresult rv = textEventDispatcher->BeginNativeInputTransaction(); |
1590 | if (NS_WARN_IF(NS_FAILED(rv))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(rv )), 0))), "NS_FAILED(rv)", "/var/lib/jenkins/workspace/firefox-scan-build/widget/gtk/nsGtkKeyUtils.cpp" , 1590)) { |
1591 | MOZ_LOG(gKeyLog, LogLevel::Error,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Error)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Error, " HandleKeyPressEvent(), stopped dispatching eKeyPress event " "because of failed to initialize TextEventDispatcher"); } } while (0) |
1592 | (" HandleKeyPressEvent(), stopped dispatching eKeyPress event "do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Error)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Error, " HandleKeyPressEvent(), stopped dispatching eKeyPress event " "because of failed to initialize TextEventDispatcher"); } } while (0) |
1593 | "because of failed to initialize TextEventDispatcher"))do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Error)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Error, " HandleKeyPressEvent(), stopped dispatching eKeyPress event " "because of failed to initialize TextEventDispatcher"); } } while (0); |
1594 | return; |
1595 | } |
1596 | |
1597 | // If the character code is in the BMP, send the key press event. |
1598 | // Otherwise, send a compositionchange event with the equivalent UTF-16 |
1599 | // string. |
1600 | // TODO: Investigate other browser's behavior in this case because |
1601 | // this hack is odd for UI Events. |
1602 | WidgetKeyboardEvent keypressEvent(true, eKeyPress, aWindow); |
1603 | KeymapWrapper::InitKeyEvent(keypressEvent, aGdkKeyEvent, false); |
1604 | nsEventStatus status = nsEventStatus_eIgnore; |
1605 | if (keypressEvent.mKeyNameIndex != KEY_NAME_INDEX_USE_STRING || |
1606 | keypressEvent.mKeyValue.Length() == 1) { |
1607 | if (textEventDispatcher->MaybeDispatchKeypressEvents(keypressEvent, status, |
1608 | aGdkKeyEvent)) { |
1609 | MOZ_LOG(gKeyLog, LogLevel::Info,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, " HandleKeyPressEvent(), dispatched eKeyPress event " "(status=%s)", GetStatusName(status)); } } while (0) |
1610 | (" HandleKeyPressEvent(), dispatched eKeyPress event "do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, " HandleKeyPressEvent(), dispatched eKeyPress event " "(status=%s)", GetStatusName(status)); } } while (0) |
1611 | "(status=%s)",do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, " HandleKeyPressEvent(), dispatched eKeyPress event " "(status=%s)", GetStatusName(status)); } } while (0) |
1612 | GetStatusName(status)))do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, " HandleKeyPressEvent(), dispatched eKeyPress event " "(status=%s)", GetStatusName(status)); } } while (0); |
1613 | } else { |
1614 | MOZ_LOG(gKeyLog, LogLevel::Info,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, " HandleKeyPressEvent(), didn't dispatch eKeyPress event " "(status=%s)", GetStatusName(status)); } } while (0) |
1615 | (" HandleKeyPressEvent(), didn't dispatch eKeyPress event "do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, " HandleKeyPressEvent(), didn't dispatch eKeyPress event " "(status=%s)", GetStatusName(status)); } } while (0) |
1616 | "(status=%s)",do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, " HandleKeyPressEvent(), didn't dispatch eKeyPress event " "(status=%s)", GetStatusName(status)); } } while (0) |
1617 | GetStatusName(status)))do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, " HandleKeyPressEvent(), didn't dispatch eKeyPress event " "(status=%s)", GetStatusName(status)); } } while (0); |
1618 | } |
1619 | } else { |
1620 | WidgetEventTime eventTime = aWindow->GetWidgetEventTime(aGdkKeyEvent->time); |
1621 | textEventDispatcher->CommitComposition(status, &keypressEvent.mKeyValue, |
1622 | &eventTime); |
1623 | MOZ_LOG(gKeyLog, LogLevel::Info,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, " HandleKeyPressEvent(), dispatched a set of composition " "events"); } } while (0) |
1624 | (" HandleKeyPressEvent(), dispatched a set of composition "do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, " HandleKeyPressEvent(), dispatched a set of composition " "events"); } } while (0) |
1625 | "events"))do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, " HandleKeyPressEvent(), dispatched a set of composition " "events"); } } while (0); |
1626 | } |
1627 | } |
1628 | |
1629 | /* static */ |
1630 | bool KeymapWrapper::HandleKeyReleaseEvent(nsWindow* aWindow, |
1631 | GdkEventKey* aGdkKeyEvent) { |
1632 | MOZ_LOG(gKeyLog, LogLevel::Info,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "HandleKeyReleaseEvent(aWindow=%p, aGdkKeyEvent={ type=%s, " "keyval=%s(0x%X), state=0x%08X, hardware_keycode=0x%08X, " "time=%u, is_modifier=%s })" , aWindow, ((aGdkKeyEvent->type == GDK_KEY_PRESS) ? "GDK_KEY_PRESS" : "GDK_KEY_RELEASE"), gdk_keyval_name(aGdkKeyEvent->keyval ), aGdkKeyEvent->keyval, aGdkKeyEvent->state, aGdkKeyEvent ->hardware_keycode, aGdkKeyEvent->time, GetBoolName(aGdkKeyEvent ->is_modifier)); } } while (0) |
1633 | ("HandleKeyReleaseEvent(aWindow=%p, aGdkKeyEvent={ type=%s, "do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "HandleKeyReleaseEvent(aWindow=%p, aGdkKeyEvent={ type=%s, " "keyval=%s(0x%X), state=0x%08X, hardware_keycode=0x%08X, " "time=%u, is_modifier=%s })" , aWindow, ((aGdkKeyEvent->type == GDK_KEY_PRESS) ? "GDK_KEY_PRESS" : "GDK_KEY_RELEASE"), gdk_keyval_name(aGdkKeyEvent->keyval ), aGdkKeyEvent->keyval, aGdkKeyEvent->state, aGdkKeyEvent ->hardware_keycode, aGdkKeyEvent->time, GetBoolName(aGdkKeyEvent ->is_modifier)); } } while (0) |
1634 | "keyval=%s(0x%X), state=0x%08X, hardware_keycode=0x%08X, "do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "HandleKeyReleaseEvent(aWindow=%p, aGdkKeyEvent={ type=%s, " "keyval=%s(0x%X), state=0x%08X, hardware_keycode=0x%08X, " "time=%u, is_modifier=%s })" , aWindow, ((aGdkKeyEvent->type == GDK_KEY_PRESS) ? "GDK_KEY_PRESS" : "GDK_KEY_RELEASE"), gdk_keyval_name(aGdkKeyEvent->keyval ), aGdkKeyEvent->keyval, aGdkKeyEvent->state, aGdkKeyEvent ->hardware_keycode, aGdkKeyEvent->time, GetBoolName(aGdkKeyEvent ->is_modifier)); } } while (0) |
1635 | "time=%u, is_modifier=%s })",do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "HandleKeyReleaseEvent(aWindow=%p, aGdkKeyEvent={ type=%s, " "keyval=%s(0x%X), state=0x%08X, hardware_keycode=0x%08X, " "time=%u, is_modifier=%s })" , aWindow, ((aGdkKeyEvent->type == GDK_KEY_PRESS) ? "GDK_KEY_PRESS" : "GDK_KEY_RELEASE"), gdk_keyval_name(aGdkKeyEvent->keyval ), aGdkKeyEvent->keyval, aGdkKeyEvent->state, aGdkKeyEvent ->hardware_keycode, aGdkKeyEvent->time, GetBoolName(aGdkKeyEvent ->is_modifier)); } } while (0) |
1636 | aWindow,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "HandleKeyReleaseEvent(aWindow=%p, aGdkKeyEvent={ type=%s, " "keyval=%s(0x%X), state=0x%08X, hardware_keycode=0x%08X, " "time=%u, is_modifier=%s })" , aWindow, ((aGdkKeyEvent->type == GDK_KEY_PRESS) ? "GDK_KEY_PRESS" : "GDK_KEY_RELEASE"), gdk_keyval_name(aGdkKeyEvent->keyval ), aGdkKeyEvent->keyval, aGdkKeyEvent->state, aGdkKeyEvent ->hardware_keycode, aGdkKeyEvent->time, GetBoolName(aGdkKeyEvent ->is_modifier)); } } while (0) |
1637 | ((aGdkKeyEvent->type == GDK_KEY_PRESS) ? "GDK_KEY_PRESS"do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "HandleKeyReleaseEvent(aWindow=%p, aGdkKeyEvent={ type=%s, " "keyval=%s(0x%X), state=0x%08X, hardware_keycode=0x%08X, " "time=%u, is_modifier=%s })" , aWindow, ((aGdkKeyEvent->type == GDK_KEY_PRESS) ? "GDK_KEY_PRESS" : "GDK_KEY_RELEASE"), gdk_keyval_name(aGdkKeyEvent->keyval ), aGdkKeyEvent->keyval, aGdkKeyEvent->state, aGdkKeyEvent ->hardware_keycode, aGdkKeyEvent->time, GetBoolName(aGdkKeyEvent ->is_modifier)); } } while (0) |
1638 | : "GDK_KEY_RELEASE"),do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "HandleKeyReleaseEvent(aWindow=%p, aGdkKeyEvent={ type=%s, " "keyval=%s(0x%X), state=0x%08X, hardware_keycode=0x%08X, " "time=%u, is_modifier=%s })" , aWindow, ((aGdkKeyEvent->type == GDK_KEY_PRESS) ? "GDK_KEY_PRESS" : "GDK_KEY_RELEASE"), gdk_keyval_name(aGdkKeyEvent->keyval ), aGdkKeyEvent->keyval, aGdkKeyEvent->state, aGdkKeyEvent ->hardware_keycode, aGdkKeyEvent->time, GetBoolName(aGdkKeyEvent ->is_modifier)); } } while (0) |
1639 | gdk_keyval_name(aGdkKeyEvent->keyval), aGdkKeyEvent->keyval,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "HandleKeyReleaseEvent(aWindow=%p, aGdkKeyEvent={ type=%s, " "keyval=%s(0x%X), state=0x%08X, hardware_keycode=0x%08X, " "time=%u, is_modifier=%s })" , aWindow, ((aGdkKeyEvent->type == GDK_KEY_PRESS) ? "GDK_KEY_PRESS" : "GDK_KEY_RELEASE"), gdk_keyval_name(aGdkKeyEvent->keyval ), aGdkKeyEvent->keyval, aGdkKeyEvent->state, aGdkKeyEvent ->hardware_keycode, aGdkKeyEvent->time, GetBoolName(aGdkKeyEvent ->is_modifier)); } } while (0) |
1640 | aGdkKeyEvent->state, aGdkKeyEvent->hardware_keycode,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "HandleKeyReleaseEvent(aWindow=%p, aGdkKeyEvent={ type=%s, " "keyval=%s(0x%X), state=0x%08X, hardware_keycode=0x%08X, " "time=%u, is_modifier=%s })" , aWindow, ((aGdkKeyEvent->type == GDK_KEY_PRESS) ? "GDK_KEY_PRESS" : "GDK_KEY_RELEASE"), gdk_keyval_name(aGdkKeyEvent->keyval ), aGdkKeyEvent->keyval, aGdkKeyEvent->state, aGdkKeyEvent ->hardware_keycode, aGdkKeyEvent->time, GetBoolName(aGdkKeyEvent ->is_modifier)); } } while (0) |
1641 | aGdkKeyEvent->time, GetBoolName(aGdkKeyEvent->is_modifier)))do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "HandleKeyReleaseEvent(aWindow=%p, aGdkKeyEvent={ type=%s, " "keyval=%s(0x%X), state=0x%08X, hardware_keycode=0x%08X, " "time=%u, is_modifier=%s })" , aWindow, ((aGdkKeyEvent->type == GDK_KEY_PRESS) ? "GDK_KEY_PRESS" : "GDK_KEY_RELEASE"), gdk_keyval_name(aGdkKeyEvent->keyval ), aGdkKeyEvent->keyval, aGdkKeyEvent->state, aGdkKeyEvent ->hardware_keycode, aGdkKeyEvent->time, GetBoolName(aGdkKeyEvent ->is_modifier)); } } while (0); |
1642 | |
1643 | RefPtr<IMContextWrapper> imContext = aWindow->GetIMContext(); |
1644 | if (imContext) { |
1645 | KeyHandlingState handlingState = |
1646 | imContext->OnKeyEvent(aWindow, aGdkKeyEvent); |
1647 | if (handlingState != KeyHandlingState::eNotHandled) { |
1648 | MOZ_LOG(gKeyLog, LogLevel::Info,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, " HandleKeyReleaseEvent(), the event was handled by " "IMContextWrapper"); } } while (0) |
1649 | (" HandleKeyReleaseEvent(), the event was handled by "do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, " HandleKeyReleaseEvent(), the event was handled by " "IMContextWrapper"); } } while (0) |
1650 | "IMContextWrapper"))do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, " HandleKeyReleaseEvent(), the event was handled by " "IMContextWrapper"); } } while (0); |
1651 | return true; |
1652 | } |
1653 | } |
1654 | |
1655 | bool isCancelled = false; |
1656 | if (NS_WARN_IF(!DispatchKeyDownOrKeyUpEvent(aWindow, aGdkKeyEvent, false,NS_warn_if_impl(!DispatchKeyDownOrKeyUpEvent(aWindow, aGdkKeyEvent , false, &isCancelled), "!DispatchKeyDownOrKeyUpEvent(aWindow, aGdkKeyEvent, false, &isCancelled)" , "/var/lib/jenkins/workspace/firefox-scan-build/widget/gtk/nsGtkKeyUtils.cpp" , 1657) |
1657 | &isCancelled))NS_warn_if_impl(!DispatchKeyDownOrKeyUpEvent(aWindow, aGdkKeyEvent , false, &isCancelled), "!DispatchKeyDownOrKeyUpEvent(aWindow, aGdkKeyEvent, false, &isCancelled)" , "/var/lib/jenkins/workspace/firefox-scan-build/widget/gtk/nsGtkKeyUtils.cpp" , 1657)) { |
1658 | MOZ_LOG(gKeyLog, LogLevel::Error,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Error)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Error, " HandleKeyReleaseEvent(), didn't dispatch eKeyUp event" ); } } while (0) |
1659 | (" HandleKeyReleaseEvent(), didn't dispatch eKeyUp event"))do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Error)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Error, " HandleKeyReleaseEvent(), didn't dispatch eKeyUp event" ); } } while (0); |
1660 | return false; |
1661 | } |
1662 | |
1663 | MOZ_LOG(gKeyLog, LogLevel::Info,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, " HandleKeyReleaseEvent(), dispatched eKeyUp event " "(isCancelled=%s)", GetBoolName(isCancelled)); } } while (0) |
1664 | (" HandleKeyReleaseEvent(), dispatched eKeyUp event "do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, " HandleKeyReleaseEvent(), dispatched eKeyUp event " "(isCancelled=%s)", GetBoolName(isCancelled)); } } while (0) |
1665 | "(isCancelled=%s)",do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, " HandleKeyReleaseEvent(), dispatched eKeyUp event " "(isCancelled=%s)", GetBoolName(isCancelled)); } } while (0) |
1666 | GetBoolName(isCancelled)))do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, " HandleKeyReleaseEvent(), dispatched eKeyUp event " "(isCancelled=%s)", GetBoolName(isCancelled)); } } while (0); |
1667 | return true; |
1668 | } |
1669 | |
1670 | guint KeymapWrapper::GetModifierState(GdkEventKey* aGdkKeyEvent, |
1671 | KeymapWrapper* aWrapper) { |
1672 | guint state = aGdkKeyEvent->state; |
1673 | if (!aGdkKeyEvent->is_modifier) { |
1674 | return state; |
1675 | } |
1676 | #ifdef MOZ_X111 |
1677 | // NOTE: The state of given key event indicates adjacent state of |
1678 | // modifier keys. E.g., even if the event is Shift key press event, |
1679 | // the bit for Shift is still false. By the same token, even if the |
1680 | // event is Shift key release event, the bit for Shift is still true. |
1681 | // Unfortunately, gdk_keyboard_get_modifiers() returns current modifier |
1682 | // state. It means if there're some pending modifier key press or |
1683 | // key release events, the result isn't what we want. |
1684 | GdkDisplay* gdkDisplay = gdk_display_get_default(); |
1685 | if (GdkIsX11Display(gdkDisplay)) { |
1686 | GdkDisplay* gdkDisplay = gdk_display_get_default(); |
1687 | Display* display = gdk_x11_display_get_xdisplay(gdkDisplay); |
1688 | if (XEventsQueued(display, QueuedAfterReading1)) { |
1689 | XEvent nextEvent; |
1690 | XPeekEvent(display, &nextEvent); |
1691 | if (nextEvent.type == aWrapper->mXKBBaseEventCode) { |
1692 | XkbEvent* XKBEvent = (XkbEvent*)&nextEvent; |
1693 | if (XKBEvent->any.xkb_type == XkbStateNotify2) { |
1694 | XkbStateNotifyEvent* stateNotifyEvent = |
1695 | (XkbStateNotifyEvent*)XKBEvent; |
1696 | state &= ~0xFF; |
1697 | state |= stateNotifyEvent->lookup_mods; |
1698 | } |
1699 | } |
1700 | } |
1701 | return state; |
1702 | } |
1703 | #endif |
1704 | #ifdef MOZ_WAYLAND1 |
1705 | int mask = 0; |
1706 | switch (aGdkKeyEvent->keyval) { |
1707 | case GDK_Shift_L0xffe1: |
1708 | case GDK_Shift_R0xffe2: |
1709 | mask = aWrapper->GetGdkModifierMask(SHIFT); |
1710 | break; |
1711 | case GDK_Control_L0xffe3: |
1712 | case GDK_Control_R0xffe4: |
1713 | mask = aWrapper->GetGdkModifierMask(CTRL); |
1714 | break; |
1715 | case GDK_Alt_L0xffe9: |
1716 | case GDK_Alt_R0xffea: |
1717 | mask = aWrapper->GetGdkModifierMask(ALT); |
1718 | break; |
1719 | case GDK_Super_L0xffeb: |
1720 | case GDK_Super_R0xffec: |
1721 | mask = aWrapper->GetGdkModifierMask(SUPER); |
1722 | break; |
1723 | case GDK_Hyper_L0xffed: |
1724 | case GDK_Hyper_R0xffee: |
1725 | mask = aWrapper->GetGdkModifierMask(HYPER); |
1726 | break; |
1727 | case GDK_Meta_L0xffe7: |
1728 | case GDK_Meta_R0xffe8: |
1729 | mask = aWrapper->GetGdkModifierMask(META); |
1730 | break; |
1731 | default: |
1732 | break; |
1733 | } |
1734 | if (aGdkKeyEvent->type == GDK_KEY_PRESS) { |
1735 | state |= mask; |
1736 | } else { |
1737 | state &= ~mask; |
1738 | } |
1739 | #endif |
1740 | return state; |
1741 | } |
1742 | |
1743 | /* static */ |
1744 | void KeymapWrapper::InitKeyEvent(WidgetKeyboardEvent& aKeyEvent, |
1745 | GdkEventKey* aGdkKeyEvent, |
1746 | bool aIsProcessedByIME) { |
1747 | MOZ_ASSERT(do { static_assert( mozilla::detail::AssertionConditionType< decltype(!aIsProcessedByIME || aKeyEvent.mMessage != eKeyPress )>::isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(!aIsProcessedByIME || aKeyEvent.mMessage != eKeyPress ))), 0))) { do { } while (false); MOZ_ReportAssertionFailure( "!aIsProcessedByIME || aKeyEvent.mMessage != eKeyPress" " (" "If the key event is handled by IME, keypress event shouldn't be fired" ")", "/var/lib/jenkins/workspace/firefox-scan-build/widget/gtk/nsGtkKeyUtils.cpp" , 1749); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!aIsProcessedByIME || aKeyEvent.mMessage != eKeyPress" ") (" "If the key event is handled by IME, keypress event shouldn't be fired" ")"); do { *((volatile int*)__null) = 1749; __attribute__((nomerge )) ::abort(); } while (false); } } while (false) |
1748 | !aIsProcessedByIME || aKeyEvent.mMessage != eKeyPress,do { static_assert( mozilla::detail::AssertionConditionType< decltype(!aIsProcessedByIME || aKeyEvent.mMessage != eKeyPress )>::isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(!aIsProcessedByIME || aKeyEvent.mMessage != eKeyPress ))), 0))) { do { } while (false); MOZ_ReportAssertionFailure( "!aIsProcessedByIME || aKeyEvent.mMessage != eKeyPress" " (" "If the key event is handled by IME, keypress event shouldn't be fired" ")", "/var/lib/jenkins/workspace/firefox-scan-build/widget/gtk/nsGtkKeyUtils.cpp" , 1749); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!aIsProcessedByIME || aKeyEvent.mMessage != eKeyPress" ") (" "If the key event is handled by IME, keypress event shouldn't be fired" ")"); do { *((volatile int*)__null) = 1749; __attribute__((nomerge )) ::abort(); } while (false); } } while (false) |
1749 | "If the key event is handled by IME, keypress event shouldn't be fired")do { static_assert( mozilla::detail::AssertionConditionType< decltype(!aIsProcessedByIME || aKeyEvent.mMessage != eKeyPress )>::isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(!aIsProcessedByIME || aKeyEvent.mMessage != eKeyPress ))), 0))) { do { } while (false); MOZ_ReportAssertionFailure( "!aIsProcessedByIME || aKeyEvent.mMessage != eKeyPress" " (" "If the key event is handled by IME, keypress event shouldn't be fired" ")", "/var/lib/jenkins/workspace/firefox-scan-build/widget/gtk/nsGtkKeyUtils.cpp" , 1749); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!aIsProcessedByIME || aKeyEvent.mMessage != eKeyPress" ") (" "If the key event is handled by IME, keypress event shouldn't be fired" ")"); do { *((volatile int*)__null) = 1749; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
1750 | |
1751 | KeymapWrapper* keymapWrapper = GetInstance(); |
1752 | |
1753 | aKeyEvent.mCodeNameIndex = ComputeDOMCodeNameIndex(aGdkKeyEvent); |
1754 | MOZ_ASSERT(aKeyEvent.mCodeNameIndex != CODE_NAME_INDEX_USE_STRING)do { static_assert( mozilla::detail::AssertionConditionType< decltype(aKeyEvent.mCodeNameIndex != CODE_NAME_INDEX_USE_STRING )>::isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(aKeyEvent.mCodeNameIndex != CODE_NAME_INDEX_USE_STRING ))), 0))) { do { } while (false); MOZ_ReportAssertionFailure( "aKeyEvent.mCodeNameIndex != CODE_NAME_INDEX_USE_STRING", "/var/lib/jenkins/workspace/firefox-scan-build/widget/gtk/nsGtkKeyUtils.cpp" , 1754); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aKeyEvent.mCodeNameIndex != CODE_NAME_INDEX_USE_STRING" ")"); do { *((volatile int*)__null) = 1754; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
1755 | aKeyEvent.mKeyNameIndex = |
1756 | aIsProcessedByIME ? KEY_NAME_INDEX_Process |
1757 | : keymapWrapper->ComputeDOMKeyNameIndex(aGdkKeyEvent); |
1758 | if (aKeyEvent.mKeyNameIndex == KEY_NAME_INDEX_Unidentified) { |
1759 | uint32_t charCode = GetCharCodeFor(aGdkKeyEvent); |
1760 | if (!charCode) { |
1761 | charCode = keymapWrapper->GetUnmodifiedCharCodeFor(aGdkKeyEvent); |
1762 | } |
1763 | if (charCode) { |
1764 | aKeyEvent.mKeyNameIndex = KEY_NAME_INDEX_USE_STRING; |
1765 | MOZ_ASSERT(aKeyEvent.mKeyValue.IsEmpty(),do { static_assert( mozilla::detail::AssertionConditionType< decltype(aKeyEvent.mKeyValue.IsEmpty())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(aKeyEvent.mKeyValue.IsEmpty( )))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("aKeyEvent.mKeyValue.IsEmpty()" " (" "Uninitialized mKeyValue must be empty" ")", "/var/lib/jenkins/workspace/firefox-scan-build/widget/gtk/nsGtkKeyUtils.cpp" , 1766); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aKeyEvent.mKeyValue.IsEmpty()" ") (" "Uninitialized mKeyValue must be empty" ")"); do { *(( volatile int*)__null) = 1766; __attribute__((nomerge)) ::abort (); } while (false); } } while (false) |
1766 | "Uninitialized mKeyValue must be empty")do { static_assert( mozilla::detail::AssertionConditionType< decltype(aKeyEvent.mKeyValue.IsEmpty())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(aKeyEvent.mKeyValue.IsEmpty( )))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("aKeyEvent.mKeyValue.IsEmpty()" " (" "Uninitialized mKeyValue must be empty" ")", "/var/lib/jenkins/workspace/firefox-scan-build/widget/gtk/nsGtkKeyUtils.cpp" , 1766); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aKeyEvent.mKeyValue.IsEmpty()" ") (" "Uninitialized mKeyValue must be empty" ")"); do { *(( volatile int*)__null) = 1766; __attribute__((nomerge)) ::abort (); } while (false); } } while (false); |
1767 | AppendUCS4ToUTF16(charCode, aKeyEvent.mKeyValue); |
1768 | } |
1769 | } |
1770 | |
1771 | if (aIsProcessedByIME) { |
1772 | aKeyEvent.mKeyCode = NS_VK_PROCESSKEY; |
1773 | } else if (aKeyEvent.mKeyNameIndex != KEY_NAME_INDEX_USE_STRING || |
1774 | aKeyEvent.mMessage != eKeyPress) { |
1775 | aKeyEvent.mKeyCode = ComputeDOMKeyCode(aGdkKeyEvent); |
1776 | } else { |
1777 | aKeyEvent.mKeyCode = 0; |
1778 | } |
1779 | |
1780 | const guint modifierState = GetModifierState(aGdkKeyEvent, keymapWrapper); |
1781 | InitInputEvent(aKeyEvent, modifierState); |
1782 | |
1783 | switch (aGdkKeyEvent->keyval) { |
1784 | case GDK_Shift_L0xffe1: |
1785 | case GDK_Control_L0xffe3: |
1786 | case GDK_Alt_L0xffe9: |
1787 | case GDK_Super_L0xffeb: |
1788 | case GDK_Hyper_L0xffed: |
1789 | case GDK_Meta_L0xffe7: |
1790 | aKeyEvent.mLocation = eKeyLocationLeft; |
1791 | break; |
1792 | |
1793 | case GDK_Shift_R0xffe2: |
1794 | case GDK_Control_R0xffe4: |
1795 | case GDK_Alt_R0xffea: |
1796 | case GDK_Super_R0xffec: |
1797 | case GDK_Hyper_R0xffee: |
1798 | case GDK_Meta_R0xffe8: |
1799 | aKeyEvent.mLocation = eKeyLocationRight; |
1800 | break; |
1801 | |
1802 | case GDK_KP_00xffb0: |
1803 | case GDK_KP_10xffb1: |
1804 | case GDK_KP_20xffb2: |
1805 | case GDK_KP_30xffb3: |
1806 | case GDK_KP_40xffb4: |
1807 | case GDK_KP_50xffb5: |
1808 | case GDK_KP_60xffb6: |
1809 | case GDK_KP_70xffb7: |
1810 | case GDK_KP_80xffb8: |
1811 | case GDK_KP_90xffb9: |
1812 | case GDK_KP_Space0xff80: |
1813 | case GDK_KP_Tab0xff89: |
1814 | case GDK_KP_Enter0xff8d: |
1815 | case GDK_KP_F10xff91: |
1816 | case GDK_KP_F20xff92: |
1817 | case GDK_KP_F30xff93: |
1818 | case GDK_KP_F40xff94: |
1819 | case GDK_KP_Home0xff95: |
1820 | case GDK_KP_Left0xff96: |
1821 | case GDK_KP_Up0xff97: |
1822 | case GDK_KP_Right0xff98: |
1823 | case GDK_KP_Down0xff99: |
1824 | case GDK_KP_Prior0xff9a: // same as GDK_KP_Page_Up |
1825 | case GDK_KP_Next0xff9b: // same as GDK_KP_Page_Down |
1826 | case GDK_KP_End0xff9c: |
1827 | case GDK_KP_Begin0xff9d: |
1828 | case GDK_KP_Insert0xff9e: |
1829 | case GDK_KP_Delete0xff9f: |
1830 | case GDK_KP_Equal0xffbd: |
1831 | case GDK_KP_Multiply0xffaa: |
1832 | case GDK_KP_Add0xffab: |
1833 | case GDK_KP_Separator0xffac: |
1834 | case GDK_KP_Subtract0xffad: |
1835 | case GDK_KP_Decimal0xffae: |
1836 | case GDK_KP_Divide0xffaf: |
1837 | aKeyEvent.mLocation = eKeyLocationNumpad; |
1838 | break; |
1839 | |
1840 | default: |
1841 | aKeyEvent.mLocation = eKeyLocationStandard; |
1842 | break; |
1843 | } |
1844 | |
1845 | // The transformations above and in gdk for the keyval are not invertible |
1846 | // so link to the GdkEvent (which will vanish soon after return from the |
1847 | // event callback) to give plugins access to hardware_keycode and state. |
1848 | // (An XEvent would be nice but the GdkEvent is good enough.) |
1849 | aKeyEvent.mNativeKeyEvent = static_cast<void*>(aGdkKeyEvent); |
1850 | aKeyEvent.mIsRepeat = |
1851 | sRepeatState == REPEATING && |
1852 | aGdkKeyEvent->hardware_keycode == sLastRepeatableHardwareKeyCode; |
1853 | |
1854 | MOZ_LOG(do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p InitKeyEvent, modifierState=0x%08X " "aKeyEvent={ mMessage=%s, isShift=%s, isControl=%s, " "isAlt=%s, isMeta=%s , mKeyCode=0x%02X, mCharCode=%s, " "mKeyNameIndex=%s, mKeyValue=%s, mCodeNameIndex=%s, mCodeValue=%s, " "mLocation=%s, mIsRepeat=%s }", keymapWrapper, modifierState , ToChar(aKeyEvent.mMessage), GetBoolName(aKeyEvent.IsShift() ), GetBoolName(aKeyEvent.IsControl()), GetBoolName(aKeyEvent. IsAlt()), GetBoolName(aKeyEvent.IsMeta()), aKeyEvent.mKeyCode , GetCharacterCodeName(static_cast<char16_t>(aKeyEvent. mCharCode)).get(), ToString(aKeyEvent.mKeyNameIndex).get(), GetCharacterCodeNames (aKeyEvent.mKeyValue).get(), ToString(aKeyEvent.mCodeNameIndex ).get(), GetCharacterCodeNames(aKeyEvent.mCodeValue).get(), GetKeyLocationName (aKeyEvent.mLocation).get(), GetBoolName(aKeyEvent.mIsRepeat) ); } } while (0) |
1855 | gKeyLog, LogLevel::Info,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p InitKeyEvent, modifierState=0x%08X " "aKeyEvent={ mMessage=%s, isShift=%s, isControl=%s, " "isAlt=%s, isMeta=%s , mKeyCode=0x%02X, mCharCode=%s, " "mKeyNameIndex=%s, mKeyValue=%s, mCodeNameIndex=%s, mCodeValue=%s, " "mLocation=%s, mIsRepeat=%s }", keymapWrapper, modifierState , ToChar(aKeyEvent.mMessage), GetBoolName(aKeyEvent.IsShift() ), GetBoolName(aKeyEvent.IsControl()), GetBoolName(aKeyEvent. IsAlt()), GetBoolName(aKeyEvent.IsMeta()), aKeyEvent.mKeyCode , GetCharacterCodeName(static_cast<char16_t>(aKeyEvent. mCharCode)).get(), ToString(aKeyEvent.mKeyNameIndex).get(), GetCharacterCodeNames (aKeyEvent.mKeyValue).get(), ToString(aKeyEvent.mCodeNameIndex ).get(), GetCharacterCodeNames(aKeyEvent.mCodeValue).get(), GetKeyLocationName (aKeyEvent.mLocation).get(), GetBoolName(aKeyEvent.mIsRepeat) ); } } while (0) |
1856 | ("%p InitKeyEvent, modifierState=0x%08X "do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p InitKeyEvent, modifierState=0x%08X " "aKeyEvent={ mMessage=%s, isShift=%s, isControl=%s, " "isAlt=%s, isMeta=%s , mKeyCode=0x%02X, mCharCode=%s, " "mKeyNameIndex=%s, mKeyValue=%s, mCodeNameIndex=%s, mCodeValue=%s, " "mLocation=%s, mIsRepeat=%s }", keymapWrapper, modifierState , ToChar(aKeyEvent.mMessage), GetBoolName(aKeyEvent.IsShift() ), GetBoolName(aKeyEvent.IsControl()), GetBoolName(aKeyEvent. IsAlt()), GetBoolName(aKeyEvent.IsMeta()), aKeyEvent.mKeyCode , GetCharacterCodeName(static_cast<char16_t>(aKeyEvent. mCharCode)).get(), ToString(aKeyEvent.mKeyNameIndex).get(), GetCharacterCodeNames (aKeyEvent.mKeyValue).get(), ToString(aKeyEvent.mCodeNameIndex ).get(), GetCharacterCodeNames(aKeyEvent.mCodeValue).get(), GetKeyLocationName (aKeyEvent.mLocation).get(), GetBoolName(aKeyEvent.mIsRepeat) ); } } while (0) |
1857 | "aKeyEvent={ mMessage=%s, isShift=%s, isControl=%s, "do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p InitKeyEvent, modifierState=0x%08X " "aKeyEvent={ mMessage=%s, isShift=%s, isControl=%s, " "isAlt=%s, isMeta=%s , mKeyCode=0x%02X, mCharCode=%s, " "mKeyNameIndex=%s, mKeyValue=%s, mCodeNameIndex=%s, mCodeValue=%s, " "mLocation=%s, mIsRepeat=%s }", keymapWrapper, modifierState , ToChar(aKeyEvent.mMessage), GetBoolName(aKeyEvent.IsShift() ), GetBoolName(aKeyEvent.IsControl()), GetBoolName(aKeyEvent. IsAlt()), GetBoolName(aKeyEvent.IsMeta()), aKeyEvent.mKeyCode , GetCharacterCodeName(static_cast<char16_t>(aKeyEvent. mCharCode)).get(), ToString(aKeyEvent.mKeyNameIndex).get(), GetCharacterCodeNames (aKeyEvent.mKeyValue).get(), ToString(aKeyEvent.mCodeNameIndex ).get(), GetCharacterCodeNames(aKeyEvent.mCodeValue).get(), GetKeyLocationName (aKeyEvent.mLocation).get(), GetBoolName(aKeyEvent.mIsRepeat) ); } } while (0) |
1858 | "isAlt=%s, isMeta=%s , mKeyCode=0x%02X, mCharCode=%s, "do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p InitKeyEvent, modifierState=0x%08X " "aKeyEvent={ mMessage=%s, isShift=%s, isControl=%s, " "isAlt=%s, isMeta=%s , mKeyCode=0x%02X, mCharCode=%s, " "mKeyNameIndex=%s, mKeyValue=%s, mCodeNameIndex=%s, mCodeValue=%s, " "mLocation=%s, mIsRepeat=%s }", keymapWrapper, modifierState , ToChar(aKeyEvent.mMessage), GetBoolName(aKeyEvent.IsShift() ), GetBoolName(aKeyEvent.IsControl()), GetBoolName(aKeyEvent. IsAlt()), GetBoolName(aKeyEvent.IsMeta()), aKeyEvent.mKeyCode , GetCharacterCodeName(static_cast<char16_t>(aKeyEvent. mCharCode)).get(), ToString(aKeyEvent.mKeyNameIndex).get(), GetCharacterCodeNames (aKeyEvent.mKeyValue).get(), ToString(aKeyEvent.mCodeNameIndex ).get(), GetCharacterCodeNames(aKeyEvent.mCodeValue).get(), GetKeyLocationName (aKeyEvent.mLocation).get(), GetBoolName(aKeyEvent.mIsRepeat) ); } } while (0) |
1859 | "mKeyNameIndex=%s, mKeyValue=%s, mCodeNameIndex=%s, mCodeValue=%s, "do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p InitKeyEvent, modifierState=0x%08X " "aKeyEvent={ mMessage=%s, isShift=%s, isControl=%s, " "isAlt=%s, isMeta=%s , mKeyCode=0x%02X, mCharCode=%s, " "mKeyNameIndex=%s, mKeyValue=%s, mCodeNameIndex=%s, mCodeValue=%s, " "mLocation=%s, mIsRepeat=%s }", keymapWrapper, modifierState , ToChar(aKeyEvent.mMessage), GetBoolName(aKeyEvent.IsShift() ), GetBoolName(aKeyEvent.IsControl()), GetBoolName(aKeyEvent. IsAlt()), GetBoolName(aKeyEvent.IsMeta()), aKeyEvent.mKeyCode , GetCharacterCodeName(static_cast<char16_t>(aKeyEvent. mCharCode)).get(), ToString(aKeyEvent.mKeyNameIndex).get(), GetCharacterCodeNames (aKeyEvent.mKeyValue).get(), ToString(aKeyEvent.mCodeNameIndex ).get(), GetCharacterCodeNames(aKeyEvent.mCodeValue).get(), GetKeyLocationName (aKeyEvent.mLocation).get(), GetBoolName(aKeyEvent.mIsRepeat) ); } } while (0) |
1860 | "mLocation=%s, mIsRepeat=%s }",do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p InitKeyEvent, modifierState=0x%08X " "aKeyEvent={ mMessage=%s, isShift=%s, isControl=%s, " "isAlt=%s, isMeta=%s , mKeyCode=0x%02X, mCharCode=%s, " "mKeyNameIndex=%s, mKeyValue=%s, mCodeNameIndex=%s, mCodeValue=%s, " "mLocation=%s, mIsRepeat=%s }", keymapWrapper, modifierState , ToChar(aKeyEvent.mMessage), GetBoolName(aKeyEvent.IsShift() ), GetBoolName(aKeyEvent.IsControl()), GetBoolName(aKeyEvent. IsAlt()), GetBoolName(aKeyEvent.IsMeta()), aKeyEvent.mKeyCode , GetCharacterCodeName(static_cast<char16_t>(aKeyEvent. mCharCode)).get(), ToString(aKeyEvent.mKeyNameIndex).get(), GetCharacterCodeNames (aKeyEvent.mKeyValue).get(), ToString(aKeyEvent.mCodeNameIndex ).get(), GetCharacterCodeNames(aKeyEvent.mCodeValue).get(), GetKeyLocationName (aKeyEvent.mLocation).get(), GetBoolName(aKeyEvent.mIsRepeat) ); } } while (0) |
1861 | keymapWrapper, modifierState, ToChar(aKeyEvent.mMessage),do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p InitKeyEvent, modifierState=0x%08X " "aKeyEvent={ mMessage=%s, isShift=%s, isControl=%s, " "isAlt=%s, isMeta=%s , mKeyCode=0x%02X, mCharCode=%s, " "mKeyNameIndex=%s, mKeyValue=%s, mCodeNameIndex=%s, mCodeValue=%s, " "mLocation=%s, mIsRepeat=%s }", keymapWrapper, modifierState , ToChar(aKeyEvent.mMessage), GetBoolName(aKeyEvent.IsShift() ), GetBoolName(aKeyEvent.IsControl()), GetBoolName(aKeyEvent. IsAlt()), GetBoolName(aKeyEvent.IsMeta()), aKeyEvent.mKeyCode , GetCharacterCodeName(static_cast<char16_t>(aKeyEvent. mCharCode)).get(), ToString(aKeyEvent.mKeyNameIndex).get(), GetCharacterCodeNames (aKeyEvent.mKeyValue).get(), ToString(aKeyEvent.mCodeNameIndex ).get(), GetCharacterCodeNames(aKeyEvent.mCodeValue).get(), GetKeyLocationName (aKeyEvent.mLocation).get(), GetBoolName(aKeyEvent.mIsRepeat) ); } } while (0) |
1862 | GetBoolName(aKeyEvent.IsShift()), GetBoolName(aKeyEvent.IsControl()),do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p InitKeyEvent, modifierState=0x%08X " "aKeyEvent={ mMessage=%s, isShift=%s, isControl=%s, " "isAlt=%s, isMeta=%s , mKeyCode=0x%02X, mCharCode=%s, " "mKeyNameIndex=%s, mKeyValue=%s, mCodeNameIndex=%s, mCodeValue=%s, " "mLocation=%s, mIsRepeat=%s }", keymapWrapper, modifierState , ToChar(aKeyEvent.mMessage), GetBoolName(aKeyEvent.IsShift() ), GetBoolName(aKeyEvent.IsControl()), GetBoolName(aKeyEvent. IsAlt()), GetBoolName(aKeyEvent.IsMeta()), aKeyEvent.mKeyCode , GetCharacterCodeName(static_cast<char16_t>(aKeyEvent. mCharCode)).get(), ToString(aKeyEvent.mKeyNameIndex).get(), GetCharacterCodeNames (aKeyEvent.mKeyValue).get(), ToString(aKeyEvent.mCodeNameIndex ).get(), GetCharacterCodeNames(aKeyEvent.mCodeValue).get(), GetKeyLocationName (aKeyEvent.mLocation).get(), GetBoolName(aKeyEvent.mIsRepeat) ); } } while (0) |
1863 | GetBoolName(aKeyEvent.IsAlt()), GetBoolName(aKeyEvent.IsMeta()),do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p InitKeyEvent, modifierState=0x%08X " "aKeyEvent={ mMessage=%s, isShift=%s, isControl=%s, " "isAlt=%s, isMeta=%s , mKeyCode=0x%02X, mCharCode=%s, " "mKeyNameIndex=%s, mKeyValue=%s, mCodeNameIndex=%s, mCodeValue=%s, " "mLocation=%s, mIsRepeat=%s }", keymapWrapper, modifierState , ToChar(aKeyEvent.mMessage), GetBoolName(aKeyEvent.IsShift() ), GetBoolName(aKeyEvent.IsControl()), GetBoolName(aKeyEvent. IsAlt()), GetBoolName(aKeyEvent.IsMeta()), aKeyEvent.mKeyCode , GetCharacterCodeName(static_cast<char16_t>(aKeyEvent. mCharCode)).get(), ToString(aKeyEvent.mKeyNameIndex).get(), GetCharacterCodeNames (aKeyEvent.mKeyValue).get(), ToString(aKeyEvent.mCodeNameIndex ).get(), GetCharacterCodeNames(aKeyEvent.mCodeValue).get(), GetKeyLocationName (aKeyEvent.mLocation).get(), GetBoolName(aKeyEvent.mIsRepeat) ); } } while (0) |
1864 | aKeyEvent.mKeyCode,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p InitKeyEvent, modifierState=0x%08X " "aKeyEvent={ mMessage=%s, isShift=%s, isControl=%s, " "isAlt=%s, isMeta=%s , mKeyCode=0x%02X, mCharCode=%s, " "mKeyNameIndex=%s, mKeyValue=%s, mCodeNameIndex=%s, mCodeValue=%s, " "mLocation=%s, mIsRepeat=%s }", keymapWrapper, modifierState , ToChar(aKeyEvent.mMessage), GetBoolName(aKeyEvent.IsShift() ), GetBoolName(aKeyEvent.IsControl()), GetBoolName(aKeyEvent. IsAlt()), GetBoolName(aKeyEvent.IsMeta()), aKeyEvent.mKeyCode , GetCharacterCodeName(static_cast<char16_t>(aKeyEvent. mCharCode)).get(), ToString(aKeyEvent.mKeyNameIndex).get(), GetCharacterCodeNames (aKeyEvent.mKeyValue).get(), ToString(aKeyEvent.mCodeNameIndex ).get(), GetCharacterCodeNames(aKeyEvent.mCodeValue).get(), GetKeyLocationName (aKeyEvent.mLocation).get(), GetBoolName(aKeyEvent.mIsRepeat) ); } } while (0) |
1865 | GetCharacterCodeName(static_cast<char16_t>(aKeyEvent.mCharCode)).get(),do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p InitKeyEvent, modifierState=0x%08X " "aKeyEvent={ mMessage=%s, isShift=%s, isControl=%s, " "isAlt=%s, isMeta=%s , mKeyCode=0x%02X, mCharCode=%s, " "mKeyNameIndex=%s, mKeyValue=%s, mCodeNameIndex=%s, mCodeValue=%s, " "mLocation=%s, mIsRepeat=%s }", keymapWrapper, modifierState , ToChar(aKeyEvent.mMessage), GetBoolName(aKeyEvent.IsShift() ), GetBoolName(aKeyEvent.IsControl()), GetBoolName(aKeyEvent. IsAlt()), GetBoolName(aKeyEvent.IsMeta()), aKeyEvent.mKeyCode , GetCharacterCodeName(static_cast<char16_t>(aKeyEvent. mCharCode)).get(), ToString(aKeyEvent.mKeyNameIndex).get(), GetCharacterCodeNames (aKeyEvent.mKeyValue).get(), ToString(aKeyEvent.mCodeNameIndex ).get(), GetCharacterCodeNames(aKeyEvent.mCodeValue).get(), GetKeyLocationName (aKeyEvent.mLocation).get(), GetBoolName(aKeyEvent.mIsRepeat) ); } } while (0) |
1866 | ToString(aKeyEvent.mKeyNameIndex).get(),do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p InitKeyEvent, modifierState=0x%08X " "aKeyEvent={ mMessage=%s, isShift=%s, isControl=%s, " "isAlt=%s, isMeta=%s , mKeyCode=0x%02X, mCharCode=%s, " "mKeyNameIndex=%s, mKeyValue=%s, mCodeNameIndex=%s, mCodeValue=%s, " "mLocation=%s, mIsRepeat=%s }", keymapWrapper, modifierState , ToChar(aKeyEvent.mMessage), GetBoolName(aKeyEvent.IsShift() ), GetBoolName(aKeyEvent.IsControl()), GetBoolName(aKeyEvent. IsAlt()), GetBoolName(aKeyEvent.IsMeta()), aKeyEvent.mKeyCode , GetCharacterCodeName(static_cast<char16_t>(aKeyEvent. mCharCode)).get(), ToString(aKeyEvent.mKeyNameIndex).get(), GetCharacterCodeNames (aKeyEvent.mKeyValue).get(), ToString(aKeyEvent.mCodeNameIndex ).get(), GetCharacterCodeNames(aKeyEvent.mCodeValue).get(), GetKeyLocationName (aKeyEvent.mLocation).get(), GetBoolName(aKeyEvent.mIsRepeat) ); } } while (0) |
1867 | GetCharacterCodeNames(aKeyEvent.mKeyValue).get(),do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p InitKeyEvent, modifierState=0x%08X " "aKeyEvent={ mMessage=%s, isShift=%s, isControl=%s, " "isAlt=%s, isMeta=%s , mKeyCode=0x%02X, mCharCode=%s, " "mKeyNameIndex=%s, mKeyValue=%s, mCodeNameIndex=%s, mCodeValue=%s, " "mLocation=%s, mIsRepeat=%s }", keymapWrapper, modifierState , ToChar(aKeyEvent.mMessage), GetBoolName(aKeyEvent.IsShift() ), GetBoolName(aKeyEvent.IsControl()), GetBoolName(aKeyEvent. IsAlt()), GetBoolName(aKeyEvent.IsMeta()), aKeyEvent.mKeyCode , GetCharacterCodeName(static_cast<char16_t>(aKeyEvent. mCharCode)).get(), ToString(aKeyEvent.mKeyNameIndex).get(), GetCharacterCodeNames (aKeyEvent.mKeyValue).get(), ToString(aKeyEvent.mCodeNameIndex ).get(), GetCharacterCodeNames(aKeyEvent.mCodeValue).get(), GetKeyLocationName (aKeyEvent.mLocation).get(), GetBoolName(aKeyEvent.mIsRepeat) ); } } while (0) |
1868 | ToString(aKeyEvent.mCodeNameIndex).get(),do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p InitKeyEvent, modifierState=0x%08X " "aKeyEvent={ mMessage=%s, isShift=%s, isControl=%s, " "isAlt=%s, isMeta=%s , mKeyCode=0x%02X, mCharCode=%s, " "mKeyNameIndex=%s, mKeyValue=%s, mCodeNameIndex=%s, mCodeValue=%s, " "mLocation=%s, mIsRepeat=%s }", keymapWrapper, modifierState , ToChar(aKeyEvent.mMessage), GetBoolName(aKeyEvent.IsShift() ), GetBoolName(aKeyEvent.IsControl()), GetBoolName(aKeyEvent. IsAlt()), GetBoolName(aKeyEvent.IsMeta()), aKeyEvent.mKeyCode , GetCharacterCodeName(static_cast<char16_t>(aKeyEvent. mCharCode)).get(), ToString(aKeyEvent.mKeyNameIndex).get(), GetCharacterCodeNames (aKeyEvent.mKeyValue).get(), ToString(aKeyEvent.mCodeNameIndex ).get(), GetCharacterCodeNames(aKeyEvent.mCodeValue).get(), GetKeyLocationName (aKeyEvent.mLocation).get(), GetBoolName(aKeyEvent.mIsRepeat) ); } } while (0) |
1869 | GetCharacterCodeNames(aKeyEvent.mCodeValue).get(),do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p InitKeyEvent, modifierState=0x%08X " "aKeyEvent={ mMessage=%s, isShift=%s, isControl=%s, " "isAlt=%s, isMeta=%s , mKeyCode=0x%02X, mCharCode=%s, " "mKeyNameIndex=%s, mKeyValue=%s, mCodeNameIndex=%s, mCodeValue=%s, " "mLocation=%s, mIsRepeat=%s }", keymapWrapper, modifierState , ToChar(aKeyEvent.mMessage), GetBoolName(aKeyEvent.IsShift() ), GetBoolName(aKeyEvent.IsControl()), GetBoolName(aKeyEvent. IsAlt()), GetBoolName(aKeyEvent.IsMeta()), aKeyEvent.mKeyCode , GetCharacterCodeName(static_cast<char16_t>(aKeyEvent. mCharCode)).get(), ToString(aKeyEvent.mKeyNameIndex).get(), GetCharacterCodeNames (aKeyEvent.mKeyValue).get(), ToString(aKeyEvent.mCodeNameIndex ).get(), GetCharacterCodeNames(aKeyEvent.mCodeValue).get(), GetKeyLocationName (aKeyEvent.mLocation).get(), GetBoolName(aKeyEvent.mIsRepeat) ); } } while (0) |
1870 | GetKeyLocationName(aKeyEvent.mLocation).get(),do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p InitKeyEvent, modifierState=0x%08X " "aKeyEvent={ mMessage=%s, isShift=%s, isControl=%s, " "isAlt=%s, isMeta=%s , mKeyCode=0x%02X, mCharCode=%s, " "mKeyNameIndex=%s, mKeyValue=%s, mCodeNameIndex=%s, mCodeValue=%s, " "mLocation=%s, mIsRepeat=%s }", keymapWrapper, modifierState , ToChar(aKeyEvent.mMessage), GetBoolName(aKeyEvent.IsShift() ), GetBoolName(aKeyEvent.IsControl()), GetBoolName(aKeyEvent. IsAlt()), GetBoolName(aKeyEvent.IsMeta()), aKeyEvent.mKeyCode , GetCharacterCodeName(static_cast<char16_t>(aKeyEvent. mCharCode)).get(), ToString(aKeyEvent.mKeyNameIndex).get(), GetCharacterCodeNames (aKeyEvent.mKeyValue).get(), ToString(aKeyEvent.mCodeNameIndex ).get(), GetCharacterCodeNames(aKeyEvent.mCodeValue).get(), GetKeyLocationName (aKeyEvent.mLocation).get(), GetBoolName(aKeyEvent.mIsRepeat) ); } } while (0) |
1871 | GetBoolName(aKeyEvent.mIsRepeat)))do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p InitKeyEvent, modifierState=0x%08X " "aKeyEvent={ mMessage=%s, isShift=%s, isControl=%s, " "isAlt=%s, isMeta=%s , mKeyCode=0x%02X, mCharCode=%s, " "mKeyNameIndex=%s, mKeyValue=%s, mCodeNameIndex=%s, mCodeValue=%s, " "mLocation=%s, mIsRepeat=%s }", keymapWrapper, modifierState , ToChar(aKeyEvent.mMessage), GetBoolName(aKeyEvent.IsShift() ), GetBoolName(aKeyEvent.IsControl()), GetBoolName(aKeyEvent. IsAlt()), GetBoolName(aKeyEvent.IsMeta()), aKeyEvent.mKeyCode , GetCharacterCodeName(static_cast<char16_t>(aKeyEvent. mCharCode)).get(), ToString(aKeyEvent.mKeyNameIndex).get(), GetCharacterCodeNames (aKeyEvent.mKeyValue).get(), ToString(aKeyEvent.mCodeNameIndex ).get(), GetCharacterCodeNames(aKeyEvent.mCodeValue).get(), GetKeyLocationName (aKeyEvent.mLocation).get(), GetBoolName(aKeyEvent.mIsRepeat) ); } } while (0); |
1872 | } |
1873 | |
1874 | /* static */ |
1875 | uint32_t KeymapWrapper::GetCharCodeFor(const GdkEventKey* aGdkKeyEvent) { |
1876 | // Anything above 0xf000 is considered a non-printable |
1877 | // Exception: directly encoded UCS characters |
1878 | if (aGdkKeyEvent->keyval > 0xf000 && |
1879 | (aGdkKeyEvent->keyval & 0xff000000) != 0x01000000) { |
1880 | // Keypad keys are an exception: they return a value different |
1881 | // from their non-keypad equivalents, but mozilla doesn't distinguish. |
1882 | switch (aGdkKeyEvent->keyval) { |
1883 | case GDK_KP_Space0xff80: |
1884 | return ' '; |
1885 | case GDK_KP_Equal0xffbd: |
1886 | return '='; |
1887 | case GDK_KP_Multiply0xffaa: |
1888 | return '*'; |
1889 | case GDK_KP_Add0xffab: |
1890 | return '+'; |
1891 | case GDK_KP_Separator0xffac: |
1892 | return ','; |
1893 | case GDK_KP_Subtract0xffad: |
1894 | return '-'; |
1895 | case GDK_KP_Decimal0xffae: |
1896 | return '.'; |
1897 | case GDK_KP_Divide0xffaf: |
1898 | return '/'; |
1899 | case GDK_KP_00xffb0: |
1900 | return '0'; |
1901 | case GDK_KP_10xffb1: |
1902 | return '1'; |
1903 | case GDK_KP_20xffb2: |
1904 | return '2'; |
1905 | case GDK_KP_30xffb3: |
1906 | return '3'; |
1907 | case GDK_KP_40xffb4: |
1908 | return '4'; |
1909 | case GDK_KP_50xffb5: |
1910 | return '5'; |
1911 | case GDK_KP_60xffb6: |
1912 | return '6'; |
1913 | case GDK_KP_70xffb7: |
1914 | return '7'; |
1915 | case GDK_KP_80xffb8: |
1916 | return '8'; |
1917 | case GDK_KP_90xffb9: |
1918 | return '9'; |
1919 | default: |
1920 | return 0; // non-printables |
1921 | } |
1922 | } |
1923 | |
1924 | static const long MAX_UNICODE = 0x10FFFF; |
1925 | |
1926 | // we're supposedly printable, let's try to convert |
1927 | long ucs = keysym2ucs(aGdkKeyEvent->keyval); |
1928 | if ((ucs != -1) && (ucs < MAX_UNICODE)) { |
1929 | return ucs; |
1930 | } |
1931 | |
1932 | // I guess we couldn't convert |
1933 | return 0; |
1934 | } |
1935 | |
1936 | uint32_t KeymapWrapper::GetCharCodeFor(const GdkEventKey* aGdkKeyEvent, |
1937 | guint aGdkModifierState, gint aGroup) { |
1938 | guint keyval; |
1939 | if (!gdk_keymap_translate_keyboard_state( |
1940 | mGdkKeymap, aGdkKeyEvent->hardware_keycode, |
1941 | GdkModifierType(aGdkModifierState), aGroup, &keyval, nullptr, nullptr, |
1942 | nullptr)) { |
1943 | return 0; |
1944 | } |
1945 | GdkEventKey tmpEvent = *aGdkKeyEvent; |
1946 | tmpEvent.state = aGdkModifierState; |
1947 | tmpEvent.keyval = keyval; |
1948 | tmpEvent.group = aGroup; |
1949 | return GetCharCodeFor(&tmpEvent); |
1950 | } |
1951 | |
1952 | uint32_t KeymapWrapper::GetUnmodifiedCharCodeFor( |
1953 | const GdkEventKey* aGdkKeyEvent) { |
1954 | guint state = |
1955 | aGdkKeyEvent->state & |
1956 | (GetGdkModifierMask(SHIFT) | GetGdkModifierMask(CAPS_LOCK) | |
1957 | GetGdkModifierMask(NUM_LOCK) | GetGdkModifierMask(SCROLL_LOCK) | |
1958 | GetGdkModifierMask(LEVEL3) | GetGdkModifierMask(LEVEL5)); |
1959 | uint32_t charCode = |
1960 | GetCharCodeFor(aGdkKeyEvent, GdkModifierType(state), aGdkKeyEvent->group); |
1961 | if (charCode) { |
1962 | return charCode; |
1963 | } |
1964 | // If no character is mapped to the key when Level3 Shift or Level5 Shift |
1965 | // is active, let's return a character which is inputted by the key without |
1966 | // Level3 nor Level5 Shift. |
1967 | guint stateWithoutAltGraph = |
1968 | state & ~(GetGdkModifierMask(LEVEL3) | GetGdkModifierMask(LEVEL5)); |
1969 | if (state == stateWithoutAltGraph) { |
1970 | return 0; |
1971 | } |
1972 | return GetCharCodeFor(aGdkKeyEvent, GdkModifierType(stateWithoutAltGraph), |
1973 | aGdkKeyEvent->group); |
1974 | } |
1975 | |
1976 | gint KeymapWrapper::GetKeyLevel(GdkEventKey* aGdkKeyEvent) { |
1977 | gint level; |
1978 | if (!gdk_keymap_translate_keyboard_state( |
1979 | mGdkKeymap, aGdkKeyEvent->hardware_keycode, |
1980 | GdkModifierType(aGdkKeyEvent->state), aGdkKeyEvent->group, nullptr, |
1981 | nullptr, &level, nullptr)) { |
1982 | return -1; |
1983 | } |
1984 | return level; |
1985 | } |
1986 | |
1987 | gint KeymapWrapper::GetFirstLatinGroup() { |
1988 | GdkKeymapKey* keys; |
1989 | gint count; |
1990 | gint minGroup = -1; |
1991 | if (gdk_keymap_get_entries_for_keyval(mGdkKeymap, GDK_a0x061, &keys, &count)) { |
1992 | // find the minimum number group for latin inputtable layout |
1993 | for (gint i = 0; i < count && minGroup != 0; ++i) { |
1994 | if (keys[i].level != 0 && keys[i].level != 1) { |
1995 | continue; |
1996 | } |
1997 | if (minGroup >= 0 && keys[i].group > minGroup) { |
1998 | continue; |
1999 | } |
2000 | minGroup = keys[i].group; |
2001 | } |
2002 | g_free(keys); |
2003 | } |
2004 | return minGroup; |
2005 | } |
2006 | |
2007 | bool KeymapWrapper::IsLatinGroup(guint8 aGroup) { |
2008 | GdkKeymapKey* keys; |
2009 | gint count; |
2010 | bool result = false; |
2011 | if (gdk_keymap_get_entries_for_keyval(mGdkKeymap, GDK_a0x061, &keys, &count)) { |
2012 | for (gint i = 0; i < count; ++i) { |
2013 | if (keys[i].level != 0 && keys[i].level != 1) { |
2014 | continue; |
2015 | } |
2016 | if (keys[i].group == aGroup) { |
2017 | result = true; |
2018 | break; |
2019 | } |
2020 | } |
2021 | g_free(keys); |
2022 | } |
2023 | return result; |
2024 | } |
2025 | |
2026 | bool KeymapWrapper::IsAutoRepeatableKey(guint aHardwareKeyCode) { |
2027 | #ifdef MOZ_X111 |
2028 | uint8_t indexOfArray = aHardwareKeyCode / 8; |
2029 | MOZ_ASSERT(indexOfArray < ArrayLength(mKeyboardState.auto_repeats),do { static_assert( mozilla::detail::AssertionConditionType< decltype(indexOfArray < ArrayLength(mKeyboardState.auto_repeats ))>::isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(indexOfArray < ArrayLength(mKeyboardState.auto_repeats )))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("indexOfArray < ArrayLength(mKeyboardState.auto_repeats)" " (" "invalid index" ")", "/var/lib/jenkins/workspace/firefox-scan-build/widget/gtk/nsGtkKeyUtils.cpp" , 2030); AnnotateMozCrashReason("MOZ_ASSERT" "(" "indexOfArray < ArrayLength(mKeyboardState.auto_repeats)" ") (" "invalid index" ")"); do { *((volatile int*)__null) = 2030 ; __attribute__((nomerge)) ::abort(); } while (false); } } while (false) |
2030 | "invalid index")do { static_assert( mozilla::detail::AssertionConditionType< decltype(indexOfArray < ArrayLength(mKeyboardState.auto_repeats ))>::isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(indexOfArray < ArrayLength(mKeyboardState.auto_repeats )))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("indexOfArray < ArrayLength(mKeyboardState.auto_repeats)" " (" "invalid index" ")", "/var/lib/jenkins/workspace/firefox-scan-build/widget/gtk/nsGtkKeyUtils.cpp" , 2030); AnnotateMozCrashReason("MOZ_ASSERT" "(" "indexOfArray < ArrayLength(mKeyboardState.auto_repeats)" ") (" "invalid index" ")"); do { *((volatile int*)__null) = 2030 ; __attribute__((nomerge)) ::abort(); } while (false); } } while (false); |
2031 | char bitMask = 1 << (aHardwareKeyCode % 8); |
2032 | return (mKeyboardState.auto_repeats[indexOfArray] & bitMask) != 0; |
2033 | #else |
2034 | return false; |
2035 | #endif |
2036 | } |
2037 | |
2038 | /* static */ |
2039 | bool KeymapWrapper::IsBasicLatinLetterOrNumeral(uint32_t aCharCode) { |
2040 | return (aCharCode >= 'a' && aCharCode <= 'z') || |
2041 | (aCharCode >= 'A' && aCharCode <= 'Z') || |
2042 | (aCharCode >= '0' && aCharCode <= '9'); |
2043 | } |
2044 | |
2045 | /* static */ |
2046 | guint KeymapWrapper::GetGDKKeyvalWithoutModifier( |
2047 | const GdkEventKey* aGdkKeyEvent) { |
2048 | KeymapWrapper* keymapWrapper = GetInstance(); |
2049 | guint state = |
2050 | (aGdkKeyEvent->state & keymapWrapper->GetGdkModifierMask(NUM_LOCK)); |
2051 | guint keyval; |
2052 | if (!gdk_keymap_translate_keyboard_state( |
2053 | keymapWrapper->mGdkKeymap, aGdkKeyEvent->hardware_keycode, |
2054 | GdkModifierType(state), aGdkKeyEvent->group, &keyval, nullptr, |
2055 | nullptr, nullptr)) { |
2056 | return 0; |
2057 | } |
2058 | return keyval; |
2059 | } |
2060 | |
2061 | struct KeyCodeData { |
2062 | const char* str; |
2063 | size_t strlength; |
2064 | uint32_t keycode; |
2065 | }; |
2066 | |
2067 | static struct KeyCodeData gKeyCodes[] = { |
2068 | #define NS_DEFINE_VK(aDOMKeyName, aDOMKeyCode) \ |
2069 | {#aDOMKeyName, sizeof(#aDOMKeyName) - 1, aDOMKeyCode}, |
2070 | #include "mozilla/VirtualKeyCodeList.h" |
2071 | #undef NS_DEFINE_VK |
2072 | {nullptr, 0, 0}}; |
2073 | |
2074 | struct KeyPair { |
2075 | uint32_t DOMKeyCode; |
2076 | guint GDKKeyval; |
2077 | }; |
2078 | |
2079 | // |
2080 | // Netscape keycodes are defined in widget/public/nsGUIEvent.h |
2081 | // GTK keycodes are defined in <gdk/gdkkeysyms.h> |
2082 | // |
2083 | static const KeyPair gKeyPairs[] = { |
2084 | {NS_VK_CANCEL, GDK_Cancel0xff69}, |
2085 | {NS_VK_BACK, GDK_BackSpace0xff08}, |
2086 | {NS_VK_TAB, GDK_Tab0xff09}, |
2087 | {NS_VK_CLEAR, GDK_Clear0xff0b}, |
2088 | {NS_VK_RETURN, GDK_Return0xff0d}, |
2089 | {NS_VK_SHIFT, GDK_Shift_L0xffe1}, |
2090 | {NS_VK_CONTROL, GDK_Control_L0xffe3}, |
2091 | {NS_VK_ALT, GDK_Alt_L0xffe9}, |
2092 | {NS_VK_META, GDK_Meta_L0xffe7}, |
2093 | |
2094 | // Assume that Super or Hyper is always mapped to physical Win key. |
2095 | {NS_VK_WIN, GDK_Super_L0xffeb}, |
2096 | |
2097 | // GTK's AltGraph key is similar to Mac's Option (Alt) key. However, |
2098 | // unfortunately, browsers on Mac are using NS_VK_ALT for it even though |
2099 | // it's really different from Alt key on Windows. |
2100 | // On the other hand, GTK's AltGrapsh keys are really different from |
2101 | // Alt key. However, there is no AltGrapsh key on Windows. On Windows, |
2102 | // both Ctrl and Alt keys are pressed internally when AltGr key is pressed. |
2103 | // For some languages' users, AltGraph key is important, so, web |
2104 | // applications on such locale may want to know AltGraph key press. |
2105 | // Therefore, we should map AltGr keycode for them only on GTK. |
2106 | {NS_VK_ALTGR, GDK_ISO_Level3_Shift0xfe03}, |
2107 | |
2108 | {NS_VK_PAUSE, GDK_Pause0xff13}, |
2109 | {NS_VK_CAPS_LOCK, GDK_Caps_Lock0xffe5}, |
2110 | {NS_VK_ESCAPE, GDK_Escape0xff1b}, |
2111 | // { NS_VK_ACCEPT, GDK_XXX }, |
2112 | // { NS_VK_MODECHANGE, GDK_XXX }, |
2113 | {NS_VK_SPACE, GDK_space0x020}, |
2114 | {NS_VK_PAGE_UP, GDK_Page_Up0xff55}, |
2115 | {NS_VK_PAGE_DOWN, GDK_Page_Down0xff56}, |
2116 | {NS_VK_END, GDK_End0xff57}, |
2117 | {NS_VK_HOME, GDK_Home0xff50}, |
2118 | {NS_VK_LEFT, GDK_Left0xff51}, |
2119 | {NS_VK_UP, GDK_Up0xff52}, |
2120 | {NS_VK_RIGHT, GDK_Right0xff53}, |
2121 | {NS_VK_DOWN, GDK_Down0xff54}, |
2122 | {NS_VK_SELECT, GDK_Select0xff60}, |
2123 | {NS_VK_PRINT, GDK_Print0xff61}, |
2124 | {NS_VK_EXECUTE, GDK_Execute0xff62}, |
2125 | {NS_VK_PRINTSCREEN, GDK_Print0xff61}, |
2126 | {NS_VK_INSERT, GDK_Insert0xff63}, |
2127 | {NS_VK_DELETE, GDK_Delete0xffff}, |
2128 | {NS_VK_HELP, GDK_Help0xff6a}, |
2129 | |
2130 | {NS_VK_NUM_LOCK, GDK_Num_Lock0xff7f}, |
2131 | {NS_VK_SCROLL_LOCK, GDK_Scroll_Lock0xff14}, |
2132 | |
2133 | // Function keys |
2134 | {NS_VK_F1, GDK_F10xffbe}, |
2135 | {NS_VK_F2, GDK_F20xffbf}, |
2136 | {NS_VK_F3, GDK_F30xffc0}, |
2137 | {NS_VK_F4, GDK_F40xffc1}, |
2138 | {NS_VK_F5, GDK_F50xffc2}, |
2139 | {NS_VK_F6, GDK_F60xffc3}, |
2140 | {NS_VK_F7, GDK_F70xffc4}, |
2141 | {NS_VK_F8, GDK_F80xffc5}, |
2142 | {NS_VK_F9, GDK_F90xffc6}, |
2143 | {NS_VK_F10, GDK_F100xffc7}, |
2144 | {NS_VK_F11, GDK_F110xffc8}, |
2145 | {NS_VK_F12, GDK_F120xffc9}, |
2146 | {NS_VK_F13, GDK_F130xffca}, |
2147 | {NS_VK_F14, GDK_F140xffcb}, |
2148 | {NS_VK_F15, GDK_F150xffcc}, |
2149 | {NS_VK_F16, GDK_F160xffcd}, |
2150 | {NS_VK_F17, GDK_F170xffce}, |
2151 | {NS_VK_F18, GDK_F180xffcf}, |
2152 | {NS_VK_F19, GDK_F190xffd0}, |
2153 | {NS_VK_F20, GDK_F200xffd1}, |
2154 | {NS_VK_F21, GDK_F210xffd2}, |
2155 | {NS_VK_F22, GDK_F220xffd3}, |
2156 | {NS_VK_F23, GDK_F230xffd4}, |
2157 | {NS_VK_F24, GDK_F240xffd5}, |
2158 | |
2159 | // context menu key, keysym 0xff67, typically keycode 117 on 105-key |
2160 | // (Microsoft) x86 keyboards, located between right 'Windows' key and right |
2161 | // Ctrl key |
2162 | {NS_VK_CONTEXT_MENU, GDK_Menu0xff67}, |
2163 | {NS_VK_SLEEP, GDK_Sleep0x1008ff2f}, |
2164 | |
2165 | {NS_VK_ATTN, GDK_3270_Attn0xfd0e}, |
2166 | {NS_VK_CRSEL, GDK_3270_CursorSelect0xfd1c}, |
2167 | {NS_VK_EXSEL, GDK_3270_ExSelect0xfd1b}, |
2168 | {NS_VK_EREOF, GDK_3270_EraseEOF0xfd06}, |
2169 | {NS_VK_PLAY, GDK_3270_Play0xfd16}, |
2170 | //{ NS_VK_ZOOM, GDK_XXX }, |
2171 | {NS_VK_PA1, GDK_3270_PA10xfd0a}, |
2172 | |
2173 | {NS_VK_MULTIPLY, GDK_KP_Multiply0xffaa}, |
2174 | {NS_VK_ADD, GDK_KP_Add0xffab}, |
2175 | {NS_VK_SEPARATOR, GDK_KP_Separator0xffac}, |
2176 | {NS_VK_SUBTRACT, GDK_KP_Subtract0xffad}, |
2177 | {NS_VK_DECIMAL, GDK_KP_Decimal0xffae}, |
2178 | {NS_VK_DIVIDE, GDK_KP_Divide0xffaf}, |
2179 | {NS_VK_NUMPAD0, GDK_KP_00xffb0}, |
2180 | {NS_VK_NUMPAD1, GDK_KP_10xffb1}, |
2181 | {NS_VK_NUMPAD2, GDK_KP_20xffb2}, |
2182 | {NS_VK_NUMPAD3, GDK_KP_30xffb3}, |
2183 | {NS_VK_NUMPAD4, GDK_KP_40xffb4}, |
2184 | {NS_VK_NUMPAD5, GDK_KP_50xffb5}, |
2185 | {NS_VK_NUMPAD6, GDK_KP_60xffb6}, |
2186 | {NS_VK_NUMPAD7, GDK_KP_70xffb7}, |
2187 | {NS_VK_NUMPAD8, GDK_KP_80xffb8}, |
2188 | {NS_VK_NUMPAD9, GDK_KP_90xffb9}, |
2189 | {NS_VK_SPACE, GDK_space0x020}, |
2190 | {NS_VK_COLON, GDK_colon0x03a}, |
2191 | {NS_VK_SEMICOLON, GDK_semicolon0x03b}, |
2192 | {NS_VK_LESS_THAN, GDK_less0x03c}, |
2193 | {NS_VK_EQUALS, GDK_equal0x03d}, |
2194 | {NS_VK_GREATER_THAN, GDK_greater0x03e}, |
2195 | {NS_VK_QUESTION_MARK, GDK_question0x03f}, |
2196 | {NS_VK_AT, GDK_at0x040}, |
2197 | {NS_VK_CIRCUMFLEX, GDK_asciicircum0x05e}, |
2198 | {NS_VK_EXCLAMATION, GDK_exclam0x021}, |
2199 | {NS_VK_DOUBLE_QUOTE, GDK_quotedbl0x022}, |
2200 | {NS_VK_HASH, GDK_numbersign0x023}, |
2201 | {NS_VK_DOLLAR, GDK_dollar0x024}, |
2202 | {NS_VK_PERCENT, GDK_percent0x025}, |
2203 | {NS_VK_AMPERSAND, GDK_ampersand0x026}, |
2204 | {NS_VK_UNDERSCORE, GDK_underscore0x05f}, |
2205 | {NS_VK_OPEN_PAREN, GDK_parenleft0x028}, |
2206 | {NS_VK_CLOSE_PAREN, GDK_parenright0x029}, |
2207 | {NS_VK_ASTERISK, GDK_asterisk0x02a}, |
2208 | {NS_VK_PLUS, GDK_plus0x02b}, |
2209 | {NS_VK_PIPE, GDK_bar0x07c}, |
2210 | {NS_VK_HYPHEN_MINUS, GDK_minus0x02d}, |
2211 | {NS_VK_OPEN_CURLY_BRACKET, GDK_braceleft0x07b}, |
2212 | {NS_VK_CLOSE_CURLY_BRACKET, GDK_braceright0x07d}, |
2213 | {NS_VK_TILDE, GDK_asciitilde0x07e}, |
2214 | {NS_VK_COMMA, GDK_comma0x02c}, |
2215 | {NS_VK_PERIOD, GDK_period0x02e}, |
2216 | {NS_VK_SLASH, GDK_slash0x02f}, |
2217 | {NS_VK_BACK_QUOTE, GDK_grave0x060}, |
2218 | {NS_VK_OPEN_BRACKET, GDK_bracketleft0x05b}, |
2219 | {NS_VK_BACK_SLASH, GDK_backslash0x05c}, |
2220 | {NS_VK_CLOSE_BRACKET, GDK_bracketright0x05d}, |
2221 | {NS_VK_QUOTE, GDK_apostrophe0x027}, |
2222 | }; |
2223 | |
2224 | /* static */ |
2225 | guint KeymapWrapper::ConvertGeckoKeyCodeToGDKKeyval(const nsAString& aKeyCode) { |
2226 | NS_ConvertUTF16toUTF8 keyName(aKeyCode); |
2227 | ToUpperCase(keyName); // We want case-insensitive comparison with data |
2228 | // stored as uppercase. |
2229 | |
2230 | uint32_t keyCode = 0; |
2231 | |
2232 | uint32_t keyNameLength = keyName.Length(); |
2233 | const char* keyNameStr = keyName.get(); |
2234 | for (const auto& code : gKeyCodes) { |
2235 | if (keyNameLength == code.strlength && |
2236 | !nsCRT::strcmp(code.str, keyNameStr)) { |
2237 | keyCode = code.keycode; |
2238 | break; |
2239 | } |
2240 | } |
2241 | |
2242 | // First, try to handle alphanumeric input, not listed in nsKeycodes: |
2243 | // most likely, more letters will be getting typed in than things in |
2244 | // the key list, so we will look through these first. |
2245 | |
2246 | if (keyCode >= NS_VK_A && keyCode <= NS_VK_Z) { |
2247 | // gdk and DOM both use the ASCII codes for these keys. |
2248 | return keyCode; |
2249 | } |
2250 | |
2251 | // numbers |
2252 | if (keyCode >= NS_VK_0 && keyCode <= NS_VK_9) { |
2253 | // gdk and DOM both use the ASCII codes for these keys. |
2254 | return keyCode - NS_VK_0 + GDK_00x030; |
2255 | } |
2256 | |
2257 | // misc other things |
2258 | for (const auto& pair : gKeyPairs) { |
2259 | if (pair.DOMKeyCode == keyCode) { |
2260 | return pair.GDKKeyval; |
2261 | } |
2262 | } |
2263 | |
2264 | return 0; |
2265 | } |
2266 | |
2267 | /* static */ |
2268 | uint32_t KeymapWrapper::GetDOMKeyCodeFromKeyPairs(guint aGdkKeyval) { |
2269 | switch (aGdkKeyval) { |
2270 | case GDK_Cancel0xff69: |
2271 | return NS_VK_CANCEL; |
2272 | case GDK_BackSpace0xff08: |
2273 | return NS_VK_BACK; |
2274 | case GDK_Tab0xff09: |
2275 | case GDK_ISO_Left_Tab0xfe20: |
2276 | return NS_VK_TAB; |
2277 | case GDK_Clear0xff0b: |
2278 | return NS_VK_CLEAR; |
2279 | case GDK_Return0xff0d: |
2280 | return NS_VK_RETURN; |
2281 | case GDK_Shift_L0xffe1: |
2282 | case GDK_Shift_R0xffe2: |
2283 | case GDK_Shift_Lock0xffe6: |
2284 | return NS_VK_SHIFT; |
2285 | case GDK_Control_L0xffe3: |
2286 | case GDK_Control_R0xffe4: |
2287 | return NS_VK_CONTROL; |
2288 | case GDK_Alt_L0xffe9: |
2289 | case GDK_Alt_R0xffea: |
2290 | return NS_VK_ALT; |
2291 | case GDK_Meta_L0xffe7: |
2292 | case GDK_Meta_R0xffe8: |
2293 | return NS_VK_META; |
2294 | |
2295 | // Assume that Super or Hyper is always mapped to physical Win key. |
2296 | case GDK_Super_L0xffeb: |
2297 | case GDK_Super_R0xffec: |
2298 | case GDK_Hyper_L0xffed: |
2299 | case GDK_Hyper_R0xffee: |
2300 | return NS_VK_WIN; |
2301 | |
2302 | // GTK's AltGraph key is similar to Mac's Option (Alt) key. However, |
2303 | // unfortunately, browsers on Mac are using NS_VK_ALT for it even though |
2304 | // it's really different from Alt key on Windows. |
2305 | // On the other hand, GTK's AltGrapsh keys are really different from |
2306 | // Alt key. However, there is no AltGrapsh key on Windows. On Windows, |
2307 | // both Ctrl and Alt keys are pressed internally when AltGr key is |
2308 | // pressed. For some languages' users, AltGraph key is important, so, |
2309 | // web applications on such locale may want to know AltGraph key press. |
2310 | // Therefore, we should map AltGr keycode for them only on GTK. |
2311 | case GDK_ISO_Level3_Shift0xfe03: |
2312 | case GDK_ISO_Level5_Shift0xfe11: |
2313 | // We assume that Mode_switch is always used for level3 shift. |
2314 | case GDK_Mode_switch0xff7e: |
2315 | return NS_VK_ALTGR; |
2316 | |
2317 | case GDK_Pause0xff13: |
2318 | return NS_VK_PAUSE; |
2319 | case GDK_Caps_Lock0xffe5: |
2320 | return NS_VK_CAPS_LOCK; |
2321 | case GDK_Kana_Lock0xff2d: |
2322 | case GDK_Kana_Shift0xff2e: |
2323 | return NS_VK_KANA; |
2324 | case GDK_Hangul0xff31: |
2325 | return NS_VK_HANGUL; |
2326 | // case GDK_XXX: return NS_VK_JUNJA; |
2327 | // case GDK_XXX: return NS_VK_FINAL; |
2328 | case GDK_Hangul_Hanja0xff34: |
2329 | return NS_VK_HANJA; |
2330 | case GDK_Kanji0xff21: |
2331 | return NS_VK_KANJI; |
2332 | case GDK_Escape0xff1b: |
2333 | return NS_VK_ESCAPE; |
2334 | case GDK_Henkan0xff23: |
2335 | return NS_VK_CONVERT; |
2336 | case GDK_Muhenkan0xff22: |
2337 | return NS_VK_NONCONVERT; |
2338 | // case GDK_XXX: return NS_VK_ACCEPT; |
2339 | // case GDK_XXX: return NS_VK_MODECHANGE; |
2340 | case GDK_Page_Up0xff55: |
2341 | return NS_VK_PAGE_UP; |
2342 | case GDK_Page_Down0xff56: |
2343 | return NS_VK_PAGE_DOWN; |
2344 | case GDK_End0xff57: |
2345 | return NS_VK_END; |
2346 | case GDK_Home0xff50: |
2347 | return NS_VK_HOME; |
2348 | case GDK_Left0xff51: |
2349 | return NS_VK_LEFT; |
2350 | case GDK_Up0xff52: |
2351 | return NS_VK_UP; |
2352 | case GDK_Right0xff53: |
2353 | return NS_VK_RIGHT; |
2354 | case GDK_Down0xff54: |
2355 | return NS_VK_DOWN; |
2356 | case GDK_Select0xff60: |
2357 | return NS_VK_SELECT; |
2358 | case GDK_Print0xff61: |
2359 | return NS_VK_PRINT; |
2360 | case GDK_Execute0xff62: |
2361 | return NS_VK_EXECUTE; |
2362 | case GDK_Insert0xff63: |
2363 | return NS_VK_INSERT; |
2364 | case GDK_Delete0xffff: |
2365 | return NS_VK_DELETE; |
2366 | case GDK_Help0xff6a: |
2367 | return NS_VK_HELP; |
2368 | |
2369 | // keypad keys |
2370 | case GDK_KP_Left0xff96: |
2371 | return NS_VK_LEFT; |
2372 | case GDK_KP_Right0xff98: |
2373 | return NS_VK_RIGHT; |
2374 | case GDK_KP_Up0xff97: |
2375 | return NS_VK_UP; |
2376 | case GDK_KP_Down0xff99: |
2377 | return NS_VK_DOWN; |
2378 | case GDK_KP_Page_Up0xff9a: |
2379 | return NS_VK_PAGE_UP; |
2380 | // Not sure what these are |
2381 | // case GDK_KP_Prior: return NS_VK_; |
2382 | // case GDK_KP_Next: return NS_VK_; |
2383 | case GDK_KP_Begin0xff9d: |
2384 | return NS_VK_CLEAR; // Num-unlocked 5 |
2385 | case GDK_KP_Page_Down0xff9b: |
2386 | return NS_VK_PAGE_DOWN; |
2387 | case GDK_KP_Home0xff95: |
2388 | return NS_VK_HOME; |
2389 | case GDK_KP_End0xff9c: |
2390 | return NS_VK_END; |
2391 | case GDK_KP_Insert0xff9e: |
2392 | return NS_VK_INSERT; |
2393 | case GDK_KP_Delete0xff9f: |
2394 | return NS_VK_DELETE; |
2395 | case GDK_KP_Enter0xff8d: |
2396 | return NS_VK_RETURN; |
2397 | |
2398 | case GDK_Num_Lock0xff7f: |
2399 | return NS_VK_NUM_LOCK; |
2400 | case GDK_Scroll_Lock0xff14: |
2401 | return NS_VK_SCROLL_LOCK; |
2402 | |
2403 | // Function keys |
2404 | case GDK_F10xffbe: |
2405 | return NS_VK_F1; |
2406 | case GDK_F20xffbf: |
2407 | return NS_VK_F2; |
2408 | case GDK_F30xffc0: |
2409 | return NS_VK_F3; |
2410 | case GDK_F40xffc1: |
2411 | return NS_VK_F4; |
2412 | case GDK_F50xffc2: |
2413 | return NS_VK_F5; |
2414 | case GDK_F60xffc3: |
2415 | return NS_VK_F6; |
2416 | case GDK_F70xffc4: |
2417 | return NS_VK_F7; |
2418 | case GDK_F80xffc5: |
2419 | return NS_VK_F8; |
2420 | case GDK_F90xffc6: |
2421 | return NS_VK_F9; |
2422 | case GDK_F100xffc7: |
2423 | return NS_VK_F10; |
2424 | case GDK_F110xffc8: |
2425 | return NS_VK_F11; |
2426 | case GDK_F120xffc9: |
2427 | return NS_VK_F12; |
2428 | case GDK_F130xffca: |
2429 | return NS_VK_F13; |
2430 | case GDK_F140xffcb: |
2431 | return NS_VK_F14; |
2432 | case GDK_F150xffcc: |
2433 | return NS_VK_F15; |
2434 | case GDK_F160xffcd: |
2435 | return NS_VK_F16; |
2436 | case GDK_F170xffce: |
2437 | return NS_VK_F17; |
2438 | case GDK_F180xffcf: |
2439 | return NS_VK_F18; |
2440 | case GDK_F190xffd0: |
2441 | return NS_VK_F19; |
2442 | case GDK_F200xffd1: |
2443 | return NS_VK_F20; |
2444 | case GDK_F210xffd2: |
2445 | return NS_VK_F21; |
2446 | case GDK_F220xffd3: |
2447 | return NS_VK_F22; |
2448 | case GDK_F230xffd4: |
2449 | return NS_VK_F23; |
2450 | case GDK_F240xffd5: |
2451 | return NS_VK_F24; |
2452 | |
2453 | // context menu key, keysym 0xff67, typically keycode 117 on 105-key |
2454 | // (Microsoft) x86 keyboards, located between right 'Windows' key and |
2455 | // right Ctrl key |
2456 | case GDK_Menu0xff67: |
2457 | return NS_VK_CONTEXT_MENU; |
2458 | case GDK_Sleep0x1008ff2f: |
2459 | return NS_VK_SLEEP; |
2460 | |
2461 | case GDK_3270_Attn0xfd0e: |
2462 | return NS_VK_ATTN; |
2463 | case GDK_3270_CursorSelect0xfd1c: |
2464 | return NS_VK_CRSEL; |
2465 | case GDK_3270_ExSelect0xfd1b: |
2466 | return NS_VK_EXSEL; |
2467 | case GDK_3270_EraseEOF0xfd06: |
2468 | return NS_VK_EREOF; |
2469 | case GDK_3270_Play0xfd16: |
2470 | return NS_VK_PLAY; |
2471 | // case GDK_XXX: return NS_VK_ZOOM; |
2472 | case GDK_3270_PA10xfd0a: |
2473 | return NS_VK_PA1; |
2474 | |
2475 | // map Sun Keyboard special keysyms on to NS_VK keys |
2476 | |
2477 | // Sun F11 key generates SunF36(0x1005ff10) keysym |
2478 | case 0x1005ff10: |
2479 | return NS_VK_F11; |
2480 | // Sun F12 key generates SunF37(0x1005ff11) keysym |
2481 | case 0x1005ff11: |
2482 | return NS_VK_F12; |
2483 | default: |
2484 | return 0; |
2485 | } |
2486 | } |
2487 | |
2488 | void KeymapWrapper::WillDispatchKeyboardEvent(WidgetKeyboardEvent& aKeyEvent, |
2489 | GdkEventKey* aGdkKeyEvent) { |
2490 | GetInstance()->WillDispatchKeyboardEventInternal(aKeyEvent, aGdkKeyEvent); |
2491 | } |
2492 | |
2493 | void KeymapWrapper::WillDispatchKeyboardEventInternal( |
2494 | WidgetKeyboardEvent& aKeyEvent, GdkEventKey* aGdkKeyEvent) { |
2495 | if (!aGdkKeyEvent) { |
2496 | // If aGdkKeyEvent is nullptr, we're trying to dispatch a fake keyboard |
2497 | // event in such case, we don't need to set alternative char codes. |
2498 | // So, we don't need to do nothing here. This case is typically we're |
2499 | // dispatching eKeyDown or eKeyUp event during composition. |
2500 | return; |
2501 | } |
2502 | |
2503 | uint32_t charCode = GetCharCodeFor(aGdkKeyEvent); |
2504 | if (!charCode) { |
2505 | MOZ_LOG(gKeyLog, LogLevel::Info,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p WillDispatchKeyboardEventInternal, " "mKeyCode=0x%02X, charCode=0x%08X" , this, aKeyEvent.mKeyCode, aKeyEvent.mCharCode); } } while ( 0) |
2506 | ("%p WillDispatchKeyboardEventInternal, "do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p WillDispatchKeyboardEventInternal, " "mKeyCode=0x%02X, charCode=0x%08X" , this, aKeyEvent.mKeyCode, aKeyEvent.mCharCode); } } while ( 0) |
2507 | "mKeyCode=0x%02X, charCode=0x%08X",do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p WillDispatchKeyboardEventInternal, " "mKeyCode=0x%02X, charCode=0x%08X" , this, aKeyEvent.mKeyCode, aKeyEvent.mCharCode); } } while ( 0) |
2508 | this, aKeyEvent.mKeyCode, aKeyEvent.mCharCode))do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p WillDispatchKeyboardEventInternal, " "mKeyCode=0x%02X, charCode=0x%08X" , this, aKeyEvent.mKeyCode, aKeyEvent.mCharCode); } } while ( 0); |
2509 | return; |
2510 | } |
2511 | |
2512 | // The mCharCode was set from mKeyValue. However, for example, when Ctrl key |
2513 | // is pressed, its value should indicate an ASCII character for backward |
2514 | // compatibility rather than inputting character without the modifiers. |
2515 | // Therefore, we need to modify mCharCode value here. |
2516 | aKeyEvent.SetCharCode(charCode); |
2517 | |
2518 | gint level = GetKeyLevel(aGdkKeyEvent); |
2519 | if (level != 0 && level != 1) { |
2520 | MOZ_LOG(gKeyLog, LogLevel::Info,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p WillDispatchKeyboardEventInternal, " "mKeyCode=0x%02X, mCharCode=0x%08X, level=%d" , this, aKeyEvent.mKeyCode, aKeyEvent.mCharCode, level); } } while (0) |
2521 | ("%p WillDispatchKeyboardEventInternal, "do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p WillDispatchKeyboardEventInternal, " "mKeyCode=0x%02X, mCharCode=0x%08X, level=%d" , this, aKeyEvent.mKeyCode, aKeyEvent.mCharCode, level); } } while (0) |
2522 | "mKeyCode=0x%02X, mCharCode=0x%08X, level=%d",do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p WillDispatchKeyboardEventInternal, " "mKeyCode=0x%02X, mCharCode=0x%08X, level=%d" , this, aKeyEvent.mKeyCode, aKeyEvent.mCharCode, level); } } while (0) |
2523 | this, aKeyEvent.mKeyCode, aKeyEvent.mCharCode, level))do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p WillDispatchKeyboardEventInternal, " "mKeyCode=0x%02X, mCharCode=0x%08X, level=%d" , this, aKeyEvent.mKeyCode, aKeyEvent.mCharCode, level); } } while (0); |
2524 | return; |
2525 | } |
2526 | |
2527 | guint baseState = aGdkKeyEvent->state & |
2528 | ~(GetGdkModifierMask(SHIFT) | GetGdkModifierMask(CTRL) | |
2529 | GetGdkModifierMask(ALT) | GetGdkModifierMask(META) | |
2530 | GetGdkModifierMask(SUPER) | GetGdkModifierMask(HYPER)); |
2531 | |
2532 | // We shold send both shifted char and unshifted char, all keyboard layout |
2533 | // users can use all keys. Don't change event.mCharCode. On some keyboard |
2534 | // layouts, Ctrl/Alt/Meta keys are used for inputting some characters. |
2535 | AlternativeCharCode altCharCodes(0, 0); |
2536 | // unshifted charcode of current keyboard layout. |
2537 | altCharCodes.mUnshiftedCharCode = |
2538 | GetCharCodeFor(aGdkKeyEvent, baseState, aGdkKeyEvent->group); |
2539 | bool isLatin = (altCharCodes.mUnshiftedCharCode <= 0xFF); |
2540 | // shifted charcode of current keyboard layout. |
2541 | altCharCodes.mShiftedCharCode = GetCharCodeFor( |
2542 | aGdkKeyEvent, baseState | GetGdkModifierMask(SHIFT), aGdkKeyEvent->group); |
2543 | isLatin = isLatin && (altCharCodes.mShiftedCharCode <= 0xFF); |
2544 | if (altCharCodes.mUnshiftedCharCode || altCharCodes.mShiftedCharCode) { |
2545 | aKeyEvent.mAlternativeCharCodes.AppendElement(altCharCodes); |
2546 | } |
2547 | |
2548 | bool needLatinKeyCodes = !isLatin; |
2549 | if (!needLatinKeyCodes) { |
2550 | needLatinKeyCodes = |
2551 | (IS_ASCII_ALPHABETICAL(altCharCodes.mUnshiftedCharCode)((('a' <= altCharCodes.mUnshiftedCharCode) && (altCharCodes .mUnshiftedCharCode <= 'z')) || (('A' <= altCharCodes.mUnshiftedCharCode ) && (altCharCodes.mUnshiftedCharCode <= 'Z'))) != |
2552 | IS_ASCII_ALPHABETICAL(altCharCodes.mShiftedCharCode)((('a' <= altCharCodes.mShiftedCharCode) && (altCharCodes .mShiftedCharCode <= 'z')) || (('A' <= altCharCodes.mShiftedCharCode ) && (altCharCodes.mShiftedCharCode <= 'Z')))); |
2553 | } |
2554 | |
2555 | // If current keyboard layout can input Latin characters, we don't need |
2556 | // more information. |
2557 | if (!needLatinKeyCodes) { |
2558 | MOZ_LOG(gKeyLog, LogLevel::Info,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p WillDispatchKeyboardEventInternal, " "mKeyCode=0x%02X, mCharCode=0x%08X, level=%d, altCharCodes={ " "mUnshiftedCharCode=0x%08X, mShiftedCharCode=0x%08X }", this , aKeyEvent.mKeyCode, aKeyEvent.mCharCode, level, altCharCodes .mUnshiftedCharCode, altCharCodes.mShiftedCharCode); } } while (0) |
2559 | ("%p WillDispatchKeyboardEventInternal, "do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p WillDispatchKeyboardEventInternal, " "mKeyCode=0x%02X, mCharCode=0x%08X, level=%d, altCharCodes={ " "mUnshiftedCharCode=0x%08X, mShiftedCharCode=0x%08X }", this , aKeyEvent.mKeyCode, aKeyEvent.mCharCode, level, altCharCodes .mUnshiftedCharCode, altCharCodes.mShiftedCharCode); } } while (0) |
2560 | "mKeyCode=0x%02X, mCharCode=0x%08X, level=%d, altCharCodes={ "do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p WillDispatchKeyboardEventInternal, " "mKeyCode=0x%02X, mCharCode=0x%08X, level=%d, altCharCodes={ " "mUnshiftedCharCode=0x%08X, mShiftedCharCode=0x%08X }", this , aKeyEvent.mKeyCode, aKeyEvent.mCharCode, level, altCharCodes .mUnshiftedCharCode, altCharCodes.mShiftedCharCode); } } while (0) |
2561 | "mUnshiftedCharCode=0x%08X, mShiftedCharCode=0x%08X }",do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p WillDispatchKeyboardEventInternal, " "mKeyCode=0x%02X, mCharCode=0x%08X, level=%d, altCharCodes={ " "mUnshiftedCharCode=0x%08X, mShiftedCharCode=0x%08X }", this , aKeyEvent.mKeyCode, aKeyEvent.mCharCode, level, altCharCodes .mUnshiftedCharCode, altCharCodes.mShiftedCharCode); } } while (0) |
2562 | this, aKeyEvent.mKeyCode, aKeyEvent.mCharCode, level,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p WillDispatchKeyboardEventInternal, " "mKeyCode=0x%02X, mCharCode=0x%08X, level=%d, altCharCodes={ " "mUnshiftedCharCode=0x%08X, mShiftedCharCode=0x%08X }", this , aKeyEvent.mKeyCode, aKeyEvent.mCharCode, level, altCharCodes .mUnshiftedCharCode, altCharCodes.mShiftedCharCode); } } while (0) |
2563 | altCharCodes.mUnshiftedCharCode, altCharCodes.mShiftedCharCode))do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p WillDispatchKeyboardEventInternal, " "mKeyCode=0x%02X, mCharCode=0x%08X, level=%d, altCharCodes={ " "mUnshiftedCharCode=0x%08X, mShiftedCharCode=0x%08X }", this , aKeyEvent.mKeyCode, aKeyEvent.mCharCode, level, altCharCodes .mUnshiftedCharCode, altCharCodes.mShiftedCharCode); } } while (0); |
2564 | return; |
2565 | } |
2566 | |
2567 | // Next, find Latin inputtable keyboard layout. |
2568 | gint minGroup = GetFirstLatinGroup(); |
2569 | if (minGroup < 0) { |
2570 | MOZ_LOG(gKeyLog, LogLevel::Info,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p WillDispatchKeyboardEventInternal, " "Latin keyboard layout isn't found: " "mKeyCode=0x%02X, mCharCode=0x%08X, level=%d, " "altCharCodes={ mUnshiftedCharCode=0x%08X, " "mShiftedCharCode=0x%08X }", this, aKeyEvent.mKeyCode, aKeyEvent .mCharCode, level, altCharCodes.mUnshiftedCharCode, altCharCodes .mShiftedCharCode); } } while (0) |
2571 | ("%p WillDispatchKeyboardEventInternal, "do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p WillDispatchKeyboardEventInternal, " "Latin keyboard layout isn't found: " "mKeyCode=0x%02X, mCharCode=0x%08X, level=%d, " "altCharCodes={ mUnshiftedCharCode=0x%08X, " "mShiftedCharCode=0x%08X }", this, aKeyEvent.mKeyCode, aKeyEvent .mCharCode, level, altCharCodes.mUnshiftedCharCode, altCharCodes .mShiftedCharCode); } } while (0) |
2572 | "Latin keyboard layout isn't found: "do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p WillDispatchKeyboardEventInternal, " "Latin keyboard layout isn't found: " "mKeyCode=0x%02X, mCharCode=0x%08X, level=%d, " "altCharCodes={ mUnshiftedCharCode=0x%08X, " "mShiftedCharCode=0x%08X }", this, aKeyEvent.mKeyCode, aKeyEvent .mCharCode, level, altCharCodes.mUnshiftedCharCode, altCharCodes .mShiftedCharCode); } } while (0) |
2573 | "mKeyCode=0x%02X, mCharCode=0x%08X, level=%d, "do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p WillDispatchKeyboardEventInternal, " "Latin keyboard layout isn't found: " "mKeyCode=0x%02X, mCharCode=0x%08X, level=%d, " "altCharCodes={ mUnshiftedCharCode=0x%08X, " "mShiftedCharCode=0x%08X }", this, aKeyEvent.mKeyCode, aKeyEvent .mCharCode, level, altCharCodes.mUnshiftedCharCode, altCharCodes .mShiftedCharCode); } } while (0) |
2574 | "altCharCodes={ mUnshiftedCharCode=0x%08X, "do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p WillDispatchKeyboardEventInternal, " "Latin keyboard layout isn't found: " "mKeyCode=0x%02X, mCharCode=0x%08X, level=%d, " "altCharCodes={ mUnshiftedCharCode=0x%08X, " "mShiftedCharCode=0x%08X }", this, aKeyEvent.mKeyCode, aKeyEvent .mCharCode, level, altCharCodes.mUnshiftedCharCode, altCharCodes .mShiftedCharCode); } } while (0) |
2575 | "mShiftedCharCode=0x%08X }",do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p WillDispatchKeyboardEventInternal, " "Latin keyboard layout isn't found: " "mKeyCode=0x%02X, mCharCode=0x%08X, level=%d, " "altCharCodes={ mUnshiftedCharCode=0x%08X, " "mShiftedCharCode=0x%08X }", this, aKeyEvent.mKeyCode, aKeyEvent .mCharCode, level, altCharCodes.mUnshiftedCharCode, altCharCodes .mShiftedCharCode); } } while (0) |
2576 | this, aKeyEvent.mKeyCode, aKeyEvent.mCharCode, level,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p WillDispatchKeyboardEventInternal, " "Latin keyboard layout isn't found: " "mKeyCode=0x%02X, mCharCode=0x%08X, level=%d, " "altCharCodes={ mUnshiftedCharCode=0x%08X, " "mShiftedCharCode=0x%08X }", this, aKeyEvent.mKeyCode, aKeyEvent .mCharCode, level, altCharCodes.mUnshiftedCharCode, altCharCodes .mShiftedCharCode); } } while (0) |
2577 | altCharCodes.mUnshiftedCharCode, altCharCodes.mShiftedCharCode))do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p WillDispatchKeyboardEventInternal, " "Latin keyboard layout isn't found: " "mKeyCode=0x%02X, mCharCode=0x%08X, level=%d, " "altCharCodes={ mUnshiftedCharCode=0x%08X, " "mShiftedCharCode=0x%08X }", this, aKeyEvent.mKeyCode, aKeyEvent .mCharCode, level, altCharCodes.mUnshiftedCharCode, altCharCodes .mShiftedCharCode); } } while (0); |
2578 | return; |
2579 | } |
2580 | |
2581 | AlternativeCharCode altLatinCharCodes(0, 0); |
2582 | uint32_t unmodifiedCh = aKeyEvent.IsShift() ? altCharCodes.mShiftedCharCode |
2583 | : altCharCodes.mUnshiftedCharCode; |
2584 | |
2585 | // unshifted charcode of found keyboard layout. |
2586 | uint32_t ch = GetCharCodeFor(aGdkKeyEvent, baseState, minGroup); |
2587 | altLatinCharCodes.mUnshiftedCharCode = |
2588 | IsBasicLatinLetterOrNumeral(ch) ? ch : 0; |
2589 | // shifted charcode of found keyboard layout. |
2590 | ch = GetCharCodeFor(aGdkKeyEvent, baseState | GetGdkModifierMask(SHIFT), |
2591 | minGroup); |
2592 | altLatinCharCodes.mShiftedCharCode = IsBasicLatinLetterOrNumeral(ch) ? ch : 0; |
2593 | if (altLatinCharCodes.mUnshiftedCharCode || |
2594 | altLatinCharCodes.mShiftedCharCode) { |
2595 | aKeyEvent.mAlternativeCharCodes.AppendElement(altLatinCharCodes); |
2596 | } |
2597 | // If the mCharCode is not Latin, and the level is 0 or 1, we should |
2598 | // replace the mCharCode to Latin char if Alt keys are not pressed. (Alt |
2599 | // should be sent the localized char for accesskey like handling of Web |
2600 | // Applications.) |
2601 | ch = aKeyEvent.IsShift() ? altLatinCharCodes.mShiftedCharCode |
2602 | : altLatinCharCodes.mUnshiftedCharCode; |
2603 | if (ch && !aKeyEvent.IsAlt() && charCode == unmodifiedCh) { |
2604 | aKeyEvent.SetCharCode(ch); |
2605 | } |
2606 | |
2607 | MOZ_LOG(gKeyLog, LogLevel::Info,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p WillDispatchKeyboardEventInternal, " "mKeyCode=0x%02X, mCharCode=0x%08X, level=%d, minGroup=%d, " "altCharCodes={ mUnshiftedCharCode=0x%08X, " "mShiftedCharCode=0x%08X } " "altLatinCharCodes={ mUnshiftedCharCode=0x%08X, " "mShiftedCharCode=0x%08X }" , this, aKeyEvent.mKeyCode, aKeyEvent.mCharCode, level, minGroup , altCharCodes.mUnshiftedCharCode, altCharCodes.mShiftedCharCode , altLatinCharCodes.mUnshiftedCharCode, altLatinCharCodes.mShiftedCharCode ); } } while (0) |
2608 | ("%p WillDispatchKeyboardEventInternal, "do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p WillDispatchKeyboardEventInternal, " "mKeyCode=0x%02X, mCharCode=0x%08X, level=%d, minGroup=%d, " "altCharCodes={ mUnshiftedCharCode=0x%08X, " "mShiftedCharCode=0x%08X } " "altLatinCharCodes={ mUnshiftedCharCode=0x%08X, " "mShiftedCharCode=0x%08X }" , this, aKeyEvent.mKeyCode, aKeyEvent.mCharCode, level, minGroup , altCharCodes.mUnshiftedCharCode, altCharCodes.mShiftedCharCode , altLatinCharCodes.mUnshiftedCharCode, altLatinCharCodes.mShiftedCharCode ); } } while (0) |
2609 | "mKeyCode=0x%02X, mCharCode=0x%08X, level=%d, minGroup=%d, "do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p WillDispatchKeyboardEventInternal, " "mKeyCode=0x%02X, mCharCode=0x%08X, level=%d, minGroup=%d, " "altCharCodes={ mUnshiftedCharCode=0x%08X, " "mShiftedCharCode=0x%08X } " "altLatinCharCodes={ mUnshiftedCharCode=0x%08X, " "mShiftedCharCode=0x%08X }" , this, aKeyEvent.mKeyCode, aKeyEvent.mCharCode, level, minGroup , altCharCodes.mUnshiftedCharCode, altCharCodes.mShiftedCharCode , altLatinCharCodes.mUnshiftedCharCode, altLatinCharCodes.mShiftedCharCode ); } } while (0) |
2610 | "altCharCodes={ mUnshiftedCharCode=0x%08X, "do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p WillDispatchKeyboardEventInternal, " "mKeyCode=0x%02X, mCharCode=0x%08X, level=%d, minGroup=%d, " "altCharCodes={ mUnshiftedCharCode=0x%08X, " "mShiftedCharCode=0x%08X } " "altLatinCharCodes={ mUnshiftedCharCode=0x%08X, " "mShiftedCharCode=0x%08X }" , this, aKeyEvent.mKeyCode, aKeyEvent.mCharCode, level, minGroup , altCharCodes.mUnshiftedCharCode, altCharCodes.mShiftedCharCode , altLatinCharCodes.mUnshiftedCharCode, altLatinCharCodes.mShiftedCharCode ); } } while (0) |
2611 | "mShiftedCharCode=0x%08X } "do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p WillDispatchKeyboardEventInternal, " "mKeyCode=0x%02X, mCharCode=0x%08X, level=%d, minGroup=%d, " "altCharCodes={ mUnshiftedCharCode=0x%08X, " "mShiftedCharCode=0x%08X } " "altLatinCharCodes={ mUnshiftedCharCode=0x%08X, " "mShiftedCharCode=0x%08X }" , this, aKeyEvent.mKeyCode, aKeyEvent.mCharCode, level, minGroup , altCharCodes.mUnshiftedCharCode, altCharCodes.mShiftedCharCode , altLatinCharCodes.mUnshiftedCharCode, altLatinCharCodes.mShiftedCharCode ); } } while (0) |
2612 | "altLatinCharCodes={ mUnshiftedCharCode=0x%08X, "do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p WillDispatchKeyboardEventInternal, " "mKeyCode=0x%02X, mCharCode=0x%08X, level=%d, minGroup=%d, " "altCharCodes={ mUnshiftedCharCode=0x%08X, " "mShiftedCharCode=0x%08X } " "altLatinCharCodes={ mUnshiftedCharCode=0x%08X, " "mShiftedCharCode=0x%08X }" , this, aKeyEvent.mKeyCode, aKeyEvent.mCharCode, level, minGroup , altCharCodes.mUnshiftedCharCode, altCharCodes.mShiftedCharCode , altLatinCharCodes.mUnshiftedCharCode, altLatinCharCodes.mShiftedCharCode ); } } while (0) |
2613 | "mShiftedCharCode=0x%08X }",do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p WillDispatchKeyboardEventInternal, " "mKeyCode=0x%02X, mCharCode=0x%08X, level=%d, minGroup=%d, " "altCharCodes={ mUnshiftedCharCode=0x%08X, " "mShiftedCharCode=0x%08X } " "altLatinCharCodes={ mUnshiftedCharCode=0x%08X, " "mShiftedCharCode=0x%08X }" , this, aKeyEvent.mKeyCode, aKeyEvent.mCharCode, level, minGroup , altCharCodes.mUnshiftedCharCode, altCharCodes.mShiftedCharCode , altLatinCharCodes.mUnshiftedCharCode, altLatinCharCodes.mShiftedCharCode ); } } while (0) |
2614 | this, aKeyEvent.mKeyCode, aKeyEvent.mCharCode, level, minGroup,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p WillDispatchKeyboardEventInternal, " "mKeyCode=0x%02X, mCharCode=0x%08X, level=%d, minGroup=%d, " "altCharCodes={ mUnshiftedCharCode=0x%08X, " "mShiftedCharCode=0x%08X } " "altLatinCharCodes={ mUnshiftedCharCode=0x%08X, " "mShiftedCharCode=0x%08X }" , this, aKeyEvent.mKeyCode, aKeyEvent.mCharCode, level, minGroup , altCharCodes.mUnshiftedCharCode, altCharCodes.mShiftedCharCode , altLatinCharCodes.mUnshiftedCharCode, altLatinCharCodes.mShiftedCharCode ); } } while (0) |
2615 | altCharCodes.mUnshiftedCharCode, altCharCodes.mShiftedCharCode,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p WillDispatchKeyboardEventInternal, " "mKeyCode=0x%02X, mCharCode=0x%08X, level=%d, minGroup=%d, " "altCharCodes={ mUnshiftedCharCode=0x%08X, " "mShiftedCharCode=0x%08X } " "altLatinCharCodes={ mUnshiftedCharCode=0x%08X, " "mShiftedCharCode=0x%08X }" , this, aKeyEvent.mKeyCode, aKeyEvent.mCharCode, level, minGroup , altCharCodes.mUnshiftedCharCode, altCharCodes.mShiftedCharCode , altLatinCharCodes.mUnshiftedCharCode, altLatinCharCodes.mShiftedCharCode ); } } while (0) |
2616 | altLatinCharCodes.mUnshiftedCharCode,do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p WillDispatchKeyboardEventInternal, " "mKeyCode=0x%02X, mCharCode=0x%08X, level=%d, minGroup=%d, " "altCharCodes={ mUnshiftedCharCode=0x%08X, " "mShiftedCharCode=0x%08X } " "altLatinCharCodes={ mUnshiftedCharCode=0x%08X, " "mShiftedCharCode=0x%08X }" , this, aKeyEvent.mKeyCode, aKeyEvent.mCharCode, level, minGroup , altCharCodes.mUnshiftedCharCode, altCharCodes.mShiftedCharCode , altLatinCharCodes.mUnshiftedCharCode, altLatinCharCodes.mShiftedCharCode ); } } while (0) |
2617 | altLatinCharCodes.mShiftedCharCode))do { const ::mozilla::LogModule* moz_real_module = gKeyLog; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Info)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Info, "%p WillDispatchKeyboardEventInternal, " "mKeyCode=0x%02X, mCharCode=0x%08X, level=%d, minGroup=%d, " "altCharCodes={ mUnshiftedCharCode=0x%08X, " "mShiftedCharCode=0x%08X } " "altLatinCharCodes={ mUnshiftedCharCode=0x%08X, " "mShiftedCharCode=0x%08X }" , this, aKeyEvent.mKeyCode, aKeyEvent.mCharCode, level, minGroup , altCharCodes.mUnshiftedCharCode, altCharCodes.mShiftedCharCode , altLatinCharCodes.mUnshiftedCharCode, altLatinCharCodes.mShiftedCharCode ); } } while (0); |
2618 | } |
2619 | |
2620 | #ifdef MOZ_WAYLAND1 |
2621 | void KeymapWrapper::SetFocusIn(wl_surface* aFocusSurface, |
2622 | uint32_t aFocusSerial) { |
2623 | LOGW("KeymapWrapper::SetFocusIn() surface %p ID %d serial %d", aFocusSurface,do { const ::mozilla::LogModule* moz_real_module = gWidgetLog ; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , mozilla::LogLevel::Debug)), 0))) { mozilla::detail::log_print (moz_real_module, mozilla::LogLevel::Debug, "KeymapWrapper::SetFocusIn() surface %p ID %d serial %d" , aFocusSurface, aFocusSurface ? wl_proxy_get_id((struct wl_proxy *)aFocusSurface) : 0, aFocusSerial); } } while (0) |
2624 | aFocusSurface ? wl_proxy_get_id((struct wl_proxy*)aFocusSurface) : 0,do { const ::mozilla::LogModule* moz_real_module = gWidgetLog ; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , mozilla::LogLevel::Debug)), 0))) { mozilla::detail::log_print (moz_real_module, mozilla::LogLevel::Debug, "KeymapWrapper::SetFocusIn() surface %p ID %d serial %d" , aFocusSurface, aFocusSurface ? wl_proxy_get_id((struct wl_proxy *)aFocusSurface) : 0, aFocusSerial); } } while (0) |
2625 | aFocusSerial)do { const ::mozilla::LogModule* moz_real_module = gWidgetLog ; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , mozilla::LogLevel::Debug)), 0))) { mozilla::detail::log_print (moz_real_module, mozilla::LogLevel::Debug, "KeymapWrapper::SetFocusIn() surface %p ID %d serial %d" , aFocusSurface, aFocusSurface ? wl_proxy_get_id((struct wl_proxy *)aFocusSurface) : 0, aFocusSerial); } } while (0); |
2626 | |
2627 | KeymapWrapper* keymapWrapper = KeymapWrapper::GetInstance(); |
2628 | keymapWrapper->mFocusSurface = aFocusSurface; |
2629 | keymapWrapper->mFocusSerial = aFocusSerial; |
2630 | } |
2631 | |
2632 | // aFocusSurface can be null in case that focused surface is already destroyed. |
2633 | void KeymapWrapper::SetFocusOut(wl_surface* aFocusSurface) { |
2634 | KeymapWrapper* keymapWrapper = KeymapWrapper::GetInstance(); |
2635 | LOGW("KeymapWrapper::SetFocusOut surface %p ID %d", aFocusSurface,do { const ::mozilla::LogModule* moz_real_module = gWidgetLog ; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , mozilla::LogLevel::Debug)), 0))) { mozilla::detail::log_print (moz_real_module, mozilla::LogLevel::Debug, "KeymapWrapper::SetFocusOut surface %p ID %d" , aFocusSurface, aFocusSurface ? wl_proxy_get_id((struct wl_proxy *)aFocusSurface) : 0); } } while (0) |
2636 | aFocusSurface ? wl_proxy_get_id((struct wl_proxy*)aFocusSurface) : 0)do { const ::mozilla::LogModule* moz_real_module = gWidgetLog ; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , mozilla::LogLevel::Debug)), 0))) { mozilla::detail::log_print (moz_real_module, mozilla::LogLevel::Debug, "KeymapWrapper::SetFocusOut surface %p ID %d" , aFocusSurface, aFocusSurface ? wl_proxy_get_id((struct wl_proxy *)aFocusSurface) : 0); } } while (0); |
2637 | |
2638 | keymapWrapper->mFocusSurface = nullptr; |
2639 | keymapWrapper->mFocusSerial = 0; |
2640 | } |
2641 | |
2642 | void KeymapWrapper::GetFocusInfo(wl_surface** aFocusSurface, |
2643 | uint32_t* aFocusSerial) { |
2644 | KeymapWrapper* keymapWrapper = KeymapWrapper::GetInstance(); |
2645 | *aFocusSurface = keymapWrapper->mFocusSurface; |
2646 | *aFocusSerial = keymapWrapper->mFocusSerial; |
2647 | } |
2648 | #endif |
2649 | |
2650 | } // namespace widget |
2651 | } // namespace mozilla |