diff --git a/src/AsyncUserInput.cxx b/src/AsyncUserInput.cxx index 49214a6c..a57444cd 100644 --- a/src/AsyncUserInput.cxx +++ b/src/AsyncUserInput.cxx @@ -55,6 +55,12 @@ AsyncUserInput::OnSocketReady(unsigned) noexcept } #endif + if (handler.OnRawKey(key)) { + // TODO: begin_input_event() ? + end_input_event(); + return; + } + Command cmd = translate_key(key); if (cmd == Command::NONE) return; diff --git a/src/Instance.cxx b/src/Instance.cxx index 6d955e4e..cb549ee5 100644 --- a/src/Instance.cxx +++ b/src/Instance.cxx @@ -82,3 +82,10 @@ Instance::Run() event_loop.Run(); } + +bool +Instance::OnRawKey(int key) noexcept +{ + (void)key; + return false; +} diff --git a/src/Instance.hxx b/src/Instance.hxx index f7e5eb79..be370328 100644 --- a/src/Instance.hxx +++ b/src/Instance.hxx @@ -119,6 +119,7 @@ private: #endif // virtual methods from AsyncUserInputHandler + bool OnRawKey(int key) noexcept override; bool OnCommand(Command cmd) noexcept override; #ifdef HAVE_GETMOUSE bool OnMouse(Point p, mmask_t bstate) noexcept override; diff --git a/src/UserInputHandler.hxx b/src/UserInputHandler.hxx index 752411bd..ebe1cf61 100644 --- a/src/UserInputHandler.hxx +++ b/src/UserInputHandler.hxx @@ -15,6 +15,16 @@ struct Point; */ class UserInputHandler { public: + /** + * Implementing this method gives the handler a chance to + * handle a key code pressed by the user. This is called + * before looking up hot keys. + * + * @return true if the character was consumed, false to pass + * it on to the hot key checker + */ + virtual bool OnRawKey(int key) noexcept = 0; + /** * A hot key for a #Command was pressed. *