OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/window_manager_state.h" | 5 #include "services/ui/ws/window_manager_state.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 | 374 |
375 void WindowManagerState::SetAllRootWindowsVisible(bool value) { | 375 void WindowManagerState::SetAllRootWindowsVisible(bool value) { |
376 for (auto& display_root_ptr : window_manager_display_roots_) | 376 for (auto& display_root_ptr : window_manager_display_roots_) |
377 display_root_ptr->root()->SetVisible(value); | 377 display_root_ptr->root()->SetVisible(value); |
378 } | 378 } |
379 | 379 |
380 ServerWindow* WindowManagerState::GetWindowManagerRootForDisplayRoot( | 380 ServerWindow* WindowManagerState::GetWindowManagerRootForDisplayRoot( |
381 ServerWindow* window) { | 381 ServerWindow* window) { |
382 for (auto& display_root_ptr : window_manager_display_roots_) { | 382 for (auto& display_root_ptr : window_manager_display_roots_) { |
383 if (display_root_ptr->root()->parent() == window) | 383 if (display_root_ptr->root()->parent() == window) |
384 return display_root_ptr->GetClientVisibileRoot(); | 384 return display_root_ptr->GetClientVisibleRoot(); |
385 } | 385 } |
386 NOTREACHED(); | 386 NOTREACHED(); |
387 return nullptr; | 387 return nullptr; |
388 } | 388 } |
389 | 389 |
390 void WindowManagerState::OnEventAck(mojom::WindowTree* tree, | 390 void WindowManagerState::OnEventAck(mojom::WindowTree* tree, |
391 mojom::EventResult result) { | 391 mojom::EventResult result) { |
392 DCHECK(in_flight_event_details_); | 392 DCHECK(in_flight_event_details_); |
393 std::unique_ptr<InFlightEventDetails> details = | 393 std::unique_ptr<InFlightEventDetails> details = |
394 std::move(in_flight_event_details_); | 394 std::move(in_flight_event_details_); |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
567 } | 567 } |
568 | 568 |
569 ServerWindow* WindowManagerState::GetFocusedWindowForEventDispatcher() { | 569 ServerWindow* WindowManagerState::GetFocusedWindowForEventDispatcher() { |
570 ServerWindow* focused_window = window_server()->GetFocusedWindow(); | 570 ServerWindow* focused_window = window_server()->GetFocusedWindow(); |
571 if (focused_window) | 571 if (focused_window) |
572 return focused_window; | 572 return focused_window; |
573 | 573 |
574 // When none of the windows have focus return the window manager's root. | 574 // When none of the windows have focus return the window manager's root. |
575 for (auto& display_root_ptr : window_manager_display_roots_) { | 575 for (auto& display_root_ptr : window_manager_display_roots_) { |
576 if (display_root_ptr->display()->GetId() == event_processing_display_id_) | 576 if (display_root_ptr->display()->GetId() == event_processing_display_id_) |
577 return display_root_ptr->GetClientVisibileRoot(); | 577 return display_root_ptr->GetClientVisibleRoot(); |
578 } | 578 } |
579 if (!window_manager_display_roots_.empty()) | 579 if (!window_manager_display_roots_.empty()) |
580 return (*window_manager_display_roots_.begin())->GetClientVisibileRoot(); | 580 return (*window_manager_display_roots_.begin())->GetClientVisibleRoot(); |
581 return nullptr; | 581 return nullptr; |
582 } | 582 } |
583 | 583 |
584 void WindowManagerState::SetNativeCapture(ServerWindow* window) { | 584 void WindowManagerState::SetNativeCapture(ServerWindow* window) { |
585 DCHECK(window); | 585 DCHECK(window); |
586 DCHECK(IsActive()); | 586 DCHECK(IsActive()); |
587 WindowManagerDisplayRoot* display_root = | 587 WindowManagerDisplayRoot* display_root = |
588 display_manager()->GetWindowManagerDisplayRoot(window); | 588 display_manager()->GetWindowManagerDisplayRoot(window); |
589 DCHECK(display_root); | 589 DCHECK(display_root); |
590 platform_display_with_capture_ = display_root->display()->platform_display(); | 590 platform_display_with_capture_ = display_root->display()->platform_display(); |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
688 if (!target_display_root) { | 688 if (!target_display_root) { |
689 DVLOG(1) << "Invalid event location " << location->ToString(); | 689 DVLOG(1) << "Invalid event location " << location->ToString(); |
690 target_display_root = window_manager_display_roots_.begin()->get(); | 690 target_display_root = window_manager_display_roots_.begin()->get(); |
691 } | 691 } |
692 | 692 |
693 // Translate the location to be relative to the display instead of relative | 693 // Translate the location to be relative to the display instead of relative |
694 // to the screen space. | 694 // to the screen space. |
695 gfx::Point origin = | 695 gfx::Point origin = |
696 target_display_root->display()->GetDisplay().bounds().origin(); | 696 target_display_root->display()->GetDisplay().bounds().origin(); |
697 *location -= origin.OffsetFromOrigin(); | 697 *location -= origin.OffsetFromOrigin(); |
698 return target_display_root->GetClientVisibileRoot(); | 698 return target_display_root->GetClientVisibleRoot(); |
699 } | 699 } |
700 | 700 |
701 void WindowManagerState::OnEventTargetNotFound(const ui::Event& event) { | 701 void WindowManagerState::OnEventTargetNotFound(const ui::Event& event) { |
702 window_server()->SendToPointerWatchers(event, user_id(), nullptr, /* window */ | 702 window_server()->SendToPointerWatchers(event, user_id(), nullptr, /* window */ |
703 nullptr /* ignore_tree */, | 703 nullptr /* ignore_tree */, |
704 event_processing_display_id_); | 704 event_processing_display_id_); |
705 if (event.IsMousePointerEvent()) | 705 if (event.IsMousePointerEvent()) |
706 UpdateNativeCursorFromDispatcher(); | 706 UpdateNativeCursorFromDispatcher(); |
707 } | 707 } |
708 | 708 |
709 void WindowManagerState::OnWindowEmbeddedAppDisconnected(ServerWindow* window) { | 709 void WindowManagerState::OnWindowEmbeddedAppDisconnected(ServerWindow* window) { |
710 for (auto iter = orphaned_window_manager_display_roots_.begin(); | 710 for (auto iter = orphaned_window_manager_display_roots_.begin(); |
711 iter != orphaned_window_manager_display_roots_.end(); ++iter) { | 711 iter != orphaned_window_manager_display_roots_.end(); ++iter) { |
712 if ((*iter)->root() == window) { | 712 if ((*iter)->root() == window) { |
713 window->RemoveObserver(this); | 713 window->RemoveObserver(this); |
714 orphaned_window_manager_display_roots_.erase(iter); | 714 orphaned_window_manager_display_roots_.erase(iter); |
715 return; | 715 return; |
716 } | 716 } |
717 } | 717 } |
718 NOTREACHED(); | 718 NOTREACHED(); |
719 } | 719 } |
720 | 720 |
721 } // namespace ws | 721 } // namespace ws |
722 } // namespace ui | 722 } // namespace ui |
OLD | NEW |