| 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 28 matching lines...) Expand all Loading... |
| 39 }; | 39 }; |
| 40 | 40 |
| 41 struct WindowServer::CurrentDragLoopState { | 41 struct WindowServer::CurrentDragLoopState { |
| 42 uint32_t change_id; | 42 uint32_t change_id; |
| 43 ServerWindow* window; | 43 ServerWindow* window; |
| 44 WindowTree* initiator; | 44 WindowTree* initiator; |
| 45 }; | 45 }; |
| 46 | 46 |
| 47 WindowServer::WindowServer(WindowServerDelegate* delegate) | 47 WindowServer::WindowServer(WindowServerDelegate* delegate) |
| 48 : delegate_(delegate), | 48 : delegate_(delegate), |
| 49 display_compositor_(new DisplayCompositor(this)), | 49 display_compositor_(new DisplayCompositor()), |
| 50 next_client_id_(1), | 50 next_client_id_(1), |
| 51 display_manager_(new DisplayManager(this, &user_id_tracker_)), | 51 display_manager_(new DisplayManager(this, &user_id_tracker_)), |
| 52 current_operation_(nullptr), | 52 current_operation_(nullptr), |
| 53 in_destructor_(false), | 53 in_destructor_(false), |
| 54 next_wm_change_id_(0), | 54 next_wm_change_id_(0), |
| 55 gpu_proxy_(new GpuServiceProxy(this)), | 55 gpu_proxy_(new GpuServiceProxy(this)), |
| 56 window_manager_window_tree_factory_set_(this, &user_id_tracker_) { | 56 window_manager_window_tree_factory_set_(this, &user_id_tracker_) { |
| 57 user_id_tracker_.AddObserver(this); | 57 user_id_tracker_.AddObserver(this); |
| 58 OnUserIdAdded(user_id_tracker_.active_id()); | 58 OnUserIdAdded(user_id_tracker_.active_id()); |
| 59 } | 59 } |
| (...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 792 } | 792 } |
| 793 | 793 |
| 794 void WindowServer::OnGpuChannelEstablished( | 794 void WindowServer::OnGpuChannelEstablished( |
| 795 scoped_refptr<gpu::GpuChannelHost> gpu_channel) { | 795 scoped_refptr<gpu::GpuChannelHost> gpu_channel) { |
| 796 gpu_channel_ = std::move(gpu_channel); | 796 gpu_channel_ = std::move(gpu_channel); |
| 797 const std::set<Display*>& displays = display_manager()->displays(); | 797 const std::set<Display*>& displays = display_manager()->displays(); |
| 798 for (auto* display : displays) | 798 for (auto* display : displays) |
| 799 display->platform_display()->OnGpuChannelEstablished(gpu_channel_); | 799 display->platform_display()->OnGpuChannelEstablished(gpu_channel_); |
| 800 } | 800 } |
| 801 | 801 |
| 802 void WindowServer::OnSurfaceCreated(const cc::SurfaceId& surface_id, | |
| 803 const gfx::Size& frame_size, | |
| 804 float device_scale_factor) { | |
| 805 WindowId window_id( | |
| 806 WindowIdFromTransportId(surface_id.frame_sink_id().client_id())); | |
| 807 mojom::SurfaceType surface_type( | |
| 808 static_cast<mojom::SurfaceType>(surface_id.frame_sink_id().sink_id())); | |
| 809 // We only care about propagating default surface IDs. | |
| 810 // TODO(fsamuel, sadrul): we should get rid of surface types. | |
| 811 if (surface_type != mojom::SurfaceType::DEFAULT) | |
| 812 return; | |
| 813 ServerWindow* window = GetWindow(window_id); | |
| 814 // If the window doesn't have a parent then we have nothing to propagate. | |
| 815 if (!window || !window->parent()) | |
| 816 return; | |
| 817 WindowTree* window_tree = GetTreeWithId(window->parent()->id().client_id); | |
| 818 if (window_tree) { | |
| 819 window_tree->ProcessWindowSurfaceChanged(window, surface_id, frame_size, | |
| 820 device_scale_factor); | |
| 821 } | |
| 822 } | |
| 823 | |
| 824 void WindowServer::OnActiveUserIdChanged(const UserId& previously_active_id, | 802 void WindowServer::OnActiveUserIdChanged(const UserId& previously_active_id, |
| 825 const UserId& active_id) { | 803 const UserId& active_id) { |
| 826 if (IsUserInHighContrastMode(previously_active_id) == | 804 if (IsUserInHighContrastMode(previously_active_id) == |
| 827 IsUserInHighContrastMode(active_id)) | 805 IsUserInHighContrastMode(active_id)) |
| 828 return; | 806 return; |
| 829 for (Display* display : display_manager_->displays()) { | 807 for (Display* display : display_manager_->displays()) { |
| 830 display->SchedulePaint(display->root_window(), | 808 display->SchedulePaint(display->root_window(), |
| 831 gfx::Rect(display->root_window()->bounds().size())); | 809 gfx::Rect(display->root_window()->bounds().size())); |
| 832 } | 810 } |
| 833 } | 811 } |
| 834 | 812 |
| 835 void WindowServer::OnUserIdAdded(const UserId& id) { | 813 void WindowServer::OnUserIdAdded(const UserId& id) { |
| 836 activity_monitor_map_[id] = base::MakeUnique<UserActivityMonitor>(nullptr); | 814 activity_monitor_map_[id] = base::MakeUnique<UserActivityMonitor>(nullptr); |
| 837 } | 815 } |
| 838 | 816 |
| 839 void WindowServer::OnUserIdRemoved(const UserId& id) { | 817 void WindowServer::OnUserIdRemoved(const UserId& id) { |
| 840 activity_monitor_map_.erase(id); | 818 activity_monitor_map_.erase(id); |
| 841 } | 819 } |
| 842 | 820 |
| 843 } // namespace ws | 821 } // namespace ws |
| 844 } // namespace ui | 822 } // namespace ui |
| OLD | NEW |