diff options
author | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-24 20:10:25 +0000 |
---|---|---|
committer | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-24 20:10:25 +0000 |
commit | 2047ef4d68229d47cba8bf7f2e0465ab31f8b3ce (patch) | |
tree | 86af296c2de9e5ac31c9ed79e21d9d0e4ccda8c4 /views | |
parent | 86e1db9d9de1ce72ba045bd3755e7a077a1f7fd8 (diff) | |
download | chromium_src-2047ef4d68229d47cba8bf7f2e0465ab31f8b3ce.zip chromium_src-2047ef4d68229d47cba8bf7f2e0465ab31f8b3ce.tar.gz chromium_src-2047ef4d68229d47cba8bf7f2e0465ab31f8b3ce.tar.bz2 |
Refactor the glib message-pump, and use it as the base for a gtk message pump and an X message pump.
The changes:
* Rename MessagePumpGlibX to MessagePumpX.
* Rename MessagePumpForUI to MessagePumpGlib.
* Move some stuff out of MessagePumpGlib, and into MessagePumpGtk and MessagePumpX.
* Rename MessagePumpForUI::Observer to MessageObserver, moved the platform-specific implementations into MessagePumpGtk and MessagePumpX. Ditto for MessagePumpForUI::Dispatcher.
MessagePumpX is independent of MessagePumpGtk. At the moment, MessagePumpX does process some GDK event, but once we have a complete native_widget_x, we can take out the GDK processing and things should continue to work.
BUG=none
TEST=existing message-pump tests.
Review URL: http://codereview.chromium.org/7250001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@90418 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r-- | views/controls/menu/menu_controller.cc | 22 | ||||
-rw-r--r-- | views/controls/menu/menu_controller.h | 7 | ||||
-rw-r--r-- | views/controls/menu/nested_dispatcher_gtk.cc | 25 | ||||
-rw-r--r-- | views/controls/menu/nested_dispatcher_gtk.h | 9 | ||||
-rw-r--r-- | views/focus/accelerator_handler.h | 7 | ||||
-rw-r--r-- | views/focus/accelerator_handler_touch.cc | 16 | ||||
-rw-r--r-- | views/views.gyp | 3 | ||||
-rw-r--r-- | views/widget/native_widget_gtk.cc | 2 |
8 files changed, 39 insertions, 52 deletions
diff --git a/views/controls/menu/menu_controller.cc b/views/controls/menu/menu_controller.cc index c1e8d2a..84544f1 100644 --- a/views/controls/menu/menu_controller.cc +++ b/views/controls/menu/menu_controller.cc @@ -858,7 +858,16 @@ bool MenuController::Dispatch(const MSG& msg) { DispatchMessage(&msg); return exit_type_ == EXIT_NONE; } +#elif defined(TOUCH_UI) +base::MessagePumpDispatcher::DispatchStatus + MenuController::Dispatch(XEvent* xev) { + if (!DispatchXEvent(xev)) + return EVENT_IGNORED; + return exit_type_ != EXIT_NONE ? + base::MessagePumpDispatcher::EVENT_QUIT : + base::MessagePumpDispatcher::EVENT_PROCESSED; +} #else bool MenuController::Dispatch(GdkEvent* event) { if (exit_type_ == EXIT_ALL || exit_type_ == EXIT_DESTROYED) { @@ -897,19 +906,6 @@ bool MenuController::Dispatch(GdkEvent* event) { gtk_main_do_event(event); return exit_type_ == EXIT_NONE; } - -#if defined(TOUCH_UI) -base::MessagePumpGlibXDispatcher::DispatchStatus - MenuController::DispatchX(XEvent* xev) { - if (!DispatchXEvent(xev)) - return EVENT_IGNORED; - - return exit_type_ != EXIT_NONE ? - base::MessagePumpGlibXDispatcher::EVENT_QUIT : - base::MessagePumpGlibXDispatcher::EVENT_PROCESSED; -} -#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 cc89808..7721a6e 100644 --- a/views/controls/menu/menu_controller.h +++ b/views/controls/menu/menu_controller.h @@ -207,15 +207,12 @@ class MenuController : public MessageLoopForUI::Dispatcher { // Dispatcher method. This returns true if the menu was canceled, or // if the message is such that the menu should be closed. virtual bool Dispatch(const MSG& msg); - +#elif defined(TOUCH_UI) + virtual base::MessagePumpDispatcher::DispatchStatus Dispatch(XEvent* xevent); #else virtual bool Dispatch(GdkEvent* event); #endif -#if defined(TOUCH_UI) - virtual MessagePumpGlibXDispatcher::DispatchStatus DispatchX(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/nested_dispatcher_gtk.cc b/views/controls/menu/nested_dispatcher_gtk.cc index 9cdc1a6..383447c 100644 --- a/views/controls/menu/nested_dispatcher_gtk.cc +++ b/views/controls/menu/nested_dispatcher_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. @@ -32,24 +32,15 @@ void NestedDispatcherGtk::CreatorDestroyed() { creator_ = NULL; } -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; - } +base::MessagePumpDispatcher::DispatchStatus + NestedDispatcherGtk::Dispatch(XEvent* xevent) { + return creator_->Dispatch(xevent); } - -#if defined(TOUCH_UI) -base::MessagePumpGlibXDispatcher::DispatchStatus - NestedDispatcherGtk::DispatchX(XEvent* xevent) { - return creator_->DispatchX(xevent); +#else +bool NestedDispatcherGtk::Dispatch(GdkEvent* event) { + return creator_ && creator_->Dispatch(event); } -#endif +#endif // defined(TOUCH_UI) } // namespace views diff --git a/views/controls/menu/nested_dispatcher_gtk.h b/views/controls/menu/nested_dispatcher_gtk.h index 342ea26..0520b4d 100644 --- a/views/controls/menu/nested_dispatcher_gtk.h +++ b/views/controls/menu/nested_dispatcher_gtk.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. @@ -37,12 +37,11 @@ class NestedDispatcherGtk : public MessageLoopForUI::Dispatcher { private: virtual ~NestedDispatcherGtk() {} +#if defined(TOUCH_UI) + virtual base::MessagePumpDispatcher::DispatchStatus Dispatch(XEvent* xevent); +#else // Overriden from MessageLoopForUI::Dispatcher: virtual bool Dispatch(GdkEvent* event); - -#if defined(TOUCH_UI) - virtual base::MessagePumpGlibXDispatcher::DispatchStatus - DispatchX(XEvent* xevent); #endif // Creator of the nested loop. diff --git a/views/focus/accelerator_handler.h b/views/focus/accelerator_handler.h index b10b587..44b411f 100644 --- a/views/focus/accelerator_handler.h +++ b/views/focus/accelerator_handler.h @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 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. @@ -41,11 +41,10 @@ class AcceleratorHandler : public MessageLoopForUI::Dispatcher { // focus manager #if defined(OS_WIN) virtual bool Dispatch(const MSG& msg); +#elif defined(TOUCH_UI) + virtual base::MessagePumpDispatcher::DispatchStatus Dispatch(XEvent* xev); #else virtual bool Dispatch(GdkEvent* event); -#if defined(TOUCH_UI) - virtual MessagePumpGlibXDispatcher::DispatchStatus DispatchX(XEvent* xev); -#endif #endif private: diff --git a/views/focus/accelerator_handler_touch.cc b/views/focus/accelerator_handler_touch.cc index 3ffbd6a..f5ccd31 100644 --- a/views/focus/accelerator_handler_touch.cc +++ b/views/focus/accelerator_handler_touch.cc @@ -177,16 +177,18 @@ void SetTouchDeviceList(std::vector<unsigned int>& devices) { AcceleratorHandler::AcceleratorHandler() {} +#if defined(TOUCH_UI) +base::MessagePumpDispatcher::DispatchStatus + AcceleratorHandler::Dispatch(XEvent* xev) { + return DispatchXEvent(xev) ? + base::MessagePumpDispatcher::EVENT_PROCESSED : + base::MessagePumpDispatcher::EVENT_IGNORED; +} +#else bool AcceleratorHandler::Dispatch(GdkEvent* event) { gtk_main_do_event(event); return true; } - -base::MessagePumpGlibXDispatcher::DispatchStatus - AcceleratorHandler::DispatchX(XEvent* xev) { - return DispatchXEvent(xev) ? - base::MessagePumpGlibXDispatcher::EVENT_PROCESSED : - base::MessagePumpGlibXDispatcher::EVENT_IGNORED; -} +#endif } // namespace views diff --git a/views/views.gyp b/views/views.gyp index 67f7974..5d099ba 100644 --- a/views/views.gyp +++ b/views/views.gyp @@ -523,6 +523,9 @@ '../base/allocator/allocator.gyp:allocator', ], }], + [ 'touchui==1', { + 'sources!': [ 'focus/accelerator_handler_gtk_unittest.cc' ], + }], ], }, ], diff --git a/views/widget/native_widget_gtk.cc b/views/widget/native_widget_gtk.cc index 6ecf284..8d6e7fe 100644 --- a/views/widget/native_widget_gtk.cc +++ b/views/widget/native_widget_gtk.cc @@ -1632,7 +1632,7 @@ void NativeWidgetGtk::OnMap(GtkWidget* widget) { // a workaround for a bug that X Expose event does not trigger // Gdk's expose signal. This happens when you try to open views menu // while a virtual keyboard gets kicked in or out. This seems to be - // a bug in message_pump_glib_x.cc as we do get X Expose event but + // a bug in message_pump_x.cc as we do get X Expose event but // it doesn't trigger gtk's expose signal. We're not going to fix this // as we're removing gtk and migrating to new compositor. gdk_window_process_all_updates(); |