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

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: moar 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_tree_unittest.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 GetWindowManagerRoot(display_root_ptr.get());
382 } 383 }
383 NOTREACHED(); 384 NOTREACHED();
384 return nullptr; 385 return nullptr;
385 } 386 }
386 387
388 ServerWindow* WindowManagerState::GetWindowManagerRoot(
389 WindowManagerDisplayRoot* display_root) {
390 if (window_tree_->automatically_create_display_roots())
391 return display_root->root();
392 DCHECK_EQ(1u, display_root->root()->children().size());
393 return display_root->root()->children()[0];
sadrul 2017/05/08 15:24:19 Maybe there should be a WindowManagerDisplayRoot::
sky 2017/05/08 15:53:00 Good idea. Done.
394 }
395
387 void WindowManagerState::OnEventAck(mojom::WindowTree* tree, 396 void WindowManagerState::OnEventAck(mojom::WindowTree* tree,
388 mojom::EventResult result) { 397 mojom::EventResult result) {
389 DCHECK(in_flight_event_details_); 398 DCHECK(in_flight_event_details_);
390 std::unique_ptr<InFlightEventDetails> details = 399 std::unique_ptr<InFlightEventDetails> details =
391 std::move(in_flight_event_details_); 400 std::move(in_flight_event_details_);
392 401
393 if (result == mojom::EventResult::UNHANDLED && 402 if (result == mojom::EventResult::UNHANDLED &&
394 details->post_target_accelerator) { 403 details->post_target_accelerator) {
395 OnAccelerator(details->post_target_accelerator->id(), *details->event, 404 OnAccelerator(details->post_target_accelerator->id(), *details->event,
396 AcceleratorPhase::POST); 405 AcceleratorPhase::POST);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 } 460 }
452 } 461 }
453 462
454 void WindowManagerState::DispatchInputEventToWindowImpl( 463 void WindowManagerState::DispatchInputEventToWindowImpl(
455 ServerWindow* target, 464 ServerWindow* target,
456 ClientSpecificId client_id, 465 ClientSpecificId client_id,
457 const ui::Event& event, 466 const ui::Event& event,
458 base::WeakPtr<Accelerator> accelerator) { 467 base::WeakPtr<Accelerator> accelerator) {
459 DCHECK(target); 468 DCHECK(target);
460 if (target->parent() == nullptr) 469 if (target->parent() == nullptr)
461 target = GetWindowManagerRoot(target); 470 target = GetWindowManagerRootForDisplayRoot(target);
462 471
463 if (event.IsMousePointerEvent()) { 472 if (event.IsMousePointerEvent()) {
464 DCHECK(event_dispatcher_.mouse_cursor_source_window()); 473 DCHECK(event_dispatcher_.mouse_cursor_source_window());
465 UpdateNativeCursorFromDispatcher(); 474 UpdateNativeCursorFromDispatcher();
466 } 475 }
467 476
468 WindowTree* tree = window_server()->GetTreeWithId(client_id); 477 WindowTree* tree = window_server()->GetTreeWithId(client_id);
469 DCHECK(tree); 478 DCHECK(tree);
470 ScheduleInputEventTimeout(tree, target, event, EventDispatchPhase::TARGET); 479 ScheduleInputEventTimeout(tree, target, event, EventDispatchPhase::TARGET);
471 in_flight_event_details_->post_target_accelerator = accelerator; 480 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)); 566 window_tree_->OnAccelerator(accelerator_id, event, std::move(ack_callback));
558 } 567 }
559 568
560 void WindowManagerState::SetFocusedWindowFromEventDispatcher( 569 void WindowManagerState::SetFocusedWindowFromEventDispatcher(
561 ServerWindow* new_focused_window) { 570 ServerWindow* new_focused_window) {
562 DCHECK(IsActive()); 571 DCHECK(IsActive());
563 window_server()->SetFocusedWindow(new_focused_window); 572 window_server()->SetFocusedWindow(new_focused_window);
564 } 573 }
565 574
566 ServerWindow* WindowManagerState::GetFocusedWindowForEventDispatcher() { 575 ServerWindow* WindowManagerState::GetFocusedWindowForEventDispatcher() {
567 return window_server()->GetFocusedWindow(); 576 ServerWindow* focused_window = window_server()->GetFocusedWindow();
577 if (focused_window)
578 return focused_window;
579
580 // When none of the windows have focus return the window manager's root.
581 for (auto& display_root_ptr : window_manager_display_roots_) {
582 if (display_root_ptr->display()->GetId() == event_processing_display_id_) {
583 return GetWindowManagerRoot(display_root_ptr.get());
584 }
585 }
586 if (!window_manager_display_roots_.empty())
587 return GetWindowManagerRoot(window_manager_display_roots_.begin()->get());
588 return nullptr;
568 } 589 }
569 590
570 void WindowManagerState::SetNativeCapture(ServerWindow* window) { 591 void WindowManagerState::SetNativeCapture(ServerWindow* window) {
571 DCHECK(window); 592 DCHECK(window);
572 DCHECK(IsActive()); 593 DCHECK(IsActive());
573 WindowManagerDisplayRoot* display_root = 594 WindowManagerDisplayRoot* display_root =
574 display_manager()->GetWindowManagerDisplayRoot(window); 595 display_manager()->GetWindowManagerDisplayRoot(window);
575 DCHECK(display_root); 596 DCHECK(display_root);
576 platform_display_with_capture_ = display_root->display()->platform_display(); 597 platform_display_with_capture_ = display_root->display()->platform_display();
577 platform_display_with_capture_->SetCapture(); 598 platform_display_with_capture_->SetCapture();
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
700 window->RemoveObserver(this); 721 window->RemoveObserver(this);
701 orphaned_window_manager_display_roots_.erase(iter); 722 orphaned_window_manager_display_roots_.erase(iter);
702 return; 723 return;
703 } 724 }
704 } 725 }
705 NOTREACHED(); 726 NOTREACHED();
706 } 727 }
707 728
708 } // namespace ws 729 } // namespace ws
709 } // namespace ui 730 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/ws/window_manager_state.h ('k') | services/ui/ws/window_tree_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698