OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_server.h" | 5 #include "services/ui/ws/window_server.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
62 | 62 |
63 WindowServer::WindowServer(WindowServerDelegate* delegate) | 63 WindowServer::WindowServer(WindowServerDelegate* delegate) |
64 : delegate_(delegate), | 64 : delegate_(delegate), |
65 next_client_id_(1), | 65 next_client_id_(1), |
66 display_manager_(new DisplayManager(this, &user_id_tracker_)), | 66 display_manager_(new DisplayManager(this, &user_id_tracker_)), |
67 current_operation_(nullptr), | 67 current_operation_(nullptr), |
68 in_destructor_(false), | 68 in_destructor_(false), |
69 next_wm_change_id_(0), | 69 next_wm_change_id_(0), |
70 gpu_host_(new GpuHost(this)), | 70 gpu_host_(new GpuHost(this)), |
71 window_manager_window_tree_factory_set_(this, &user_id_tracker_), | 71 window_manager_window_tree_factory_set_(this, &user_id_tracker_), |
72 frame_sink_manager_client_binding_(this) { | 72 frame_sink_manager_client_binding_(this), |
73 weak_ptr_factory_(this) { | |
73 user_id_tracker_.AddObserver(this); | 74 user_id_tracker_.AddObserver(this); |
74 OnUserIdAdded(user_id_tracker_.active_id()); | 75 OnUserIdAdded(user_id_tracker_.active_id()); |
75 gpu_host_->CreateFrameSinkManager( | 76 gpu_host_->CreateFrameSinkManager( |
76 mojo::MakeRequest(&frame_sink_manager_), | 77 mojo::MakeRequest(&frame_sink_manager_), |
77 frame_sink_manager_client_binding_.CreateInterfacePtrAndBind()); | 78 frame_sink_manager_client_binding_.CreateInterfacePtrAndBind()); |
78 } | 79 } |
79 | 80 |
80 WindowServer::~WindowServer() { | 81 WindowServer::~WindowServer() { |
81 in_destructor_ = true; | 82 in_destructor_ = true; |
82 | 83 |
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
591 CHECK(current_operation_); | 592 CHECK(current_operation_); |
592 current_operation_ = nullptr; | 593 current_operation_ = nullptr; |
593 } | 594 } |
594 | 595 |
595 void WindowServer::UpdateNativeCursorFromMouseLocation(ServerWindow* window) { | 596 void WindowServer::UpdateNativeCursorFromMouseLocation(ServerWindow* window) { |
596 WindowManagerDisplayRoot* display_root = | 597 WindowManagerDisplayRoot* display_root = |
597 display_manager_->GetWindowManagerDisplayRoot(window); | 598 display_manager_->GetWindowManagerDisplayRoot(window); |
598 if (display_root) { | 599 if (display_root) { |
599 EventDispatcher* event_dispatcher = | 600 EventDispatcher* event_dispatcher = |
600 display_root->window_manager_state()->event_dispatcher(); | 601 display_root->window_manager_state()->event_dispatcher(); |
601 event_dispatcher->UpdateCursorProviderByLastKnownLocation(); | 602 event_dispatcher->UpdateCursorProviderByLastKnownLocation( |
602 display_root->display()->UpdateNativeCursor( | 603 base::Bind(&WindowServer::OnCursorUpdated, |
603 event_dispatcher->GetCurrentMouseCursor()); | 604 weak_ptr_factory_.GetWeakPtr(), display_root)); |
sky
2017/05/15 21:20:23
In this code you shouldn't need a weakptrfactory a
riajiang
2017/05/17 02:01:59
Ah I see. And deleted this since not passing a cal
| |
604 } | 605 } |
605 } | 606 } |
606 | 607 |
607 void WindowServer::UpdateNativeCursorIfOver(ServerWindow* window) { | 608 void WindowServer::UpdateNativeCursorIfOver(ServerWindow* window) { |
608 WindowManagerDisplayRoot* display_root = | 609 WindowManagerDisplayRoot* display_root = |
609 display_manager_->GetWindowManagerDisplayRoot(window); | 610 display_manager_->GetWindowManagerDisplayRoot(window); |
610 if (!display_root) | 611 if (!display_root) |
611 return; | 612 return; |
612 | 613 |
613 EventDispatcher* event_dispatcher = | 614 EventDispatcher* event_dispatcher = |
614 display_root->window_manager_state()->event_dispatcher(); | 615 display_root->window_manager_state()->event_dispatcher(); |
615 if (window != event_dispatcher->GetWindowForMouseCursor()) | 616 if (window != event_dispatcher->GetWindowForMouseCursor()) |
616 return; | 617 return; |
617 | 618 |
618 event_dispatcher->UpdateNonClientAreaForCurrentWindow(); | 619 event_dispatcher->UpdateNonClientAreaForCurrentWindow( |
620 base::Bind(&WindowServer::OnCursorUpdated, weak_ptr_factory_.GetWeakPtr(), | |
621 display_root)); | |
622 } | |
623 | |
624 void WindowServer::OnCursorUpdated(WindowManagerDisplayRoot* display_root) { | |
sky
2017/05/15 21:20:24
Style guide says position of declaration and defin
| |
619 display_root->display()->UpdateNativeCursor( | 625 display_root->display()->UpdateNativeCursor( |
620 event_dispatcher->GetCurrentMouseCursor()); | 626 display_root->window_manager_state() |
627 ->event_dispatcher() | |
628 ->GetCurrentMouseCursor()); | |
621 } | 629 } |
622 | 630 |
623 bool WindowServer::IsUserInHighContrastMode(const UserId& user) const { | 631 bool WindowServer::IsUserInHighContrastMode(const UserId& user) const { |
624 const auto iter = high_contrast_mode_.find(user); | 632 const auto iter = high_contrast_mode_.find(user); |
625 return (iter == high_contrast_mode_.end()) ? false : iter->second; | 633 return (iter == high_contrast_mode_.end()) ? false : iter->second; |
626 } | 634 } |
627 | 635 |
628 void WindowServer::HandleTemporaryReferenceForNewSurface( | 636 void WindowServer::HandleTemporaryReferenceForNewSurface( |
629 const cc::SurfaceId& surface_id, | 637 const cc::SurfaceId& surface_id, |
630 ServerWindow* window) { | 638 ServerWindow* window) { |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
871 void WindowServer::OnUserIdAdded(const UserId& id) { | 879 void WindowServer::OnUserIdAdded(const UserId& id) { |
872 activity_monitor_map_[id] = base::MakeUnique<UserActivityMonitor>(nullptr); | 880 activity_monitor_map_[id] = base::MakeUnique<UserActivityMonitor>(nullptr); |
873 } | 881 } |
874 | 882 |
875 void WindowServer::OnUserIdRemoved(const UserId& id) { | 883 void WindowServer::OnUserIdRemoved(const UserId& id) { |
876 activity_monitor_map_.erase(id); | 884 activity_monitor_map_.erase(id); |
877 } | 885 } |
878 | 886 |
879 } // namespace ws | 887 } // namespace ws |
880 } // namespace ui | 888 } // namespace ui |
OLD | NEW |