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

Unified Diff: components/mus/ws/window_manager_state.cc

Issue 1953193002: mus: Add debug key to print the server window hierarchy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: uint32 for win Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/mus/ws/window_manager_state.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/mus/ws/window_manager_state.cc
diff --git a/components/mus/ws/window_manager_state.cc b/components/mus/ws/window_manager_state.cc
index 71e69c4d4434ef16c794bd7931f443be8da3b0b6..18c0c205727c17c1451d2d8028be587c2b17e9e4 100644
--- a/components/mus/ws/window_manager_state.cc
+++ b/components/mus/ws/window_manager_state.cc
@@ -5,6 +5,7 @@
#include "components/mus/ws/window_manager_state.h"
#include "base/memory/weak_ptr.h"
+#include "components/mus/common/event_matcher_util.h"
#include "components/mus/ws/accelerator.h"
#include "components/mus/ws/display_manager.h"
#include "components/mus/ws/platform_display.h"
@@ -20,6 +21,10 @@ namespace mus {
namespace ws {
namespace {
+// Debug accelerator IDs start far above the highest valid Windows command ID
+// (0xDFFF) and Chrome's highest IDC command ID.
+const uint32_t kPrintWindowsDebugAcceleratorId = 1u << 31;
+
base::TimeDelta GetDefaultAckTimerDelay() {
#if defined(NDEBUG)
return base::TimeDelta::FromMilliseconds(100);
@@ -185,6 +190,8 @@ WindowManagerState::WindowManagerState(Display* display,
event_dispatcher_.set_root(root_.get());
event_dispatcher_.set_surface_id(surface_id);
+
+ AddDebugAccelerators();
}
bool WindowManagerState::IsActive() const {
@@ -329,12 +336,37 @@ void WindowManagerState::DispatchInputEventToWindowImpl(
tree->DispatchInputEvent(target, event);
}
+void WindowManagerState::AddDebugAccelerators() {
+ // Always register the accelerators, even if they only work in debug, so that
+ // keyboard behavior is the same in release and debug builds.
+ mojom::EventMatcherPtr matcher = CreateKeyMatcher(
+ mus::mojom::KeyboardCode::S,
+ mus::mojom::kEventFlagControlDown | mus::mojom::kEventFlagAltDown
+ | mus::mojom::kEventFlagShiftDown);
+ event_dispatcher_.AddAccelerator(kPrintWindowsDebugAcceleratorId,
+ std::move(matcher));
+}
+
+bool WindowManagerState::HandleDebugAccelerator(uint32_t accelerator_id) {
+#if !defined(NDEBUG)
+ if (accelerator_id == kPrintWindowsDebugAcceleratorId) {
+ // Error so it will be collected in system logs.
+ LOG(ERROR) << "ServerWindow hierarchy:\n"
+ << root()->GetDebugWindowHierarchy();
+ return true;
+ }
+#endif
+ return false;
+}
+
////////////////////////////////////////////////////////////////////////////////
// EventDispatcherDelegate:
void WindowManagerState::OnAccelerator(uint32_t accelerator_id,
const ui::Event& event) {
DCHECK(IsActive());
+ if (HandleDebugAccelerator(accelerator_id))
+ return;
tree_->OnAccelerator(accelerator_id, event);
}
« no previous file with comments | « components/mus/ws/window_manager_state.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698