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

Side by Side Diff: services/ui/ws/event_dispatcher.cc

Issue 2237003002: Find display root ServerWindow for located events in mus. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@add_display
Patch Set: Fixes. Created 4 years, 4 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 "services/ui/ws/event_dispatcher.h" 5 #include "services/ui/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 "services/ui/ws/accelerator.h" 10 #include "services/ui/ws/accelerator.h"
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 delegate_->OnAccelerator(post_target->id(), event, 315 delegate_->OnAccelerator(post_target->id(), event,
316 EventDispatcherDelegate::AcceleratorPhase::POST); 316 EventDispatcherDelegate::AcceleratorPhase::POST);
317 } 317 }
318 318
319 void EventDispatcher::ProcessLocatedEvent(const ui::LocatedEvent& event) { 319 void EventDispatcher::ProcessLocatedEvent(const ui::LocatedEvent& event) {
320 DCHECK(event.IsPointerEvent() || event.IsMouseWheelEvent()); 320 DCHECK(event.IsPointerEvent() || event.IsMouseWheelEvent());
321 const bool is_mouse_event = 321 const bool is_mouse_event =
322 event.IsMousePointerEvent() || event.IsMouseWheelEvent(); 322 event.IsMousePointerEvent() || event.IsMouseWheelEvent();
323 323
324 if (is_mouse_event) { 324 if (is_mouse_event) {
325 mouse_pointer_last_location_ = event.location(); 325 mouse_pointer_last_location_ = event.root_location();
326 delegate_->OnMouseCursorLocationChanged(event.root_location()); 326 delegate_->OnMouseCursorLocationChanged(event.root_location());
327 } 327 }
328 328
329 // Release capture on pointer up. For mouse we only release if there are 329 // Release capture on pointer up. For mouse we only release if there are
330 // no buttons down. 330 // no buttons down.
331 const bool is_pointer_going_up = 331 const bool is_pointer_going_up =
332 (event.type() == ui::ET_POINTER_UP || 332 (event.type() == ui::ET_POINTER_UP ||
333 event.type() == ui::ET_POINTER_CANCELLED) && 333 event.type() == ui::ET_POINTER_CANCELLED) &&
334 (!is_mouse_event || IsOnlyOneMouseButtonDown(event.flags())); 334 (!is_mouse_event || IsOnlyOneMouseButtonDown(event.flags()));
335 335
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 432
433 // Technically we're updating in place, but calling start then stop makes for 433 // Technically we're updating in place, but calling start then stop makes for
434 // simpler code. 434 // simpler code.
435 StopTrackingPointer(pointer_id); 435 StopTrackingPointer(pointer_id);
436 StartTrackingPointer(pointer_id, pointer_target); 436 StartTrackingPointer(pointer_id, pointer_target);
437 } 437 }
438 438
439 EventDispatcher::PointerTarget EventDispatcher::PointerTargetForEvent( 439 EventDispatcher::PointerTarget EventDispatcher::PointerTargetForEvent(
440 const ui::LocatedEvent& event) { 440 const ui::LocatedEvent& event) {
441 PointerTarget pointer_target; 441 PointerTarget pointer_target;
442 gfx::Point location(event.location()); 442 gfx::Point location(event.root_location());
443 ServerWindow* target_window = FindDeepestVisibleWindowForEvents(&location); 443 ServerWindow* target_window = FindDeepestVisibleWindowForEvents(&location);
444 pointer_target.window = 444 pointer_target.window =
445 modal_window_controller_.GetTargetForWindow(target_window); 445 modal_window_controller_.GetTargetForWindow(target_window);
446 pointer_target.is_mouse_event = event.IsMousePointerEvent(); 446 pointer_target.is_mouse_event = event.IsMousePointerEvent();
447 pointer_target.in_nonclient_area = 447 pointer_target.in_nonclient_area =
448 target_window != pointer_target.window || 448 target_window != pointer_target.window ||
449 IsLocationInNonclientArea(pointer_target.window, location); 449 IsLocationInNonclientArea(pointer_target.window, location);
450 pointer_target.is_pointer_down = event.type() == ui::ET_POINTER_DOWN; 450 pointer_target.is_pointer_down = event.type() == ui::ET_POINTER_DOWN;
451 return pointer_target; 451 return pointer_target;
452 } 452 }
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 const ui::mojom::AcceleratorPhase phase) { 533 const ui::mojom::AcceleratorPhase phase) {
534 for (const auto& pair : accelerators_) { 534 for (const auto& pair : accelerators_) {
535 if (pair.second->MatchesEvent(event, phase)) 535 if (pair.second->MatchesEvent(event, phase))
536 return pair.second.get(); 536 return pair.second.get();
537 } 537 }
538 return nullptr; 538 return nullptr;
539 } 539 }
540 540
541 ServerWindow* EventDispatcher::FindDeepestVisibleWindowForEvents( 541 ServerWindow* EventDispatcher::FindDeepestVisibleWindowForEvents(
542 gfx::Point* location) { 542 gfx::Point* location) {
543 ServerWindow* root = delegate_->GetRootWindowContaining(*location); 543 ServerWindow* root = delegate_->GetRootWindowContaining(location);
544 if (!root) 544 if (!root)
545 return nullptr; 545 return nullptr;
546 546
547 return ui::ws::FindDeepestVisibleWindowForEvents(root, location); 547 return ui::ws::FindDeepestVisibleWindowForEvents(root, location);
548 } 548 }
549 549
550 void EventDispatcher::OnWillChangeWindowHierarchy(ServerWindow* window, 550 void EventDispatcher::OnWillChangeWindowHierarchy(ServerWindow* window,
551 ServerWindow* new_parent, 551 ServerWindow* new_parent,
552 ServerWindow* old_parent) { 552 ServerWindow* old_parent) {
553 // TODO(sky): moving to a different root likely needs to transfer capture. 553 // TODO(sky): moving to a different root likely needs to transfer capture.
(...skipping 16 matching lines...) Expand all
570 570
571 void EventDispatcher::OnWindowDestroyed(ServerWindow* window) { 571 void EventDispatcher::OnWindowDestroyed(ServerWindow* window) {
572 CancelPointerEventsToTarget(window); 572 CancelPointerEventsToTarget(window);
573 573
574 if (mouse_cursor_source_window_ == window) 574 if (mouse_cursor_source_window_ == window)
575 mouse_cursor_source_window_ = nullptr; 575 mouse_cursor_source_window_ = nullptr;
576 } 576 }
577 577
578 } // namespace ws 578 } // namespace ws
579 } // namespace ui 579 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698