From beb411cb94f07df7b4df4efed47d4fca236df086 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 11 Sep 2024 13:27:46 +0200 Subject: [PATCH] UseInputHandler: OnCommand() and OnMouse() return void The return value has become obsolete with commit 315522e63671 --- src/AsyncUserInput.cxx | 14 +++----------- src/Instance.hxx | 4 ++-- src/Main.cxx | 12 ++++-------- src/UserInputHandler.hxx | 8 ++------ src/lirc.cxx | 3 +-- src/screen.cxx | 8 +++----- src/screen.hxx | 2 +- 7 files changed, 16 insertions(+), 35 deletions(-) diff --git a/src/AsyncUserInput.cxx b/src/AsyncUserInput.cxx index 64a07bf7..bdc0384a 100644 --- a/src/AsyncUserInput.cxx +++ b/src/AsyncUserInput.cxx @@ -50,9 +50,7 @@ AsyncUserInput::OnSocketReady(unsigned) noexcept getmouse(&event); #endif - if (!handler.OnMouse({event.x, event.y}, event.bstate)) - return; - + handler.OnMouse({event.x, event.y}, event.bstate); return; } #endif @@ -61,14 +59,8 @@ AsyncUserInput::OnSocketReady(unsigned) noexcept return; } - Command cmd = translate_key(key); - if (cmd == Command::NONE) - return; - - if (!handler.OnCommand(cmd)) - return; - - return; + if (Command cmd = translate_key(key); cmd != Command::NONE) + handler.OnCommand(cmd); } AsyncUserInput::AsyncUserInput(EventLoop &event_loop, WINDOW &_w, diff --git a/src/Instance.hxx b/src/Instance.hxx index 461f7f4c..4431886f 100644 --- a/src/Instance.hxx +++ b/src/Instance.hxx @@ -134,9 +134,9 @@ private: // virtual methods from UserInputHandler bool OnRawKey(int key) noexcept override; - bool OnCommand(Command cmd) noexcept override; + void OnCommand(Command cmd) noexcept override; #ifdef HAVE_GETMOUSE - bool OnMouse(Point p, mmask_t bstate) noexcept override; + void OnMouse(Point p, mmask_t bstate) noexcept override; #endif bool CancelModalDialog() noexcept override; }; diff --git a/src/Main.cxx b/src/Main.cxx index 715486a3..984c41f3 100644 --- a/src/Main.cxx +++ b/src/Main.cxx @@ -186,33 +186,31 @@ Instance::OnUpdateScreen() noexcept auto_update_timer(*this); } -bool +void Instance::OnCommand(Command cmd) noexcept { update_screen_event.Schedule(); if (cmd == Command::QUIT) { event_loop.Break(); - return false; + return; } try { screen_manager.OnCommand(GetClient(), GetSeek(), cmd); } catch (...) { screen_status_error(std::current_exception()); - return true; + return; } if (cmd == Command::VOLUME_UP || cmd == Command::VOLUME_DOWN) /* make sure we don't update the volume yet */ DisableUpdateTimer(); - - return true; } #ifdef HAVE_GETMOUSE -bool +void Instance::OnMouse(Point p, mmask_t bstate) noexcept { update_screen_event.Schedule(); @@ -222,8 +220,6 @@ Instance::OnMouse(Point p, mmask_t bstate) noexcept } catch (...) { screen_status_error(std::current_exception()); } - - return true; } #endif diff --git a/src/UserInputHandler.hxx b/src/UserInputHandler.hxx index 0eb0b389..f58fa876 100644 --- a/src/UserInputHandler.hxx +++ b/src/UserInputHandler.hxx @@ -27,10 +27,8 @@ public: /** * A hot key for a #Command was pressed. - * - * @return false if ncmpc will quit */ - virtual bool OnCommand(Command cmd) noexcept = 0; + virtual void OnCommand(Command cmd) noexcept = 0; #ifdef HAVE_GETMOUSE /** @@ -38,10 +36,8 @@ public: * * @param p the position of the mouse cursor on the screen * @param bstate the state of all mouse buttons - * - * @return false if ncmpc will quit */ - virtual bool OnMouse(Point p, mmask_t bstate) noexcept = 0; + virtual void OnMouse(Point p, mmask_t bstate) noexcept = 0; #endif /** diff --git a/src/lirc.cxx b/src/lirc.cxx index 675c6ca2..929f9b8d 100644 --- a/src/lirc.cxx +++ b/src/lirc.cxx @@ -16,8 +16,7 @@ LircInput::OnSocketReady(unsigned) noexcept if (lirc_nextcode(&code) == 0) { while (lirc_code2char(lc, code, &txt) == 0 && txt != nullptr) { const auto cmd = get_key_command_from_name(txt); - if (!handler.OnCommand(cmd)) - return; + handler.OnCommand(cmd); } } } diff --git a/src/screen.cxx b/src/screen.cxx index 2b544de8..209d6932 100644 --- a/src/screen.cxx +++ b/src/screen.cxx @@ -305,20 +305,18 @@ ScreenManager::OnCommand(struct mpdclient &c, DelayedSeek &seek, Command cmd) #ifdef HAVE_GETMOUSE -bool +void ScreenManager::OnMouse(struct mpdclient &c, DelayedSeek &seek, Point p, mmask_t bstate) { if (GetCurrentPage().OnMouse(c, p - GetMainPosition(), bstate)) - return true; + return; /* if button 2 was pressed switch screen */ if (bstate & BUTTON2_CLICKED) { OnCommand(c, seek, Command::SCREEN_NEXT); - return true; + return; } - - return false; } #endif diff --git a/src/screen.hxx b/src/screen.hxx index 9e4f6d81..e2be8b1a 100644 --- a/src/screen.hxx +++ b/src/screen.hxx @@ -127,7 +127,7 @@ public: void OnCommand(struct mpdclient &c, DelayedSeek &seek, Command cmd); #ifdef HAVE_GETMOUSE - bool OnMouse(struct mpdclient &c, DelayedSeek &seek, + void OnMouse(struct mpdclient &c, DelayedSeek &seek, Point p, mmask_t bstate); #endif