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