Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Side by Side Diff: components/view_manager/event_dispatcher.cc

Issue 1149083010: Mandoline: Remove native_viewport.mojom (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Simplified headless logic Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/view_manager/event_dispatcher.h" 5 #include "components/view_manager/event_dispatcher.h"
6 6
7 #include "components/view_manager/connection_manager.h" 7 #include "components/view_manager/connection_manager.h"
8 #include "components/view_manager/server_view.h" 8 #include "components/view_manager/server_view.h"
9 #include "components/view_manager/view_coordinate_conversions.h" 9 #include "components/view_manager/view_coordinate_conversions.h"
10 #include "components/view_manager/view_locator.h" 10 #include "components/view_manager/view_locator.h"
(...skipping 12 matching lines...) Expand all
23 void EventDispatcher::AddAccelerator(mojo::KeyboardCode keyboard_code, 23 void EventDispatcher::AddAccelerator(mojo::KeyboardCode keyboard_code,
24 mojo::EventFlags flags) { 24 mojo::EventFlags flags) {
25 accelerators_.insert(Accelerator(keyboard_code, flags)); 25 accelerators_.insert(Accelerator(keyboard_code, flags));
26 } 26 }
27 27
28 void EventDispatcher::RemoveAccelerator(mojo::KeyboardCode keyboard_code, 28 void EventDispatcher::RemoveAccelerator(mojo::KeyboardCode keyboard_code,
29 mojo::EventFlags flags) { 29 mojo::EventFlags flags) {
30 accelerators_.erase(Accelerator(keyboard_code, flags)); 30 accelerators_.erase(Accelerator(keyboard_code, flags));
31 } 31 }
32 32
33 void EventDispatcher::OnEvent(mojo::EventPtr event, 33 void EventDispatcher::OnEvent(mojo::EventPtr event) {
34 const OnEventCallback& callback) {
35 callback.Run();
36
37 if (event->pointer_data) { 34 if (event->pointer_data) {
38 const gfx::Point root_point(static_cast<int>(event->pointer_data->x), 35 const gfx::Point root_point(static_cast<int>(event->pointer_data->x),
39 static_cast<int>(event->pointer_data->y)); 36 static_cast<int>(event->pointer_data->y));
40 ServerView* target = connection_manager_->GetFocusedView(); 37 ServerView* target = connection_manager_->GetFocusedView();
41 ;
42 if (event->action == mojo::EVENT_TYPE_POINTER_DOWN || !target) { 38 if (event->action == mojo::EVENT_TYPE_POINTER_DOWN || !target) {
43 target = FindDeepestVisibleView(connection_manager_->root(), root_point); 39 target = FindDeepestVisibleView(connection_manager_->root(), root_point);
44 CHECK(target); 40 CHECK(target);
45 connection_manager_->SetFocusedView(target); 41 connection_manager_->SetFocusedView(target);
46 } 42 }
47 const gfx::PointF local_point(ConvertPointFBetweenViews( 43 const gfx::PointF local_point(ConvertPointFBetweenViews(
48 connection_manager_->root(), target, 44 connection_manager_->root(), target,
49 gfx::PointF(event->pointer_data->x, event->pointer_data->y))); 45 gfx::PointF(event->pointer_data->x, event->pointer_data->y)));
50 event->pointer_data->x = local_point.x(); 46 event->pointer_data->x = local_point.x();
51 event->pointer_data->y = local_point.y(); 47 event->pointer_data->y = local_point.y();
48
sky 2015/06/05 23:25:50 IMO this relates to the previous code, so no newli
Fady Samuel 2015/06/05 23:34:52 Done.
52 connection_manager_->DispatchInputEventToView(target, event.Pass()); 49 connection_manager_->DispatchInputEventToView(target, event.Pass());
53 } else if (event->action == mojo::EVENT_TYPE_KEY_PRESSED && 50 } else if (event->action == mojo::EVENT_TYPE_KEY_PRESSED &&
54 accelerators_.count(Accelerator(event->key_data->windows_key_code, 51 accelerators_.count(Accelerator(event->key_data->windows_key_code,
55 event->flags))) { 52 event->flags))) {
56 connection_manager_->view_manager_root_client()->OnAccelerator( 53 connection_manager_->view_manager_root_client()->OnAccelerator(
57 event.Pass()); 54 event.Pass());
58 } else { 55 } else {
59 ServerView* focused_view = connection_manager_->GetFocusedView(); 56 ServerView* focused_view = connection_manager_->GetFocusedView();
60 if (focused_view) 57 if (focused_view)
61 connection_manager_->DispatchInputEventToView(focused_view, event.Pass()); 58 connection_manager_->DispatchInputEventToView(focused_view, event.Pass());
62 } 59 }
63 } 60 }
64 61
65 } // namespace view_manager 62 } // namespace view_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698