Bug Summary

File:root/firefox-clang/obj-x86_64-pc-linux-gnu/widget/gtk/./../../../widget/gtk/nsGtkKeyUtils.cpp
Warning:line 1662, column 5
Value stored to 'handlingState' is never read

Annotated Source Code

Press '?' to see keyboard shortcuts

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