diff options
author | rjkroege@google.com <rjkroege@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-26 18:43:18 +0000 |
---|---|---|
committer | rjkroege@google.com <rjkroege@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-26 18:43:18 +0000 |
commit | b2f7ac4583b968d0c20ea8f6c4110aeb6882699a (patch) | |
tree | 7bcf1278af056ab056221da0ee01e81851e9ebde /views/controls | |
parent | bd2b41afb25b648e3f77dce87064971f63894a7f (diff) | |
download | chromium_src-b2f7ac4583b968d0c20ea8f6c4110aeb6882699a.zip chromium_src-b2f7ac4583b968d0c20ea8f6c4110aeb6882699a.tar.gz chromium_src-b2f7ac4583b968d0c20ea8f6c4110aeb6882699a.tar.bz2 |
touchui: Directly process key and mouse events.
Capture the keyboard and mouse events directly from X, create a corresponding
views::Event out of it, and send it to the associated RootView.
Includes Chad's (wyck) function FindRootViewForGdkEvent (from #3704005) slightly
modified (called FindRootViewForGdkWindow).
BUG=None
TEST=Click/Keypress events in a webpage should work correctly.
Review URL: http://codereview.chromium.org/3801011
Patch from Sadrul Chowdhury <sadrul@chromium.org>.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@63916 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/controls')
-rw-r--r-- | views/controls/menu/menu_controller.cc | 13 | ||||
-rw-r--r-- | views/controls/menu/menu_controller.h | 4 | ||||
-rw-r--r-- | views/controls/menu/native_menu_gtk.cc | 10 | ||||
-rw-r--r-- | views/controls/menu/native_menu_gtk.h | 3 | ||||
-rw-r--r-- | views/controls/menu/nested_dispatcher_gtk.cc | 15 | ||||
-rw-r--r-- | views/controls/menu/nested_dispatcher_gtk.h | 10 |
6 files changed, 53 insertions, 2 deletions
diff --git a/views/controls/menu/menu_controller.cc b/views/controls/menu/menu_controller.cc index affddeb..e0701a2 100644 --- a/views/controls/menu/menu_controller.cc +++ b/views/controls/menu/menu_controller.cc @@ -25,6 +25,10 @@ #include "app/keyboard_code_conversion_gtk.h" #endif +#if defined(TOUCH_UI) +#include "views/focus/accelerator_handler.h" +#endif + using base::Time; using base::TimeDelta; @@ -848,12 +852,19 @@ bool MenuController::Dispatch(GdkEvent* event) { break; } - // We don not want Gtk to handle keyboard events, otherwise if they get + // We don't want Gtk to handle keyboard events, otherwise if they get // handled by Gtk, unexpected behavior may occur. For example Tab key // may cause unexpected focus traversing. gtk_main_do_event(event); return exit_type_ == EXIT_NONE; } + +#if defined(TOUCH_UI) +bool MenuController::Dispatch(XEvent* xev) { + return DispatchXEvent(xev); +} +#endif + #endif bool MenuController::OnKeyDown(int key_code diff --git a/views/controls/menu/menu_controller.h b/views/controls/menu/menu_controller.h index fe379b8..539c2ee 100644 --- a/views/controls/menu/menu_controller.h +++ b/views/controls/menu/menu_controller.h @@ -192,6 +192,10 @@ class MenuController : public MessageLoopForUI::Dispatcher { virtual bool Dispatch(GdkEvent* event); #endif +#if defined(TOUCH_UI) + virtual bool Dispatch(XEvent* xevent); +#endif + // Key processing. The return value of this is returned from Dispatch. // In other words, if this returns false (which happens if escape was // pressed, or a matching mnemonic was found) the message loop returns. diff --git a/views/controls/menu/native_menu_gtk.cc b/views/controls/menu/native_menu_gtk.cc index 12f73da..45c64c0 100644 --- a/views/controls/menu/native_menu_gtk.cc +++ b/views/controls/menu/native_menu_gtk.cc @@ -23,6 +23,10 @@ #include "views/controls/menu/menu_2.h" #include "views/controls/menu/nested_dispatcher_gtk.h" +#if defined(TOUCH_UI) +#include "views/focus/accelerator_handler.h" +#endif + namespace { const char kPositionString[] = "position"; @@ -220,6 +224,12 @@ void NativeMenuGtk::SetMinimumWidth(int width) { gtk_widget_set_size_request(menu_, width, -1); } +#if defined(TOUCH_UI) +bool NativeMenuGtk::Dispatch(XEvent* xevent) { + return DispatchXEvent(xevent); +} +#endif + bool NativeMenuGtk::Dispatch(GdkEvent* event) { if (menu_hidden_) { // The menu has been closed but the message loop is still nested. Don't diff --git a/views/controls/menu/native_menu_gtk.h b/views/controls/menu/native_menu_gtk.h index 6145925..4278d2c 100644 --- a/views/controls/menu/native_menu_gtk.h +++ b/views/controls/menu/native_menu_gtk.h @@ -51,6 +51,9 @@ class NativeMenuGtk : public MenuWrapper, // Overriden from MessageLoopForUI::Dispatcher: virtual bool Dispatch(GdkEvent* event); +#if defined(TOUCH_UI) + virtual bool Dispatch(XEvent* xevent); +#endif private: CHROMEGTK_CALLBACK_0(NativeMenuGtk, void, OnMenuHidden); diff --git a/views/controls/menu/nested_dispatcher_gtk.cc b/views/controls/menu/nested_dispatcher_gtk.cc index 856b0a8..ba7a7b2 100644 --- a/views/controls/menu/nested_dispatcher_gtk.cc +++ b/views/controls/menu/nested_dispatcher_gtk.cc @@ -4,6 +4,10 @@ #include "views/controls/menu/nested_dispatcher_gtk.h" +#if defined(TOUCH_UI) +#include "views/focus/accelerator_handler.h" +#endif + namespace views { NestedDispatcherGtk::NestedDispatcherGtk(MessageLoopForUI::Dispatcher* creator, @@ -30,10 +34,21 @@ void NestedDispatcherGtk::CreatorDestroyed() { bool NestedDispatcherGtk::Dispatch(GdkEvent* event) { if (creator_ != NULL) { +#if defined(TOUCH_UI) + return static_cast<base::MessagePumpForUI::Dispatcher*> + (creator_)->Dispatch(event); +#else return creator_->Dispatch(event); +#endif } else { return false; } } +#if defined(TOUCH_UI) +bool NestedDispatcherGtk::Dispatch(XEvent* xevent) { + return creator_ ? creator_->Dispatch(xevent) : false; +} +#endif + } // namespace views diff --git a/views/controls/menu/nested_dispatcher_gtk.h b/views/controls/menu/nested_dispatcher_gtk.h index 06f54fa..f17e9a4 100644 --- a/views/controls/menu/nested_dispatcher_gtk.h +++ b/views/controls/menu/nested_dispatcher_gtk.h @@ -3,11 +3,15 @@ // found in the LICENSE file. #ifndef VIEWS_CONTROLS_MENU_NESTED_DISPATCHER_GTK_H_ -#define VIEWS_CONTROLS_MENU_NATIVE_DISPATCHER_GTK_H_ +#define VIEWS_CONTROLS_MENU_NESTED_DISPATCHER_GTK_H_ #pragma once #include "base/message_loop.h" +#if defined(TOUCH_UI) +typedef union _XEvent XEvent; +#endif + namespace views { // A nested dispatcher that can out-live the creator of this @@ -36,6 +40,10 @@ class NestedDispatcherGtk : public MessageLoopForUI::Dispatcher { // Overriden from MessageLoopForUI::Dispatcher: virtual bool Dispatch(GdkEvent* event); +#if defined(TOUCH_UI) + virtual bool Dispatch(XEvent* xevent); +#endif + // Creator of the nested loop. MessageLoopForUI::Dispatcher* creator_; |