From 80af01d2ff57ea6a1a69723e96581a56496a597c Mon Sep 17 00:00:00 2001 From: Michael Wu Date: Tue, 13 Dec 2011 10:51:25 -0800 Subject: [PATCH] Bug 706599 - Handle no default in gonk key dispatching, r=jlebar a=gonk-only --- widget/src/gonk/nsAppShell.cpp | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/widget/src/gonk/nsAppShell.cpp b/widget/src/gonk/nsAppShell.cpp index 407ee46c392..943fa65119b 100644 --- a/widget/src/gonk/nsAppShell.cpp +++ b/widget/src/gonk/nsAppShell.cpp @@ -217,27 +217,33 @@ multitouchHandler(int fd, FdHandler *data) } } -static void -sendKeyEventWithMsg(PRUint32 keyCode, PRUint32 msg, const struct timeval &time) +static nsEventStatus +sendKeyEventWithMsg(PRUint32 keyCode, + PRUint32 msg, + const timeval &time, + PRUint32 flags) { nsKeyEvent event(true, msg, NULL); event.keyCode = keyCode; event.time = timevalToMS(time); - nsWindow::DispatchInputEvent(event); + event.flags |= flags; + return nsWindow::DispatchInputEvent(event); } static void -sendKeyEvent(PRUint32 keyCode, bool keyDown, const struct timeval &time) +sendKeyEvent(PRUint32 keyCode, bool down, const timeval &time) { - sendKeyEventWithMsg(keyCode, keyDown ? NS_KEY_DOWN : NS_KEY_UP, time); - if (keyDown) { - // Send a key press event right after the key down event. - sendKeyEventWithMsg(keyCode, NS_KEY_PRESS, time); + nsEventStatus status = + sendKeyEventWithMsg(keyCode, down ? NS_KEY_DOWN : NS_KEY_UP, time, 0); + if (down) { + sendKeyEventWithMsg(keyCode, NS_KEY_PRESS, time, + status == nsEventStatus_eConsumeNoDefault ? + NS_EVENT_FLAG_NO_DEFAULT : 0); } } static void -sendSpecialKeyEvent(nsIAtom *command, const struct timeval &time) +sendSpecialKeyEvent(nsIAtom *command, const timeval &time) { nsCommandEvent event(true, nsGkAtoms::onAppCommand, command, NULL); event.time = timevalToMS(time);