From b337f99ca7a03d2cf4bc4999f8c9630637b9bd02 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Sat, 26 Nov 2016 13:29:17 +0000 Subject: [PATCH] Add a 'keys' debug flag, showing the keystrokes comming to clients --- src/client.cc | 6 ++++++ src/option_types.hh | 6 ++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/client.cc b/src/client.cc index 6019f391..c95e8281 100644 --- a/src/client.cc +++ b/src/client.cc @@ -77,8 +77,14 @@ void Client::handle_available_input(EventMode mode) try { + const bool debug_keys = (bool)(context().options()["debug"].get() & DebugFlags::Keys); + while (Optional key = get_next_key(mode)) { + if (debug_keys) + write_to_debug_buffer(format("Client '{}' got key '{}'", + context().name(), key_to_str(*key))); + if (*key == ctrl('c')) killpg(getpgrp(), SIGINT); else if (*key == Key::FocusIn) diff --git a/src/option_types.hh b/src/option_types.hh index a37f37f3..b0d9b054 100644 --- a/src/option_types.hh +++ b/src/option_types.hh @@ -242,17 +242,19 @@ enum class DebugFlags Hooks = 1 << 0, Shell = 1 << 1, Profile = 1 << 2, + Keys = 1 << 3, }; template<> struct WithBitOps : std::true_type {}; -constexpr Array, 3> enum_desc(DebugFlags) +constexpr Array, 4> enum_desc(DebugFlags) { return { { { DebugFlags::Hooks, "hooks" }, { DebugFlags::Shell, "shell" }, - { DebugFlags::Profile, "profile" } + { DebugFlags::Profile, "profile" }, + { DebugFlags::Keys, "keys" } } }; }