Bug 730848 - [Gonk] Generate key events instead of AppCommands for devices hw keys r=mwu
authorVivien Nicolas <21@vingtetun.org>
Thu, 01 Mar 2012 17:03:59 +0100
changeset 88096 41205fe435777a75a89b120a05fb12051c6dbd7f
parent 88095 21e7e8e9d75ab2ccf5d3104d6bec760a378596cb
child 88097 bef026927a580b819879b8c9e534df97061d150e
push id22171
push usermak77@bonardo.net
push dateFri, 02 Mar 2012 13:56:30 +0000
treeherdermozilla-central@343ec916dfd5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmwu
bugs730848
milestone13.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 730848 - [Gonk] Generate key events instead of AppCommands for devices hw keys r=mwu
widget/gonk/nsAppShell.cpp
--- a/widget/gonk/nsAppShell.cpp
+++ b/widget/gonk/nsAppShell.cpp
@@ -236,51 +236,39 @@ sendKeyEvent(PRUint32 keyCode, bool down
     if (down) {
         sendKeyEventWithMsg(keyCode, NS_KEY_PRESS, timeMs,
                             status == nsEventStatus_eConsumeNoDefault ?
                             NS_EVENT_FLAG_NO_DEFAULT : 0);
     }
 }
 
 static void
-sendSpecialKeyEvent(nsIAtom *command, uint64_t timeMs)
-{
-    nsCommandEvent event(true, nsGkAtoms::onAppCommand, command, NULL);
-    event.time = timeMs;
-    nsWindow::DispatchInputEvent(event);
-}
-
-static void
 maybeSendKeyEvent(int keyCode, bool pressed, uint64_t timeMs)
 {
     switch (keyCode) {
     case KEY_BACK:
         sendKeyEvent(NS_VK_ESCAPE, pressed, timeMs);
         break;
     case KEY_MENU:
-        if (!pressed)
-            sendSpecialKeyEvent(nsGkAtoms::Menu, timeMs);
+         sendKeyEvent(NS_VK_CONTEXT_MENU, pressed, timeMs);
         break;
     case KEY_SEARCH:
-        if (pressed)
-            sendSpecialKeyEvent(nsGkAtoms::Search, timeMs);
+        sendKeyEvent(NS_VK_F5, pressed, timeMs);
         break;
     case KEY_HOME:
         sendKeyEvent(NS_VK_HOME, pressed, timeMs);
         break;
     case KEY_POWER:
         sendKeyEvent(NS_VK_SLEEP, pressed, timeMs);
         break;
     case KEY_VOLUMEUP:
-        if (pressed)
-            sendSpecialKeyEvent(nsGkAtoms::VolumeUp, timeMs);
+        sendKeyEvent(NS_VK_PAGE_UP, pressed, timeMs);
         break;
     case KEY_VOLUMEDOWN:
-        if (pressed)
-            sendSpecialKeyEvent(nsGkAtoms::VolumeDown, timeMs);
+        sendKeyEvent(NS_VK_PAGE_DOWN, pressed, timeMs);
         break;
     default:
         VERBOSE_LOG("Got unknown key event code. type 0x%04x code 0x%04x value %d",
                     keyCode, pressed);
     }
 }
 
 class GeckoInputReaderPolicy : public InputReaderPolicyInterface {