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

Side by Side Diff: components/mus/ws/event_dispatcher.cc

Issue 1465803003: mus: Let clients set the cursor of their window. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix WindowTreeAppTest.SetCursor. Created 5 years 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/mus/ws/event_dispatcher.h" 5 #include "components/mus/ws/event_dispatcher.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "cc/surfaces/surface_hittest.h" 9 #include "cc/surfaces/surface_hittest.h"
10 #include "components/mus/surfaces/surfaces_state.h" 10 #include "components/mus/surfaces/surfaces_state.h"
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 mojom::EventType event_type_; 134 mojom::EventType event_type_;
135 mojom::EventFlags event_flags_; 135 mojom::EventFlags event_flags_;
136 mojom::KeyboardCode keyboard_code_; 136 mojom::KeyboardCode keyboard_code_;
137 mojom::PointerKind pointer_kind_; 137 mojom::PointerKind pointer_kind_;
138 gfx::RectF pointer_region_; 138 gfx::RectF pointer_region_;
139 }; 139 };
140 140
141 //////////////////////////////////////////////////////////////////////////////// 141 ////////////////////////////////////////////////////////////////////////////////
142 142
143 EventDispatcher::EventDispatcher(EventDispatcherDelegate* delegate) 143 EventDispatcher::EventDispatcher(EventDispatcherDelegate* delegate)
144 : delegate_(delegate), root_(nullptr) {} 144 : delegate_(delegate),
145 root_(nullptr),
146 last_pointer_target_window_(nullptr) {}
145 147
146 EventDispatcher::~EventDispatcher() { 148 EventDispatcher::~EventDispatcher() {
147 std::set<ServerWindow*> pointer_targets; 149 std::set<ServerWindow*> pointer_targets;
148 for (const auto& pair : pointer_targets_) { 150 for (const auto& pair : pointer_targets_) {
149 if (pair.second.window && 151 if (pair.second.window &&
150 pointer_targets.insert(pair.second.window).second) { 152 pointer_targets.insert(pair.second.window).second) {
151 pair.second.window->RemoveObserver(this); 153 pair.second.window->RemoveObserver(this);
152 } 154 }
153 } 155 }
154 } 156 }
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 if (target && !IsObservingWindow(target)) 258 if (target && !IsObservingWindow(target))
257 target->RemoveObserver(this); 259 target->RemoveObserver(this);
258 } 260 }
259 } 261 }
260 262
261 void EventDispatcher::DispatchToPointerTarget(const PointerTarget& target, 263 void EventDispatcher::DispatchToPointerTarget(const PointerTarget& target,
262 mojom::EventPtr event) { 264 mojom::EventPtr event) {
263 if (!target.window) 265 if (!target.window)
264 return; 266 return;
265 267
268 if (event->pointer_data->kind == mojom::PointerKind::POINTER_KIND_MOUSE)
269 last_pointer_target_window_ = target.window;
270
266 gfx::Point location(EventLocationToPoint(*event)); 271 gfx::Point location(EventLocationToPoint(*event));
267 gfx::Transform transform(GetTransformToWindow(surface_id_, target.window)); 272 gfx::Transform transform(GetTransformToWindow(surface_id_, target.window));
268 transform.TransformPoint(&location); 273 transform.TransformPoint(&location);
269 event->pointer_data->location->x = location.x(); 274 event->pointer_data->location->x = location.x();
270 event->pointer_data->location->y = location.y(); 275 event->pointer_data->location->y = location.y();
271 delegate_->DispatchInputEventToWindow(target.window, target.in_nonclient_area, 276 delegate_->DispatchInputEventToWindow(target.window, target.in_nonclient_area,
272 event.Pass()); 277 event.Pass());
273 } 278 }
274 279
275 void EventDispatcher::CancelPointerEventsToTarget(ServerWindow* window) { 280 void EventDispatcher::CancelPointerEventsToTarget(ServerWindow* window) {
(...skipping 30 matching lines...) Expand all
306 ServerWindow* old_parent) { 311 ServerWindow* old_parent) {
307 CancelPointerEventsToTarget(window); 312 CancelPointerEventsToTarget(window);
308 } 313 }
309 314
310 void EventDispatcher::OnWindowVisibilityChanged(ServerWindow* window) { 315 void EventDispatcher::OnWindowVisibilityChanged(ServerWindow* window) {
311 CancelPointerEventsToTarget(window); 316 CancelPointerEventsToTarget(window);
312 } 317 }
313 318
314 void EventDispatcher::OnWindowDestroyed(ServerWindow* window) { 319 void EventDispatcher::OnWindowDestroyed(ServerWindow* window) {
315 CancelPointerEventsToTarget(window); 320 CancelPointerEventsToTarget(window);
321
322 if (last_pointer_target_window_ == window)
323 last_pointer_target_window_ = nullptr;
316 } 324 }
317 325
318 } // namespace ws 326 } // namespace ws
319 } // namespace mus 327 } // namespace mus
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698