summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/view_manager/connection_manager.cc11
-rw-r--r--components/view_manager/connection_manager.h7
-rw-r--r--components/view_manager/event_dispatcher.cc13
-rw-r--r--components/view_manager/event_dispatcher.h3
-rw-r--r--components/view_manager/view_manager_service_unittest.cc10
5 files changed, 23 insertions, 21 deletions
diff --git a/components/view_manager/connection_manager.cc b/components/view_manager/connection_manager.cc
index 39b6051..167d5fe 100644
--- a/components/view_manager/connection_manager.cc
+++ b/components/view_manager/connection_manager.cc
@@ -206,6 +206,11 @@ void ConnectionManager::EmbedAtView(mojo::ConnectionSpecificId creator_id,
OnConnectionMessagedClient(client_connection->service()->id());
}
+void ConnectionManager::OnAccelerator(ServerView* root, mojo::EventPtr event) {
+ // TODO(fsamuel): Support multiple roots.
+ view_manager_root_client_->OnAccelerator(event.Pass());
+}
+
ViewManagerServiceImpl* ConnectionManager::GetConnection(
ConnectionSpecificId connection_id) {
ConnectionMap::iterator i = connection_map_.find(connection_id);
@@ -301,10 +306,6 @@ bool ConnectionManager::CloneAndAnimate(const ViewId& view_id) {
return true;
}
-void ConnectionManager::ProcessEvent(mojo::EventPtr event) {
- event_dispatcher_.OnEvent(event.Pass());
-}
-
void ConnectionManager::DispatchInputEventToView(const ServerView* view,
mojo::EventPtr event) {
// It's possible for events to flow through here from the platform_window
@@ -327,7 +328,7 @@ ServerView* ConnectionManager::GetRoot() {
}
void ConnectionManager::OnEvent(mojo::EventPtr event) {
- event_dispatcher_.OnEvent(event.Pass());
+ event_dispatcher_.OnEvent(root_.get(), event.Pass());
}
void ConnectionManager::OnDisplayClosed() {
diff --git a/components/view_manager/connection_manager.h b/components/view_manager/connection_manager.h
index 9b21437..47ad06f 100644
--- a/components/view_manager/connection_manager.h
+++ b/components/view_manager/connection_manager.h
@@ -97,6 +97,10 @@ class ConnectionManager : public ServerViewDelegate,
const ViewId& view_id,
mojo::ViewManagerClientPtr client);
+ // Invoked when an accelerator has been triggered on a view tree with the
+ // provided |root|.
+ void OnAccelerator(ServerView* root, mojo::EventPtr event);
+
// Returns the connection by id.
ViewManagerServiceImpl* GetConnection(
mojo::ConnectionSpecificId connection_id);
@@ -151,9 +155,6 @@ class ConnectionManager : public ServerViewDelegate,
// ViewManagerRoot implementation helper; see mojom for details.
bool CloneAndAnimate(const ViewId& view_id);
- // Processes an event, potentially changing focus.
- void ProcessEvent(mojo::EventPtr event);
-
// Dispatches |event| directly to the appropriate connection for |view|.
void DispatchInputEventToView(const ServerView* view, mojo::EventPtr event);
diff --git a/components/view_manager/event_dispatcher.cc b/components/view_manager/event_dispatcher.cc
index c3b1604..3a3ec4d 100644
--- a/components/view_manager/event_dispatcher.cc
+++ b/components/view_manager/event_dispatcher.cc
@@ -30,19 +30,19 @@ void EventDispatcher::RemoveAccelerator(mojo::KeyboardCode keyboard_code,
accelerators_.erase(Accelerator(keyboard_code, flags));
}
-void EventDispatcher::OnEvent(mojo::EventPtr event) {
+void EventDispatcher::OnEvent(ServerView* root, mojo::EventPtr event) {
if (event->pointer_data) {
const gfx::Point root_point(static_cast<int>(event->pointer_data->x),
static_cast<int>(event->pointer_data->y));
ServerView* target = connection_manager_->GetFocusedView();
- if (event->action == mojo::EVENT_TYPE_POINTER_DOWN || !target) {
- target =
- FindDeepestVisibleView(connection_manager_->GetRoot(), root_point);
+ if (event->action == mojo::EVENT_TYPE_POINTER_DOWN || !target ||
+ !root->Contains(target)) {
+ target = FindDeepestVisibleView(root, root_point);
CHECK(target);
connection_manager_->SetFocusedView(target);
}
const gfx::PointF local_point(ConvertPointFBetweenViews(
- connection_manager_->GetRoot(), target,
+ root, target,
gfx::PointF(event->pointer_data->x, event->pointer_data->y)));
event->pointer_data->x = local_point.x();
event->pointer_data->y = local_point.y();
@@ -50,8 +50,7 @@ void EventDispatcher::OnEvent(mojo::EventPtr event) {
} else if (event->action == mojo::EVENT_TYPE_KEY_PRESSED &&
accelerators_.count(Accelerator(event->key_data->windows_key_code,
event->flags))) {
- connection_manager_->view_manager_root_client()->OnAccelerator(
- event.Pass());
+ connection_manager_->OnAccelerator(root, event.Pass());
} else {
ServerView* focused_view = connection_manager_->GetFocusedView();
if (focused_view)
diff --git a/components/view_manager/event_dispatcher.h b/components/view_manager/event_dispatcher.h
index a2d4514..75d1689 100644
--- a/components/view_manager/event_dispatcher.h
+++ b/components/view_manager/event_dispatcher.h
@@ -15,6 +15,7 @@
namespace view_manager {
class ConnectionManager;
+class ServerView;
// Handles dispatching events to the right location as well as updating focus.
class EventDispatcher {
@@ -26,7 +27,7 @@ class EventDispatcher {
void RemoveAccelerator(mojo::KeyboardCode keyboard_code,
mojo::EventFlags flags);
- void OnEvent(mojo::EventPtr event);
+ void OnEvent(ServerView* root, mojo::EventPtr event);
private:
struct Accelerator {
diff --git a/components/view_manager/view_manager_service_unittest.cc b/components/view_manager/view_manager_service_unittest.cc
index 2c9e6a6..9ff8283 100644
--- a/components/view_manager/view_manager_service_unittest.cc
+++ b/components/view_manager/view_manager_service_unittest.cc
@@ -520,7 +520,7 @@ TEST_F(ViewManagerServiceTest, FocusOnPointer) {
connection1_client->tracker()->changes()->clear();
wm_client()->tracker()->changes()->clear();
- connection_manager()->ProcessEvent(CreatePointerDownEvent(21, 22));
+ connection_manager()->OnEvent(CreatePointerDownEvent(21, 22));
// Focus should go to child1. This results in notifying both the window
// manager and client connection being notified.
EXPECT_EQ(v1, connection_manager()->GetFocusedView());
@@ -532,14 +532,14 @@ TEST_F(ViewManagerServiceTest, FocusOnPointer) {
"Focused id=2,1",
ChangesToDescription1(*connection1_client->tracker()->changes())[0]);
- connection_manager()->ProcessEvent(CreatePointerUpEvent(21, 22));
+ connection_manager()->OnEvent(CreatePointerUpEvent(21, 22));
wm_client()->tracker()->changes()->clear();
connection1_client->tracker()->changes()->clear();
// Press outside of the embedded view. Focus should go to the root. Notice
// the client1 doesn't see who has focus as the focused view (root) isn't
// visible to it.
- connection_manager()->ProcessEvent(CreatePointerDownEvent(61, 22));
+ connection_manager()->OnEvent(CreatePointerDownEvent(61, 22));
EXPECT_EQ(connection_manager()->GetRoot(),
connection_manager()->GetFocusedView());
ASSERT_GE(wm_client()->tracker()->changes()->size(), 1u);
@@ -550,13 +550,13 @@ TEST_F(ViewManagerServiceTest, FocusOnPointer) {
"Focused id=null",
ChangesToDescription1(*connection1_client->tracker()->changes())[0]);
- connection_manager()->ProcessEvent(CreatePointerUpEvent(21, 22));
+ connection_manager()->OnEvent(CreatePointerUpEvent(21, 22));
wm_client()->tracker()->changes()->clear();
connection1_client->tracker()->changes()->clear();
// Press in the same location. Should not get a focus change event (only input
// event).
- connection_manager()->ProcessEvent(CreatePointerDownEvent(61, 22));
+ connection_manager()->OnEvent(CreatePointerDownEvent(61, 22));
EXPECT_EQ(connection_manager()->GetRoot(),
connection_manager()->GetFocusedView());
ASSERT_EQ(wm_client()->tracker()->changes()->size(), 1u);