diff options
26 files changed, 199 insertions, 381 deletions
diff --git a/ash/cancel_mode.cc b/ash/cancel_mode.cc index 9d5456da..96d7dcd 100644 --- a/ash/cancel_mode.cc +++ b/ash/cancel_mode.cc @@ -15,7 +15,7 @@ void DispatchCancelMode() { Shell::GetAllRootWindowControllers()); for (Shell::RootWindowControllerList::const_iterator i = controllers.begin(); i != controllers.end(); ++i) { - (*i)->host()->dispatcher()->AsWindowTreeHostDelegate()->OnHostCancelMode(); + (*i)->host()->dispatcher()->DispatchCancelModeEvent(); } } diff --git a/ash/cancel_mode.h b/ash/cancel_mode.h index 915fe43..d3c3669 100644 --- a/ash/cancel_mode.h +++ b/ash/cancel_mode.h @@ -7,7 +7,7 @@ namespace ash { -// Sends OnHostCancelMode() to all RootWindows. +// Sends a CancelMode event to all window hierarchies. void DispatchCancelMode(); } // namespace ash diff --git a/ash/first_run/desktop_cleaner.cc b/ash/first_run/desktop_cleaner.cc index 9e6da0ff..8008cda 100644 --- a/ash/first_run/desktop_cleaner.cc +++ b/ash/first_run/desktop_cleaner.cc @@ -8,6 +8,7 @@ #include "ash/shell_window_ids.h" #include "ui/aura/window_event_dispatcher.h" #include "ui/aura/window_observer.h" +#include "ui/compositor/layer_animation_observer.h" #include "ui/compositor/scoped_layer_animation_settings.h" #include "ui/message_center/message_center.h" #include "ui/message_center/notification_blocker.h" diff --git a/ash/sticky_keys/sticky_keys_overlay_unittest.cc b/ash/sticky_keys/sticky_keys_overlay_unittest.cc index 5d13f31..246481d 100644 --- a/ash/sticky_keys/sticky_keys_overlay_unittest.cc +++ b/ash/sticky_keys/sticky_keys_overlay_unittest.cc @@ -9,7 +9,6 @@ #include "ash/test/ash_test_base.h" #include "base/memory/scoped_ptr.h" #include "ui/aura/window_event_dispatcher.h" -#include "ui/aura/window_tree_host_delegate.h" #include "ui/events/event.h" namespace ash { diff --git a/ash/sticky_keys/sticky_keys_unittest.cc b/ash/sticky_keys/sticky_keys_unittest.cc index 6da0984..e552c22 100644 --- a/ash/sticky_keys/sticky_keys_unittest.cc +++ b/ash/sticky_keys/sticky_keys_unittest.cc @@ -16,7 +16,6 @@ #include "base/memory/scoped_vector.h" #include "ui/aura/window.h" #include "ui/aura/window_event_dispatcher.h" -#include "ui/aura/window_tree_host_delegate.h" #include "ui/events/event_handler.h" #include "ui/events/test/events_test_utils_x11.h" #include "ui/events/x/device_data_manager.h" diff --git a/ash/wm/overview/window_overview.cc b/ash/wm/overview/window_overview.cc index f2a4b86..34d4dc4 100644 --- a/ash/wm/overview/window_overview.cc +++ b/ash/wm/overview/window_overview.cc @@ -19,6 +19,7 @@ #include "ui/aura/client/cursor_client.h" #include "ui/aura/window.h" #include "ui/aura/window_event_dispatcher.h" +#include "ui/compositor/layer_animation_observer.h" #include "ui/compositor/scoped_layer_animation_settings.h" #include "ui/events/event.h" #include "ui/views/background.h" diff --git a/chrome/browser/ui/views/omnibox/omnibox_view_views_browsertest.cc b/chrome/browser/ui/views/omnibox/omnibox_view_views_browsertest.cc index 905747f..7081677 100644 --- a/chrome/browser/ui/views/omnibox/omnibox_view_views_browsertest.cc +++ b/chrome/browser/ui/views/omnibox/omnibox_view_views_browsertest.cc @@ -22,7 +22,6 @@ #include "ui/aura/test/event_generator.h" #include "ui/aura/window.h" #include "ui/aura/window_event_dispatcher.h" -#include "ui/aura/window_tree_host_delegate.h" #endif // defined(USE_AURA) class OmniboxViewViewsTest : public InProcessBrowserTest { diff --git a/mojo/examples/aura_demo/window_tree_host_mojo.cc b/mojo/examples/aura_demo/window_tree_host_mojo.cc index 266d923..815cce66 100644 --- a/mojo/examples/aura_demo/window_tree_host_mojo.cc +++ b/mojo/examples/aura_demo/window_tree_host_mojo.cc @@ -10,7 +10,7 @@ #include "mojo/services/native_viewport/geometry_conversions.h" #include "ui/aura/env.h" #include "ui/aura/window.h" -#include "ui/aura/window_tree_host_delegate.h" +#include "ui/aura/window_event_dispatcher.h" #include "ui/compositor/compositor.h" #include "ui/events/event.h" #include "ui/events/event_constants.h" @@ -148,7 +148,7 @@ void WindowTreeHostMojo::OnCursorVisibilityChangedNative(bool show) { // WindowTreeHostMojo, ui::EventSource implementation: ui::EventProcessor* WindowTreeHostMojo::GetEventProcessor() { - return delegate_->GetEventProcessor(); + return dispatcher(); } //////////////////////////////////////////////////////////////////////////////// @@ -162,8 +162,7 @@ void WindowTreeHostMojo::OnCreated() { void WindowTreeHostMojo::OnBoundsChanged(const Rect& bounds) { bounds_ = gfx::Rect(bounds.position().x(), bounds.position().y(), bounds.size().width(), bounds.size().height()); - if (delegate_) - window()->SetBounds(gfx::Rect(bounds_.size())); + window()->SetBounds(gfx::Rect(bounds_.size())); OnHostResized(bounds_.size()); } diff --git a/ui/app_list/views/app_list_view.cc b/ui/app_list/views/app_list_view.cc index b1f15f4..cab7fd5 100644 --- a/ui/app_list/views/app_list_view.cc +++ b/ui/app_list/views/app_list_view.cc @@ -23,6 +23,7 @@ #include "ui/app_list/views/speech_view.h" #include "ui/base/ui_base_switches.h" #include "ui/compositor/layer.h" +#include "ui/compositor/layer_animation_observer.h" #include "ui/compositor/scoped_layer_animation_settings.h" #include "ui/gfx/image/image_skia.h" #include "ui/gfx/insets.h" diff --git a/ui/aura/aura.gyp b/ui/aura/aura.gyp index f3de1fb..3453031 100644 --- a/ui/aura/aura.gyp +++ b/ui/aura/aura.gyp @@ -107,7 +107,6 @@ 'window_tracker.h', 'window_tree_host.cc', 'window_tree_host.h', - 'window_tree_host_delegate.h', 'window_tree_host_mac.mm', 'window_tree_host_mac.h', 'window_tree_host_observer.h', diff --git a/ui/aura/remote_window_tree_host_win.cc b/ui/aura/remote_window_tree_host_win.cc index 7669fae..17ef1b2 100644 --- a/ui/aura/remote_window_tree_host_win.cc +++ b/ui/aura/remote_window_tree_host_win.cc @@ -489,7 +489,7 @@ void RemoteWindowTreeHostWin::PrepareForShutdown() { } ui::EventProcessor* RemoteWindowTreeHostWin::GetEventProcessor() { - return delegate_->GetEventProcessor(); + return dispatcher(); } void RemoteWindowTreeHostWin::CancelComposition() { @@ -591,7 +591,7 @@ void RemoteWindowTreeHostWin::OnChar(uint32 key_code, } void RemoteWindowTreeHostWin::OnWindowActivated() { - delegate_->OnHostActivated(); + OnHostActivated(); } void RemoteWindowTreeHostWin::OnEdgeGesture() { diff --git a/ui/aura/remote_window_tree_host_win.h b/ui/aura/remote_window_tree_host_win.h index 6ccd06c..ab03b26 100644 --- a/ui/aura/remote_window_tree_host_win.h +++ b/ui/aura/remote_window_tree_host_win.h @@ -247,7 +247,7 @@ class AURA_EXPORT RemoteWindowTreeHostWin const std::vector<gfx::Rect>& composition_character_bounds) OVERRIDE; // Helper function to dispatch a keyboard message to the desired target. - // The default target is the WindowTreeHostDelegate. For nested message loop + // The default target is the WindowEventDispatcher. For nested message loop // invocations we post a synthetic keyboard message directly into the message // loop. The dispatcher for the nested loop would then decide how this // message is routed. diff --git a/ui/aura/window_event_dispatcher.cc b/ui/aura/window_event_dispatcher.cc index c317e15..b6a8dcd 100644 --- a/ui/aura/window_event_dispatcher.cc +++ b/ui/aura/window_event_dispatcher.cc @@ -4,10 +4,7 @@ #include "ui/aura/window_event_dispatcher.h" -#include <vector> - #include "base/bind.h" -#include "base/command_line.h" #include "base/debug/trace_event.h" #include "base/logging.h" #include "base/message_loop/message_loop.h" @@ -24,14 +21,9 @@ #include "ui/aura/window_tree_host.h" #include "ui/base/hit_test.h" #include "ui/compositor/dip_util.h" -#include "ui/compositor/layer.h" -#include "ui/compositor/layer_animator.h" #include "ui/events/event.h" #include "ui/events/gestures/gesture_recognizer.h" #include "ui/events/gestures/gesture_types.h" -#include "ui/gfx/screen.h" - -using std::vector; typedef ui::EventDispatchDetails DispatchDetails; @@ -129,10 +121,6 @@ void WindowEventDispatcher::RepostEvent(const ui::LocatedEvent& event) { } } -WindowTreeHostDelegate* WindowEventDispatcher::AsWindowTreeHostDelegate() { - return this; -} - void WindowEventDispatcher::OnMouseEventsEnableStateChanged(bool enabled) { // Send entered / exited so that visual state can be updated to match // mouse events state. @@ -140,6 +128,17 @@ void WindowEventDispatcher::OnMouseEventsEnableStateChanged(bool enabled) { // TODO(mazda): Add code to disable mouse events when |enabled| == false. } +void WindowEventDispatcher::DispatchCancelModeEvent() { + ui::CancelModeEvent event; + Window* focused_window = client::GetFocusClient(window())->GetFocusedWindow(); + if (focused_window && !window()->Contains(focused_window)) + focused_window = NULL; + DispatchDetails details = + DispatchEvent(focused_window ? focused_window : window(), &event); + if (details.dispatcher_destroyed) + return; +} + Window* WindowEventDispatcher::GetGestureTarget(ui::GestureEvent* event) { Window* target = NULL; if (!event->IsEndingEvent()) { @@ -275,6 +274,34 @@ gfx::Point WindowEventDispatcher::GetLastMouseLocationInRoot() const { return location; } +void WindowEventDispatcher::OnHostLostMouseGrab() { + mouse_pressed_handler_ = NULL; + mouse_moved_handler_ = NULL; +} + +void WindowEventDispatcher::OnHostResized(const gfx::Size& size) { + TRACE_EVENT1("ui", "WindowEventDispatcher::OnHostResized", + "size", size.ToString()); + + DispatchDetails details = DispatchHeldEvents(); + if (details.dispatcher_destroyed) + return; + + // Constrain the mouse position within the new root Window size. + gfx::Point point; + if (host_->QueryMouseLocation(&point)) { + SetLastMouseLocation(window(), + ui::ConvertPointToDIP(window()->layer(), point)); + } + synthesize_mouse_move_ = false; +} + +void WindowEventDispatcher::OnCursorMovedToRootLocation( + const gfx::Point& root_location) { + SetLastMouseLocation(window(), root_location); + synthesize_mouse_move_ = false; +} + //////////////////////////////////////////////////////////////////////////////// // WindowEventDispatcher, private: @@ -556,86 +583,6 @@ void WindowEventDispatcher::DispatchCancelTouchEvent(ui::TouchEvent* event) { } //////////////////////////////////////////////////////////////////////////////// -// WindowEventDispatcher, ui::LayerAnimationObserver implementation: - -void WindowEventDispatcher::OnLayerAnimationEnded( - ui::LayerAnimationSequence* animation) { - host()->UpdateRootWindowSize(host_->GetBounds().size()); -} - -void WindowEventDispatcher::OnLayerAnimationScheduled( - ui::LayerAnimationSequence* animation) { -} - -void WindowEventDispatcher::OnLayerAnimationAborted( - ui::LayerAnimationSequence* animation) { -} - -//////////////////////////////////////////////////////////////////////////////// -// WindowEventDispatcher, WindowTreeHostDelegate implementation: - -void WindowEventDispatcher::OnHostCancelMode() { - ui::CancelModeEvent event; - Window* focused_window = client::GetFocusClient(window())->GetFocusedWindow(); - if (focused_window && !window()->Contains(focused_window)) - focused_window = NULL; - DispatchDetails details = - DispatchEvent(focused_window ? focused_window : window(), &event); - if (details.dispatcher_destroyed) - return; -} - -void WindowEventDispatcher::OnHostActivated() { - Env::GetInstance()->RootWindowActivated(this); -} - -void WindowEventDispatcher::OnHostLostWindowCapture() { - Window* capture_window = client::GetCaptureWindow(window()); - if (capture_window && capture_window->GetRootWindow() == window()) - capture_window->ReleaseCapture(); -} - -void WindowEventDispatcher::OnHostLostMouseGrab() { - mouse_pressed_handler_ = NULL; - mouse_moved_handler_ = NULL; -} - -void WindowEventDispatcher::OnHostResized(const gfx::Size& size) { - TRACE_EVENT1("ui", "WindowEventDispatcher::OnHostResized", - "size", size.ToString()); - - DispatchDetails details = DispatchHeldEvents(); - if (details.dispatcher_destroyed) - return; - - // Constrain the mouse position within the new root Window size. - gfx::Point point; - if (host_->QueryMouseLocation(&point)) { - SetLastMouseLocation(window(), - ui::ConvertPointToDIP(window()->layer(), point)); - } - synthesize_mouse_move_ = false; -} - -void WindowEventDispatcher::OnCursorMovedToRootLocation( - const gfx::Point& root_location) { - SetLastMouseLocation(window(), root_location); - synthesize_mouse_move_ = false; -} - -WindowEventDispatcher* WindowEventDispatcher::AsDispatcher() { - return this; -} - -const WindowEventDispatcher* WindowEventDispatcher::AsDispatcher() const { - return this; -} - -ui::EventProcessor* WindowEventDispatcher::GetEventProcessor() { - return this; -} - -//////////////////////////////////////////////////////////////////////////////// // WindowEventDispatcher, private: ui::EventDispatchDetails WindowEventDispatcher::DispatchHeldEvents() { diff --git a/ui/aura/window_event_dispatcher.h b/ui/aura/window_event_dispatcher.h index 9fe917b..7ea3d60 100644 --- a/ui/aura/window_event_dispatcher.h +++ b/ui/aura/window_event_dispatcher.h @@ -16,10 +16,7 @@ #include "ui/aura/aura_export.h" #include "ui/aura/client/capture_delegate.h" #include "ui/aura/window_tree_host.h" -#include "ui/aura/window_tree_host_delegate.h" #include "ui/base/cursor/cursor.h" -#include "ui/compositor/compositor.h" -#include "ui/compositor/layer_animation_observer.h" #include "ui/events/event_constants.h" #include "ui/events/event_processor.h" #include "ui/events/event_targeter.h" @@ -37,7 +34,6 @@ namespace ui { class GestureEvent; class GestureRecognizer; class KeyEvent; -class LayerAnimationSequence; class MouseEvent; class ScrollEvent; class TouchEvent; @@ -54,9 +50,7 @@ class WindowTargeter; // event dispatch. class AURA_EXPORT WindowEventDispatcher : public ui::EventProcessor, public ui::GestureEventHelper, - public ui::LayerAnimationObserver, - public client::CaptureDelegate, - public WindowTreeHostDelegate { + public client::CaptureDelegate { public: explicit WindowEventDispatcher(WindowTreeHost* host); virtual ~WindowEventDispatcher(); @@ -79,11 +73,11 @@ class AURA_EXPORT WindowEventDispatcher : public ui::EventProcessor, // types (although the latter is currently a no-op). void RepostEvent(const ui::LocatedEvent& event); - WindowTreeHostDelegate* AsWindowTreeHostDelegate(); - // Invoked when the mouse events get enabled or disabled. void OnMouseEventsEnableStateChanged(bool enabled); + void DispatchCancelModeEvent(); + // Returns a target window for the given gesture event. Window* GetGestureTarget(ui::GestureEvent* event); @@ -139,6 +133,11 @@ class AURA_EXPORT WindowEventDispatcher : public ui::EventProcessor, // coordinates. This may return a point outside the root window's bounds. gfx::Point GetLastMouseLocationInRoot() const; + void OnHostLostMouseGrab(); + // TODO(beng): replace with a window observer. + void OnHostResized(const gfx::Size& size); + void OnCursorMovedToRootLocation(const gfx::Point& root_location); + private: FRIEND_TEST_ALL_PREFIXES(WindowEventDispatcherTest, KeepTranslatedEventInRoot); @@ -155,7 +154,7 @@ class AURA_EXPORT WindowEventDispatcher : public ui::EventProcessor, }; // Updates the event with the appropriate transform for the device scale - // factor. The WindowTreeHostDelegate dispatches events in the physical pixel + // factor. The WindowEventDispatcher dispatches events in the physical pixel // coordinate. But the event processing from WindowEventDispatcher onwards // happen in device-independent pixel coordinate. So it is necessary to update // the event received from the host. @@ -207,26 +206,6 @@ class AURA_EXPORT WindowEventDispatcher : public ui::EventProcessor, virtual void DispatchPostponedGestureEvent(ui::GestureEvent* event) OVERRIDE; virtual void DispatchCancelTouchEvent(ui::TouchEvent* event) OVERRIDE; - // Overridden from ui::LayerAnimationObserver: - virtual void OnLayerAnimationEnded( - ui::LayerAnimationSequence* animation) OVERRIDE; - virtual void OnLayerAnimationScheduled( - ui::LayerAnimationSequence* animation) OVERRIDE; - virtual void OnLayerAnimationAborted( - ui::LayerAnimationSequence* animation) OVERRIDE; - - // Overridden from aura::WindowTreeHostDelegate: - virtual void OnHostCancelMode() OVERRIDE; - virtual void OnHostActivated() OVERRIDE; - virtual void OnHostLostWindowCapture() OVERRIDE; - virtual void OnHostLostMouseGrab() OVERRIDE; - virtual void OnHostResized(const gfx::Size& size) OVERRIDE; - virtual void OnCursorMovedToRootLocation( - const gfx::Point& root_location) OVERRIDE; - virtual WindowEventDispatcher* AsDispatcher() OVERRIDE; - virtual const WindowEventDispatcher* AsDispatcher() const OVERRIDE; - virtual ui::EventProcessor* GetEventProcessor() OVERRIDE; - // We hold and aggregate mouse drags and touch moves as a way of throttling // resizes when HoldMouseMoves() is called. The following methods are used to // dispatch held and newly incoming mouse and touch events, typically when an diff --git a/ui/aura/window_event_dispatcher_unittest.cc b/ui/aura/window_event_dispatcher_unittest.cc index f091110..67866e9 100644 --- a/ui/aura/window_event_dispatcher_unittest.cc +++ b/ui/aura/window_event_dispatcher_unittest.cc @@ -1831,7 +1831,7 @@ TEST_F(WindowEventDispatcherTest, HostCancelModeWithFocusedWindowOutside) { EXPECT_FALSE(root_window()->Contains(focused.get())); EXPECT_EQ(focused.get(), client::GetFocusClient(root_window())->GetFocusedWindow()); - dispatcher()->AsWindowTreeHostDelegate()->OnHostCancelMode(); + dispatcher()->DispatchCancelModeEvent(); EXPECT_EQ(focused.get(), client::GetFocusClient(root_window())->GetFocusedWindow()); } diff --git a/ui/aura/window_tree_host.cc b/ui/aura/window_tree_host.cc index 2f60c7c..93c624b 100644 --- a/ui/aura/window_tree_host.cc +++ b/ui/aura/window_tree_host.cc @@ -5,13 +5,13 @@ #include "ui/aura/window_tree_host.h" #include "base/debug/trace_event.h" +#include "ui/aura/client/capture_client.h" #include "ui/aura/client/cursor_client.h" #include "ui/aura/env.h" #include "ui/aura/root_window_transformer.h" #include "ui/aura/window.h" #include "ui/aura/window_event_dispatcher.h" #include "ui/aura/window_targeter.h" -#include "ui/aura/window_tree_host_delegate.h" #include "ui/aura/window_tree_host_observer.h" #include "ui/base/view_prop.h" #include "ui/compositor/dip_util.h" @@ -84,6 +84,17 @@ WindowTreeHost::~WindowTreeHost() { DCHECK(!compositor_) << "compositor must be destroyed before root window"; } +#if defined(OS_ANDROID) +// static +WindowTreeHost* WindowTreeHost::Create(const gfx::Rect& bounds) { + // This is only hit for tests and ash, right now these aren't an issue so + // adding the CHECK. + // TODO(sky): decide if we want a factory. + CHECK(false); + return NULL; +} +#endif + // static WindowTreeHost* WindowTreeHost::GetForAcceleratedWidget( gfx::AcceleratedWidget widget) { @@ -94,7 +105,7 @@ WindowTreeHost* WindowTreeHost::GetForAcceleratedWidget( void WindowTreeHost::InitHost() { InitCompositor(); UpdateRootWindowSize(GetBounds().size()); - Env::GetInstance()->NotifyRootWindowInitialized(delegate_->AsDispatcher()); + Env::GetInstance()->NotifyRootWindowInitialized(dispatcher()); window()->Show(); } @@ -187,8 +198,8 @@ void WindowTreeHost::OnCursorVisibilityChanged(bool show) { // visible because that can only happen in response to a mouse event, which // will trigger its own mouse enter. if (!show) { - delegate_->AsDispatcher()->DispatchMouseExitAtPoint( - delegate_->AsDispatcher()->GetLastMouseLocationInRoot()); + dispatcher()->DispatchMouseExitAtPoint( + dispatcher()->GetLastMouseLocationInRoot()); } OnCursorVisibilityChangedNative(show); @@ -206,16 +217,11 @@ void WindowTreeHost::MoveCursorToHostLocation(const gfx::Point& host_location) { MoveCursorToInternal(root_location, host_location); } -WindowEventDispatcher* WindowTreeHost::GetDispatcher() { - return delegate_->AsDispatcher(); -} - //////////////////////////////////////////////////////////////////////////////// // WindowTreeHost, protected: WindowTreeHost::WindowTreeHost() - : delegate_(NULL), - window_(new Window(NULL)), + : window_(new Window(NULL)), last_cursor_(ui::kCursorNull) { } @@ -225,10 +231,6 @@ void WindowTreeHost::DestroyCompositor() { } void WindowTreeHost::DestroyDispatcher() { - // An observer may have been added by an animation on the - // WindowEventDispatcher. - window()->layer()->GetAnimator()->RemoveObserver(dispatcher()); - delete window_; window_ = NULL; dispatcher_.reset(); @@ -260,7 +262,6 @@ void WindowTreeHost::CreateCompositor( this)); dispatcher_.reset(new WindowEventDispatcher(this)); } - delegate_ = dispatcher(); } void WindowTreeHost::OnHostMoved(const gfx::Point& new_location) { @@ -282,7 +283,7 @@ void WindowTreeHost::OnHostResized(const gfx::Size& new_size) { // transformed size of the root window. UpdateRootWindowSize(layer_size); FOR_EACH_OBSERVER(WindowTreeHostObserver, observers_, OnHostResized(this)); - delegate_->OnHostResized(layer_size); + dispatcher()->OnHostResized(layer_size); } void WindowTreeHost::OnHostCloseRequested() { @@ -290,6 +291,19 @@ void WindowTreeHost::OnHostCloseRequested() { OnHostCloseRequested(this)); } +void WindowTreeHost::OnHostActivated() { + Env::GetInstance()->RootWindowActivated(dispatcher()); +} + +void WindowTreeHost::OnHostLostWindowCapture() { + Window* capture_window = client::GetCaptureWindow(window()); + if (capture_window && capture_window->GetRootWindow() == window()) + capture_window->ReleaseCapture(); +} + +//////////////////////////////////////////////////////////////////////////////// +// WindowTreeHost, private: + void WindowTreeHost::MoveCursorToInternal(const gfx::Point& root_location, const gfx::Point& host_location) { MoveCursorToNative(host_location); @@ -299,18 +313,7 @@ void WindowTreeHost::MoveCursorToInternal(const gfx::Point& root_location, gfx::Screen::GetScreenFor(window())->GetDisplayNearestWindow(window()); cursor_client->SetDisplay(display); } - delegate_->OnCursorMovedToRootLocation(root_location); + dispatcher()->OnCursorMovedToRootLocation(root_location); } -#if defined(OS_ANDROID) -// static -WindowTreeHost* WindowTreeHost::Create(const gfx::Rect& bounds) { - // This is only hit for tests and ash, right now these aren't an issue so - // adding the CHECK. - // TODO(sky): decide if we want a factory. - CHECK(false); - return NULL; -} -#endif - } // namespace aura diff --git a/ui/aura/window_tree_host.h b/ui/aura/window_tree_host.h index 1c7e3d1..dc2b7c5 100644 --- a/ui/aura/window_tree_host.h +++ b/ui/aura/window_tree_host.h @@ -29,7 +29,6 @@ class ViewProp; namespace aura { class RootWindowTransformer; class WindowEventDispatcher; -class WindowTreeHostDelegate; class WindowTreeHostObserver; // WindowTreeHost bridges between a native window and the embedded RootWindow. @@ -79,10 +78,6 @@ class AURA_EXPORT WindowTreeHost { // (gfx::Screen only reports on the virtual desktop exposed by Aura.) static gfx::Size GetNativeScreenSize(); - void set_delegate(WindowTreeHostDelegate* delegate) { - delegate_ = delegate; - } - // Converts |point| from the root window's coordinate system to native // screen's. void ConvertPointToNativeScreen(gfx::Point* point) const; @@ -116,8 +111,6 @@ class AURA_EXPORT WindowTreeHost { gfx::NativeCursor last_cursor() const { return last_cursor_; } - WindowEventDispatcher* GetDispatcher(); - // Returns the accelerated widget. virtual gfx::AcceleratedWidget GetAcceleratedWidget() = 0; @@ -185,6 +178,8 @@ class AURA_EXPORT WindowTreeHost { void OnHostMoved(const gfx::Point& new_location); void OnHostResized(const gfx::Size& new_size); void OnHostCloseRequested(); + void OnHostActivated(); + void OnHostLostWindowCapture(); // Sets the currently displayed cursor. virtual void SetCursorNative(gfx::NativeCursor cursor) = 0; @@ -195,8 +190,6 @@ class AURA_EXPORT WindowTreeHost { // kCalled when the cursor visibility has changed. virtual void OnCursorVisibilityChangedNative(bool show) = 0; - WindowTreeHostDelegate* delegate_; - private: // Moves the cursor to the specified location. This method is internally used // by MoveCursorTo() and MoveCursorToHostLocation(). diff --git a/ui/aura/window_tree_host_delegate.h b/ui/aura/window_tree_host_delegate.h deleted file mode 100644 index c5ba407..0000000 --- a/ui/aura/window_tree_host_delegate.h +++ /dev/null @@ -1,60 +0,0 @@ -// 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. - -#ifndef UI_AURA_WINDOW_TREE_HOST_DELEGATE_H_ -#define UI_AURA_WINDOW_TREE_HOST_DELEGATE_H_ - -#include "ui/aura/aura_export.h" - -namespace gfx { -class Point; -class Rect; -class Size; -} - -namespace ui { -class Event; -class EventProcessor; -class KeyEvent; -class MouseEvent; -class ScrollEvent; -class TouchEvent; -} - -namespace aura { - -class RootWindow; - -// A private interface used by WindowTreeHost implementations to communicate -// with their owning RootWindow. -class AURA_EXPORT WindowTreeHostDelegate { - public: - virtual void OnHostCancelMode() = 0; - - // Called when the windowing system activates the window. - virtual void OnHostActivated() = 0; - - // Called when system focus is changed to another window. - virtual void OnHostLostWindowCapture() = 0; - - // Called when the windowing system has mouse grab because it's performing a - // window move on our behalf, but we should still paint as if we're active. - virtual void OnHostLostMouseGrab() = 0; - - virtual void OnHostResized(const gfx::Size& size) = 0; - - virtual void OnCursorMovedToRootLocation(const gfx::Point& root_location) = 0; - - virtual WindowEventDispatcher* AsDispatcher() = 0; - virtual const WindowEventDispatcher* AsDispatcher() const = 0; - - virtual ui::EventProcessor* GetEventProcessor() = 0; - - protected: - virtual ~WindowTreeHostDelegate() {} -}; - -} // namespace aura - -#endif // UI_AURA_WINDOW_TREE_HOST_DELEGATE_H_ diff --git a/ui/aura/window_tree_host_mac.mm b/ui/aura/window_tree_host_mac.mm index b814f03..e75875b 100644 --- a/ui/aura/window_tree_host_mac.mm +++ b/ui/aura/window_tree_host_mac.mm @@ -6,7 +6,6 @@ #include "ui/aura/window_tree_host_mac.h" #include "ui/aura/window_tree_host.h" -#include "ui/aura/window_tree_host_delegate.h" namespace aura { diff --git a/ui/aura/window_tree_host_ozone.cc b/ui/aura/window_tree_host_ozone.cc index a2c6f3b..ea9c45b 100644 --- a/ui/aura/window_tree_host_ozone.cc +++ b/ui/aura/window_tree_host_ozone.cc @@ -110,7 +110,7 @@ void WindowTreeHostOzone::OnCursorVisibilityChangedNative(bool show) { } ui::EventProcessor* WindowTreeHostOzone::GetEventProcessor() { - return delegate_->GetEventProcessor(); + return dispatcher(); } // static diff --git a/ui/aura/window_tree_host_win.cc b/ui/aura/window_tree_host_win.cc index eb3af31..cddc5b3 100644 --- a/ui/aura/window_tree_host_win.cc +++ b/ui/aura/window_tree_host_win.cc @@ -13,6 +13,7 @@ #include "ui/aura/window_event_dispatcher.h" #include "ui/base/cursor/cursor_loader_win.h" #include "ui/base/view_prop.h" +#include "ui/compositor/compositor.h" #include "ui/events/event.h" #include "ui/gfx/display.h" #include "ui/gfx/insets.h" @@ -134,9 +135,8 @@ void WindowTreeHostWin::SetBounds(const gfx::Rect& bounds) { // Explicity call OnHostResized when the scale has changed because // the window size may not have changed. float current_scale = compositor()->device_scale_factor(); - float new_scale = gfx::Screen::GetScreenFor( - delegate_->AsDispatcher()->window())->GetDisplayNearestWindow( - delegate_->AsDispatcher()->window()).device_scale_factor(); + float new_scale = gfx::Screen::GetScreenFor(window())-> + GetDisplayNearestWindow(window()).device_scale_factor(); if (current_scale != new_scale) OnHostResized(bounds.size()); } @@ -230,7 +230,7 @@ void WindowTreeHostWin::PrepareForShutdown() { } ui::EventProcessor* WindowTreeHostWin::GetEventProcessor() { - return delegate_->GetEventProcessor(); + return dispatcher(); } void WindowTreeHostWin::OnClose() { @@ -268,7 +268,7 @@ LRESULT WindowTreeHostWin::OnCaptureChanged(UINT message, LPARAM l_param) { if (has_capture_) { has_capture_ = false; - delegate_->OnHostLostWindowCapture(); + OnHostLostWindowCapture(); } return 0; } @@ -277,7 +277,7 @@ LRESULT WindowTreeHostWin::OnNCActivate(UINT message, WPARAM w_param, LPARAM l_param) { if (!!w_param) - delegate_->OnHostActivated(); + OnHostActivated(); return DefWindowProc(hwnd(), message, w_param, l_param); } @@ -297,7 +297,7 @@ void WindowTreeHostWin::OnPaint(HDC dc) { void WindowTreeHostWin::OnSize(UINT param, const gfx::Size& size) { // Minimizing resizes the window to 0x0 which causes our layout to go all // screwy, so we just ignore it. - if (delegate_ && param != SIZE_MINIMIZED) + if (param != SIZE_MINIMIZED) OnHostResized(size); } diff --git a/ui/aura/window_tree_host_x11.cc b/ui/aura/window_tree_host_x11.cc index 8b0f564..6286742 100644 --- a/ui/aura/window_tree_host_x11.cc +++ b/ui/aura/window_tree_host_x11.cc @@ -36,6 +36,7 @@ #include "ui/base/ui_base_switches.h" #include "ui/base/view_prop.h" #include "ui/base/x/x11_util.h" +#include "ui/compositor/compositor.h" #include "ui/compositor/dip_util.h" #include "ui/compositor/layer.h" #include "ui/events/event.h" @@ -403,7 +404,7 @@ uint32_t WindowTreeHostX11::Dispatch(const base::NativeEvent& event) { if (static_cast<int>(xev->xbutton.button) == kBackMouseButton || static_cast<int>(xev->xbutton.button) == kForwardMouseButton) { client::UserActionClient* gesture_client = - client::GetUserActionClient(delegate_->AsDispatcher()->window()); + client::GetUserActionClient(window()); if (gesture_client) { gesture_client->OnUserAction( static_cast<int>(xev->xbutton.button) == kBackMouseButton ? @@ -436,7 +437,7 @@ uint32_t WindowTreeHostX11::Dispatch(const base::NativeEvent& event) { } case FocusOut: if (xev->xfocus.mode != NotifyGrab) - delegate_->OnHostLostWindowCapture(); + OnHostLostWindowCapture(); break; case ConfigureNotify: { DCHECK_EQ(xwindow_, xev->xconfigure.event); @@ -569,9 +570,8 @@ void WindowTreeHostX11::SetBounds(const gfx::Rect& bounds) { // Even if the host window's size doesn't change, aura's root window // size, which is in DIP, changes when the scale changes. float current_scale = compositor()->device_scale_factor(); - float new_scale = gfx::Screen::GetScreenFor( - delegate_->AsDispatcher()->window())->GetDisplayNearestWindow( - delegate_->AsDispatcher()->window()).device_scale_factor(); + float new_scale = gfx::Screen::GetScreenFor(window())-> + GetDisplayNearestWindow(window()).device_scale_factor(); bool origin_changed = bounds_.origin() != bounds.origin(); bool size_changed = bounds_.size() != bounds.size(); XWindowChanges changes = {0}; @@ -603,8 +603,7 @@ void WindowTreeHostX11::SetBounds(const gfx::Rect& bounds) { if (size_changed || current_scale != new_scale) { OnHostResized(bounds.size()); } else { - delegate_->AsDispatcher()->window()->SchedulePaintInRect( - delegate_->AsDispatcher()->window()->bounds()); + window()->SchedulePaintInRect(window()->bounds()); } } @@ -727,7 +726,7 @@ void WindowTreeHostX11::PostNativeEvent( xevent.xmotion.time = CurrentTime; gfx::Point point(xevent.xmotion.x, xevent.xmotion.y); - delegate_->AsDispatcher()->host()->ConvertPointToNativeScreen(&point); + ConvertPointToNativeScreen(&point); xevent.xmotion.x_root = point.x(); xevent.xmotion.y_root = point.y(); } @@ -767,14 +766,11 @@ void WindowTreeHostX11::OnWindowInitialized(Window* window) { void WindowTreeHostX11::OnRootWindowInitialized( WindowEventDispatcher* d) { - // UpdateIsInternalDisplay relies on: - // 1. delegate_ pointing to WindowEventDispatcher - available after - // SetDelegate. - // 2. WED's kDisplayIdKey property set - available by the time - // WED::Init is called. - // (set in DisplayManager::CreateRootWindowForDisplay) + // UpdateIsInternalDisplay relies on WED's kDisplayIdKey property being set + // available by the time WED::Init is called. (set in + // DisplayManager::CreateRootWindowForDisplay) // Ready when NotifyRootWindowInitialized is called from WED::Init. - if (!delegate_ || d != dispatcher()) + if (d != dispatcher()) return; UpdateIsInternalDisplay(); @@ -784,7 +780,7 @@ void WindowTreeHostX11::OnRootWindowInitialized( } ui::EventProcessor* WindowTreeHostX11::GetEventProcessor() { - return delegate_->GetEventProcessor(); + return dispatcher(); } void WindowTreeHostX11::DispatchXI2Event(const base::NativeEvent& event) { @@ -874,7 +870,7 @@ void WindowTreeHostX11::DispatchXI2Event(const base::NativeEvent& event) { if (type == ui::ET_MOUSE_RELEASED) break; client::UserActionClient* gesture_client = - client::GetUserActionClient(delegate_->AsDispatcher()->window()); + client::GetUserActionClient(window()); if (gesture_client) { bool reverse_direction = ui::IsTouchpadEvent(xev) && ui::IsNaturalScrollEnabled(); diff --git a/ui/aura/window_tree_host_x11.h b/ui/aura/window_tree_host_x11.h index 99dbcd3..c116094 100644 --- a/ui/aura/window_tree_host_x11.h +++ b/ui/aura/window_tree_host_x11.h @@ -90,7 +90,7 @@ class AURA_EXPORT WindowTreeHostX11 : public WindowTreeHost, void SetCursorInternal(gfx::NativeCursor cursor); // Translates the native mouse location into screen coordinates and and - // dispatches the event to WindowTreeHostDelegate. + // dispatches the event via WindowEventDispatcher. void TranslateAndDispatchMouseEvent(ui::MouseEvent* event); // Update is_internal_display_ based on delegate_ state diff --git a/ui/aura/window_tree_host_x11_unittest.cc b/ui/aura/window_tree_host_x11_unittest.cc index c1e5579..0deb034 100644 --- a/ui/aura/window_tree_host_x11_unittest.cc +++ b/ui/aura/window_tree_host_x11_unittest.cc @@ -6,8 +6,8 @@ #include "base/sys_info.h" #include "testing/gtest/include/gtest/gtest.h" #include "ui/aura/test/aura_test_base.h" +#include "ui/aura/window.h" #include "ui/aura/window_event_dispatcher.h" -#include "ui/aura/window_tree_host_delegate.h" #include "ui/aura/window_tree_host_x11.h" #include "ui/events/event_processor.h" #include "ui/events/event_target.h" @@ -15,37 +15,14 @@ #include "ui/events/test/events_test_utils_x11.h" namespace { -class TestWindowTreeHostDelegate : public aura::WindowTreeHostDelegate, - public ui::EventProcessor, - public ui::EventTarget { - public: - TestWindowTreeHostDelegate() : last_touch_type_(ui::ET_UNKNOWN), - last_touch_id_(-1), - last_touch_location_(0, 0) { - } - virtual ~TestWindowTreeHostDelegate() {} - - // aura::WindowTreeHostDelegate: - virtual void OnHostCancelMode() OVERRIDE {} - virtual void OnHostActivated() OVERRIDE {} - virtual void OnHostLostWindowCapture() OVERRIDE {} - virtual void OnHostLostMouseGrab() OVERRIDE {} - virtual void OnHostResized(const gfx::Size& size) OVERRIDE {} - virtual void OnCursorMovedToRootLocation( - const gfx::Point& root_location) OVERRIDE {} - virtual aura::WindowEventDispatcher* AsDispatcher() OVERRIDE { return NULL; } - virtual const aura::WindowEventDispatcher* AsDispatcher() const OVERRIDE { - return NULL; - } - virtual ui::EventProcessor* GetEventProcessor() OVERRIDE { - return this; - } - // ui::EventProcessor: - virtual ui::EventTarget* GetRootTarget() OVERRIDE { return this; } - virtual bool CanDispatchToTarget(ui::EventTarget* target) OVERRIDE { - return true; +class RootWindowEventHandler : public ui::EventHandler { + public: + RootWindowEventHandler() : last_touch_type_(ui::ET_UNKNOWN), + last_touch_id_(-1), + last_touch_location_(0, 0) { } + virtual ~RootWindowEventHandler () {} // ui::EventHandler: virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE { @@ -54,17 +31,6 @@ class TestWindowTreeHostDelegate : public aura::WindowTreeHostDelegate, last_touch_location_ = event->location(); } - // ui::EventTarget: - virtual bool CanAcceptEvent(const ui::Event& event) OVERRIDE { - return true; - } - virtual ui::EventTarget* GetParentTarget() OVERRIDE { return NULL; } - virtual scoped_ptr<ui::EventTargetIterator> - GetChildIterator() const OVERRIDE { - return scoped_ptr<ui::EventTargetIterator>(); - } - virtual ui::EventTargeter* GetEventTargeter() OVERRIDE { return &targeter_; } - ui::EventType last_touch_type() { return last_touch_type_; } @@ -81,9 +47,8 @@ class TestWindowTreeHostDelegate : public aura::WindowTreeHostDelegate, ui::EventType last_touch_type_; int last_touch_id_; gfx::Point last_touch_location_; - ui::EventTargeter targeter_; - DISALLOW_COPY_AND_ASSIGN(TestWindowTreeHostDelegate); + DISALLOW_COPY_AND_ASSIGN(RootWindowEventHandler); }; } // namespace @@ -104,17 +69,17 @@ TEST_F(WindowTreeHostX11Test, DispatchTouchEventToOneRootWindow) { scoped_ptr<WindowTreeHostX11> window_tree_host( new WindowTreeHostX11(gfx::Rect(0, 0, 2560, 1700))); - scoped_ptr<TestWindowTreeHostDelegate> delegate( - new TestWindowTreeHostDelegate()); - window_tree_host->set_delegate(delegate.get()); + window_tree_host->InitHost(); + scoped_ptr<RootWindowEventHandler> handler(new RootWindowEventHandler()); + window_tree_host->window()->AddPreTargetHandler(handler.get()); std::vector<unsigned int> devices; devices.push_back(0); ui::SetUpTouchDevicesForTest(devices); std::vector<ui::Valuator> valuators; - EXPECT_EQ(ui::ET_UNKNOWN, delegate->last_touch_type()); - EXPECT_EQ(-1, delegate->last_touch_id()); + EXPECT_EQ(ui::ET_UNKNOWN, handler->last_touch_type()); + EXPECT_EQ(-1, handler->last_touch_id()); ui::ScopedXI2Event scoped_xevent; #if defined(OS_CHROMEOS) @@ -122,32 +87,32 @@ TEST_F(WindowTreeHostX11Test, DispatchTouchEventToOneRootWindow) { scoped_xevent.InitTouchEvent( 0, XI_TouchBegin, 5, gfx::Point(1500, 2500), valuators); window_tree_host->Dispatch(scoped_xevent); - EXPECT_EQ(ui::ET_UNKNOWN, delegate->last_touch_type()); - EXPECT_EQ(-1, delegate->last_touch_id()); - EXPECT_EQ(gfx::Point(0, 0), delegate->last_touch_location()); + EXPECT_EQ(ui::ET_UNKNOWN, handler->last_touch_type()); + EXPECT_EQ(-1, handler->last_touch_id()); + EXPECT_EQ(gfx::Point(0, 0), handler->last_touch_location()); #endif // defined(OS_CHROMEOS) // Following touchs are within bounds and are passed to delegate. scoped_xevent.InitTouchEvent( 0, XI_TouchBegin, 5, gfx::Point(1500, 1500), valuators); window_tree_host->Dispatch(scoped_xevent); - EXPECT_EQ(ui::ET_TOUCH_PRESSED, delegate->last_touch_type()); - EXPECT_EQ(0, delegate->last_touch_id()); - EXPECT_EQ(gfx::Point(1500, 1500), delegate->last_touch_location()); + EXPECT_EQ(ui::ET_TOUCH_PRESSED, handler->last_touch_type()); + EXPECT_EQ(0, handler->last_touch_id()); + EXPECT_EQ(gfx::Point(1500, 1500), handler->last_touch_location()); scoped_xevent.InitTouchEvent( 0, XI_TouchUpdate, 5, gfx::Point(1500, 1600), valuators); window_tree_host->Dispatch(scoped_xevent); - EXPECT_EQ(ui::ET_TOUCH_MOVED, delegate->last_touch_type()); - EXPECT_EQ(0, delegate->last_touch_id()); - EXPECT_EQ(gfx::Point(1500, 1600), delegate->last_touch_location()); + EXPECT_EQ(ui::ET_TOUCH_MOVED, handler->last_touch_type()); + EXPECT_EQ(0, handler->last_touch_id()); + EXPECT_EQ(gfx::Point(1500, 1600), handler->last_touch_location()); scoped_xevent.InitTouchEvent( 0, XI_TouchEnd, 5, gfx::Point(1500, 1600), valuators); window_tree_host->Dispatch(scoped_xevent); - EXPECT_EQ(ui::ET_TOUCH_RELEASED, delegate->last_touch_type()); - EXPECT_EQ(0, delegate->last_touch_id()); - EXPECT_EQ(gfx::Point(1500, 1600), delegate->last_touch_location()); + EXPECT_EQ(ui::ET_TOUCH_RELEASED, handler->last_touch_type()); + EXPECT_EQ(0, handler->last_touch_id()); + EXPECT_EQ(gfx::Point(1500, 1600), handler->last_touch_location()); // Revert the CrOS testing env otherwise the following non-CrOS aura // tests will fail. @@ -169,26 +134,26 @@ TEST_F(WindowTreeHostX11Test, DispatchTouchEventToTwoRootWindow) { scoped_ptr<WindowTreeHostX11> window_tree_host1( new WindowTreeHostX11(gfx::Rect(0, 0, 2560, 1700))); - scoped_ptr<TestWindowTreeHostDelegate> delegate1( - new TestWindowTreeHostDelegate()); - window_tree_host1->set_delegate(delegate1.get()); + window_tree_host1->InitHost(); + scoped_ptr<RootWindowEventHandler> handler1(new RootWindowEventHandler()); + window_tree_host1->window()->AddPreTargetHandler(handler1.get()); int host2_y_offset = 1700; scoped_ptr<WindowTreeHostX11> window_tree_host2( new WindowTreeHostX11(gfx::Rect(0, host2_y_offset, 1920, 1080))); - scoped_ptr<TestWindowTreeHostDelegate> delegate2( - new TestWindowTreeHostDelegate()); - window_tree_host2->set_delegate(delegate2.get()); + window_tree_host2->InitHost(); + scoped_ptr<RootWindowEventHandler> handler2(new RootWindowEventHandler()); + window_tree_host2->window()->AddPreTargetHandler(handler2.get()); std::vector<unsigned int> devices; devices.push_back(0); ui::SetUpTouchDevicesForTest(devices); std::vector<ui::Valuator> valuators; - EXPECT_EQ(ui::ET_UNKNOWN, delegate1->last_touch_type()); - EXPECT_EQ(-1, delegate1->last_touch_id()); - EXPECT_EQ(ui::ET_UNKNOWN, delegate2->last_touch_type()); - EXPECT_EQ(-1, delegate2->last_touch_id()); + EXPECT_EQ(ui::ET_UNKNOWN, handler1->last_touch_type()); + EXPECT_EQ(-1, handler1->last_touch_id()); + EXPECT_EQ(ui::ET_UNKNOWN, handler2->last_touch_type()); + EXPECT_EQ(-1, handler2->last_touch_id()); // 2 Touch events are targeted at the second WindowTreeHost. ui::ScopedXI2Event scoped_xevent; @@ -196,73 +161,73 @@ TEST_F(WindowTreeHostX11Test, DispatchTouchEventToTwoRootWindow) { 0, XI_TouchBegin, 5, gfx::Point(1500, 2500), valuators); window_tree_host1->Dispatch(scoped_xevent); window_tree_host2->Dispatch(scoped_xevent); - EXPECT_EQ(ui::ET_UNKNOWN, delegate1->last_touch_type()); - EXPECT_EQ(-1, delegate1->last_touch_id()); - EXPECT_EQ(gfx::Point(0, 0), delegate1->last_touch_location()); - EXPECT_EQ(ui::ET_TOUCH_PRESSED, delegate2->last_touch_type()); - EXPECT_EQ(0, delegate2->last_touch_id()); + EXPECT_EQ(ui::ET_UNKNOWN, handler1->last_touch_type()); + EXPECT_EQ(-1, handler1->last_touch_id()); + EXPECT_EQ(gfx::Point(0, 0), handler1->last_touch_location()); + EXPECT_EQ(ui::ET_TOUCH_PRESSED, handler2->last_touch_type()); + EXPECT_EQ(0, handler2->last_touch_id()); EXPECT_EQ(gfx::Point(1500, 2500 - host2_y_offset), - delegate2->last_touch_location()); + handler2->last_touch_location()); scoped_xevent.InitTouchEvent( 0, XI_TouchBegin, 6, gfx::Point(1600, 2600), valuators); window_tree_host1->Dispatch(scoped_xevent); window_tree_host2->Dispatch(scoped_xevent); - EXPECT_EQ(ui::ET_UNKNOWN, delegate1->last_touch_type()); - EXPECT_EQ(-1, delegate1->last_touch_id()); - EXPECT_EQ(gfx::Point(0, 0), delegate1->last_touch_location()); - EXPECT_EQ(ui::ET_TOUCH_PRESSED, delegate2->last_touch_type()); - EXPECT_EQ(1, delegate2->last_touch_id()); + EXPECT_EQ(ui::ET_UNKNOWN, handler1->last_touch_type()); + EXPECT_EQ(-1, handler1->last_touch_id()); + EXPECT_EQ(gfx::Point(0, 0), handler1->last_touch_location()); + EXPECT_EQ(ui::ET_TOUCH_PRESSED, handler2->last_touch_type()); + EXPECT_EQ(1, handler2->last_touch_id()); EXPECT_EQ(gfx::Point(1600, 2600 - host2_y_offset), - delegate2->last_touch_location()); + handler2->last_touch_location()); scoped_xevent.InitTouchEvent( 0, XI_TouchUpdate, 5, gfx::Point(1500, 2550), valuators); window_tree_host1->Dispatch(scoped_xevent); window_tree_host2->Dispatch(scoped_xevent); - EXPECT_EQ(ui::ET_UNKNOWN, delegate1->last_touch_type()); - EXPECT_EQ(-1, delegate1->last_touch_id()); - EXPECT_EQ(gfx::Point(0, 0), delegate1->last_touch_location()); - EXPECT_EQ(ui::ET_TOUCH_MOVED, delegate2->last_touch_type()); - EXPECT_EQ(0, delegate2->last_touch_id()); + EXPECT_EQ(ui::ET_UNKNOWN, handler1->last_touch_type()); + EXPECT_EQ(-1, handler1->last_touch_id()); + EXPECT_EQ(gfx::Point(0, 0), handler1->last_touch_location()); + EXPECT_EQ(ui::ET_TOUCH_MOVED, handler2->last_touch_type()); + EXPECT_EQ(0, handler2->last_touch_id()); EXPECT_EQ(gfx::Point(1500, 2550 - host2_y_offset), - delegate2->last_touch_location()); + handler2->last_touch_location()); scoped_xevent.InitTouchEvent( 0, XI_TouchUpdate, 6, gfx::Point(1600, 2650), valuators); window_tree_host1->Dispatch(scoped_xevent); window_tree_host2->Dispatch(scoped_xevent); - EXPECT_EQ(ui::ET_UNKNOWN, delegate1->last_touch_type()); - EXPECT_EQ(-1, delegate1->last_touch_id()); - EXPECT_EQ(gfx::Point(0, 0), delegate1->last_touch_location()); - EXPECT_EQ(ui::ET_TOUCH_MOVED, delegate2->last_touch_type()); - EXPECT_EQ(1, delegate2->last_touch_id()); + EXPECT_EQ(ui::ET_UNKNOWN, handler1->last_touch_type()); + EXPECT_EQ(-1, handler1->last_touch_id()); + EXPECT_EQ(gfx::Point(0, 0), handler1->last_touch_location()); + EXPECT_EQ(ui::ET_TOUCH_MOVED, handler2->last_touch_type()); + EXPECT_EQ(1, handler2->last_touch_id()); EXPECT_EQ(gfx::Point(1600, 2650 - host2_y_offset), - delegate2->last_touch_location()); + handler2->last_touch_location()); scoped_xevent.InitTouchEvent( 0, XI_TouchEnd, 5, gfx::Point(1500, 2550), valuators); window_tree_host1->Dispatch(scoped_xevent); window_tree_host2->Dispatch(scoped_xevent); - EXPECT_EQ(ui::ET_UNKNOWN, delegate1->last_touch_type()); - EXPECT_EQ(-1, delegate1->last_touch_id()); - EXPECT_EQ(gfx::Point(0, 0), delegate1->last_touch_location()); - EXPECT_EQ(ui::ET_TOUCH_RELEASED, delegate2->last_touch_type()); - EXPECT_EQ(0, delegate2->last_touch_id()); + EXPECT_EQ(ui::ET_UNKNOWN, handler1->last_touch_type()); + EXPECT_EQ(-1, handler1->last_touch_id()); + EXPECT_EQ(gfx::Point(0, 0), handler1->last_touch_location()); + EXPECT_EQ(ui::ET_TOUCH_RELEASED, handler2->last_touch_type()); + EXPECT_EQ(0, handler2->last_touch_id()); EXPECT_EQ(gfx::Point(1500, 2550 - host2_y_offset), - delegate2->last_touch_location()); + handler2->last_touch_location()); scoped_xevent.InitTouchEvent( 0, XI_TouchEnd, 6, gfx::Point(1600, 2650), valuators); window_tree_host1->Dispatch(scoped_xevent); window_tree_host2->Dispatch(scoped_xevent); - EXPECT_EQ(ui::ET_UNKNOWN, delegate1->last_touch_type()); - EXPECT_EQ(-1, delegate1->last_touch_id()); - EXPECT_EQ(gfx::Point(0, 0), delegate1->last_touch_location()); - EXPECT_EQ(ui::ET_TOUCH_RELEASED, delegate2->last_touch_type()); - EXPECT_EQ(1, delegate2->last_touch_id()); + EXPECT_EQ(ui::ET_UNKNOWN, handler1->last_touch_type()); + EXPECT_EQ(-1, handler1->last_touch_id()); + EXPECT_EQ(gfx::Point(0, 0), handler1->last_touch_location()); + EXPECT_EQ(ui::ET_TOUCH_RELEASED, handler2->last_touch_type()); + EXPECT_EQ(1, handler2->last_touch_id()); EXPECT_EQ(gfx::Point(1600, 2650 - host2_y_offset), - delegate2->last_touch_location()); + handler2->last_touch_location()); // Revert the CrOS testing env otherwise the following non-CrOS aura // tests will fail. diff --git a/ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc b/ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc index b88e3a5..f723aeb 100644 --- a/ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc +++ b/ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc @@ -586,7 +586,7 @@ void DesktopWindowTreeHostWin::MoveCursorToNative(const gfx::Point& location) { // DesktopWindowTreeHostWin, ui::EventSource implementation: ui::EventProcessor* DesktopWindowTreeHostWin::GetEventProcessor() { - return delegate_->GetEventProcessor(); + return dispatcher(); } //////////////////////////////////////////////////////////////////////////////// @@ -736,11 +736,12 @@ void DesktopWindowTreeHostWin::HandleAppDeactivated() { void DesktopWindowTreeHostWin::HandleActivationChanged(bool active) { // This can be invoked from HWNDMessageHandler::Init(), at which point we're // not in a good state and need to ignore it. - if (!delegate_) + // TODO(beng): Do we need this still now the host owns the dispatcher? + if (!dispatcher()) return; if (active) - delegate_->OnHostActivated(); + OnHostActivated(); desktop_native_widget_aura_->HandleActivationChanged(active); } @@ -752,11 +753,11 @@ bool DesktopWindowTreeHostWin::HandleAppCommand(short command) { } void DesktopWindowTreeHostWin::HandleCancelMode() { - delegate_->OnHostCancelMode(); + dispatcher()->DispatchCancelModeEvent(); } void DesktopWindowTreeHostWin::HandleCaptureLost() { - delegate_->OnHostLostWindowCapture(); + OnHostLostWindowCapture(); native_widget_delegate_->OnMouseCaptureLost(); } @@ -826,8 +827,7 @@ void DesktopWindowTreeHostWin::HandleVisibilityChanged(bool visible) { void DesktopWindowTreeHostWin::HandleClientSizeChanged( const gfx::Size& new_size) { - if (delegate_) - OnHostResized(new_size); + OnHostResized(new_size); } void DesktopWindowTreeHostWin::HandleFrameChanged() { diff --git a/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc b/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc index 71fe892..4eb30c4 100644 --- a/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc +++ b/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc @@ -183,7 +183,7 @@ gfx::Rect DesktopWindowTreeHostX11::GetX11RootWindowBounds() const { void DesktopWindowTreeHostX11::HandleNativeWidgetActivationChanged( bool active) { if (active) { - delegate_->OnHostActivated(); + OnHostActivated(); open_windows().remove(xwindow_); open_windows().insert(open_windows().begin(), xwindow_); } @@ -237,7 +237,6 @@ void DesktopWindowTreeHostX11::OnRootWindowCreated( dispatcher_->window()->SetProperty(kViewsWindowForRootWindow, content_window_); dispatcher_->window()->SetProperty(kHostForRootWindow, this); - delegate_ = dispatcher_; // If we're given a parent, we need to mark ourselves as transient to another // window. Otherwise activation gets screwy. @@ -927,7 +926,7 @@ void DesktopWindowTreeHostX11::PrepareForShutdown() { // DesktopWindowTreeHostX11, ui::EventSource implementation: ui::EventProcessor* DesktopWindowTreeHostX11::GetEventProcessor() { - return delegate_->GetEventProcessor(); + return dispatcher(); } //////////////////////////////////////////////////////////////////////////////// @@ -1135,7 +1134,7 @@ void DesktopWindowTreeHostX11::SetUseNativeFrame(bool use_native_frame) { void DesktopWindowTreeHostX11::OnCaptureReleased() { x11_capture_.reset(); g_current_capture = NULL; - delegate_->OnHostLostWindowCapture(); + OnHostLostWindowCapture(); native_widget_delegate_->OnMouseCaptureLost(); } @@ -1348,9 +1347,9 @@ uint32_t DesktopWindowTreeHostX11::Dispatch(const base::NativeEvent& event) { case FocusOut: if (xev->xfocus.mode != NotifyGrab) { ReleaseCapture(); - delegate_->OnHostLostWindowCapture(); + OnHostLostWindowCapture(); } else { - delegate_->OnHostLostMouseGrab(); + dispatcher()->OnHostLostMouseGrab(); } break; case FocusIn: @@ -1421,8 +1420,7 @@ uint32_t DesktopWindowTreeHostX11::Dispatch(const base::NativeEvent& event) { int button = xievent->detail; if (button == kBackMouseButton || button == kForwardMouseButton) { aura::client::UserActionClient* gesture_client = - aura::client::GetUserActionClient( - delegate_->AsDispatcher()->window()); + aura::client::GetUserActionClient(window()); if (gesture_client) { bool reverse_direction = ui::IsTouchpadEvent(xev) && ui::IsNaturalScrollEnabled(); |