Add a 'keys' debug flag, showing the keystrokes comming to clients

This commit is contained in:
Maxime Coste 2016-11-26 13:29:17 +00:00
parent e340e0ed39
commit b337f99ca7
2 changed files with 10 additions and 2 deletions

View File

@ -77,8 +77,14 @@ void Client::handle_available_input(EventMode mode)
try
{
const bool debug_keys = (bool)(context().options()["debug"].get<DebugFlags>() & DebugFlags::Keys);
while (Optional<Key> 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)

View File

@ -242,17 +242,19 @@ enum class DebugFlags
Hooks = 1 << 0,
Shell = 1 << 1,
Profile = 1 << 2,
Keys = 1 << 3,
};
template<>
struct WithBitOps<DebugFlags> : std::true_type {};
constexpr Array<EnumDesc<DebugFlags>, 3> enum_desc(DebugFlags)
constexpr Array<EnumDesc<DebugFlags>, 4> enum_desc(DebugFlags)
{
return { {
{ DebugFlags::Hooks, "hooks" },
{ DebugFlags::Shell, "shell" },
{ DebugFlags::Profile, "profile" }
{ DebugFlags::Profile, "profile" },
{ DebugFlags::Keys, "keys" }
} };
}