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

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

Issue 2863913004: chromeos: makes mus send keyevents to display root when nothing has focus (Closed)
Patch Set: GetClientVisibleRoot Created 3 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 | « services/ui/ws/window_manager_state.h ('k') | services/ui/ws/window_server.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 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 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 return; 368 return;
369 } 369 }
370 } 370 }
371 } 371 }
372 372
373 void WindowManagerState::SetAllRootWindowsVisible(bool value) { 373 void WindowManagerState::SetAllRootWindowsVisible(bool value) {
374 for (auto& display_root_ptr : window_manager_display_roots_) 374 for (auto& display_root_ptr : window_manager_display_roots_)
375 display_root_ptr->root()->SetVisible(value); 375 display_root_ptr->root()->SetVisible(value);
376 } 376 }
377 377
378 ServerWindow* WindowManagerState::GetWindowManagerRoot(ServerWindow* window) { 378 ServerWindow* WindowManagerState::GetWindowManagerRootForDisplayRoot(
379 ServerWindow* window) {
379 for (auto& display_root_ptr : window_manager_display_roots_) { 380 for (auto& display_root_ptr : window_manager_display_roots_) {
380 if (display_root_ptr->root()->parent() == window) 381 if (display_root_ptr->root()->parent() == window)
381 return display_root_ptr->root(); 382 return display_root_ptr->GetClientVisibileRoot();
382 } 383 }
383 NOTREACHED(); 384 NOTREACHED();
384 return nullptr; 385 return nullptr;
385 } 386 }
386 387
387 void WindowManagerState::OnEventAck(mojom::WindowTree* tree, 388 void WindowManagerState::OnEventAck(mojom::WindowTree* tree,
388 mojom::EventResult result) { 389 mojom::EventResult result) {
389 DCHECK(in_flight_event_details_); 390 DCHECK(in_flight_event_details_);
390 std::unique_ptr<InFlightEventDetails> details = 391 std::unique_ptr<InFlightEventDetails> details =
391 std::move(in_flight_event_details_); 392 std::move(in_flight_event_details_);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 } 452 }
452 } 453 }
453 454
454 void WindowManagerState::DispatchInputEventToWindowImpl( 455 void WindowManagerState::DispatchInputEventToWindowImpl(
455 ServerWindow* target, 456 ServerWindow* target,
456 ClientSpecificId client_id, 457 ClientSpecificId client_id,
457 const ui::Event& event, 458 const ui::Event& event,
458 base::WeakPtr<Accelerator> accelerator) { 459 base::WeakPtr<Accelerator> accelerator) {
459 DCHECK(target); 460 DCHECK(target);
460 if (target->parent() == nullptr) 461 if (target->parent() == nullptr)
461 target = GetWindowManagerRoot(target); 462 target = GetWindowManagerRootForDisplayRoot(target);
462 463
463 if (event.IsMousePointerEvent()) { 464 if (event.IsMousePointerEvent()) {
464 DCHECK(event_dispatcher_.mouse_cursor_source_window()); 465 DCHECK(event_dispatcher_.mouse_cursor_source_window());
465 UpdateNativeCursorFromDispatcher(); 466 UpdateNativeCursorFromDispatcher();
466 } 467 }
467 468
468 WindowTree* tree = window_server()->GetTreeWithId(client_id); 469 WindowTree* tree = window_server()->GetTreeWithId(client_id);
469 DCHECK(tree); 470 DCHECK(tree);
470 ScheduleInputEventTimeout(tree, target, event, EventDispatchPhase::TARGET); 471 ScheduleInputEventTimeout(tree, target, event, EventDispatchPhase::TARGET);
471 in_flight_event_details_->post_target_accelerator = accelerator; 472 in_flight_event_details_->post_target_accelerator = accelerator;
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 window_tree_->OnAccelerator(accelerator_id, event, std::move(ack_callback)); 558 window_tree_->OnAccelerator(accelerator_id, event, std::move(ack_callback));
558 } 559 }
559 560
560 void WindowManagerState::SetFocusedWindowFromEventDispatcher( 561 void WindowManagerState::SetFocusedWindowFromEventDispatcher(
561 ServerWindow* new_focused_window) { 562 ServerWindow* new_focused_window) {
562 DCHECK(IsActive()); 563 DCHECK(IsActive());
563 window_server()->SetFocusedWindow(new_focused_window); 564 window_server()->SetFocusedWindow(new_focused_window);
564 } 565 }
565 566
566 ServerWindow* WindowManagerState::GetFocusedWindowForEventDispatcher() { 567 ServerWindow* WindowManagerState::GetFocusedWindowForEventDispatcher() {
567 return window_server()->GetFocusedWindow(); 568 ServerWindow* focused_window = window_server()->GetFocusedWindow();
569 if (focused_window)
570 return focused_window;
571
572 // When none of the windows have focus return the window manager's root.
573 for (auto& display_root_ptr : window_manager_display_roots_) {
574 if (display_root_ptr->display()->GetId() == event_processing_display_id_)
575 return display_root_ptr->GetClientVisibileRoot();
576 }
577 if (!window_manager_display_roots_.empty())
578 return (*window_manager_display_roots_.begin())->GetClientVisibileRoot();
579 return nullptr;
568 } 580 }
569 581
570 void WindowManagerState::SetNativeCapture(ServerWindow* window) { 582 void WindowManagerState::SetNativeCapture(ServerWindow* window) {
571 DCHECK(window); 583 DCHECK(window);
572 DCHECK(IsActive()); 584 DCHECK(IsActive());
573 WindowManagerDisplayRoot* display_root = 585 WindowManagerDisplayRoot* display_root =
574 display_manager()->GetWindowManagerDisplayRoot(window); 586 display_manager()->GetWindowManagerDisplayRoot(window);
575 DCHECK(display_root); 587 DCHECK(display_root);
576 platform_display_with_capture_ = display_root->display()->platform_display(); 588 platform_display_with_capture_ = display_root->display()->platform_display();
577 platform_display_with_capture_->SetCapture(); 589 platform_display_with_capture_->SetCapture();
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 if (!target_display_root) { 687 if (!target_display_root) {
676 DVLOG(1) << "Invalid event location " << location->ToString(); 688 DVLOG(1) << "Invalid event location " << location->ToString();
677 target_display_root = window_manager_display_roots_.begin()->get(); 689 target_display_root = window_manager_display_roots_.begin()->get();
678 } 690 }
679 691
680 // Translate the location to be relative to the display instead of relative 692 // Translate the location to be relative to the display instead of relative
681 // to the screen space. 693 // to the screen space.
682 gfx::Point origin = 694 gfx::Point origin =
683 target_display_root->display()->GetDisplay().bounds().origin(); 695 target_display_root->display()->GetDisplay().bounds().origin();
684 *location -= origin.OffsetFromOrigin(); 696 *location -= origin.OffsetFromOrigin();
685 return target_display_root->root(); 697 return target_display_root->GetClientVisibileRoot();
686 } 698 }
687 699
688 void WindowManagerState::OnEventTargetNotFound(const ui::Event& event) { 700 void WindowManagerState::OnEventTargetNotFound(const ui::Event& event) {
689 window_server()->SendToPointerWatchers(event, user_id(), nullptr, /* window */ 701 window_server()->SendToPointerWatchers(event, user_id(), nullptr, /* window */
690 nullptr /* ignore_tree */, 702 nullptr /* ignore_tree */,
691 event_processing_display_id_); 703 event_processing_display_id_);
692 if (event.IsMousePointerEvent()) 704 if (event.IsMousePointerEvent())
693 UpdateNativeCursorFromDispatcher(); 705 UpdateNativeCursorFromDispatcher();
694 } 706 }
695 707
696 void WindowManagerState::OnWindowEmbeddedAppDisconnected(ServerWindow* window) { 708 void WindowManagerState::OnWindowEmbeddedAppDisconnected(ServerWindow* window) {
697 for (auto iter = orphaned_window_manager_display_roots_.begin(); 709 for (auto iter = orphaned_window_manager_display_roots_.begin();
698 iter != orphaned_window_manager_display_roots_.end(); ++iter) { 710 iter != orphaned_window_manager_display_roots_.end(); ++iter) {
699 if ((*iter)->root() == window) { 711 if ((*iter)->root() == window) {
700 window->RemoveObserver(this); 712 window->RemoveObserver(this);
701 orphaned_window_manager_display_roots_.erase(iter); 713 orphaned_window_manager_display_roots_.erase(iter);
702 return; 714 return;
703 } 715 }
704 } 716 }
705 NOTREACHED(); 717 NOTREACHED();
706 } 718 }
707 719
708 } // namespace ws 720 } // namespace ws
709 } // namespace ui 721 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/ws/window_manager_state.h ('k') | services/ui/ws/window_server.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698