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

Side by Side Diff: components/mus/ws/window_manager_state.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 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 "components/mus/ws/window_manager_state.h" 5 #include "components/mus/ws/window_manager_state.h"
6 6
7 #include "base/memory/weak_ptr.h" 7 #include "base/memory/weak_ptr.h"
8 #include "components/mus/common/event_matcher_util.h" 8 #include "components/mus/common/event_matcher_util.h"
9 #include "components/mus/ws/accelerator.h" 9 #include "components/mus/ws/accelerator.h"
10 #include "components/mus/ws/display_manager.h" 10 #include "components/mus/ws/display_manager.h"
11 #include "components/mus/ws/platform_display.h" 11 #include "components/mus/ws/platform_display.h"
12 #include "components/mus/ws/server_window.h" 12 #include "components/mus/ws/server_window.h"
13 #include "components/mus/ws/user_activity_monitor.h"
13 #include "components/mus/ws/user_display_manager.h" 14 #include "components/mus/ws/user_display_manager.h"
14 #include "components/mus/ws/user_id_tracker.h" 15 #include "components/mus/ws/user_id_tracker.h"
15 #include "components/mus/ws/window_manager_display_root.h" 16 #include "components/mus/ws/window_manager_display_root.h"
16 #include "components/mus/ws/window_server.h" 17 #include "components/mus/ws/window_server.h"
17 #include "components/mus/ws/window_tree.h" 18 #include "components/mus/ws/window_tree.h"
18 #include "services/shell/public/interfaces/connector.mojom.h" 19 #include "services/shell/public/interfaces/connector.mojom.h"
19 #include "ui/events/event.h" 20 #include "ui/events/event.h"
20 21
21 namespace mus { 22 namespace mus {
22 namespace ws { 23 namespace ws {
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 const ClientSpecificId client_id_; 88 const ClientSpecificId client_id_;
88 base::WeakPtr<Accelerator> accelerator_; 89 base::WeakPtr<Accelerator> accelerator_;
89 90
90 DISALLOW_COPY_AND_ASSIGN(ProcessedEventTarget); 91 DISALLOW_COPY_AND_ASSIGN(ProcessedEventTarget);
91 }; 92 };
92 93
93 WindowManagerState::QueuedEvent::QueuedEvent() {} 94 WindowManagerState::QueuedEvent::QueuedEvent() {}
94 WindowManagerState::QueuedEvent::~QueuedEvent() {} 95 WindowManagerState::QueuedEvent::~QueuedEvent() {}
95 96
96 WindowManagerState::WindowManagerState(WindowTree* window_tree) 97 WindowManagerState::WindowManagerState(WindowTree* window_tree)
97 : window_tree_(window_tree), event_dispatcher_(this), weak_factory_(this) { 98 : window_tree_(window_tree),
99 user_activity_monitor_(new UserActivityMonitor(nullptr)),
100 event_dispatcher_(this),
101 weak_factory_(this) {
98 frame_decoration_values_ = mojom::FrameDecorationValues::New(); 102 frame_decoration_values_ = mojom::FrameDecorationValues::New();
99 frame_decoration_values_->max_title_bar_button_width = 0u; 103 frame_decoration_values_->max_title_bar_button_width = 0u;
100 104
101 AddDebugAccelerators(); 105 AddDebugAccelerators();
102 } 106 }
103 107
104 WindowManagerState::~WindowManagerState() {} 108 WindowManagerState::~WindowManagerState() {}
105 109
106 void WindowManagerState::SetFrameDecorationValues( 110 void WindowManagerState::SetFrameDecorationValues(
107 mojom::FrameDecorationValuesPtr values) { 111 mojom::FrameDecorationValuesPtr values) {
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 void WindowManagerState::Deactivate() { 176 void WindowManagerState::Deactivate() {
173 SetAllRootWindowsVisible(false); 177 SetAllRootWindowsVisible(false);
174 event_dispatcher_.Reset(); 178 event_dispatcher_.Reset();
175 // The tree is no longer active, so no point in dispatching any further 179 // The tree is no longer active, so no point in dispatching any further
176 // events. 180 // events.
177 std::queue<std::unique_ptr<QueuedEvent>> event_queue; 181 std::queue<std::unique_ptr<QueuedEvent>> event_queue;
178 event_queue.swap(event_queue_); 182 event_queue.swap(event_queue_);
179 } 183 }
180 184
181 void WindowManagerState::ProcessEvent(const ui::Event& event) { 185 void WindowManagerState::ProcessEvent(const ui::Event& event) {
186 user_activity_monitor_->OnUserActivity();
182 // If this is still waiting for an ack from a previously sent event, then 187 // If this is still waiting for an ack from a previously sent event, then
183 // queue up the event to be dispatched once the ack is received. 188 // queue up the event to be dispatched once the ack is received.
184 if (event_ack_timer_.IsRunning()) { 189 if (event_ack_timer_.IsRunning()) {
185 if (!event_queue_.empty() && !event_queue_.back()->processed_target && 190 if (!event_queue_.empty() && !event_queue_.back()->processed_target &&
186 EventsCanBeCoalesced(*event_queue_.back()->event, event)) { 191 EventsCanBeCoalesced(*event_queue_.back()->event, event)) {
187 event_queue_.back()->event = CoalesceEvents( 192 event_queue_.back()->event = CoalesceEvents(
188 std::move(event_queue_.back()->event), ui::Event::Clone(event)); 193 std::move(event_queue_.back()->event), ui::Event::Clone(event));
189 return; 194 return;
190 } 195 }
191 QueueEvent(event, nullptr); 196 QueueEvent(event, nullptr);
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 return display_root ? display_root->root() : nullptr; 462 return display_root ? display_root->root() : nullptr;
458 } 463 }
459 464
460 void WindowManagerState::OnEventTargetNotFound(const ui::Event& event) { 465 void WindowManagerState::OnEventTargetNotFound(const ui::Event& event) {
461 window_server()->SendToEventObservers(event, user_id(), 466 window_server()->SendToEventObservers(event, user_id(),
462 nullptr /* ignore_tree */); 467 nullptr /* ignore_tree */);
463 } 468 }
464 469
465 } // namespace ws 470 } // namespace ws
466 } // namespace mus 471 } // namespace mus
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698