| OLD | NEW |
| 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/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 CancelPointerEventsToTarget(capture_window_); | 69 CancelPointerEventsToTarget(capture_window_); |
| 70 DCHECK(capture_window_ == nullptr); | 70 DCHECK(capture_window_ == nullptr); |
| 71 } | 71 } |
| 72 | 72 |
| 73 while (!pointer_targets_.empty()) | 73 while (!pointer_targets_.empty()) |
| 74 StopTrackingPointer(pointer_targets_.begin()->first); | 74 StopTrackingPointer(pointer_targets_.begin()->first); |
| 75 | 75 |
| 76 mouse_button_down_ = false; | 76 mouse_button_down_ = false; |
| 77 } | 77 } |
| 78 | 78 |
| 79 void EventDispatcher::SetMousePointerScreenLocation( | 79 void EventDispatcher::SetMousePointerDisplayLocation( |
| 80 const gfx::Point& screen_location) { | 80 const gfx::Point& display_location, |
| 81 const int64_t display_id) { |
| 81 DCHECK(pointer_targets_.empty()); | 82 DCHECK(pointer_targets_.empty()); |
| 82 mouse_pointer_last_location_ = screen_location; | 83 mouse_pointer_last_location_ = display_location; |
| 84 mouse_pointer_display_id_ = display_id; |
| 83 UpdateCursorProviderByLastKnownLocation(); | 85 UpdateCursorProviderByLastKnownLocation(); |
| 84 // Write our initial location back to our shared screen coordinate. This | 86 // Write our initial location back to our shared screen coordinate. This |
| 85 // shouldn't cause problems because we already read the cursor before we | 87 // shouldn't cause problems because we already read the cursor before we |
| 86 // process any events in views during window construction. | 88 // process any events in views during window construction. |
| 87 delegate_->OnMouseCursorLocationChanged(screen_location); | 89 delegate_->OnMouseCursorLocationChanged(display_location, display_id); |
| 88 } | 90 } |
| 89 | 91 |
| 90 ui::CursorData EventDispatcher::GetCurrentMouseCursor() const { | 92 ui::CursorData EventDispatcher::GetCurrentMouseCursor() const { |
| 91 if (drag_controller_) | 93 if (drag_controller_) |
| 92 return drag_controller_->current_cursor(); | 94 return drag_controller_->current_cursor(); |
| 93 | 95 |
| 94 if (!mouse_cursor_source_window_) | 96 if (!mouse_cursor_source_window_) |
| 95 return ui::CursorData(ui::CursorType::kPointer); | 97 return ui::CursorData(ui::CursorType::kPointer); |
| 96 | 98 |
| 97 if (mouse_cursor_in_non_client_area_) | 99 if (mouse_cursor_in_non_client_area_) |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 const ClientSpecificId target_client_id = delegate_->GetEventTargetClientId( | 214 const ClientSpecificId target_client_id = delegate_->GetEventTargetClientId( |
| 213 mouse_cursor_source_window_, mouse_cursor_in_non_client_area_); | 215 mouse_cursor_source_window_, mouse_cursor_in_non_client_area_); |
| 214 const ServerWindow* window = mouse_cursor_source_window_; | 216 const ServerWindow* window = mouse_cursor_source_window_; |
| 215 while (window && window->id().client_id == target_client_id) | 217 while (window && window->id().client_id == target_client_id) |
| 216 window = window->parent(); | 218 window = window->parent(); |
| 217 return window; | 219 return window; |
| 218 } | 220 } |
| 219 | 221 |
| 220 void EventDispatcher::UpdateNonClientAreaForCurrentWindow() { | 222 void EventDispatcher::UpdateNonClientAreaForCurrentWindow() { |
| 221 if (mouse_cursor_source_window_) { | 223 if (mouse_cursor_source_window_) { |
| 222 DeepestWindow deepest_window = | 224 DeepestWindow deepest_window = FindDeepestVisibleWindowForEvents( |
| 223 FindDeepestVisibleWindowForEvents(mouse_pointer_last_location_); | 225 &mouse_pointer_last_location_, &mouse_pointer_display_id_); |
| 224 if (deepest_window.window == mouse_cursor_source_window_) { | 226 if (deepest_window.window == mouse_cursor_source_window_) { |
| 225 mouse_cursor_in_non_client_area_ = mouse_cursor_source_window_ | 227 mouse_cursor_in_non_client_area_ = mouse_cursor_source_window_ |
| 226 ? deepest_window.in_non_client_area | 228 ? deepest_window.in_non_client_area |
| 227 : false; | 229 : false; |
| 228 } | 230 } |
| 229 } | 231 } |
| 230 } | 232 } |
| 231 | 233 |
| 232 void EventDispatcher::UpdateCursorProviderByLastKnownLocation() { | 234 void EventDispatcher::UpdateCursorProviderByLastKnownLocation() { |
| 233 if (!mouse_button_down_) { | 235 if (!mouse_button_down_) { |
| 234 DeepestWindow deepest_window = | 236 DeepestWindow deepest_window = FindDeepestVisibleWindowForEvents( |
| 235 FindDeepestVisibleWindowForEvents(mouse_pointer_last_location_); | 237 &mouse_pointer_last_location_, &mouse_pointer_display_id_); |
| 236 SetMouseCursorSourceWindow(deepest_window.window); | 238 SetMouseCursorSourceWindow(deepest_window.window); |
| 237 if (mouse_cursor_source_window_) { | 239 if (mouse_cursor_source_window_) { |
| 238 mouse_cursor_in_non_client_area_ = deepest_window.in_non_client_area; | 240 mouse_cursor_in_non_client_area_ = deepest_window.in_non_client_area; |
| 239 } else { | 241 } else { |
| 240 gfx::Point location = mouse_pointer_last_location_; | 242 SetMouseCursorSourceWindow(delegate_->GetRootWindowContaining( |
| 241 SetMouseCursorSourceWindow(delegate_->GetRootWindowContaining(&location)); | 243 &mouse_pointer_last_location_, &mouse_pointer_display_id_)); |
| 242 mouse_cursor_in_non_client_area_ = true; | 244 mouse_cursor_in_non_client_area_ = true; |
| 243 } | 245 } |
| 244 } | 246 } |
| 245 } | 247 } |
| 246 | 248 |
| 247 bool EventDispatcher::AddAccelerator(uint32_t id, | 249 bool EventDispatcher::AddAccelerator(uint32_t id, |
| 248 mojom::EventMatcherPtr event_matcher) { | 250 mojom::EventMatcherPtr event_matcher) { |
| 249 std::unique_ptr<Accelerator> accelerator(new Accelerator(id, *event_matcher)); | 251 std::unique_ptr<Accelerator> accelerator(new Accelerator(id, *event_matcher)); |
| 250 // If an accelerator with the same id or matcher already exists, then abort. | 252 // If an accelerator with the same id or matcher already exists, then abort. |
| 251 for (const auto& pair : accelerators_) { | 253 for (const auto& pair : accelerators_) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 266 } | 268 } |
| 267 | 269 |
| 268 void EventDispatcher::RemoveAccelerator(uint32_t id) { | 270 void EventDispatcher::RemoveAccelerator(uint32_t id) { |
| 269 auto it = accelerators_.find(id); | 271 auto it = accelerators_.find(id); |
| 270 // Clients may pass bogus ids. | 272 // Clients may pass bogus ids. |
| 271 if (it != accelerators_.end()) | 273 if (it != accelerators_.end()) |
| 272 accelerators_.erase(it); | 274 accelerators_.erase(it); |
| 273 } | 275 } |
| 274 | 276 |
| 275 void EventDispatcher::ProcessEvent(const ui::Event& event, | 277 void EventDispatcher::ProcessEvent(const ui::Event& event, |
| 278 const int64_t display_id, |
| 276 AcceleratorMatchPhase match_phase) { | 279 AcceleratorMatchPhase match_phase) { |
| 277 #if !defined(NDEBUG) | 280 #if !defined(NDEBUG) |
| 278 if (match_phase == AcceleratorMatchPhase::POST_ONLY) { | 281 if (match_phase == AcceleratorMatchPhase::POST_ONLY) { |
| 279 // POST_ONLY should always be preceeded by ANY with the same event. | 282 // POST_ONLY should always be preceeded by ANY with the same event. |
| 280 DCHECK(previous_event_); | 283 DCHECK(previous_event_); |
| 281 // Event doesn't define ==, so this compares the key fields. | 284 // Event doesn't define ==, so this compares the key fields. |
| 282 DCHECK(event.type() == previous_event_->type() && | 285 DCHECK(event.type() == previous_event_->type() && |
| 283 event.time_stamp() == previous_event_->time_stamp() && | 286 event.time_stamp() == previous_event_->time_stamp() && |
| 284 event.flags() == previous_event_->flags()); | 287 event.flags() == previous_event_->flags()); |
| 285 DCHECK_EQ(previous_accelerator_match_phase_, AcceleratorMatchPhase::ANY); | 288 DCHECK_EQ(previous_accelerator_match_phase_, AcceleratorMatchPhase::ANY); |
| 286 } | 289 } |
| 287 previous_event_ = Event::Clone(event); | 290 previous_event_ = Event::Clone(event); |
| 288 previous_accelerator_match_phase_ = match_phase; | 291 previous_accelerator_match_phase_ = match_phase; |
| 289 #endif | 292 #endif |
| 293 event_display_id_ = display_id; |
| 290 if (event.IsKeyEvent()) { | 294 if (event.IsKeyEvent()) { |
| 291 const ui::KeyEvent* key_event = event.AsKeyEvent(); | 295 const ui::KeyEvent* key_event = event.AsKeyEvent(); |
| 292 if (!key_event->is_char() && match_phase == AcceleratorMatchPhase::ANY) { | 296 if (!key_event->is_char() && match_phase == AcceleratorMatchPhase::ANY) { |
| 293 Accelerator* pre_target = | 297 Accelerator* pre_target = |
| 294 FindAccelerator(*key_event, ui::mojom::AcceleratorPhase::PRE_TARGET); | 298 FindAccelerator(*key_event, ui::mojom::AcceleratorPhase::PRE_TARGET); |
| 295 if (pre_target) { | 299 if (pre_target) { |
| 296 delegate_->OnAccelerator( | 300 delegate_->OnAccelerator( |
| 297 pre_target->id(), event, | 301 pre_target->id(), event_display_id_, event, |
| 298 EventDispatcherDelegate::AcceleratorPhase::PRE); | 302 EventDispatcherDelegate::AcceleratorPhase::PRE); |
| 299 return; | 303 return; |
| 300 } | 304 } |
| 301 } | 305 } |
| 302 ProcessKeyEvent(*key_event, match_phase); | 306 ProcessKeyEvent(*key_event, match_phase); |
| 303 return; | 307 return; |
| 304 } | 308 } |
| 305 | 309 |
| 306 DCHECK(event.IsPointerEvent()); | 310 DCHECK(event.IsPointerEvent()); |
| 307 ProcessPointerEvent(*event.AsPointerEvent()); | 311 ProcessPointerEvent(*event.AsPointerEvent()); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 322 void EventDispatcher::ProcessKeyEvent(const ui::KeyEvent& event, | 326 void EventDispatcher::ProcessKeyEvent(const ui::KeyEvent& event, |
| 323 AcceleratorMatchPhase match_phase) { | 327 AcceleratorMatchPhase match_phase) { |
| 324 Accelerator* post_target = | 328 Accelerator* post_target = |
| 325 FindAccelerator(event, ui::mojom::AcceleratorPhase::POST_TARGET); | 329 FindAccelerator(event, ui::mojom::AcceleratorPhase::POST_TARGET); |
| 326 if (drag_controller_ && event.type() == ui::ET_KEY_PRESSED && | 330 if (drag_controller_ && event.type() == ui::ET_KEY_PRESSED && |
| 327 event.key_code() == ui::VKEY_ESCAPE) { | 331 event.key_code() == ui::VKEY_ESCAPE) { |
| 328 drag_controller_->Cancel(); | 332 drag_controller_->Cancel(); |
| 329 return; | 333 return; |
| 330 } | 334 } |
| 331 ServerWindow* focused_window = | 335 ServerWindow* focused_window = |
| 332 delegate_->GetFocusedWindowForEventDispatcher(); | 336 delegate_->GetFocusedWindowForEventDispatcher(event_display_id_); |
| 333 if (focused_window) { | 337 if (focused_window) { |
| 334 // Assume key events are for the client area. | 338 // Assume key events are for the client area. |
| 335 const bool in_nonclient_area = false; | 339 const bool in_nonclient_area = false; |
| 336 const ClientSpecificId client_id = | 340 const ClientSpecificId client_id = |
| 337 delegate_->GetEventTargetClientId(focused_window, in_nonclient_area); | 341 delegate_->GetEventTargetClientId(focused_window, in_nonclient_area); |
| 338 delegate_->DispatchInputEventToWindow(focused_window, client_id, event, | 342 delegate_->DispatchInputEventToWindow( |
| 339 post_target); | 343 focused_window, client_id, event_display_id_, event, post_target); |
| 340 return; | 344 return; |
| 341 } | 345 } |
| 342 delegate_->OnEventTargetNotFound(event); | 346 delegate_->OnEventTargetNotFound(event, event_display_id_); |
| 343 if (post_target) | 347 if (post_target) |
| 344 delegate_->OnAccelerator(post_target->id(), event, | 348 delegate_->OnAccelerator(post_target->id(), event_display_id_, event, |
| 345 EventDispatcherDelegate::AcceleratorPhase::POST); | 349 EventDispatcherDelegate::AcceleratorPhase::POST); |
| 346 } | 350 } |
| 347 | 351 |
| 348 void EventDispatcher::ProcessPointerEvent(const ui::PointerEvent& event) { | 352 void EventDispatcher::ProcessPointerEvent(const ui::PointerEvent& event) { |
| 349 DCHECK(event.IsPointerEvent()); | 353 DCHECK(event.IsPointerEvent()); |
| 350 const bool is_mouse_event = event.IsMousePointerEvent(); | 354 const bool is_mouse_event = event.IsMousePointerEvent(); |
| 351 | 355 |
| 352 if (is_mouse_event) { | 356 if (is_mouse_event) { |
| 353 mouse_pointer_last_location_ = event.root_location(); | 357 mouse_pointer_last_location_ = event.root_location(); |
| 354 delegate_->OnMouseCursorLocationChanged(event.root_location()); | 358 mouse_pointer_display_id_ = event_display_id_; |
| 359 delegate_->OnMouseCursorLocationChanged(event.root_location(), |
| 360 event_display_id_); |
| 355 } | 361 } |
| 356 | 362 |
| 357 // Release capture on pointer up. For mouse we only release if there are | 363 // Release capture on pointer up. For mouse we only release if there are |
| 358 // no buttons down. | 364 // no buttons down. |
| 359 const bool is_pointer_going_up = | 365 const bool is_pointer_going_up = |
| 360 (event.type() == ui::ET_POINTER_UP || | 366 (event.type() == ui::ET_POINTER_UP || |
| 361 event.type() == ui::ET_POINTER_CANCELLED) && | 367 event.type() == ui::ET_POINTER_CANCELLED) && |
| 362 (!is_mouse_event || IsOnlyOneMouseButtonDown(event.flags())); | 368 (!is_mouse_event || IsOnlyOneMouseButtonDown(event.flags())); |
| 363 | 369 |
| 364 // Update mouse down state upon events which change it. | 370 // Update mouse down state upon events which change it. |
| (...skipping 27 matching lines...) Expand all Loading... |
| 392 PointerTarget& pointer_target = pointer_targets_[pointer_id]; | 398 PointerTarget& pointer_target = pointer_targets_[pointer_id]; |
| 393 if (pointer_target.is_pointer_down) { | 399 if (pointer_target.is_pointer_down) { |
| 394 if (is_mouse_event) | 400 if (is_mouse_event) |
| 395 SetMouseCursorSourceWindow(pointer_target.window); | 401 SetMouseCursorSourceWindow(pointer_target.window); |
| 396 if (!any_pointers_down) { | 402 if (!any_pointers_down) { |
| 397 if (pointer_target.window) | 403 if (pointer_target.window) |
| 398 delegate_->SetFocusedWindowFromEventDispatcher(pointer_target.window); | 404 delegate_->SetFocusedWindowFromEventDispatcher(pointer_target.window); |
| 399 ServerWindow* capture_window = pointer_target.window; | 405 ServerWindow* capture_window = pointer_target.window; |
| 400 if (!capture_window) { | 406 if (!capture_window) { |
| 401 gfx::Point event_location = event.root_location(); | 407 gfx::Point event_location = event.root_location(); |
| 402 capture_window = delegate_->GetRootWindowContaining(&event_location); | 408 int64_t event_display_id = event_display_id_; |
| 409 capture_window = delegate_->GetRootWindowContaining( |
| 410 &event_location, &event_display_id); |
| 403 } | 411 } |
| 404 delegate_->SetNativeCapture(capture_window); | 412 delegate_->SetNativeCapture(capture_window); |
| 405 } | 413 } |
| 406 } | 414 } |
| 407 } | 415 } |
| 408 | 416 |
| 409 // When we release the mouse button, we want the cursor to be sourced from | 417 // When we release the mouse button, we want the cursor to be sourced from |
| 410 // the window under the mouse pointer, even though we're sending the button | 418 // the window under the mouse pointer, even though we're sending the button |
| 411 // up event to the window that had implicit capture. We have to set this | 419 // up event to the window that had implicit capture. We have to set this |
| 412 // before we perform dispatch because the Delegate is going to read this | 420 // before we perform dispatch because the Delegate is going to read this |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 | 482 |
| 475 // Technically we're updating in place, but calling start then stop makes for | 483 // Technically we're updating in place, but calling start then stop makes for |
| 476 // simpler code. | 484 // simpler code. |
| 477 StopTrackingPointer(pointer_id); | 485 StopTrackingPointer(pointer_id); |
| 478 StartTrackingPointer(pointer_id, pointer_target); | 486 StartTrackingPointer(pointer_id, pointer_target); |
| 479 } | 487 } |
| 480 | 488 |
| 481 EventDispatcher::PointerTarget EventDispatcher::PointerTargetForEvent( | 489 EventDispatcher::PointerTarget EventDispatcher::PointerTargetForEvent( |
| 482 const ui::LocatedEvent& event) { | 490 const ui::LocatedEvent& event) { |
| 483 PointerTarget pointer_target; | 491 PointerTarget pointer_target; |
| 484 DeepestWindow deepest_window = | 492 gfx::Point event_root_location(event.root_location()); |
| 485 FindDeepestVisibleWindowForEvents(event.root_location()); | 493 DeepestWindow deepest_window = FindDeepestVisibleWindowForEvents( |
| 494 &event_root_location, &event_display_id_); |
| 486 pointer_target.window = | 495 pointer_target.window = |
| 487 modal_window_controller_.GetTargetForWindow(deepest_window.window); | 496 modal_window_controller_.GetTargetForWindow(deepest_window.window); |
| 488 pointer_target.is_mouse_event = event.IsMousePointerEvent(); | 497 pointer_target.is_mouse_event = event.IsMousePointerEvent(); |
| 489 pointer_target.in_nonclient_area = | 498 pointer_target.in_nonclient_area = |
| 490 deepest_window.window != pointer_target.window || | 499 deepest_window.window != pointer_target.window || |
| 491 !pointer_target.window || deepest_window.in_non_client_area; | 500 !pointer_target.window || deepest_window.in_non_client_area; |
| 492 pointer_target.is_pointer_down = event.type() == ui::ET_POINTER_DOWN; | 501 pointer_target.is_pointer_down = event.type() == ui::ET_POINTER_DOWN; |
| 493 return pointer_target; | 502 return pointer_target; |
| 494 } | 503 } |
| 495 | 504 |
| 496 bool EventDispatcher::AreAnyPointersDown() const { | 505 bool EventDispatcher::AreAnyPointersDown() const { |
| 497 for (const auto& pair : pointer_targets_) { | 506 for (const auto& pair : pointer_targets_) { |
| 498 if (pair.second.is_pointer_down) | 507 if (pair.second.is_pointer_down) |
| 499 return true; | 508 return true; |
| 500 } | 509 } |
| 501 return false; | 510 return false; |
| 502 } | 511 } |
| 503 | 512 |
| 504 void EventDispatcher::DispatchToPointerTarget(const PointerTarget& target, | 513 void EventDispatcher::DispatchToPointerTarget(const PointerTarget& target, |
| 505 const ui::LocatedEvent& event) { | 514 const ui::LocatedEvent& event) { |
| 506 if (!target.window) { | 515 if (!target.window) { |
| 507 delegate_->OnEventTargetNotFound(event); | 516 delegate_->OnEventTargetNotFound(event, event_display_id_); |
| 508 return; | 517 return; |
| 509 } | 518 } |
| 510 | 519 |
| 511 if (target.is_mouse_event) | 520 if (target.is_mouse_event) |
| 512 mouse_cursor_in_non_client_area_ = target.in_nonclient_area; | 521 mouse_cursor_in_non_client_area_ = target.in_nonclient_area; |
| 513 | 522 |
| 514 DispatchToClient(target.window, delegate_->GetEventTargetClientId( | 523 DispatchToClient(target.window, delegate_->GetEventTargetClientId( |
| 515 target.window, target.in_nonclient_area), | 524 target.window, target.in_nonclient_area), |
| 516 event); | 525 event); |
| 517 } | 526 } |
| 518 | 527 |
| 519 void EventDispatcher::DispatchToClient(ServerWindow* window, | 528 void EventDispatcher::DispatchToClient(ServerWindow* window, |
| 520 ClientSpecificId client_id, | 529 ClientSpecificId client_id, |
| 521 const ui::LocatedEvent& event) { | 530 const ui::LocatedEvent& event) { |
| 522 gfx::Point location(event.location()); | 531 gfx::Point location(event.location()); |
| 523 gfx::Transform transform(GetTransformToWindow(window)); | 532 gfx::Transform transform(GetTransformToWindow(window)); |
| 524 transform.TransformPoint(&location); | 533 transform.TransformPoint(&location); |
| 525 std::unique_ptr<ui::Event> clone = ui::Event::Clone(event); | 534 std::unique_ptr<ui::Event> clone = ui::Event::Clone(event); |
| 526 clone->AsLocatedEvent()->set_location(location); | 535 clone->AsLocatedEvent()->set_location(location); |
| 527 // TODO(jonross): add post-target accelerator support once accelerators | 536 // TODO(jonross): add post-target accelerator support once accelerators |
| 528 // support pointer events. | 537 // support pointer events. |
| 529 delegate_->DispatchInputEventToWindow(window, client_id, *clone, nullptr); | 538 delegate_->DispatchInputEventToWindow(window, client_id, event_display_id_, |
| 539 *clone, nullptr); |
| 530 } | 540 } |
| 531 | 541 |
| 532 void EventDispatcher::CancelPointerEventsToTarget(ServerWindow* window) { | 542 void EventDispatcher::CancelPointerEventsToTarget(ServerWindow* window) { |
| 533 if (capture_window_ == window) { | 543 if (capture_window_ == window) { |
| 534 UnobserveWindow(window); | 544 UnobserveWindow(window); |
| 535 capture_window_ = nullptr; | 545 capture_window_ = nullptr; |
| 536 capture_window_client_id_ = kInvalidClientId; | 546 capture_window_client_id_ = kInvalidClientId; |
| 537 mouse_button_down_ = false; | 547 mouse_button_down_ = false; |
| 538 // A window only cares to be informed that it lost capture if it explicitly | 548 // A window only cares to be informed that it lost capture if it explicitly |
| 539 // requested capture. A window can lose capture if another window gains | 549 // requested capture. A window can lose capture if another window gains |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 574 const ui::KeyEvent& event, | 584 const ui::KeyEvent& event, |
| 575 const ui::mojom::AcceleratorPhase phase) { | 585 const ui::mojom::AcceleratorPhase phase) { |
| 576 for (const auto& pair : accelerators_) { | 586 for (const auto& pair : accelerators_) { |
| 577 if (pair.second->MatchesEvent(event, phase)) | 587 if (pair.second->MatchesEvent(event, phase)) |
| 578 return pair.second.get(); | 588 return pair.second.get(); |
| 579 } | 589 } |
| 580 return nullptr; | 590 return nullptr; |
| 581 } | 591 } |
| 582 | 592 |
| 583 DeepestWindow EventDispatcher::FindDeepestVisibleWindowForEvents( | 593 DeepestWindow EventDispatcher::FindDeepestVisibleWindowForEvents( |
| 584 const gfx::Point& location) { | 594 gfx::Point* location, |
| 585 gfx::Point relative_location(location); | 595 int64_t* display_id) { |
| 586 // For the case of no root. | 596 ServerWindow* root = delegate_->GetRootWindowContaining(location, display_id); |
| 587 ServerWindow* root = delegate_->GetRootWindowContaining(&relative_location); | 597 return root ? ui::ws::FindDeepestVisibleWindowForEvents(root, *location) |
| 588 return root ? ui::ws::FindDeepestVisibleWindowForEvents(root, | |
| 589 relative_location) | |
| 590 : DeepestWindow(); | 598 : DeepestWindow(); |
| 591 } | 599 } |
| 592 | 600 |
| 593 void EventDispatcher::CancelImplicitCaptureExcept(ServerWindow* window, | 601 void EventDispatcher::CancelImplicitCaptureExcept(ServerWindow* window, |
| 594 ClientSpecificId client_id) { | 602 ClientSpecificId client_id) { |
| 595 for (const auto& pair : pointer_targets_) { | 603 for (const auto& pair : pointer_targets_) { |
| 596 ServerWindow* target = pair.second.window; | 604 ServerWindow* target = pair.second.window; |
| 597 if (!target) | 605 if (!target) |
| 598 continue; | 606 continue; |
| 599 UnobserveWindow(target); | 607 UnobserveWindow(target); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 653 if (mouse_cursor_source_window_ == window) | 661 if (mouse_cursor_source_window_ == window) |
| 654 SetMouseCursorSourceWindow(nullptr); | 662 SetMouseCursorSourceWindow(nullptr); |
| 655 } | 663 } |
| 656 | 664 |
| 657 void EventDispatcher::OnDragCursorUpdated() { | 665 void EventDispatcher::OnDragCursorUpdated() { |
| 658 delegate_->UpdateNativeCursorFromDispatcher(); | 666 delegate_->UpdateNativeCursorFromDispatcher(); |
| 659 } | 667 } |
| 660 | 668 |
| 661 } // namespace ws | 669 } // namespace ws |
| 662 } // namespace ui | 670 } // namespace ui |
| OLD | NEW |