Skip to content

Commit

Permalink
UseInputHandler: OnCommand() and OnMouse() return void
Browse files Browse the repository at this point in the history
The return value has become obsolete with commit 315522e
  • Loading branch information
MaxKellermann committed Sep 11, 2024
1 parent d9c53b3 commit beb411c
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 35 deletions.
14 changes: 3 additions & 11 deletions src/AsyncUserInput.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/Instance.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
12 changes: 4 additions & 8 deletions src/Main.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -222,8 +220,6 @@ Instance::OnMouse(Point p, mmask_t bstate) noexcept
} catch (...) {
screen_status_error(std::current_exception());
}

return true;
}

#endif
Expand Down
8 changes: 2 additions & 6 deletions src/UserInputHandler.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,17 @@ 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
/**
* An input event from the mouse was detected.
*
* @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

/**
Expand Down
3 changes: 1 addition & 2 deletions src/lirc.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Expand Down
8 changes: 3 additions & 5 deletions src/screen.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/screen.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit beb411c

Please sign in to comment.