Bug Summary

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