summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsky <sky@chromium.org>2015-10-21 16:36:24 -0700
committerCommit bot <commit-bot@chromium.org>2015-10-21 23:37:41 +0000
commitfab6928ec86fd06059a60088b8d9e8b6b635a746 (patch)
treeb859a0c54af9da8ae69e758165087ea38f6b6e53
parent07bf441cde8273632d1b5a178700eac66a43a3f1 (diff)
downloadchromium_src-fab6928ec86fd06059a60088b8d9e8b6b635a746.zip
chromium_src-fab6928ec86fd06059a60088b8d9e8b6b635a746.tar.gz
chromium_src-fab6928ec86fd06059a60088b8d9e8b6b635a746.tar.bz2
Makes EventDispatcher not depend upon WindowTreeHostImpl
I've moved the necessary functionality into a delegate. This way it's easier to mock for tests. BUG=none TEST=none R=fsamuel@chromium.org Review URL: https://codereview.chromium.org/1419753003 Cr-Commit-Position: refs/heads/master@{#355433}
-rw-r--r--components/mus/ws/BUILD.gn5
-rw-r--r--components/mus/ws/event_dispatcher.cc80
-rw-r--r--components/mus/ws/event_dispatcher.h25
-rw-r--r--components/mus/ws/event_dispatcher_delegate.h33
-rw-r--r--components/mus/ws/event_dispatcher_unittest.cc95
-rw-r--r--components/mus/ws/window_finder.cc64
-rw-r--r--components/mus/ws/window_finder.h35
-rw-r--r--components/mus/ws/window_tree_host_impl.cc52
-rw-r--r--components/mus/ws/window_tree_host_impl.h19
9 files changed, 297 insertions, 111 deletions
diff --git a/components/mus/ws/BUILD.gn b/components/mus/ws/BUILD.gn
index ef3795f..6d686b7 100644
--- a/components/mus/ws/BUILD.gn
+++ b/components/mus/ws/BUILD.gn
@@ -23,6 +23,7 @@ source_set("lib") {
"display_manager_factory.h",
"event_dispatcher.cc",
"event_dispatcher.h",
+ "event_dispatcher_delegate.h",
"focus_controller.cc",
"focus_controller.h",
"focus_controller_delegate.h",
@@ -37,6 +38,8 @@ source_set("lib") {
"server_window_surface.h",
"window_coordinate_conversions.cc",
"window_coordinate_conversions.h",
+ "window_finder.cc",
+ "window_finder.h",
"window_manager_access_policy.cc",
"window_manager_access_policy.h",
"window_tree_host_connection.cc",
@@ -107,6 +110,7 @@ group("tests") {
test("window_manager_unittests") {
sources = [
+ "event_dispatcher_unittest.cc",
"focus_controller_unittest.cc",
"server_window_drawn_tracker_unittest.cc",
"test_server_window_delegate.cc",
@@ -134,6 +138,7 @@ test("window_manager_unittests") {
"//ui/mojo/geometry:interfaces",
"//ui/mojo/events:interfaces",
"//testing/gtest",
+ "//ui/events",
"//ui/gfx",
"//ui/gfx:test_support",
"//ui/gfx/geometry",
diff --git a/components/mus/ws/event_dispatcher.cc b/components/mus/ws/event_dispatcher.cc
index b76d102..17c9da0 100644
--- a/components/mus/ws/event_dispatcher.cc
+++ b/components/mus/ws/event_dispatcher.cc
@@ -4,22 +4,17 @@
#include "components/mus/ws/event_dispatcher.h"
-#include "cc/surfaces/surface_id.h"
-#include "components/mus/surfaces/surfaces_state.h"
-#include "components/mus/ws/connection_manager.h"
+#include "components/mus/ws/event_dispatcher_delegate.h"
#include "components/mus/ws/server_window.h"
-#include "components/mus/ws/server_window_delegate.h"
#include "components/mus/ws/window_coordinate_conversions.h"
-#include "components/mus/ws/window_tree_host_impl.h"
+#include "components/mus/ws/window_finder.h"
#include "ui/gfx/geometry/point.h"
-#include "ui/gfx/geometry/point_f.h"
namespace mus {
-
namespace ws {
-EventDispatcher::EventDispatcher(WindowTreeHostImpl* window_tree_host)
- : window_tree_host_(window_tree_host) {}
+EventDispatcher::EventDispatcher(EventDispatcherDelegate* delegate)
+ : delegate_(delegate), root_(nullptr) {}
EventDispatcher::~EventDispatcher() {}
@@ -43,11 +38,14 @@ void EventDispatcher::RemoveAccelerator(uint32_t id) {
}
void EventDispatcher::OnEvent(mojo::EventPtr event) {
+ if (!root_)
+ return;
+
if (event->action == mojo::EVENT_TYPE_KEY_PRESSED &&
!event->key_data->is_char) {
uint32_t accelerator = 0u;
if (FindAccelerator(*event, &accelerator)) {
- window_tree_host_->OnAccelerator(accelerator, event.Pass());
+ delegate_->OnAccelerator(accelerator, event.Pass());
return;
}
}
@@ -56,8 +54,8 @@ void EventDispatcher::OnEvent(mojo::EventPtr event) {
if (target) {
// Update focus on pointer-down.
if (event->action == mojo::EVENT_TYPE_POINTER_DOWN)
- window_tree_host_->SetFocusedWindow(target);
- window_tree_host_->DispatchInputEventToWindow(target, event.Pass());
+ delegate_->SetFocusedWindowFromEventDispatcher(target);
+ delegate_->DispatchInputEventToWindow(target, event.Pass());
}
}
@@ -75,7 +73,8 @@ bool EventDispatcher::FindAccelerator(const mojo::Event& event,
}
ServerWindow* EventDispatcher::FindEventTarget(mojo::Event* event) {
- ServerWindow* focused_window = window_tree_host_->GetFocusedWindow();
+ ServerWindow* focused_window =
+ delegate_->GetFocusedWindowForEventDispatcher();
if (event->key_data)
return focused_window;
@@ -91,18 +90,17 @@ ServerWindow* EventDispatcher::FindEventTarget(mojo::Event* event) {
gfx::Point location(static_cast<int>(event_location->x),
static_cast<int>(event_location->y));
ServerWindow* target = focused_window;
- ServerWindow* root = window_tree_host_->root_window();
if (event->action == mojo::EVENT_TYPE_POINTER_DOWN || !target ||
- !root->Contains(target)) {
- target = FindDeepestVisibleWindowFromSurface(&location);
+ !root_->Contains(target)) {
+ target = FindDeepestVisibleWindowFromSurface(root_, surface_id_, &location);
// Surface-based hit-testing will not return a valid target if no
// compositor-frame have been submitted (e.g. in unit-tests).
if (!target)
- target = FindDeepestVisibleWindow(root, &location);
+ target = FindDeepestVisibleWindow(root_, &location);
CHECK(target);
} else {
gfx::Point old_point = location;
- location = ConvertPointBetweenWindows(root, target, location);
+ location = ConvertPointBetweenWindows(root_, target, location);
}
event_location->x = location.x();
@@ -110,51 +108,5 @@ ServerWindow* EventDispatcher::FindEventTarget(mojo::Event* event) {
return target;
}
-ServerWindow* EventDispatcher::FindDeepestVisibleWindow(ServerWindow* window,
- gfx::Point* location) {
- for (ServerWindow* child : window->GetChildren()) {
- if (!child->visible())
- continue;
-
- // TODO(sky): support transform.
- gfx::Point child_location(location->x() - child->bounds().x(),
- location->y() - child->bounds().y());
- if (child_location.x() >= 0 && child_location.y() >= 0 &&
- child_location.x() < child->bounds().width() &&
- child_location.y() < child->bounds().height()) {
- *location = child_location;
- return FindDeepestVisibleWindow(child, location);
- }
- }
- return window;
-}
-
-ServerWindow* EventDispatcher::FindDeepestVisibleWindowFromSurface(
- gfx::Point* location) {
- if (window_tree_host_->surface_id().is_null())
- return nullptr;
-
- gfx::Transform transform_to_target_surface;
- cc::SurfaceId target_surface =
- window_tree_host_->root_window()
- ->delegate()
- ->GetSurfacesState()
- ->hit_tester()
- ->GetTargetSurfaceAtPoint(window_tree_host_->surface_id(), *location,
- &transform_to_target_surface);
- WindowId id = WindowIdFromTransportId(
- cc::SurfaceIdAllocator::NamespaceForId(target_surface));
- ServerWindow* target = window_tree_host_->connection_manager()->GetWindow(id);
- // TODO(fsamuel): This should be a DCHECK but currently we use stale
- // information to decide where to route input events. This should be fixed
- // once we implement a UI scheduler.
- if (target) {
- transform_to_target_surface.TransformPoint(location);
- return target;
- }
- return nullptr;
-}
-
} // namespace ws
-
} // namespace mus
diff --git a/components/mus/ws/event_dispatcher.h b/components/mus/ws/event_dispatcher.h
index a984f06..f108f09 100644
--- a/components/mus/ws/event_dispatcher.h
+++ b/components/mus/ws/event_dispatcher.h
@@ -8,6 +8,7 @@
#include <map>
#include "base/basictypes.h"
+#include "cc/surfaces/surface_id.h"
#include "ui/mojo/events/input_event_constants.mojom.h"
#include "ui/mojo/events/input_events.mojom.h"
#include "ui/mojo/events/input_key_codes.mojom.h"
@@ -17,18 +18,21 @@ class Point;
}
namespace mus {
-
namespace ws {
+class EventDispatcherDelegate;
class ServerWindow;
-class WindowTreeHostImpl;
// Handles dispatching events to the right location as well as updating focus.
class EventDispatcher {
public:
- explicit EventDispatcher(WindowTreeHostImpl* window_tree_host);
+ explicit EventDispatcher(EventDispatcherDelegate* delegate);
~EventDispatcher();
+ void set_root(ServerWindow* root) { root_ = root; }
+
+ void set_surface_id(cc::SurfaceId surface_id) { surface_id_ = surface_id; }
+
void AddAccelerator(uint32_t id,
mojo::KeyboardCode keyboard_code,
mojo::EventFlags flags);
@@ -63,18 +67,10 @@ class EventDispatcher {
// make sure it is in the returned target's coordinate space.
ServerWindow* FindEventTarget(mojo::Event* event);
- // Finds the deepest visible window that contains the specified location, and
- // updates |location| to be in the returned window's coordinate space.
- ServerWindow* FindDeepestVisibleWindow(ServerWindow* window,
- gfx::Point* location);
+ EventDispatcherDelegate* delegate_;
+ ServerWindow* root_;
- // Finds the deepest visible window for the specified location based on
- // surface
- // hit-testing. Updates |location| to be in the returned window's coordinate
- // space.
- ServerWindow* FindDeepestVisibleWindowFromSurface(gfx::Point* location);
-
- WindowTreeHostImpl* window_tree_host_;
+ cc::SurfaceId surface_id_;
using Entry = std::pair<uint32_t, Accelerator>;
std::map<uint32_t, Accelerator> accelerators_;
@@ -83,7 +79,6 @@ class EventDispatcher {
};
} // namespace ws
-
} // namespace mus
#endif // COMPONENTS_MUS_WS_EVENT_DISPATCHER_H_
diff --git a/components/mus/ws/event_dispatcher_delegate.h b/components/mus/ws/event_dispatcher_delegate.h
new file mode 100644
index 0000000..707b819
--- /dev/null
+++ b/components/mus/ws/event_dispatcher_delegate.h
@@ -0,0 +1,33 @@
+// Copyright 2015 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 COMPONENTS_MUS_WS_EVENT_DISPATCHER_DELEGATE_H_
+#define COMPONENTS_MUS_WS_EVENT_DISPATCHER_DELEGATE_H_
+
+#include "ui/mojo/events/input_events.mojom.h"
+
+namespace mus {
+namespace ws {
+
+class ServerWindow;
+
+// Used by EventDispatcher for mocking in tests.
+class EventDispatcherDelegate {
+ public:
+ virtual void OnAccelerator(uint32_t accelerator, mojo::EventPtr event) = 0;
+
+ virtual void SetFocusedWindowFromEventDispatcher(ServerWindow* window) = 0;
+ virtual ServerWindow* GetFocusedWindowForEventDispatcher() = 0;
+
+ virtual void DispatchInputEventToWindow(ServerWindow* target,
+ mojo::EventPtr event) = 0;
+
+ protected:
+ virtual ~EventDispatcherDelegate() {}
+};
+
+} // namespace ws
+} // namespace mus
+
+#endif // COMPONENTS_MUS_WS_EVENT_DISPATCHER_DELEGATE_H_
diff --git a/components/mus/ws/event_dispatcher_unittest.cc b/components/mus/ws/event_dispatcher_unittest.cc
new file mode 100644
index 0000000..ee337b35
--- /dev/null
+++ b/components/mus/ws/event_dispatcher_unittest.cc
@@ -0,0 +1,95 @@
+// Copyright 2015 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.
+
+#include "components/mus/ws/event_dispatcher.h"
+
+#include "components/mus/ws/event_dispatcher_delegate.h"
+#include "components/mus/ws/server_window.h"
+#include "components/mus/ws/test_server_window_delegate.h"
+#include "mojo/converters/input_events/input_events_type_converters.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/events/event.h"
+
+namespace mus {
+namespace ws {
+namespace {
+
+class TestEventDispatcherDelegate : public EventDispatcherDelegate {
+ public:
+ explicit TestEventDispatcherDelegate(ServerWindow* root)
+ : root_(root), focused_window_(nullptr), last_target_(nullptr) {}
+ ~TestEventDispatcherDelegate() override {}
+
+ mojo::EventPtr GetAndClearLastDispatchedEvent() {
+ return last_dispatched_event_.Pass();
+ }
+
+ ServerWindow* last_target() { return last_target_; }
+
+ private:
+ // EventDispatcherDelegate:
+ void OnAccelerator(uint32_t accelerator, mojo::EventPtr event) override {}
+ void SetFocusedWindowFromEventDispatcher(ServerWindow* window) override {
+ focused_window_ = window;
+ }
+ ServerWindow* GetFocusedWindowForEventDispatcher() override {
+ return focused_window_;
+ }
+ void DispatchInputEventToWindow(ServerWindow* target,
+ mojo::EventPtr event) override {
+ last_target_ = target;
+ last_dispatched_event_ = event.Pass();
+ }
+
+ ServerWindow* root_;
+ ServerWindow* focused_window_;
+ ServerWindow* last_target_;
+ mojo::EventPtr last_dispatched_event_;
+
+ DISALLOW_COPY_AND_ASSIGN(TestEventDispatcherDelegate);
+};
+
+} // namespace
+
+TEST(EventDispatcherTest, OnEvent) {
+ TestServerWindowDelegate window_delegate;
+ ServerWindow root(&window_delegate, WindowId(1, 2));
+ window_delegate.set_root_window(&root);
+ root.SetVisible(true);
+
+ ServerWindow child(&window_delegate, WindowId(1, 3));
+ root.Add(&child);
+ child.SetVisible(true);
+
+ root.SetBounds(gfx::Rect(0, 0, 100, 100));
+ child.SetBounds(gfx::Rect(10, 10, 20, 20));
+
+ TestEventDispatcherDelegate event_dispatcher_delegate(&root);
+ EventDispatcher dispatcher(&event_dispatcher_delegate);
+ dispatcher.set_root(&root);
+
+ // Send event that is over child.
+ const ui::MouseEvent ui_event(
+ ui::ET_MOUSE_PRESSED, gfx::PointF(20.f, 25.f), gfx::PointF(20.f, 25.f),
+ base::TimeDelta(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON);
+ dispatcher.OnEvent(
+ mojo::Event::From(static_cast<const ui::Event&>(ui_event)));
+
+ ASSERT_EQ(&child, event_dispatcher_delegate.last_target());
+
+ mojo::EventPtr dispatched_event_mojo =
+ event_dispatcher_delegate.GetAndClearLastDispatchedEvent();
+ ASSERT_TRUE(dispatched_event_mojo.get());
+ scoped_ptr<ui::Event> dispatched_event(
+ dispatched_event_mojo.To<scoped_ptr<ui::Event>>());
+ ASSERT_TRUE(dispatched_event.get());
+ ASSERT_TRUE(dispatched_event->IsMouseEvent());
+ ui::MouseEvent* dispatched_mouse_event =
+ static_cast<ui::MouseEvent*>(dispatched_event.get());
+ EXPECT_EQ(gfx::Point(20, 25), dispatched_mouse_event->root_location());
+ EXPECT_EQ(gfx::Point(10, 15), dispatched_mouse_event->location());
+}
+
+} // namespace ws
+} // namespace mus
diff --git a/components/mus/ws/window_finder.cc b/components/mus/ws/window_finder.cc
new file mode 100644
index 0000000..afca266
--- /dev/null
+++ b/components/mus/ws/window_finder.cc
@@ -0,0 +1,64 @@
+// Copyright 2015 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.
+
+#include "components/mus/ws/window_finder.h"
+
+#include "cc/surfaces/surface_id.h"
+#include "components/mus/surfaces/surfaces_state.h"
+#include "components/mus/ws/server_window.h"
+#include "components/mus/ws/server_window_delegate.h"
+#include "components/mus/ws/window_coordinate_conversions.h"
+#include "ui/gfx/geometry/point.h"
+#include "ui/gfx/geometry/point_f.h"
+
+namespace mus {
+namespace ws {
+
+ServerWindow* FindDeepestVisibleWindow(ServerWindow* window,
+ gfx::Point* location) {
+ for (ServerWindow* child : window->GetChildren()) {
+ if (!child->visible())
+ continue;
+
+ // TODO(sky): support transform.
+ gfx::Point child_location(location->x() - child->bounds().x(),
+ location->y() - child->bounds().y());
+ if (child_location.x() >= 0 && child_location.y() >= 0 &&
+ child_location.x() < child->bounds().width() &&
+ child_location.y() < child->bounds().height()) {
+ *location = child_location;
+ return FindDeepestVisibleWindow(child, location);
+ }
+ }
+ return window;
+}
+
+ServerWindow* FindDeepestVisibleWindowFromSurface(ServerWindow* window,
+ cc::SurfaceId surface_id,
+ gfx::Point* location) {
+ if (surface_id.is_null())
+ return nullptr;
+
+ gfx::Transform transform_to_target_surface;
+ cc::SurfaceId target_surface =
+ window->delegate()
+ ->GetSurfacesState()
+ ->hit_tester()
+ ->GetTargetSurfaceAtPoint(surface_id, *location,
+ &transform_to_target_surface);
+ WindowId id = WindowIdFromTransportId(
+ cc::SurfaceIdAllocator::NamespaceForId(target_surface));
+ ServerWindow* target = window->GetChildWindow(id);
+ // TODO(fsamuel): This should be a DCHECK but currently we use stale
+ // information to decide where to route input events. This should be fixed
+ // once we implement a UI scheduler.
+ if (target) {
+ transform_to_target_surface.TransformPoint(location);
+ return target;
+ }
+ return nullptr;
+}
+
+} // namespace ws
+} // namespace mus
diff --git a/components/mus/ws/window_finder.h b/components/mus/ws/window_finder.h
new file mode 100644
index 0000000..e6226f1
--- /dev/null
+++ b/components/mus/ws/window_finder.h
@@ -0,0 +1,35 @@
+// Copyright 2015 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 COMPONENTS_MUS_WS_WINDOW_FINDER_H_
+#define COMPONENTS_MUS_WS_WINDOW_FINDER_H_
+
+namespace cc {
+struct SurfaceId;
+}
+
+namespace gfx {
+class Point;
+}
+
+namespace mus {
+namespace ws {
+
+class ServerWindow;
+
+// Find the deepest visible child of |root| that contains |location|. If a
+// child is found |location| is reset to the coordinates of the child.
+ServerWindow* FindDeepestVisibleWindow(ServerWindow* root,
+ gfx::Point* location);
+
+// Find the deepest visible child of |root| that contains |location| using
+// a previously submitted frame.
+ServerWindow* FindDeepestVisibleWindowFromSurface(ServerWindow* root,
+ cc::SurfaceId surface_id,
+ gfx::Point* location);
+
+} // namespace ws
+} // namespace mus
+
+#endif // COMPONENTS_MUS_WS_WINDOW_FINDER_H_
diff --git a/components/mus/ws/window_tree_host_impl.cc b/components/mus/ws/window_tree_host_impl.cc
index 516803f..d65b0af 100644
--- a/components/mus/ws/window_tree_host_impl.cc
+++ b/components/mus/ws/window_tree_host_impl.cc
@@ -15,7 +15,6 @@
#include "mojo/converters/geometry/geometry_type_converters.h"
namespace mus {
-
namespace ws {
WindowTreeHostImpl::WindowTreeHostImpl(
@@ -101,24 +100,6 @@ void WindowTreeHostImpl::SetImeVisibility(ServerWindow* window, bool visible) {
display_manager_->SetImeVisibility(visible);
}
-void WindowTreeHostImpl::OnAccelerator(uint32_t accelerator_id,
- mojo::EventPtr event) {
- client()->OnAccelerator(accelerator_id, event.Pass());
-}
-
-void WindowTreeHostImpl::DispatchInputEventToWindow(ServerWindow* target,
- mojo::EventPtr event) {
- // If the window is an embed root, forward to the embedded window, not the
- // owner.
- WindowTreeImpl* connection =
- connection_manager_->GetConnectionWithRoot(target->id());
- if (!connection)
- connection = connection_manager_->GetConnection(target->id().connection_id);
- connection->client()->OnWindowInputEvent(WindowIdToTransportId(target->id()),
- event.Pass(),
- base::Bind(&base::DoNothing));
-}
-
void WindowTreeHostImpl::SetSize(mojo::SizePtr size) {
display_manager_->SetViewportSize(size.To<gfx::Size>());
}
@@ -169,16 +150,15 @@ void WindowTreeHostImpl::OnViewportMetricsChanged(
root_->SetVisible(true);
if (delegate_)
delegate_->OnDisplayInitialized();
+ event_dispatcher_.set_root(root_.get());
} else {
root_->SetBounds(gfx::Rect(new_metrics.size_in_pixels.To<gfx::Size>()));
}
- // TODO(fsamuel): We shouldn't broadcast this to all connections but only
- // those within a window root.
connection_manager_->ProcessViewportMetricsChanged(old_metrics, new_metrics);
}
void WindowTreeHostImpl::OnTopLevelSurfaceChanged(cc::SurfaceId surface_id) {
- surface_id_ = surface_id;
+ event_dispatcher_.set_surface_id(surface_id);
}
void WindowTreeHostImpl::OnFocusChanged(ServerWindow* old_focused_window,
@@ -243,6 +223,32 @@ void WindowTreeHostImpl::OnFocusChanged(ServerWindow* old_focused_window,
new_focused_window->text_input_state());
}
-} // namespace ws
+void WindowTreeHostImpl::OnAccelerator(uint32_t accelerator_id,
+ mojo::EventPtr event) {
+ client()->OnAccelerator(accelerator_id, event.Pass());
+}
+void WindowTreeHostImpl::SetFocusedWindowFromEventDispatcher(
+ ServerWindow* new_focused_window) {
+ SetFocusedWindow(new_focused_window);
+}
+
+ServerWindow* WindowTreeHostImpl::GetFocusedWindowForEventDispatcher() {
+ return GetFocusedWindow();
+}
+
+void WindowTreeHostImpl::DispatchInputEventToWindow(ServerWindow* target,
+ mojo::EventPtr event) {
+ // If the window is an embed root, forward to the embedded window, not the
+ // owner.
+ WindowTreeImpl* connection =
+ connection_manager_->GetConnectionWithRoot(target->id());
+ if (!connection)
+ connection = connection_manager_->GetConnection(target->id().connection_id);
+ connection->client()->OnWindowInputEvent(WindowIdToTransportId(target->id()),
+ event.Pass(),
+ base::Bind(&base::DoNothing));
+}
+
+} // namespace ws
} // namespace mus
diff --git a/components/mus/ws/window_tree_host_impl.h b/components/mus/ws/window_tree_host_impl.h
index faefc3e..2f538fd 100644
--- a/components/mus/ws/window_tree_host_impl.h
+++ b/components/mus/ws/window_tree_host_impl.h
@@ -11,11 +11,11 @@
#include "components/mus/public/interfaces/window_tree_host.mojom.h"
#include "components/mus/ws/display_manager.h"
#include "components/mus/ws/event_dispatcher.h"
+#include "components/mus/ws/event_dispatcher_delegate.h"
#include "components/mus/ws/focus_controller_delegate.h"
#include "components/mus/ws/server_window.h"
namespace mus {
-
namespace ws {
class ConnectionManager;
@@ -30,7 +30,8 @@ class WindowTreeImpl;
// deleted.
class WindowTreeHostImpl : public DisplayManagerDelegate,
public mojom::WindowTreeHost,
- public FocusControllerDelegate {
+ public FocusControllerDelegate,
+ public EventDispatcherDelegate {
public:
// TODO(fsamuel): All these parameters are just plumbing for creating
// DisplayManagers. We should probably just store these common parameters
@@ -49,8 +50,6 @@ class WindowTreeHostImpl : public DisplayManagerDelegate,
mojom::WindowTreeHostClient* client() const { return client_.get(); }
- cc::SurfaceId surface_id() const { return surface_id_; }
-
// Returns whether |window| is a descendant of this root but not itself a
// root window.
bool IsWindowAttachedToRoot(const ServerWindow* window) const;
@@ -79,9 +78,6 @@ class WindowTreeHostImpl : public DisplayManagerDelegate,
const ui::TextInputState& state);
void SetImeVisibility(ServerWindow* window, bool visible);
- void OnAccelerator(uint32_t accelerator_id, mojo::EventPtr event);
- void DispatchInputEventToWindow(ServerWindow* target, mojo::EventPtr event);
-
// WindowTreeHost:
void SetSize(mojo::SizePtr size) override;
void SetTitle(const mojo::String& title) override;
@@ -106,6 +102,13 @@ class WindowTreeHostImpl : public DisplayManagerDelegate,
void OnFocusChanged(ServerWindow* old_focused_window,
ServerWindow* new_focused_window) override;
+ // EventDispatcherDelegate:
+ void OnAccelerator(uint32_t accelerator_id, mojo::EventPtr event) override;
+ void SetFocusedWindowFromEventDispatcher(ServerWindow* window) override;
+ ServerWindow* GetFocusedWindowForEventDispatcher() override;
+ void DispatchInputEventToWindow(ServerWindow* target,
+ mojo::EventPtr event) override;
+
WindowTreeHostDelegate* delegate_;
ConnectionManager* const connection_manager_;
mojom::WindowTreeHostClientPtr client_;
@@ -113,13 +116,11 @@ class WindowTreeHostImpl : public DisplayManagerDelegate,
scoped_ptr<ServerWindow> root_;
scoped_ptr<DisplayManager> display_manager_;
scoped_ptr<FocusController> focus_controller_;
- cc::SurfaceId surface_id_;
DISALLOW_COPY_AND_ASSIGN(WindowTreeHostImpl);
};
} // namespace ws
-
} // namespace mus
#endif // COMPONENTS_MUS_WS_WINDOW_TREE_HOST_IMPL_H_