Bug Summary

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