summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-19 20:27:07 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-19 20:27:07 +0000
commita8a1992ce36c243c05cd649558e6da6f6d61f3b6 (patch)
treec1534730f8ba522640756ffa4269075a1cf78ce6
parent750c2e814d92771b254d39305fb8593fcf238585 (diff)
downloadchromium_src-a8a1992ce36c243c05cd649558e6da6f6d61f3b6.zip
chromium_src-a8a1992ce36c243c05cd649558e6da6f6d61f3b6.tar.gz
chromium_src-a8a1992ce36c243c05cd649558e6da6f6d61f3b6.tar.bz2
Get KeyEvents to limp in Aura. This assumes the desktop host is going to send two aura::KeyEvents for every keydown - one raw key down, and one char. They share the same ET, but the first has is_char = false, the second is_char = true.
http://crbug.com/99757 TEST=none Review URL: http://codereview.chromium.org/8342026 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@106374 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--content/browser/renderer_host/web_input_event_aura.cc17
-rw-r--r--content/browser/renderer_host/web_input_event_aurax11.cc8
-rw-r--r--ui/aura/desktop_host_linux.cc12
-rw-r--r--ui/aura/desktop_host_win.cc2
-rw-r--r--ui/aura/desktop_host_win.h3
-rw-r--r--ui/aura/event.cc8
-rw-r--r--ui/aura/event.h6
-rw-r--r--views/widget/native_widget_aura.cc5
8 files changed, 49 insertions, 12 deletions
diff --git a/content/browser/renderer_host/web_input_event_aura.cc b/content/browser/renderer_host/web_input_event_aura.cc
index bbadb7c..a677b0c 100644
--- a/content/browser/renderer_host/web_input_event_aura.cc
+++ b/content/browser/renderer_host/web_input_event_aura.cc
@@ -8,11 +8,16 @@
namespace content {
+#if defined(OS_WIN)
WebKit::WebMouseEvent MakeUntranslatedWebMouseEventFromNativeEvent(
base::NativeEvent native_event);
-WebKit::WebMouseEvent MakeWebMouseEventFromAuraEvent(aura::MouseEvent* event);
WebKit::WebKeyboardEvent MakeWebKeyboardEventFromNativeEvent(
base::NativeEvent native_event);
+#else
+WebKit::WebMouseEvent MakeWebMouseEventFromAuraEvent(aura::MouseEvent* event);
+WebKit::WebKeyboardEvent MakeWebKeyboardEventFromAuraEvent(
+ aura::KeyEvent* event);
+#endif
// General approach:
//
@@ -59,8 +64,18 @@ WebKit::WebMouseEvent MakeWebMouseEvent(aura::MouseEvent* event) {
}
WebKit::WebKeyboardEvent MakeWebKeyboardEvent(aura::KeyEvent* event) {
+ // Windows can figure out whether or not to construct a RawKeyDown or a Char
+ // WebInputEvent based on the type of message carried in
+ // event->native_event(). X11 is not so fortunate, there is no separate
+ // translated event type, so DesktopHostLinux sends an extra KeyEvent with
+ // is_char() == true. We need to pass the aura::KeyEvent to the X11 function
+ // to detect this case so the right event type can be constructed.
+#if defined(OS_WIN)
// Key events require no translation by the aura system.
return MakeWebKeyboardEventFromNativeEvent(event->native_event());
+#else
+ return MakeWebKeyboardEventFromAuraEvent(event);
+#endif
}
} // namespace content
diff --git a/content/browser/renderer_host/web_input_event_aurax11.cc b/content/browser/renderer_host/web_input_event_aurax11.cc
index c361b2b..2b54343 100644
--- a/content/browser/renderer_host/web_input_event_aurax11.cc
+++ b/content/browser/renderer_host/web_input_event_aurax11.cc
@@ -251,8 +251,9 @@ WebKit::WebMouseEvent MakeWebMouseEventFromAuraEvent(aura::MouseEvent* event) {
return webkit_event;
}
-WebKit::WebKeyboardEvent MakeWebKeyboardEventFromNativeEvent(
- base::NativeEvent native_event) {
+WebKit::WebKeyboardEvent MakeWebKeyboardEventFromAuraEvent(
+ aura::KeyEvent* event) {
+ base::NativeEvent native_event = event->native_event();
WebKit::WebKeyboardEvent webkit_event;
XKeyEvent* native_key_event = &native_event->xkey;
@@ -262,7 +263,8 @@ WebKit::WebKeyboardEvent MakeWebKeyboardEventFromNativeEvent(
switch (native_event->type) {
case KeyPress:
- webkit_event.type = WebKit::WebInputEvent::RawKeyDown;
+ webkit_event.type = event->is_char() ? WebKit::WebInputEvent::Char :
+ WebKit::WebInputEvent::RawKeyDown;
break;
case KeyRelease:
webkit_event.type = WebKit::WebInputEvent::KeyUp;
diff --git a/ui/aura/desktop_host_linux.cc b/ui/aura/desktop_host_linux.cc
index e09e5fc..9609167 100644
--- a/ui/aura/desktop_host_linux.cc
+++ b/ui/aura/desktop_host_linux.cc
@@ -185,10 +185,16 @@ base::MessagePumpDispatcher::DispatchStatus DesktopHostLinux::Dispatch(
desktop_->Draw();
handled = true;
break;
- case KeyPress:
+ case KeyPress: {
+ KeyEvent keydown_event(xev, false);
+ handled = desktop_->OnKeyEvent(keydown_event);
+ KeyEvent char_event(xev, true);
+ handled |= desktop_->OnKeyEvent(char_event);
+ break;
+ }
case KeyRelease: {
- KeyEvent keyev(xev);
- handled = desktop_->OnKeyEvent(keyev);
+ KeyEvent keyup_event(xev, false);
+ handled = desktop_->OnKeyEvent(keyup_event);
break;
}
case ButtonPress:
diff --git a/ui/aura/desktop_host_win.cc b/ui/aura/desktop_host_win.cc
index 2a3e64a..0c8f234 100644
--- a/ui/aura/desktop_host_win.cc
+++ b/ui/aura/desktop_host_win.cc
@@ -177,7 +177,7 @@ LRESULT DesktopHostWin::OnKeyEvent(UINT message,
WPARAM w_param,
LPARAM l_param) {
MSG msg = { hwnd(), message, w_param, l_param };
- SetMsgHandled(desktop_->OnKeyEvent(KeyEvent(msg)));
+ SetMsgHandled(desktop_->OnKeyEvent(KeyEvent(msg, message == WM_CHAR)));
return 0;
}
diff --git a/ui/aura/desktop_host_win.h b/ui/aura/desktop_host_win.h
index ed66d3b..94bc39c 100644
--- a/ui/aura/desktop_host_win.h
+++ b/ui/aura/desktop_host_win.h
@@ -40,6 +40,9 @@ class DesktopHostWin : public DesktopHost, public ui::WindowImpl {
MESSAGE_HANDLER_EX(WM_KEYUP, OnKeyEvent)
MESSAGE_HANDLER_EX(WM_SYSKEYDOWN, OnKeyEvent)
MESSAGE_HANDLER_EX(WM_SYSKEYUP, OnKeyEvent)
+ MESSAGE_HANDLER_EX(WM_CHAR, OnKeyEvent)
+ MESSAGE_HANDLER_EX(WM_SYSCHAR, OnKeyEvent)
+ MESSAGE_HANDLER_EX(WM_IME_CHAR, OnKeyEvent)
MSG_WM_CLOSE(OnClose)
MSG_WM_PAINT(OnPaint)
diff --git a/ui/aura/event.cc b/ui/aura/event.cc
index 1ba9119..08940eb 100644
--- a/ui/aura/event.cc
+++ b/ui/aura/event.cc
@@ -115,18 +115,20 @@ TouchEvent::TouchEvent(ui::EventType type,
force_(0.0f) {
}
-KeyEvent::KeyEvent(const base::NativeEvent& native_event)
+KeyEvent::KeyEvent(const base::NativeEvent& native_event, bool is_char)
: Event(native_event,
ui::EventTypeFromNative(native_event),
ui::EventFlagsFromNative(native_event)),
- key_code_(ui::KeyboardCodeFromNative(native_event)) {
+ key_code_(ui::KeyboardCodeFromNative(native_event)),
+ is_char_(is_char) {
}
KeyEvent::KeyEvent(ui::EventType type,
ui::KeyboardCode key_code,
int flags)
: Event(type, flags),
- key_code_(key_code) {
+ key_code_(key_code),
+ is_char_(false) {
}
} // namespace aura
diff --git a/ui/aura/event.h b/ui/aura/event.h
index 481728d..9673d0f 100644
--- a/ui/aura/event.h
+++ b/ui/aura/event.h
@@ -127,7 +127,7 @@ class AURA_EXPORT TouchEvent : public LocatedEvent {
class AURA_EXPORT KeyEvent : public Event {
public:
- explicit KeyEvent(const base::NativeEvent& native_event);
+ KeyEvent(const base::NativeEvent& native_event, bool is_char);
// Used for synthetic events in testing.
KeyEvent(ui::EventType type,
@@ -135,9 +135,13 @@ class AURA_EXPORT KeyEvent : public Event {
int flags);
ui::KeyboardCode key_code() const { return key_code_; }
+ bool is_char() const { return is_char_; }
private:
ui::KeyboardCode key_code_;
+ // True if this is a translated character event (vs. a raw key down). Both
+ // share the same type: ui::ET_KEY_PRESSED.
+ bool is_char_;
};
} // namespace aura
diff --git a/views/widget/native_widget_aura.cc b/views/widget/native_widget_aura.cc
index ac3d781..25a74ae 100644
--- a/views/widget/native_widget_aura.cc
+++ b/views/widget/native_widget_aura.cc
@@ -495,6 +495,11 @@ void NativeWidgetAura::OnBlur() {
}
bool NativeWidgetAura::OnKeyEvent(aura::KeyEvent* event) {
+ // TODO(beng): Need an InputMethodAura to properly handle character events.
+ // Right now, we just skip these.
+ if (event->is_char())
+ return false;
+
DCHECK(window_->IsVisible());
InputMethod* input_method = GetWidget()->GetInputMethod();
DCHECK(input_method);