Bug 447757 part.4 Clean up modifier keycode mapping on GTK r=karlt, sr=smaug
authorMasayuki Nakano <masayuki@d-toybox.com>
Thu, 17 May 2012 16:04:16 +0900
changeset 94214 c9ce0e49040a3f005d865d6ffa7ccce8afcdc423
parent 94213 d94270b8449f5bf59f6ff04cff32b14f581f636e
child 94215 12f13acb5ea84c633b07153f09ccd8a27561d130
push id22702
push userryanvm@gmail.com
push dateThu, 17 May 2012 18:02:05 +0000
treeherdermozilla-central@895e12563245 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskarlt, smaug
bugs447757
milestone15.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 447757 part.4 Clean up modifier keycode mapping on GTK r=karlt, sr=smaug
content/events/public/nsVKList.h
dom/interfaces/events/nsIDOMKeyEvent.idl
widget/gtk2/nsGtkKeyUtils.cpp
--- a/content/events/public/nsVKList.h
+++ b/content/events/public/nsVKList.h
@@ -179,12 +179,13 @@ DEFINE_VK_INTERNAL(_COMMA),
 DEFINE_VK_INTERNAL(_PERIOD),
 DEFINE_VK_INTERNAL(_SLASH),
 DEFINE_VK_INTERNAL(_BACK_QUOTE),
 DEFINE_VK_INTERNAL(_OPEN_BRACKET),
 DEFINE_VK_INTERNAL(_BACK_SLASH),
 DEFINE_VK_INTERNAL(_CLOSE_BRACKET),
 DEFINE_VK_INTERNAL(_QUOTE),
 
-DEFINE_VK_INTERNAL(_META)
+DEFINE_VK_INTERNAL(_META),
+DEFINE_VK_INTERNAL(_ALTGR)
 
 #undef DEFINE_VK_INTERNAL
 #undef DEFINE_VK_INTERNAL2
--- a/dom/interfaces/events/nsIDOMKeyEvent.idl
+++ b/dom/interfaces/events/nsIDOMKeyEvent.idl
@@ -205,16 +205,17 @@ interface nsIDOMKeyEvent : nsIDOMUIEvent
   const unsigned long DOM_VK_SLASH          = 0xBF;
   const unsigned long DOM_VK_BACK_QUOTE     = 0xC0;
   const unsigned long DOM_VK_OPEN_BRACKET   = 0xDB; // square bracket
   const unsigned long DOM_VK_BACK_SLASH     = 0xDC;
   const unsigned long DOM_VK_CLOSE_BRACKET  = 0xDD; // square bracket
   const unsigned long DOM_VK_QUOTE          = 0xDE; // Apostrophe
 
   const unsigned long DOM_VK_META           = 0xE0;
+  const unsigned long DOM_VK_ALTGR          = 0xE1;
 
   readonly attribute unsigned long    charCode;
   readonly attribute unsigned long    keyCode;
 
   readonly attribute boolean          altKey;
   readonly attribute boolean          ctrlKey;
   readonly attribute boolean          shiftKey;
   readonly attribute boolean          metaKey;
--- a/widget/gtk2/nsGtkKeyUtils.cpp
+++ b/widget/gtk2/nsGtkKeyUtils.cpp
@@ -84,18 +84,41 @@ static const KeyPair kKeyPairs[] = {
     { NS_VK_CLEAR,      GDK_Clear },
     { NS_VK_RETURN,     GDK_Return },
     { NS_VK_SHIFT,      GDK_Shift_L },
     { NS_VK_SHIFT,      GDK_Shift_R },
     { NS_VK_CONTROL,    GDK_Control_L },
     { NS_VK_CONTROL,    GDK_Control_R },
     { NS_VK_ALT,        GDK_Alt_L },
     { NS_VK_ALT,        GDK_Alt_R },
-    { NS_VK_META,       GDK_Meta_L },
-    { NS_VK_META,       GDK_Meta_R },
+
+    // NS_VK_META is used for Command key of Mac.  It's a modifier key for
+    // shortcut keys like Ctrl key on GTK or Windows.  So, it's really different
+    // from GTK's META key, we shouldn't use it on GTK.
+    // { NS_VK_META,       GDK_Meta_L },
+    // { NS_VK_META,       GDK_Meta_R },
+
+    // Assume that Super or Hyper is always mapped to physical Win key.
+    { NS_VK_WIN,        GDK_Super_L },
+    { NS_VK_WIN,        GDK_Super_R },
+    { NS_VK_WIN,        GDK_Hyper_L },
+    { NS_VK_WIN,        GDK_Hyper_R },
+
+    // GTK's AltGraph key is similar to Mac's Option (Alt) key.  However,
+    // unfortunately, browsers on Mac are using NS_VK_ALT for it even though
+    // it's really different from Alt key on Windows.
+    // On the other hand, GTK's AltGrapsh keys are really different from
+    // Alt key.  However, there is no AltGrapsh key on Windows.  On Windows,
+    // both Ctrl and Alt keys are pressed internally when AltGr key is pressed.
+    // For some languages' users, AltGraph key is important, so, web
+    // applications on such locale may want to know AltGraph key press.
+    // Therefore, we should map AltGr keycode for them only on GTK.
+    { NS_VK_ALTGR,      GDK_ISO_Level3_Shift },
+    { NS_VK_ALTGR,      GDK_Mode_switch },
+
     { NS_VK_PAUSE,      GDK_Pause },
     { NS_VK_CAPS_LOCK,  GDK_Caps_Lock },
     { NS_VK_KANA,       GDK_Kana_Lock },
     { NS_VK_KANA,       GDK_Kana_Shift },
     { NS_VK_HANGUL,     GDK_Hangul },
     // { NS_VK_JUNJA,      GDK_XXX },
     // { NS_VK_FINAL,      GDK_XXX },
     { NS_VK_HANJA,      GDK_Hangul_Hanja },
@@ -1256,18 +1279,19 @@ KeymapWrapper::InitKeypressEvent(nsKeyEv
 
 /* static */ bool
 KeymapWrapper::IsKeyPressEventNecessary(GdkEventKey* aGdkKeyEvent)
 {
     // If this is a modifier key event, we shouldn't send keypress event.
     switch (ComputeDOMKeyCode(aGdkKeyEvent)) {
         case NS_VK_SHIFT:
         case NS_VK_CONTROL:
-        case NS_VK_META:
         case NS_VK_ALT:
+        case NS_VK_ALTGR:
+        case NS_VK_WIN:
         case NS_VK_CAPS_LOCK:
         case NS_VK_NUM_LOCK:
         case NS_VK_SCROLL_LOCK:
             return false;
         default:
             return true;
     }
 }