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

Side by Side Diff: services/ui/ws/window_manager_state.cc

Issue 2257503002: Improve some debug tools for mus. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@fix_mash
Patch Set: Fixes. Created 4 years, 4 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 | « services/ui/ws/window_manager_state.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 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 "services/ui/ws/window_manager_state.h" 5 #include "services/ui/ws/window_manager_state.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "services/shell/public/interfaces/connector.mojom.h" 10 #include "services/shell/public/interfaces/connector.mojom.h"
11 #include "services/ui/common/event_matcher_util.h" 11 #include "services/ui/common/event_matcher_util.h"
12 #include "services/ui/ws/accelerator.h" 12 #include "services/ui/ws/accelerator.h"
13 #include "services/ui/ws/display_manager.h" 13 #include "services/ui/ws/display_manager.h"
14 #include "services/ui/ws/platform_display.h" 14 #include "services/ui/ws/platform_display.h"
15 #include "services/ui/ws/server_window.h" 15 #include "services/ui/ws/server_window.h"
16 #include "services/ui/ws/user_display_manager.h" 16 #include "services/ui/ws/user_display_manager.h"
17 #include "services/ui/ws/user_id_tracker.h" 17 #include "services/ui/ws/user_id_tracker.h"
18 #include "services/ui/ws/window_manager_display_root.h" 18 #include "services/ui/ws/window_manager_display_root.h"
19 #include "services/ui/ws/window_server.h" 19 #include "services/ui/ws/window_server.h"
20 #include "services/ui/ws/window_tree.h" 20 #include "services/ui/ws/window_tree.h"
21 #include "ui/events/event.h" 21 #include "ui/events/event.h"
22 22
23 namespace ui { 23 namespace ui {
24 namespace ws { 24 namespace ws {
25 namespace { 25 namespace {
26 26
27 // Flags that matter when checking if a key event matches an accelerator.
28 const int kAcceleratorEventFlags =
29 EF_SHIFT_DOWN | EF_CONTROL_DOWN | EF_ALT_DOWN | EF_COMMAND_DOWN;
30
27 base::TimeDelta GetDefaultAckTimerDelay() { 31 base::TimeDelta GetDefaultAckTimerDelay() {
28 #if defined(NDEBUG) 32 #if defined(NDEBUG)
29 return base::TimeDelta::FromMilliseconds(100); 33 return base::TimeDelta::FromMilliseconds(100);
30 #else 34 #else
31 return base::TimeDelta::FromMilliseconds(1000); 35 return base::TimeDelta::FromMilliseconds(1000);
32 #endif 36 #endif
33 } 37 }
34 38
35 bool EventsCanBeCoalesced(const ui::Event& one, const ui::Event& two) { 39 bool EventsCanBeCoalesced(const ui::Event& one, const ui::Event& two) {
36 if (one.type() != two.type() || one.flags() != two.flags()) 40 if (one.type() != two.type() || one.flags() != two.flags())
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 base::WeakPtr<Accelerator> accelerator() { return accelerator_; } 93 base::WeakPtr<Accelerator> accelerator() { return accelerator_; }
90 94
91 private: 95 private:
92 ServerWindowTracker tracker_; 96 ServerWindowTracker tracker_;
93 const ClientSpecificId client_id_; 97 const ClientSpecificId client_id_;
94 base::WeakPtr<Accelerator> accelerator_; 98 base::WeakPtr<Accelerator> accelerator_;
95 99
96 DISALLOW_COPY_AND_ASSIGN(ProcessedEventTarget); 100 DISALLOW_COPY_AND_ASSIGN(ProcessedEventTarget);
97 }; 101 };
98 102
103 bool WindowManagerState::DebugAccelerator::Matches(
104 const ui::KeyEvent& event) const {
105 return key_code == event.key_code() &&
106 event_flags == (kAcceleratorEventFlags & event.flags());
107 }
108
99 WindowManagerState::QueuedEvent::QueuedEvent() {} 109 WindowManagerState::QueuedEvent::QueuedEvent() {}
100 WindowManagerState::QueuedEvent::~QueuedEvent() {} 110 WindowManagerState::QueuedEvent::~QueuedEvent() {}
101 111
102 WindowManagerState::WindowManagerState(WindowTree* window_tree) 112 WindowManagerState::WindowManagerState(WindowTree* window_tree)
103 : window_tree_(window_tree), event_dispatcher_(this), weak_factory_(this) { 113 : window_tree_(window_tree), event_dispatcher_(this), weak_factory_(this) {
104 frame_decoration_values_ = mojom::FrameDecorationValues::New(); 114 frame_decoration_values_ = mojom::FrameDecorationValues::New();
105 frame_decoration_values_->max_title_bar_button_width = 0u; 115 frame_decoration_values_->max_title_bar_button_width = 0u;
106 116
107 AddDebugAccelerators(); 117 AddDebugAccelerators();
108 } 118 }
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN | ui::EF_SHIFT_DOWN}; 382 ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN | ui::EF_SHIFT_DOWN};
373 debug_accelerators_.push_back(accelerator); 383 debug_accelerators_.push_back(accelerator);
374 } 384 }
375 385
376 void WindowManagerState::ProcessDebugAccelerator(const ui::Event& event) { 386 void WindowManagerState::ProcessDebugAccelerator(const ui::Event& event) {
377 if (event.type() != ui::ET_KEY_PRESSED) 387 if (event.type() != ui::ET_KEY_PRESSED)
378 return; 388 return;
379 389
380 const ui::KeyEvent& key_event = *event.AsKeyEvent(); 390 const ui::KeyEvent& key_event = *event.AsKeyEvent();
381 for (const DebugAccelerator& accelerator : debug_accelerators_) { 391 for (const DebugAccelerator& accelerator : debug_accelerators_) {
382 if (accelerator.key_code == key_event.key_code() && 392 if (accelerator.Matches(key_event)) {
383 accelerator.event_flags == key_event.flags()) {
384 HandleDebugAccelerator(accelerator.type); 393 HandleDebugAccelerator(accelerator.type);
385 break; 394 break;
386 } 395 }
387 } 396 }
388 } 397 }
389 398
390 void WindowManagerState::HandleDebugAccelerator(DebugAcceleratorType type) { 399 void WindowManagerState::HandleDebugAccelerator(DebugAcceleratorType type) {
391 #if !defined(NDEBUG) 400 #if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)
392 // Error so it will be collected in system logs. 401 // Error so it will be collected in system logs.
393 for (Display* display : display_manager()->displays()) { 402 for (Display* display : display_manager()->displays()) {
394 WindowManagerDisplayRoot* display_root = 403 WindowManagerDisplayRoot* display_root =
395 display->GetWindowManagerDisplayRootForUser(user_id()); 404 display->GetWindowManagerDisplayRootForUser(user_id());
396 if (display_root) { 405 if (display_root) {
397 LOG(ERROR) << "ServerWindow hierarchy:\n" 406 LOG(ERROR) << "ServerWindow hierarchy:\n"
398 << display_root->root()->GetDebugWindowHierarchy(); 407 << display_root->root()->GetDebugWindowHierarchy();
399 } 408 }
400 } 409 }
401 #endif 410 #endif
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 return display_root->root(); 565 return display_root->root();
557 } 566 }
558 567
559 void WindowManagerState::OnEventTargetNotFound(const ui::Event& event) { 568 void WindowManagerState::OnEventTargetNotFound(const ui::Event& event) {
560 window_server()->SendToPointerWatchers(event, user_id(), nullptr, /* window */ 569 window_server()->SendToPointerWatchers(event, user_id(), nullptr, /* window */
561 nullptr /* ignore_tree */); 570 nullptr /* ignore_tree */);
562 } 571 }
563 572
564 } // namespace ws 573 } // namespace ws
565 } // namespace ui 574 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/ws/window_manager_state.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698