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

Side by Side Diff: components/mus/ws/window_server.cc

Issue 2094933003: mus: Add UserActivityMonitor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 5 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
OLDNEW
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 "components/mus/ws/window_server.h" 5 #include "components/mus/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"
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "base/stl_util.h" 12 #include "base/stl_util.h"
13 #include "components/mus/public/cpp/surfaces/surfaces_type_converters.h" 13 #include "components/mus/public/cpp/surfaces/surfaces_type_converters.h"
14 #include "components/mus/ws/display.h" 14 #include "components/mus/ws/display.h"
15 #include "components/mus/ws/display_binding.h" 15 #include "components/mus/ws/display_binding.h"
16 #include "components/mus/ws/display_manager.h" 16 #include "components/mus/ws/display_manager.h"
17 #include "components/mus/ws/operation.h" 17 #include "components/mus/ws/operation.h"
18 #include "components/mus/ws/server_window.h" 18 #include "components/mus/ws/server_window.h"
19 #include "components/mus/ws/user_activity_monitor.h"
19 #include "components/mus/ws/window_coordinate_conversions.h" 20 #include "components/mus/ws/window_coordinate_conversions.h"
20 #include "components/mus/ws/window_manager_access_policy.h" 21 #include "components/mus/ws/window_manager_access_policy.h"
21 #include "components/mus/ws/window_manager_display_root.h" 22 #include "components/mus/ws/window_manager_display_root.h"
22 #include "components/mus/ws/window_manager_state.h" 23 #include "components/mus/ws/window_manager_state.h"
23 #include "components/mus/ws/window_manager_window_tree_factory.h" 24 #include "components/mus/ws/window_manager_window_tree_factory.h"
24 #include "components/mus/ws/window_server_delegate.h" 25 #include "components/mus/ws/window_server_delegate.h"
25 #include "components/mus/ws/window_tree.h" 26 #include "components/mus/ws/window_tree.h"
26 #include "components/mus/ws/window_tree_binding.h" 27 #include "components/mus/ws/window_tree_binding.h"
27 #include "services/shell/public/cpp/connection.h" 28 #include "services/shell/public/cpp/connection.h"
28 #include "ui/gfx/geometry/size_conversions.h" 29 #include "ui/gfx/geometry/size_conversions.h"
29 30
30 namespace mus { 31 namespace mus {
31 namespace ws { 32 namespace ws {
32 33
33 WindowServer::WindowServer( 34 WindowServer::WindowServer(
34 WindowServerDelegate* delegate, 35 WindowServerDelegate* delegate,
35 const scoped_refptr<mus::SurfacesState>& surfaces_state) 36 const scoped_refptr<mus::SurfacesState>& surfaces_state)
36 : delegate_(delegate), 37 : delegate_(delegate),
37 surfaces_state_(surfaces_state), 38 surfaces_state_(surfaces_state),
38 next_client_id_(1), 39 next_client_id_(1),
39 display_manager_(new DisplayManager(this, &user_id_tracker_)), 40 display_manager_(new DisplayManager(this, &user_id_tracker_)),
40 current_operation_(nullptr), 41 current_operation_(nullptr),
41 in_destructor_(false), 42 in_destructor_(false),
42 next_wm_change_id_(0), 43 next_wm_change_id_(0),
43 window_manager_window_tree_factory_set_(this, &user_id_tracker_) {} 44 window_manager_window_tree_factory_set_(this, &user_id_tracker_) {
45 user_id_tracker_.AddObserver(this);
46 OnUserIdAdded(user_id_tracker_.active_id());
sadrul 2016/06/27 20:46:13 This is necessary since the 'root user id' is adde
47 }
44 48
45 WindowServer::~WindowServer() { 49 WindowServer::~WindowServer() {
46 in_destructor_ = true; 50 in_destructor_ = true;
47 51
48 // Destroys the window trees results in querying for the display. Tear down 52 // Destroys the window trees results in querying for the display. Tear down
49 // the displays first so that the trees are notified of the display going 53 // the displays first so that the trees are notified of the display going
50 // away while the display is still valid. 54 // away while the display is still valid.
51 display_manager_->DestroyAllDisplays(); 55 display_manager_->DestroyAllDisplays();
52 56
53 while (!tree_map_.empty()) 57 while (!tree_map_.empty())
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 void WindowServer::OnFirstWindowManagerWindowTreeFactoryReady() { 229 void WindowServer::OnFirstWindowManagerWindowTreeFactoryReady() {
226 if (display_manager_->has_active_or_pending_displays()) 230 if (display_manager_->has_active_or_pending_displays())
227 return; 231 return;
228 232
229 // We've been supplied a WindowManagerFactory and no displays have been 233 // We've been supplied a WindowManagerFactory and no displays have been
230 // created yet. Treat this as a signal to create a Display. 234 // created yet. Treat this as a signal to create a Display.
231 // TODO(sky): we need a better way to determine this, most likely a switch. 235 // TODO(sky): we need a better way to determine this, most likely a switch.
232 delegate_->CreateDefaultDisplays(); 236 delegate_->CreateDefaultDisplays();
233 } 237 }
234 238
239 UserActivityMonitor* WindowServer::GetUserActivityMonitorForUser(
240 const UserId& user_id) {
241 DCHECK_GT(activity_monitor_map_.count(user_id), 0u);
242 return activity_monitor_map_[user_id].get();
243 }
244
235 bool WindowServer::SetFocusedWindow(ServerWindow* window) { 245 bool WindowServer::SetFocusedWindow(ServerWindow* window) {
236 // TODO(sky): this should fail if there is modal dialog active and |window| 246 // TODO(sky): this should fail if there is modal dialog active and |window|
237 // is outside that. 247 // is outside that.
238 ServerWindow* currently_focused = GetFocusedWindow(); 248 ServerWindow* currently_focused = GetFocusedWindow();
239 Display* focused_display = 249 Display* focused_display =
240 currently_focused 250 currently_focused
241 ? display_manager_->GetDisplayContaining(currently_focused) 251 ? display_manager_->GetDisplayContaining(currently_focused)
242 : nullptr; 252 : nullptr;
243 if (!window) 253 if (!window)
244 return focused_display ? focused_display->SetFocusedWindow(nullptr) : true; 254 return focused_display ? focused_display->SetFocusedWindow(nullptr) : true;
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
676 *values = window_manager_state->frame_decoration_values().Clone(); 686 *values = window_manager_state->frame_decoration_values().Clone();
677 return window_manager_state->got_frame_decoration_values(); 687 return window_manager_state->got_frame_decoration_values();
678 } 688 }
679 689
680 WindowManagerState* WindowServer::GetWindowManagerStateForUser( 690 WindowManagerState* WindowServer::GetWindowManagerStateForUser(
681 const UserId& user_id) { 691 const UserId& user_id) {
682 return window_manager_window_tree_factory_set_.GetWindowManagerStateForUser( 692 return window_manager_window_tree_factory_set_.GetWindowManagerStateForUser(
683 user_id); 693 user_id);
684 } 694 }
685 695
696 void WindowServer::OnActiveUserIdChanged(const UserId& previously_active_id,
697 const UserId& active_id) {}
698
699 void WindowServer::OnUserIdAdded(const UserId& id) {
700 activity_monitor_map_[id] = base::MakeUnique<UserActivityMonitor>(nullptr);
701 }
702
703 void WindowServer::OnUserIdRemoved(const UserId& id) {
704 activity_monitor_map_.erase(id);
705 }
706
686 } // namespace ws 707 } // namespace ws
687 } // namespace mus 708 } // namespace mus
OLDNEW
« components/mus/ws/user_activity_monitor.cc ('K') | « components/mus/ws/window_server.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698