Bug Summary

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