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

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

Powered by Google App Engine
This is Rietveld 408576698