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

Side by Side Diff: mojo/services/window_manager/focus_controller.cc

Issue 724973003: Get event targetting working for mouse events. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: More comments, de-const a bunch of stuff in ui/. Created 6 years, 1 month 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "mojo/services/window_manager/focus_controller.h" 5 #include "mojo/services/window_manager/focus_controller.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "mojo/services/public/cpp/view_manager/view_tracker.h" 8 #include "mojo/services/public/cpp/view_manager/view_tracker.h"
9 #include "mojo/services/window_manager/focus_controller_observer.h" 9 #include "mojo/services/window_manager/focus_controller_observer.h"
10 #include "mojo/services/window_manager/focus_rules.h" 10 #include "mojo/services/window_manager/focus_rules.h"
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 } 111 }
112 112
113 //////////////////////////////////////////////////////////////////////////////// 113 ////////////////////////////////////////////////////////////////////////////////
114 // FocusController, ui::EventHandler implementation: 114 // FocusController, ui::EventHandler implementation:
115 115
116 void FocusController::OnKeyEvent(ui::KeyEvent* event) { 116 void FocusController::OnKeyEvent(ui::KeyEvent* event) {
117 } 117 }
118 118
119 void FocusController::OnMouseEvent(ui::MouseEvent* event) { 119 void FocusController::OnMouseEvent(ui::MouseEvent* event) {
120 if (event->type() == ui::ET_MOUSE_PRESSED && !event->handled()) { 120 if (event->type() == ui::ET_MOUSE_PRESSED && !event->handled()) {
121 View* view = mojo::WindowManagerApp::GetViewForViewTarget( 121 View* view = static_cast<ViewTarget*>(event->target())->view();
122 static_cast<ViewTarget*>(event->target()));
123 ViewFocusedFromInputEvent(view); 122 ViewFocusedFromInputEvent(view);
124 } 123 }
125 } 124 }
126 125
127 void FocusController::OnScrollEvent(ui::ScrollEvent* event) { 126 void FocusController::OnScrollEvent(ui::ScrollEvent* event) {
128 } 127 }
129 128
130 void FocusController::OnTouchEvent(ui::TouchEvent* event) { 129 void FocusController::OnTouchEvent(ui::TouchEvent* event) {
131 } 130 }
132 131
133 void FocusController::OnGestureEvent(ui::GestureEvent* event) { 132 void FocusController::OnGestureEvent(ui::GestureEvent* event) {
134 if (event->type() == ui::ET_GESTURE_BEGIN && 133 if (event->type() == ui::ET_GESTURE_BEGIN &&
135 event->details().touch_points() == 1 && 134 event->details().touch_points() == 1 &&
136 !event->handled()) { 135 !event->handled()) {
137 View* view = mojo::WindowManagerApp::GetViewForViewTarget( 136 View* view = static_cast<ViewTarget*>(event->target())->view();
138 static_cast<ViewTarget*>(event->target()));
139 ViewFocusedFromInputEvent(view); 137 ViewFocusedFromInputEvent(view);
140 } 138 }
141 } 139 }
142 140
143 //////////////////////////////////////////////////////////////////////////////// 141 ////////////////////////////////////////////////////////////////////////////////
144 // FocusController, aura::WindowObserver implementation: 142 // FocusController, aura::WindowObserver implementation:
145 143
146 void FocusController::OnViewVisibilityChanged(View* view) { 144 void FocusController::OnViewVisibilityChanged(View* view) {
147 bool visible = view->visible(); 145 bool visible = view->visible();
148 if (!visible) 146 if (!visible)
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 292
295 void FocusController::ViewFocusedFromInputEvent(View* view) { 293 void FocusController::ViewFocusedFromInputEvent(View* view) {
296 // Only focus |window| if it or any of its parents can be focused. Otherwise 294 // Only focus |window| if it or any of its parents can be focused. Otherwise
297 // FocusWindow() will focus the topmost window, which may not be the 295 // FocusWindow() will focus the topmost window, which may not be the
298 // currently focused one. 296 // currently focused one.
299 if (rules_->CanFocusView(GetToplevelView(view))) 297 if (rules_->CanFocusView(GetToplevelView(view)))
300 FocusView(view); 298 FocusView(view);
301 } 299 }
302 300
303 } // namespace mojo 301 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/services/window_manager/BUILD.gn ('k') | mojo/services/window_manager/view_event_dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698