diff options
author | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-09 19:50:06 +0000 |
---|---|---|
committer | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-09 19:50:06 +0000 |
commit | 046460d54e5397286cba1b3ce9462b4129b2aaab (patch) | |
tree | 79b0e31f0a28b01ae9b1dfd12dad5be6fa3368b4 /ui | |
parent | c90ec6552b57ec596c35a4c44082ad518857a393 (diff) | |
download | chromium_src-046460d54e5397286cba1b3ce9462b4129b2aaab.zip chromium_src-046460d54e5397286cba1b3ce9462b4129b2aaab.tar.gz chromium_src-046460d54e5397286cba1b3ce9462b4129b2aaab.tar.bz2 |
Consolidate win/x dispatchers
BUG=116282
TEST=no functional change. All tests should pass.
Review URL: http://codereview.chromium.org/9958152
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@131412 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r-- | ui/aura/dispatcher_linux.cc | 9 | ||||
-rw-r--r-- | ui/aura/dispatcher_linux.h | 3 | ||||
-rw-r--r-- | ui/aura/dispatcher_win.cc | 4 | ||||
-rw-r--r-- | ui/aura/monitor_change_observer_x11.cc | 6 | ||||
-rw-r--r-- | ui/aura/monitor_change_observer_x11.h | 3 | ||||
-rw-r--r-- | ui/aura/root_window_host_linux.cc | 29 | ||||
-rw-r--r-- | ui/aura/root_window_host_linux.h | 3 | ||||
-rw-r--r-- | ui/gfx/compositor/test/test_compositor_host_linux.cc | 18 | ||||
-rw-r--r-- | ui/gfx/compositor/test/test_compositor_host_win.cc | 2 | ||||
-rw-r--r-- | ui/views/controls/menu/menu_controller.cc | 30 | ||||
-rw-r--r-- | ui/views/controls/menu/menu_controller.h | 7 | ||||
-rw-r--r-- | ui/views/focus/accelerator_handler.h | 7 | ||||
-rw-r--r-- | ui/views/focus/accelerator_handler_aura.cc | 17 | ||||
-rw-r--r-- | ui/views/focus/accelerator_handler_win.cc | 17 |
14 files changed, 52 insertions, 103 deletions
diff --git a/ui/aura/dispatcher_linux.cc b/ui/aura/dispatcher_linux.cc index a10fba5..b580be8 100644 --- a/ui/aura/dispatcher_linux.cc +++ b/ui/aura/dispatcher_linux.cc @@ -28,14 +28,13 @@ void DispatcherLinux::WindowDispatcherDestroying(::Window window) { dispatchers_.erase(window); } -base::MessagePumpDispatcher::DispatchStatus DispatcherLinux::Dispatch( - XEvent* xev) { +bool DispatcherLinux::Dispatch(const base::NativeEvent& xev) { // XI_HierarchyChanged events are special. There is no window associated with // these events. So process them directly from here. if (xev->type == GenericEvent && xev->xgeneric.evtype == XI_HierarchyChanged) { ui::UpdateDeviceList(); - return EVENT_PROCESSED; + return true; } // MappingNotify events (meaning that the keyboard or pointer buttons have @@ -46,11 +45,11 @@ base::MessagePumpDispatcher::DispatchStatus DispatcherLinux::Dispatch( it != dispatchers_.end(); ++it) { it->second->Dispatch(xev); } - return EVENT_PROCESSED; + return true; } MessageLoop::Dispatcher* dispatcher = GetDispatcherForXEvent(xev); - return dispatcher ? dispatcher->Dispatch(xev) : EVENT_IGNORED; + return dispatcher ? dispatcher->Dispatch(xev) : true; } MessageLoop::Dispatcher* DispatcherLinux::GetDispatcherForXEvent( diff --git a/ui/aura/dispatcher_linux.h b/ui/aura/dispatcher_linux.h index 31328ec..5625558 100644 --- a/ui/aura/dispatcher_linux.h +++ b/ui/aura/dispatcher_linux.h @@ -27,8 +27,7 @@ class DispatcherLinux : public MessageLoop::Dispatcher { void WindowDispatcherDestroying(::Window window); // Overridden from MessageLoop::Dispatcher: - virtual base::MessagePumpDispatcher::DispatchStatus Dispatch( - XEvent* xev) OVERRIDE; + virtual bool Dispatch(const base::NativeEvent& event) OVERRIDE; private: typedef std::map< ::Window, MessageLoop::Dispatcher* > DispatchersMap; diff --git a/ui/aura/dispatcher_win.cc b/ui/aura/dispatcher_win.cc index 9f60436..c406ede 100644 --- a/ui/aura/dispatcher_win.cc +++ b/ui/aura/dispatcher_win.cc @@ -14,13 +14,13 @@ class DispatcherWin : public MessageLoop::Dispatcher { virtual ~DispatcherWin() {} // Overridden from MessageLoop::Dispatcher: - virtual bool Dispatch(const MSG& msg) OVERRIDE; + virtual bool Dispatch(const base::NativeEvent& event) OVERRIDE; private: DISALLOW_COPY_AND_ASSIGN(DispatcherWin); }; -bool DispatcherWin::Dispatch(const MSG& msg) { +bool DispatcherWin::Dispatch(const base::NativeEvent& msg) { TranslateMessage(&msg); DispatchMessage(&msg); return true; diff --git a/ui/aura/monitor_change_observer_x11.cc b/ui/aura/monitor_change_observer_x11.cc index 8618d1f..bb2904f 100644 --- a/ui/aura/monitor_change_observer_x11.cc +++ b/ui/aura/monitor_change_observer_x11.cc @@ -55,13 +55,11 @@ MonitorChangeObserverX11::~MonitorChangeObserverX11() { WindowDispatcherDestroying(x_root_window_); } -base::MessagePumpDispatcher::DispatchStatus -MonitorChangeObserverX11::Dispatch(XEvent* event) { +bool MonitorChangeObserverX11::Dispatch(const base::NativeEvent& event) { if (event->type - xrandr_event_base_ == RRScreenChangeNotify) { NotifyMonitorChange(); - return base::MessagePumpDispatcher::EVENT_PROCESSED; } - return base::MessagePumpDispatcher::EVENT_IGNORED; + return true; } void MonitorChangeObserverX11::NotifyMonitorChange() { diff --git a/ui/aura/monitor_change_observer_x11.h b/ui/aura/monitor_change_observer_x11.h index 077e8c6..45ff332 100644 --- a/ui/aura/monitor_change_observer_x11.h +++ b/ui/aura/monitor_change_observer_x11.h @@ -25,8 +25,7 @@ class MonitorChangeObserverX11 : public MessageLoop::Dispatcher { virtual ~MonitorChangeObserverX11(); // Overridden from Dispatcher overrides: - virtual base::MessagePumpDispatcher::DispatchStatus Dispatch( - XEvent* xev) OVERRIDE; + virtual bool Dispatch(const base::NativeEvent& xev) OVERRIDE; // Reads monitor configurations from the system and notifies // |monitor_manager_| about the change. diff --git a/ui/aura/root_window_host_linux.cc b/ui/aura/root_window_host_linux.cc index 0b36cb4..6699780 100644 --- a/ui/aura/root_window_host_linux.cc +++ b/ui/aura/root_window_host_linux.cc @@ -386,9 +386,8 @@ RootWindowHostLinux::~RootWindowHostLinux() { XFreeCursor(xdisplay_, invisible_cursor_); } -base::MessagePumpDispatcher::DispatchStatus RootWindowHostLinux::Dispatch( - XEvent* xev) { - bool handled = false; +bool RootWindowHostLinux::Dispatch(const base::NativeEvent& event) { + XEvent* xev = event; // See crbug.com/109884. // CheckXEventForConsistency(xev); @@ -396,22 +395,21 @@ base::MessagePumpDispatcher::DispatchStatus RootWindowHostLinux::Dispatch( switch (xev->type) { case Expose: root_window_->ScheduleFullDraw(); - handled = true; break; case KeyPress: { KeyEvent keydown_event(xev, false); - handled = root_window_->DispatchKeyEvent(&keydown_event); + root_window_->DispatchKeyEvent(&keydown_event); break; } case KeyRelease: { KeyEvent keyup_event(xev, false); - handled = root_window_->DispatchKeyEvent(&keyup_event); + root_window_->DispatchKeyEvent(&keyup_event); break; } case ButtonPress: case ButtonRelease: { MouseEvent mouseev(xev); - handled = root_window_->DispatchMouseEvent(&mouseev); + root_window_->DispatchMouseEvent(&mouseev); break; } case FocusOut: @@ -438,7 +436,6 @@ base::MessagePumpDispatcher::DispatchStatus RootWindowHostLinux::Dispatch( bounds_ = bounds; if (size_changed) root_window_->OnHostResized(bounds.size()); - handled = true; break; } case GenericEvent: { @@ -457,7 +454,7 @@ base::MessagePumpDispatcher::DispatchStatus RootWindowHostLinux::Dispatch( case ui::ET_TOUCH_RELEASED: case ui::ET_TOUCH_MOVED: { TouchEvent touchev(xev); - handled = root_window_->DispatchTouchEvent(&touchev); + root_window_->DispatchTouchEvent(&touchev); break; } case ui::ET_MOUSE_MOVED: @@ -474,18 +471,17 @@ base::MessagePumpDispatcher::DispatchStatus RootWindowHostLinux::Dispatch( case ui::ET_MOUSE_ENTERED: case ui::ET_MOUSE_EXITED: { MouseEvent mouseev(xev); - handled = root_window_->DispatchMouseEvent(&mouseev); + root_window_->DispatchMouseEvent(&mouseev); break; } case ui::ET_SCROLL_FLING_START: case ui::ET_SCROLL_FLING_CANCEL: case ui::ET_SCROLL: { ScrollEvent scrollev(xev); - handled = root_window_->DispatchScrollEvent(&scrollev); + root_window_->DispatchScrollEvent(&scrollev); break; } case ui::ET_UNKNOWN: - handled = false; break; default: NOTREACHED(); @@ -501,7 +497,6 @@ base::MessagePumpDispatcher::DispatchStatus RootWindowHostLinux::Dispatch( // focus to our host window. if (!IsWindowManagerPresent() && focus_when_shown_) XSetInputFocus(xdisplay_, xwindow_, RevertToNone, CurrentTime); - handled = true; break; } case ClientMessage: { @@ -509,7 +504,6 @@ base::MessagePumpDispatcher::DispatchStatus RootWindowHostLinux::Dispatch( if (message_type == cached_atoms_[ATOM_WM_DELETE_WINDOW]) { // We have received a close message from the window manager. root_window_->OnRootWindowHostClosed(); - handled = true; } else if (message_type == cached_atoms_[ATOM__NET_WM_PING]) { XEvent reply_event = *xev; reply_event.xclient.window = x_root_window_; @@ -519,8 +513,6 @@ base::MessagePumpDispatcher::DispatchStatus RootWindowHostLinux::Dispatch( False, SubstructureRedirectMask | SubstructureNotifyMask, &reply_event); - - handled = true; } break; } @@ -559,12 +551,11 @@ base::MessagePumpDispatcher::DispatchStatus RootWindowHostLinux::Dispatch( } MouseEvent mouseev(xev); - handled = root_window_->DispatchMouseEvent(&mouseev); + root_window_->DispatchMouseEvent(&mouseev); break; } } - return handled ? base::MessagePumpDispatcher::EVENT_PROCESSED : - base::MessagePumpDispatcher::EVENT_IGNORED; + return true; } void RootWindowHostLinux::SetRootWindow(RootWindow* root_window) { diff --git a/ui/aura/root_window_host_linux.h b/ui/aura/root_window_host_linux.h index f1d61a1..04c2cc1 100644 --- a/ui/aura/root_window_host_linux.h +++ b/ui/aura/root_window_host_linux.h @@ -25,8 +25,7 @@ class RootWindowHostLinux : public RootWindowHost, virtual ~RootWindowHostLinux(); // Overridden from Dispatcher overrides: - virtual base::MessagePumpDispatcher::DispatchStatus - Dispatch(XEvent* xev) OVERRIDE; + virtual bool Dispatch(const base::NativeEvent& event) OVERRIDE; private: // RootWindowHost Overrides. diff --git a/ui/gfx/compositor/test/test_compositor_host_linux.cc b/ui/gfx/compositor/test/test_compositor_host_linux.cc index 61578b8..b601810 100644 --- a/ui/gfx/compositor/test/test_compositor_host_linux.cc +++ b/ui/gfx/compositor/test/test_compositor_host_linux.cc @@ -38,12 +38,7 @@ class TestCompositorHostLinux : public TestCompositorHost, virtual void ScheduleDraw() OVERRIDE; // Overridden from MessagePumpDispatcher: -#if defined(USE_AURA) - virtual base::MessagePumpDispatcher::DispatchStatus - Dispatch(XEvent* xev) OVERRIDE; -#elif defined(TOOLKIT_GTK) - virtual bool Dispatch(GdkEvent* event) OVERRIDE; -#endif + virtual bool Dispatch(const base::NativeEvent& event) OVERRIDE; void Draw(); @@ -104,16 +99,9 @@ void TestCompositorHostLinux::ScheduleDraw() { } } -#if defined(USE_AURA) -base::MessagePumpDispatcher::DispatchStatus TestCompositorHostLinux::Dispatch( - XEvent* xev) { - return MessagePumpDispatcher::EVENT_IGNORED; +bool TestCompositorHostLinux::Dispatch(const base::NativeEvent& event) { + return true; } -#elif defined(TOOLKIT_GTK) -bool TestCompositorHostLinux::Dispatch(GdkEvent*) { - return false; -} -#endif void TestCompositorHostLinux::Draw() { if (compositor_.get()) diff --git a/ui/gfx/compositor/test/test_compositor_host_win.cc b/ui/gfx/compositor/test/test_compositor_host_win.cc index d25b58b..68da209 100644 --- a/ui/gfx/compositor/test/test_compositor_host_win.cc +++ b/ui/gfx/compositor/test/test_compositor_host_win.cc @@ -25,7 +25,7 @@ class TestCompositorHostWin : public TestCompositorHost, } // Overridden from MessageLoop::Dispatcher: - virtual bool Dispatch(const MSG& msg) { + virtual bool Dispatch(const base::NativeEvent& msg) { TranslateMessage(&msg); DispatchMessage(&msg); return true; diff --git a/ui/views/controls/menu/menu_controller.cc b/ui/views/controls/menu/menu_controller.cc index a1438fb..4dd0f06 100644 --- a/ui/views/controls/menu/menu_controller.cc +++ b/ui/views/controls/menu/menu_controller.cc @@ -890,7 +890,6 @@ bool MenuController::Dispatch(const MSG& msg) { } case WM_CHAR: return !SelectByChar(static_cast<char16>(msg.wParam)); - case WM_KEYUP: return true; @@ -914,34 +913,25 @@ bool MenuController::Dispatch(const MSG& msg) { return exit_type_ == EXIT_NONE; } #elif defined(USE_AURA) -base::MessagePumpDispatcher::DispatchStatus - MenuController::Dispatch(XEvent* xev) { +bool MenuController::Dispatch(const base::NativeEvent& event) { if (exit_type_ == EXIT_ALL || exit_type_ == EXIT_DESTROYED) { - aura::Env::GetInstance()->GetDispatcher()->Dispatch(xev); - return base::MessagePumpDispatcher::EVENT_QUIT; + aura::Env::GetInstance()->GetDispatcher()->Dispatch(event); + return false; } - switch (ui::EventTypeFromNative(xev)) { + switch (ui::EventTypeFromNative(event)) { case ui::ET_KEY_PRESSED: - if (!OnKeyDown(ui::KeyboardCodeFromNative(xev))) - return base::MessagePumpDispatcher::EVENT_QUIT; + if (!OnKeyDown(ui::KeyboardCodeFromNative(event))) + return false; - return SelectByChar(ui::KeyboardCodeFromNative(xev)) ? - base::MessagePumpDispatcher::EVENT_QUIT : - base::MessagePumpDispatcher::EVENT_PROCESSED; + return !SelectByChar(ui::KeyboardCodeFromNative(event)); case ui::ET_KEY_RELEASED: - return base::MessagePumpDispatcher::EVENT_PROCESSED; + return true; default: break; } - // TODO(oshima): Update Windows' Dispatcher to return DispatchStatus - // instead of bool. - if (aura::Env::GetInstance()->GetDispatcher()->Dispatch(xev) == - base::MessagePumpDispatcher::EVENT_IGNORED) - return EVENT_IGNORED; - return exit_type_ != EXIT_NONE ? - base::MessagePumpDispatcher::EVENT_QUIT : - base::MessagePumpDispatcher::EVENT_PROCESSED; + aura::Env::GetInstance()->GetDispatcher()->Dispatch(event); + return exit_type_ == EXIT_NONE; } #endif diff --git a/ui/views/controls/menu/menu_controller.h b/ui/views/controls/menu/menu_controller.h index f8bb62e..4376b75 100644 --- a/ui/views/controls/menu/menu_controller.h +++ b/ui/views/controls/menu/menu_controller.h @@ -238,13 +238,10 @@ class VIEWS_EXPORT MenuController : public MessageLoop::Dispatcher { const LocatedEvent& event); void StartDrag(SubmenuView* source, const gfx::Point& location); -#if defined(OS_WIN) +#if defined(OS_WIN) || defined(USE_AURA) // 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) OVERRIDE; -#elif defined(USE_AURA) - virtual base::MessagePumpDispatcher::DispatchStatus Dispatch( - XEvent* xevent) OVERRIDE; + virtual bool Dispatch(const base::NativeEvent& event) OVERRIDE; #endif // Key processing. The return value of this is returned from Dispatch. diff --git a/ui/views/focus/accelerator_handler.h b/ui/views/focus/accelerator_handler.h index 7f5cab1..a79fc02 100644 --- a/ui/views/focus/accelerator_handler.h +++ b/ui/views/focus/accelerator_handler.h @@ -35,13 +35,10 @@ class VIEWS_EXPORT AcceleratorHandler : public MessageLoop::Dispatcher { // Dispatcher method. This returns true if an accelerator was processed by the // focus manager -#if defined(OS_WIN) - virtual bool Dispatch(const MSG& msg) OVERRIDE; +#if defined(OS_WIN) || defined(USE_AURA) + virtual bool Dispatch(const base::NativeEvent& event) OVERRIDE; #elif defined(OS_MACOSX) // TODO(dhollowa): Implement on Mac. http://crbug.com/109946 -#elif defined(USE_AURA) - virtual base::MessagePumpDispatcher::DispatchStatus Dispatch( - XEvent* xev) OVERRIDE; #endif private: diff --git a/ui/views/focus/accelerator_handler_aura.cc b/ui/views/focus/accelerator_handler_aura.cc index 274de1e..8daa0f39 100644 --- a/ui/views/focus/accelerator_handler_aura.cc +++ b/ui/views/focus/accelerator_handler_aura.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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,21 +9,18 @@ namespace views { AcceleratorHandler::AcceleratorHandler() { } +bool AcceleratorHandler::Dispatch(const base::NativeEvent& event) { #if defined(OS_WIN) -bool AcceleratorHandler::Dispatch(const MSG& msg) { - TranslateMessage(&msg); - DispatchMessage(&msg); + TranslateMessage(&event); + DispatchMessage(&event); +#endif // defined(OS_WIN) return true; } -#else -base::MessagePumpDispatcher::DispatchStatus AcceleratorHandler::Dispatch( - XEvent*) { - return base::MessagePumpDispatcher::EVENT_IGNORED; -} +#if defined(USE_X11) bool DispatchXEvent(XEvent* xev) { return false; } -#endif // defined(OS_WIN) +#endif // defined(USE_X11) } // namespace views diff --git a/ui/views/focus/accelerator_handler_win.cc b/ui/views/focus/accelerator_handler_win.cc index 13c3081..a6b3e59 100644 --- a/ui/views/focus/accelerator_handler_win.cc +++ b/ui/views/focus/accelerator_handler_win.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -15,9 +15,7 @@ namespace views { AcceleratorHandler::AcceleratorHandler() { } -bool AcceleratorHandler::Dispatch(const MSG& msg) { - bool process_message = true; - +bool AcceleratorHandler::Dispatch(const base::NativeEvent& msg) { if (msg.message >= WM_KEYFIRST && msg.message <= WM_KEYLAST) { Widget* widget = Widget::GetTopLevelWidgetForNativeView(msg.hwnd); FocusManager* focus_manager = widget ? widget->GetFocusManager() : NULL; @@ -26,11 +24,11 @@ bool AcceleratorHandler::Dispatch(const MSG& msg) { case WM_KEYDOWN: case WM_SYSKEYDOWN: { KeyEvent event(msg); - process_message = focus_manager->OnKeyEvent(event); - if (!process_message) { + if (!focus_manager->OnKeyEvent(event)) { // Record that this key is pressed so we can remember not to // translate and dispatch the associated WM_KEYUP. pressed_keys_.insert(msg.wParam); + return true; } break; } @@ -49,11 +47,8 @@ bool AcceleratorHandler::Dispatch(const MSG& msg) { } } - if (process_message) { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - + TranslateMessage(&msg); + DispatchMessage(&msg); return true; } |