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

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

Issue 1987133002: Delete mus surfaces hit testing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix unittests Created 4 years, 7 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
« no previous file with comments | « components/mus/ws/event_dispatcher.h ('k') | components/mus/ws/platform_display.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <algorithm> 7 #include <algorithm>
8 8
9 #include "base/time/time.h" 9 #include "base/time/time.h"
10 #include "cc/surfaces/surface_hittest.h"
11 #include "components/mus/surfaces/surfaces_state.h"
12 #include "components/mus/ws/accelerator.h" 10 #include "components/mus/ws/accelerator.h"
13 #include "components/mus/ws/display.h" 11 #include "components/mus/ws/display.h"
14 #include "components/mus/ws/event_dispatcher_delegate.h" 12 #include "components/mus/ws/event_dispatcher_delegate.h"
15 #include "components/mus/ws/server_window.h" 13 #include "components/mus/ws/server_window.h"
16 #include "components/mus/ws/server_window_delegate.h" 14 #include "components/mus/ws/server_window_delegate.h"
17 #include "components/mus/ws/window_coordinate_conversions.h" 15 #include "components/mus/ws/window_coordinate_conversions.h"
18 #include "components/mus/ws/window_finder.h" 16 #include "components/mus/ws/window_finder.h"
19 #include "mojo/converters/geometry/geometry_type_converters.h" 17 #include "mojo/converters/geometry/geometry_type_converters.h"
20 #include "mojo/converters/input_events/input_events_type_converters.h" 18 #include "mojo/converters/input_events/input_events_type_converters.h"
21 #include "ui/events/event_utils.h" 19 #include "ui/events/event_utils.h"
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 if (!capture_window_) 199 if (!capture_window_)
202 return; 200 return;
203 201
204 if (modal_window_controller_.IsWindowBlocked(capture_window_)) 202 if (modal_window_controller_.IsWindowBlocked(capture_window_))
205 SetCaptureWindow(nullptr, false); 203 SetCaptureWindow(nullptr, false);
206 } 204 }
207 205
208 void EventDispatcher::UpdateNonClientAreaForCurrentWindow() { 206 void EventDispatcher::UpdateNonClientAreaForCurrentWindow() {
209 if (mouse_cursor_source_window_) { 207 if (mouse_cursor_source_window_) {
210 gfx::Point location = mouse_pointer_last_location_; 208 gfx::Point location = mouse_pointer_last_location_;
211 ServerWindow* target = 209 ServerWindow* target = FindDeepestVisibleWindowForEvents(root_, &location);
212 FindDeepestVisibleWindowForEvents(root_, surface_id_, &location);
213 if (target == mouse_cursor_source_window_) { 210 if (target == mouse_cursor_source_window_) {
214 mouse_cursor_in_non_client_area_ = 211 mouse_cursor_in_non_client_area_ =
215 mouse_cursor_source_window_ 212 mouse_cursor_source_window_
216 ? IsLocationInNonclientArea(mouse_cursor_source_window_, location) 213 ? IsLocationInNonclientArea(mouse_cursor_source_window_, location)
217 : false; 214 : false;
218 } 215 }
219 } 216 }
220 } 217 }
221 218
222 void EventDispatcher::UpdateCursorProviderByLastKnownLocation() { 219 void EventDispatcher::UpdateCursorProviderByLastKnownLocation() {
223 if (!mouse_button_down_) { 220 if (!mouse_button_down_) {
224 gfx::Point location = mouse_pointer_last_location_; 221 gfx::Point location = mouse_pointer_last_location_;
225 mouse_cursor_source_window_ = 222 mouse_cursor_source_window_ =
226 FindDeepestVisibleWindowForEvents(root_, surface_id_, &location); 223 FindDeepestVisibleWindowForEvents(root_, &location);
227 224
228 mouse_cursor_in_non_client_area_ = 225 mouse_cursor_in_non_client_area_ =
229 mouse_cursor_source_window_ 226 mouse_cursor_source_window_
230 ? IsLocationInNonclientArea(mouse_cursor_source_window_, location) 227 ? IsLocationInNonclientArea(mouse_cursor_source_window_, location)
231 : false; 228 : false;
232 } 229 }
233 } 230 }
234 231
235 bool EventDispatcher::AddAccelerator(uint32_t id, 232 bool EventDispatcher::AddAccelerator(uint32_t id,
236 mojom::EventMatcherPtr event_matcher) { 233 mojom::EventMatcherPtr event_matcher) {
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 // simpler code. 409 // simpler code.
413 StopTrackingPointer(pointer_id); 410 StopTrackingPointer(pointer_id);
414 StartTrackingPointer(pointer_id, pointer_target); 411 StartTrackingPointer(pointer_id, pointer_target);
415 } 412 }
416 413
417 EventDispatcher::PointerTarget EventDispatcher::PointerTargetForEvent( 414 EventDispatcher::PointerTarget EventDispatcher::PointerTargetForEvent(
418 const ui::LocatedEvent& event) const { 415 const ui::LocatedEvent& event) const {
419 PointerTarget pointer_target; 416 PointerTarget pointer_target;
420 gfx::Point location(event.location()); 417 gfx::Point location(event.location());
421 ServerWindow* target_window = 418 ServerWindow* target_window =
422 FindDeepestVisibleWindowForEvents(root_, surface_id_, &location); 419 FindDeepestVisibleWindowForEvents(root_, &location);
423 pointer_target.window = 420 pointer_target.window =
424 modal_window_controller_.GetTargetForWindow(target_window); 421 modal_window_controller_.GetTargetForWindow(target_window);
425 pointer_target.is_mouse_event = event.IsMousePointerEvent(); 422 pointer_target.is_mouse_event = event.IsMousePointerEvent();
426 pointer_target.in_nonclient_area = 423 pointer_target.in_nonclient_area =
427 target_window != pointer_target.window || 424 target_window != pointer_target.window ||
428 IsLocationInNonclientArea(pointer_target.window, location); 425 IsLocationInNonclientArea(pointer_target.window, location);
429 pointer_target.is_pointer_down = event.type() == ui::ET_POINTER_DOWN; 426 pointer_target.is_pointer_down = event.type() == ui::ET_POINTER_DOWN;
430 return pointer_target; 427 return pointer_target;
431 } 428 }
432 429
433 bool EventDispatcher::AreAnyPointersDown() const { 430 bool EventDispatcher::AreAnyPointersDown() const {
434 for (const auto& pair : pointer_targets_) { 431 for (const auto& pair : pointer_targets_) {
435 if (pair.second.is_pointer_down) 432 if (pair.second.is_pointer_down)
436 return true; 433 return true;
437 } 434 }
438 return false; 435 return false;
439 } 436 }
440 437
441 void EventDispatcher::DispatchToPointerTarget(const PointerTarget& target, 438 void EventDispatcher::DispatchToPointerTarget(const PointerTarget& target,
442 const ui::LocatedEvent& event) { 439 const ui::LocatedEvent& event) {
443 if (!target.window) { 440 if (!target.window) {
444 delegate_->OnEventTargetNotFound(event); 441 delegate_->OnEventTargetNotFound(event);
445 return; 442 return;
446 } 443 }
447 444
448 if (target.is_mouse_event) 445 if (target.is_mouse_event)
449 mouse_cursor_in_non_client_area_ = target.in_nonclient_area; 446 mouse_cursor_in_non_client_area_ = target.in_nonclient_area;
450 447
451 gfx::Point location(event.location()); 448 gfx::Point location(event.location());
452 gfx::Transform transform(GetTransformToWindow(surface_id_, target.window)); 449 gfx::Transform transform(GetTransformToWindow(target.window));
453 transform.TransformPoint(&location); 450 transform.TransformPoint(&location);
454 std::unique_ptr<ui::Event> clone = ui::Event::Clone(event); 451 std::unique_ptr<ui::Event> clone = ui::Event::Clone(event);
455 clone->AsLocatedEvent()->set_location(location); 452 clone->AsLocatedEvent()->set_location(location);
456 // TODO(jonross): add post-target accelerator support once accelerators 453 // TODO(jonross): add post-target accelerator support once accelerators
457 // support pointer events. 454 // support pointer events.
458 delegate_->DispatchInputEventToWindow(target.window, target.in_nonclient_area, 455 delegate_->DispatchInputEventToWindow(target.window, target.in_nonclient_area,
459 *clone, nullptr); 456 *clone, nullptr);
460 } 457 }
461 458
462 void EventDispatcher::CancelPointerEventsToTarget(ServerWindow* window) { 459 void EventDispatcher::CancelPointerEventsToTarget(ServerWindow* window) {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 519
523 void EventDispatcher::OnWindowDestroyed(ServerWindow* window) { 520 void EventDispatcher::OnWindowDestroyed(ServerWindow* window) {
524 CancelPointerEventsToTarget(window); 521 CancelPointerEventsToTarget(window);
525 522
526 if (mouse_cursor_source_window_ == window) 523 if (mouse_cursor_source_window_ == window)
527 mouse_cursor_source_window_ = nullptr; 524 mouse_cursor_source_window_ = nullptr;
528 } 525 }
529 526
530 } // namespace ws 527 } // namespace ws
531 } // namespace mus 528 } // namespace mus
OLDNEW
« no previous file with comments | « components/mus/ws/event_dispatcher.h ('k') | components/mus/ws/platform_display.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698