summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormsw@chromium.org <msw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-26 02:37:52 +0000
committermsw@chromium.org <msw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-26 02:37:52 +0000
commit331fdb258d70ff5d78b08006a8506691cca65432 (patch)
tree32cc4f80237c5e6492a01e938243aa6413f87baa
parent2f60f4aaaf70bbb5ee35a42ee216eed74e2ad3c2 (diff)
downloadchromium_src-331fdb258d70ff5d78b08006a8506691cca65432.zip
chromium_src-331fdb258d70ff5d78b08006a8506691cca65432.tar.gz
chromium_src-331fdb258d70ff5d78b08006a8506691cca65432.tar.bz2
Add NativeWidgetDelegate/Widget::OnKeyEvent post-IME handling.
Refactor XEvent code and InputMethodGtk::DispatchKeyEvent. Nix WidgetWin::GetFocusedViewRootView, rename RootView::OnKeyEvent. Cleanup headers and refactor code in extension_input_api.cc. Rename WidgetGtk::OnEventKey to avoid overloading Widget::OnEventKey. BUG=72040 TEST=Key event handling in win/linux_views/touch; extension input API SendKeyboardEventInputFunction use. Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=82713 Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=82751 Review URL: http://codereview.chromium.org/6823055 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@82983 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/chromeos/login/screen_locker.cc47
-rw-r--r--chrome/browser/extensions/extension_input_api.cc42
-rw-r--r--chrome/browser/extensions/extension_input_api.h6
-rw-r--r--views/focus/accelerator_handler_gtk.cc4
-rw-r--r--views/focus/accelerator_handler_touch.cc2
-rw-r--r--views/ime/input_method_gtk.cc72
-rw-r--r--views/widget/native_widget_delegate.h3
-rw-r--r--views/widget/root_view.cc2
-rw-r--r--views/widget/root_view.h4
-rw-r--r--views/widget/widget.cc4
-rw-r--r--views/widget/widget.h1
-rw-r--r--views/widget/widget_gtk.cc12
-rw-r--r--views/widget/widget_gtk.h2
-rw-r--r--views/widget/widget_win.cc19
-rw-r--r--views/widget/widget_win.h4
15 files changed, 87 insertions, 137 deletions
diff --git a/chrome/browser/chromeos/login/screen_locker.cc b/chrome/browser/chromeos/login/screen_locker.cc
index bb3c860..2e79b6f 100644
--- a/chrome/browser/chromeos/login/screen_locker.cc
+++ b/chrome/browser/chromeos/login/screen_locker.cc
@@ -82,7 +82,7 @@ class ScreenLockObserver : public chromeos::ScreenLockLibrary::Observer,
// NotificationObserver overrides:
virtual void Observe(NotificationType type,
const NotificationSource& source,
- const NotificationDetails& details) {
+ const NotificationDetails& details) OVERRIDE {
if (type == NotificationType::LOGIN_USER_CHANGED) {
// Register Screen Lock after login screen to make sure
// we don't show the screen lock on top of the login screen by accident.
@@ -91,18 +91,18 @@ class ScreenLockObserver : public chromeos::ScreenLockLibrary::Observer,
}
}
- virtual void LockScreen(chromeos::ScreenLockLibrary* obj) {
+ virtual void LockScreen(chromeos::ScreenLockLibrary* obj) OVERRIDE {
VLOG(1) << "In: ScreenLockObserver::LockScreen";
SetupInputMethodsForScreenLocker();
chromeos::ScreenLocker::Show();
}
- virtual void UnlockScreen(chromeos::ScreenLockLibrary* obj) {
+ virtual void UnlockScreen(chromeos::ScreenLockLibrary* obj) OVERRIDE {
RestoreInputMethods();
chromeos::ScreenLocker::Hide();
}
- virtual void UnlockScreenFailed(chromeos::ScreenLockLibrary* obj) {
+ virtual void UnlockScreenFailed(chromeos::ScreenLockLibrary* obj) OVERRIDE {
chromeos::ScreenLocker::UnlockScreenFailed();
}
@@ -206,17 +206,17 @@ class LockWindow : public views::WidgetGtk {
// GTK propagates key events from parents to children.
// Make sure LockWindow will never handle key events.
- virtual gboolean OnKeyEvent(GtkWidget* widget, GdkEventKey* event) {
+ virtual gboolean OnEventKey(GtkWidget* widget, GdkEventKey* event) OVERRIDE {
// Don't handle key event in the lock window.
return false;
}
- virtual void OnDestroy(GtkWidget* object) {
+ virtual void OnDestroy(GtkWidget* object) OVERRIDE {
VLOG(1) << "OnDestroy: LockWindow destroyed";
views::WidgetGtk::OnDestroy(object);
}
- virtual void ClearNativeFocus() {
+ virtual void ClearNativeFocus() OVERRIDE {
DCHECK(toplevel_focus_widget_);
gtk_widget_grab_focus(toplevel_focus_widget_);
}
@@ -254,14 +254,14 @@ class GrabWidgetRootView
}
// views::View implementation.
- virtual void Layout() {
+ virtual void Layout() OVERRIDE {
gfx::Size size = screen_lock_view_->GetPreferredSize();
screen_lock_view_->SetBounds(0, 0, size.width(), size.height());
shutdown_button_->LayoutIn(this);
}
// ScreenLocker::ScreenLockViewContainer implementation:
- void SetScreenLockView(views::View* screen_lock_view) {
+ void SetScreenLockView(views::View* screen_lock_view) OVERRIDE {
if (screen_lock_view_) {
RemoveChildView(screen_lock_view_);
}
@@ -294,7 +294,7 @@ class GrabWidget : public views::WidgetGtk {
shutdown_(NULL) {
}
- virtual void Show() {
+ virtual void Show() OVERRIDE {
views::WidgetGtk::Show();
signout_link_ =
screen_locker_->GetViewByID(VIEW_ID_SCREEN_LOCKER_SIGNOUT_LINK);
@@ -317,7 +317,7 @@ class GrabWidget : public views::WidgetGtk {
gtk_grab_remove(current_grab_window);
}
- virtual gboolean OnKeyEvent(GtkWidget* widget, GdkEventKey* event) {
+ virtual gboolean OnEventKey(GtkWidget* widget, GdkEventKey* event) OVERRIDE {
views::KeyEvent key_event(reinterpret_cast<GdkEvent*>(event));
// This is a hack to workaround the issue crosbug.com/10655 due to
// the limitation that a focus manager cannot handle views in
@@ -338,10 +338,11 @@ class GrabWidget : public views::WidgetGtk {
return true;
}
}
- return views::WidgetGtk::OnKeyEvent(widget, event);
+ return views::WidgetGtk::OnEventKey(widget, event);
}
- virtual gboolean OnButtonPress(GtkWidget* widget, GdkEventButton* event) {
+ virtual gboolean OnButtonPress(GtkWidget* widget,
+ GdkEventButton* event) OVERRIDE {
WidgetGtk::OnButtonPress(widget, event);
// Never propagate event to parent.
return true;
@@ -357,7 +358,7 @@ class GrabWidget : public views::WidgetGtk {
void TryUngrabOtherClients();
private:
- virtual void HandleGtkGrabBroke() {
+ virtual void HandleGtkGrabBroke() OVERRIDE {
// Input should never be stolen from ScreenLocker once it's
// grabbed. If this happens, it's a bug and has to be fixed. We
// let chrome crash to get a crash report and dump, and
@@ -483,11 +484,11 @@ class ScreenLockerBackgroundView
screen_lock_view_(screen_lock_view) {
}
- virtual ScreenMode GetScreenMode() const {
+ virtual ScreenMode GetScreenMode() const OVERRIDE {
return kScreenLockerMode;
}
- virtual void Layout() {
+ virtual void Layout() OVERRIDE {
chromeos::BackgroundView::Layout();
gfx::Rect screen = bounds();
if (screen_lock_view_) {
@@ -504,7 +505,7 @@ class ScreenLockerBackgroundView
}
// ScreenLocker::ScreenLockViewContainer implementation:
- void SetScreenLockView(views::View* screen_lock_view) {
+ virtual void SetScreenLockView(views::View* screen_lock_view) OVERRIDE {
screen_lock_view_ = screen_lock_view;
Layout();
}
@@ -536,9 +537,9 @@ class MouseEventRelay : public MessageLoopForUI::Observer {
DCHECK(dest_);
}
- virtual void WillProcessEvent(GdkEvent* event) {}
+ virtual void WillProcessEvent(GdkEvent* event) OVERRIDE {}
- virtual void DidProcessEvent(GdkEvent* event) {
+ virtual void DidProcessEvent(GdkEvent* event) OVERRIDE {
if (event->any.window != src_)
return;
if (!initialized_) {
@@ -595,7 +596,7 @@ class InputEventObserver : public MessageLoopForUI::Observer {
activated_(false) {
}
- virtual void WillProcessEvent(GdkEvent* event) {
+ virtual void WillProcessEvent(GdkEvent* event) OVERRIDE {
if ((event->type == GDK_KEY_PRESS ||
event->type == GDK_BUTTON_PRESS ||
event->type == GDK_MOTION_NOTIFY) &&
@@ -610,7 +611,7 @@ class InputEventObserver : public MessageLoopForUI::Observer {
}
}
- virtual void DidProcessEvent(GdkEvent* event) {
+ virtual void DidProcessEvent(GdkEvent* event) OVERRIDE {
}
private:
@@ -633,7 +634,7 @@ class LockerInputEventObserver : public MessageLoopForUI::Observer {
&LockerInputEventObserver::StartScreenSaver)) {
}
- virtual void WillProcessEvent(GdkEvent* event) {
+ virtual void WillProcessEvent(GdkEvent* event) OVERRIDE {
if ((event->type == GDK_KEY_PRESS ||
event->type == GDK_BUTTON_PRESS ||
event->type == GDK_MOTION_NOTIFY)) {
@@ -642,7 +643,7 @@ class LockerInputEventObserver : public MessageLoopForUI::Observer {
}
}
- virtual void DidProcessEvent(GdkEvent* event) {
+ virtual void DidProcessEvent(GdkEvent* event) OVERRIDE {
}
private:
diff --git a/chrome/browser/extensions/extension_input_api.cc b/chrome/browser/extensions/extension_input_api.cc
index b3b8473..ffcd659 100644
--- a/chrome/browser/extensions/extension_input_api.cc
+++ b/chrome/browser/extensions/extension_input_api.cc
@@ -8,17 +8,12 @@
#include "base/string_util.h"
#include "base/values.h"
-#include "chrome/browser/extensions/extension_tabs_module.h"
#include "chrome/browser/extensions/key_identifier_conversion_views.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
-#include "content/browser/renderer_host/render_view_host.h"
-#include "content/common/native_web_keyboard_event.h"
-#include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
#include "views/events/event.h"
#include "views/ime/input_method.h"
-#include "views/widget/root_view.h"
#include "views/widget/widget.h"
namespace {
@@ -56,7 +51,7 @@ void InputFunction::Run() {
SendResponse(RunImpl());
}
-views::RootView* SendKeyboardEventInputFunction::GetRootView() {
+views::Widget* SendKeyboardEventInputFunction::GetTopLevelWidget() {
Browser* browser = GetCurrentBrowser();
if (!browser)
return NULL;
@@ -67,10 +62,7 @@ views::RootView* SendKeyboardEventInputFunction::GetRootView() {
BrowserView* browser_view = BrowserView::GetBrowserViewForNativeWindow(
window->GetNativeHandle());
- if (!browser_view)
- return NULL;
-
- return browser_view->GetRootView();
+ return browser_view ? browser_view->GetWidget() : NULL;
}
bool SendKeyboardEventInputFunction::RunImpl() {
@@ -96,36 +88,28 @@ bool SendKeyboardEventInputFunction::RunImpl() {
return false;
}
+ bool flag = false;
int flags = prototype_event.flags();
- bool alt = false;
- if (args->GetBoolean(kAlt, &alt))
- flags |= alt ? ui::EF_ALT_DOWN : 0;
- bool ctrl = false;
- if (args->GetBoolean(kCtrl, &ctrl))
- flags |= ctrl ? ui::EF_CONTROL_DOWN : 0;
- bool shift = false;
- if (args->GetBoolean(kShift, &shift))
- flags |= shift ? ui::EF_SHIFT_DOWN : 0;
- bool meta = false;
- if (args->GetBoolean(kMeta, &meta)) {
+ flags |= (args->GetBoolean(kAlt, &flag) && flag) ? ui::EF_ALT_DOWN : 0;
+ flags |= (args->GetBoolean(kCtrl, &flag) && flag) ? ui::EF_CONTROL_DOWN : 0;
+ flags |= (args->GetBoolean(kShift, &flag) && flag) ? ui::EF_SHIFT_DOWN : 0;
+ if (args->GetBoolean(kMeta, &flag) && flag) {
// Views does not have a Meta event flag, so return an error for now.
- if (meta) {
- error_ = kUnsupportedModifier;
- return false;
- }
+ error_ = kUnsupportedModifier;
+ return false;
}
- views::RootView* root_view = GetRootView();
- if (!root_view) {
+ views::Widget* widget = GetTopLevelWidget();
+ if (!widget) {
error_ = kNoValidRecipientError;
return false;
}
views::KeyEvent event(type, prototype_event.key_code(), flags);
- views::InputMethod* ime = root_view->GetWidget()->GetInputMethod();
+ views::InputMethod* ime = widget->GetInputMethod();
if (ime) {
ime->DispatchKeyEvent(event);
- } else if (!root_view->ProcessKeyEvent(event)) {
+ } else if (!widget->OnKeyEvent(event)) {
error_ = kKeyEventUnprocessedError;
return false;
}
diff --git a/chrome/browser/extensions/extension_input_api.h b/chrome/browser/extensions/extension_input_api.h
index 3000211..39a8161 100644
--- a/chrome/browser/extensions/extension_input_api.h
+++ b/chrome/browser/extensions/extension_input_api.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -9,7 +9,7 @@
#include "chrome/browser/extensions/extension_function.h"
namespace views {
- class RootView;
+class Widget;
} // namespace views
// Base class for input APIs.
@@ -30,7 +30,7 @@ class SendKeyboardEventInputFunction : public InputFunction {
DECLARE_EXTENSION_FUNCTION_NAME("experimental.input.sendKeyboardEvent");
private:
- views::RootView* GetRootView();
+ views::Widget* GetTopLevelWidget();
};
#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INPUT_API_H_
diff --git a/views/focus/accelerator_handler_gtk.cc b/views/focus/accelerator_handler_gtk.cc
index f1dc140..6c50f8b 100644
--- a/views/focus/accelerator_handler_gtk.cc
+++ b/views/focus/accelerator_handler_gtk.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -16,7 +16,7 @@ AcceleratorHandler::AcceleratorHandler() {}
bool AcceleratorHandler::Dispatch(GdkEvent* event) {
// The logic for handling keyboard accelerators has been moved into
- // WidgetGtk::OnKeyEvent handler (views/widget/widget_gtk.cc).
+ // WidgetGtk::OnEventKey handler (views/widget/widget_gtk.cc).
gtk_main_do_event(event);
return true;
}
diff --git a/views/focus/accelerator_handler_touch.cc b/views/focus/accelerator_handler_touch.cc
index 716cb29..4981bc4 100644
--- a/views/focus/accelerator_handler_touch.cc
+++ b/views/focus/accelerator_handler_touch.cc
@@ -186,7 +186,7 @@ bool DispatchXEvent(XEvent* xev) {
ime->DispatchKeyEvent(keyev);
return true;
}
- return root->ProcessKeyEvent(keyev);
+ return widget->OnKeyEvent(keyev);
}
case ButtonPress:
diff --git a/views/ime/input_method_gtk.cc b/views/ime/input_method_gtk.cc
index 023bcc6..07da18f 100644
--- a/views/ime/input_method_gtk.cc
+++ b/views/ime/input_method_gtk.cc
@@ -110,13 +110,13 @@ void InputMethodGtk::OnBlur() {
}
void InputMethodGtk::DispatchKeyEvent(const KeyEvent& key) {
+ DCHECK(key.type() == ui::ET_KEY_PRESSED || key.type() == ui::ET_KEY_RELEASED);
suppress_next_result_ = false;
// We should bypass |context_| and |context_simple_| only if there is no
- // text input client is focused at all. Otherwise, we should always send the
- // key event to either |context_| or |context_simple_| even if the text input
- // type is ui::TEXT_INPUT_TYPE_NONE, to make sure we can get correct character
- // result.
+ // text input client focused. Otherwise, always send the key event to either
+ // |context_| or |context_simple_| even if the text input type is
+ // ui::TEXT_INPUT_TYPE_NONE, to make sure we can get correct character result.
if (!GetTextInputClient()) {
DispatchKeyEventPostIME(key);
return;
@@ -126,22 +126,11 @@ void InputMethodGtk::DispatchKeyEvent(const KeyEvent& key) {
composition_changed_ = false;
result_text_.clear();
- GdkEvent* event = key.native_event();
- DCHECK(!event || event->type == GDK_KEY_PRESS ||
- event->type == GDK_KEY_RELEASE);
-
- // If it's a fake key event, then we need to synthesis a GdkEventKey.
- bool need_free_event = false;
- if (!event) {
- event = SynthesizeGdkEventKey(key);
- need_free_event = true;
- }
-
- gboolean filtered = false;
- if (context_focused_)
- filtered = gtk_im_context_filter_keypress(context_, &event->key);
- else
- filtered = gtk_im_context_filter_keypress(context_simple_, &event->key);
+ // If it's a fake key event, then we need to synthesize a GdkEventKey.
+ GdkEvent* event = key.native_event() ? key.native_event() :
+ SynthesizeGdkEventKey(key);
+ gboolean filtered = gtk_im_context_filter_keypress(
+ context_focused_ ? context_ : context_simple_, &event->key);
handling_key_event_ = false;
@@ -149,24 +138,21 @@ void InputMethodGtk::DispatchKeyEvent(const KeyEvent& key) {
if (key.type() == ui::ET_KEY_PRESSED && filtered)
ProcessFilteredKeyPressEvent(key);
- // In case the focus was changed by the key event.
- if (old_focused_view != focused_view())
- return;
-
- if (HasInputMethodResult())
- ProcessInputMethodResult(key, filtered);
-
- // In case the focus was changed when sending input method results to the
- // focused View.
- if (old_focused_view != focused_view())
- return;
-
- if (key.type() == ui::ET_KEY_PRESSED && !filtered)
- ProcessUnfilteredKeyPressEvent(key);
- else if (key.type() == ui::ET_KEY_RELEASED)
- DispatchKeyEventPostIME(key);
+ // Ensure no focus change from processing the key event.
+ if (old_focused_view == focused_view()) {
+ if (HasInputMethodResult())
+ ProcessInputMethodResult(key, filtered);
+ // Ensure no focus change sending input method results to the focused View.
+ if (old_focused_view == focused_view()) {
+ if (key.type() == ui::ET_KEY_PRESSED && !filtered)
+ ProcessUnfilteredKeyPressEvent(key);
+ else if (key.type() == ui::ET_KEY_RELEASED)
+ DispatchKeyEventPostIME(key);
+ }
+ }
- if (need_free_event)
+ // Free the synthesized event if there was no underlying native event.
+ if (event != key.native_event())
gdk_event_free(event);
}
@@ -360,14 +346,10 @@ GdkEvent* InputMethodGtk::SynthesizeGdkEventKey(const KeyEvent& key) const {
guint keyval =
ui::GdkKeyCodeForWindowsKeyCode(key.key_code(), key.IsShiftDown());
guint state = 0;
- if (key.IsShiftDown())
- state |= GDK_SHIFT_MASK;
- if (key.IsControlDown())
- state |= GDK_CONTROL_MASK;
- if (key.IsAltDown())
- state |= GDK_MOD1_MASK;
- if (key.IsCapsLockDown())
- state |= GDK_LOCK_MASK;
+ state |= key.IsShiftDown() ? GDK_SHIFT_MASK : 0;
+ state |= key.IsControlDown() ? GDK_CONTROL_MASK : 0;
+ state |= key.IsAltDown() ? GDK_MOD1_MASK : 0;
+ state |= key.IsCapsLockDown() ? GDK_LOCK_MASK : 0;
DCHECK(widget()->GetNativeView()->window);
return ui::SynthesizeKeyEvent(widget()->GetNativeView()->window,
diff --git a/views/widget/native_widget_delegate.h b/views/widget/native_widget_delegate.h
index e5e3752..0ac5e09 100644
--- a/views/widget/native_widget_delegate.h
+++ b/views/widget/native_widget_delegate.h
@@ -41,7 +41,8 @@ class NativeWidgetDelegate {
// tree if necessary when accelerated painting is enabled.
virtual void OnNativeWidgetPaint(gfx::Canvas* canvas) = 0;
- // MouseEvent handlers.
+ // Mouse and key event handlers.
+ virtual bool OnKeyEvent(const KeyEvent& event) = 0;
virtual bool OnMouseEvent(const MouseEvent& event) = 0;
virtual void OnMouseCaptureLost() = 0;
};
diff --git a/views/widget/root_view.cc b/views/widget/root_view.cc
index 323612e..f69c6a4 100644
--- a/views/widget/root_view.cc
+++ b/views/widget/root_view.cc
@@ -82,7 +82,7 @@ void RootView::NotifyNativeViewHierarchyChanged(bool attached,
// Input -----------------------------------------------------------------------
-bool RootView::ProcessKeyEvent(const KeyEvent& event) {
+bool RootView::OnKeyEvent(const KeyEvent& event) {
bool consumed = false;
View* v = GetFocusManager()->GetFocusedView();
diff --git a/views/widget/root_view.h b/views/widget/root_view.h
index 3465312..11541d2 100644
--- a/views/widget/root_view.h
+++ b/views/widget/root_view.h
@@ -61,8 +61,8 @@ class RootView : public View,
// Process a key event. Send the event to the focused view and up the focus
// path, and finally to the default keyboard handler, until someone consumes
- // it. Returns whether anyone consumed the event.
- bool ProcessKeyEvent(const KeyEvent& event);
+ // it. Returns whether anyone consumed the event.
+ bool OnKeyEvent(const KeyEvent& event);
#if defined(TOUCH_UI) && defined(UNIT_TEST)
// For unit testing purposes, we use this method to set a mock
diff --git a/views/widget/widget.cc b/views/widget/widget.cc
index 924c448..aeaebad8 100644
--- a/views/widget/widget.cc
+++ b/views/widget/widget.cc
@@ -320,6 +320,10 @@ void Widget::OnNativeWidgetPaint(gfx::Canvas* canvas) {
RefreshCompositeTree();
}
+bool Widget::OnKeyEvent(const KeyEvent& event) {
+ return GetRootView()->OnKeyEvent(event);
+}
+
bool Widget::OnMouseEvent(const MouseEvent& event) {
switch (event.type()) {
case ui::ET_MOUSE_PRESSED:
diff --git a/views/widget/widget.h b/views/widget/widget.h
index ec126a0..d2c17a7 100644
--- a/views/widget/widget.h
+++ b/views/widget/widget.h
@@ -291,6 +291,7 @@ class Widget : public internal::NativeWidgetDelegate,
virtual void OnSizeChanged(const gfx::Size& new_size) OVERRIDE;
virtual bool HasFocusManager() const OVERRIDE;
virtual void OnNativeWidgetPaint(gfx::Canvas* canvas) OVERRIDE;
+ virtual bool OnKeyEvent(const KeyEvent& event) OVERRIDE;
virtual bool OnMouseEvent(const MouseEvent& event) OVERRIDE;
virtual void OnMouseCaptureLost() OVERRIDE;
diff --git a/views/widget/widget_gtk.cc b/views/widget/widget_gtk.cc
index 00c9610..85b361c 100644
--- a/views/widget/widget_gtk.cc
+++ b/views/widget/widget_gtk.cc
@@ -615,9 +615,9 @@ void WidgetGtk::Init(GtkWidget* parent,
// See views::Views::Focus and views::FocusManager::ClearNativeFocus
// for more details.
g_signal_connect(widget_, "key_press_event",
- G_CALLBACK(&OnKeyEventThunk), this);
+ G_CALLBACK(&OnEventKeyThunk), this);
g_signal_connect(widget_, "key_release_event",
- G_CALLBACK(&OnKeyEventThunk), this);
+ G_CALLBACK(&OnEventKeyThunk), this);
// Drag and drop.
gtk_drag_dest_set(window_contents_, static_cast<GtkDestDefaults>(0),
@@ -1291,7 +1291,7 @@ gboolean WidgetGtk::OnFocusOut(GtkWidget* widget, GdkEventFocus* event) {
return false;
}
-gboolean WidgetGtk::OnKeyEvent(GtkWidget* widget, GdkEventKey* event) {
+gboolean WidgetGtk::OnEventKey(GtkWidget* widget, GdkEventKey* event) {
KeyEvent key(reinterpret_cast<NativeEvent>(event));
if (input_method_.get())
input_method_->DispatchKeyEvent(key);
@@ -1385,10 +1385,8 @@ void WidgetGtk::DispatchKeyEventPostIME(const KeyEvent& key) {
if (key.key_code() != ui::VKEY_MENU || key.type() != ui::ET_KEY_RELEASED)
should_handle_menu_key_release_ = false;
- bool handled = false;
-
- // Dispatch the key event to View hierarchy first.
- handled = GetRootView()->ProcessKeyEvent(key);
+ // Send the key event to View hierarchy first.
+ bool handled = delegate_->OnKeyEvent(key);
if (key.key_code() == ui::VKEY_PROCESSKEY || handled)
return;
diff --git a/views/widget/widget_gtk.h b/views/widget/widget_gtk.h
index e931f59..a7ede90 100644
--- a/views/widget/widget_gtk.h
+++ b/views/widget/widget_gtk.h
@@ -272,7 +272,7 @@ class WidgetGtk : public Widget,
CHROMEGTK_CALLBACK_1(WidgetGtk, gboolean, OnButtonRelease, GdkEventButton*);
CHROMEGTK_CALLBACK_1(WidgetGtk, gboolean, OnFocusIn, GdkEventFocus*);
CHROMEGTK_CALLBACK_1(WidgetGtk, gboolean, OnFocusOut, GdkEventFocus*);
- CHROMEGTK_CALLBACK_1(WidgetGtk, gboolean, OnKeyEvent, GdkEventKey*);
+ CHROMEGTK_CALLBACK_1(WidgetGtk, gboolean, OnEventKey, GdkEventKey*);
CHROMEGTK_CALLBACK_4(WidgetGtk, gboolean, OnQueryTooltip,
gint, gint, gboolean, GtkTooltip*);
CHROMEGTK_CALLBACK_1(WidgetGtk, gboolean, OnScroll, GdkEventScroll*);
diff --git a/views/widget/widget_win.cc b/views/widget/widget_win.cc
index d05b725..edecafb 100644
--- a/views/widget/widget_win.cc
+++ b/views/widget/widget_win.cc
@@ -1028,19 +1028,6 @@ Window* WidgetWin::GetWindowImpl(HWND hwnd) {
return NULL;
}
-RootView* WidgetWin::GetFocusedViewRootView() {
- // TODO(beng): get rid of this
- FocusManager* focus_manager = GetFocusManager();
- if (!focus_manager) {
- NOTREACHED();
- return NULL;
- }
- View* focused_view = focus_manager->GetFocusedView();
- if (!focused_view)
- return NULL;
- return focused_view->GetRootView();
-}
-
// static
void WidgetWin::PostProcessActivateMessage(WidgetWin* widget,
int activation_state) {
@@ -1129,11 +1116,7 @@ gfx::AcceleratedWidget WidgetWin::GetAcceleratedWidget() {
}
void WidgetWin::DispatchKeyEventPostIME(const KeyEvent& key) {
- RootView* root_view = GetFocusedViewRootView();
- if (!root_view)
- root_view = GetRootView();
-
- SetMsgHandled(root_view->ProcessKeyEvent(key));
+ SetMsgHandled(delegate_->OnKeyEvent(key));
}
////////////////////////////////////////////////////////////////////////////////
diff --git a/views/widget/widget_win.h b/views/widget/widget_win.h
index 6e795de..5f92a1f 100644
--- a/views/widget/widget_win.h
+++ b/views/widget/widget_win.h
@@ -419,10 +419,6 @@ class WidgetWin : public ui::WindowImpl,
// first ancestor that is a Window.
static Window* GetWindowImpl(HWND hwnd);
- // Returns the RootView that contains the focused view, or NULL if there is no
- // focused view.
- RootView* GetFocusedViewRootView();
-
// Called after the WM_ACTIVATE message has been processed by the default
// windows procedure.
static void PostProcessActivateMessage(WidgetWin* widget,