Fix #2884: minimap buttons don't do anything
Charry-pick of commit
a0b54b1513
.
This commit is contained in:
parent
f6933b98f8
commit
2bf39f7ee8
2 changed files with 21 additions and 3 deletions
|
@ -524,6 +524,19 @@ void command_executor::get_menu_images(display& disp, std::vector<config>& items
|
|||
void mbutton_event(const SDL_Event& event, command_executor* executor)
|
||||
{
|
||||
event_queue(event, executor);
|
||||
|
||||
/* Run mouse events immediately.
|
||||
|
||||
This is necessary because the sidebar doesn't allow set_button_state() to be called after a
|
||||
button has received the mouse press event but before it has received the mouse release event.
|
||||
When https://github.com/wesnoth/wesnoth/pull/2872 delayed the processing of input events,
|
||||
set_button_state() ended up being called at such a time. However, if we run the event handlers
|
||||
now, the button (if any) hasn't received the press event yet and we can call set_button_state()
|
||||
safely.
|
||||
|
||||
See https://github.com/wesnoth/wesnoth/issues/2884 */
|
||||
|
||||
run_events(executor);
|
||||
}
|
||||
|
||||
void jbutton_event(const SDL_Event& event, command_executor* executor)
|
||||
|
@ -551,7 +564,10 @@ void keyup_event(const SDL_Event&, command_executor* executor)
|
|||
void run_events(command_executor* executor)
|
||||
{
|
||||
if(!executor) return;
|
||||
executor->run_queued_commands();
|
||||
bool commands_ran = executor->run_queued_commands();
|
||||
if(commands_ran) {
|
||||
executor->set_button_state();
|
||||
}
|
||||
}
|
||||
|
||||
static void event_queue(const SDL_Event& event, command_executor* executor)
|
||||
|
@ -729,12 +745,14 @@ std::vector<command_executor::queued_command> command_executor::filter_command_q
|
|||
return filtered_commands;
|
||||
}
|
||||
|
||||
void command_executor::run_queued_commands()
|
||||
bool command_executor::run_queued_commands()
|
||||
{
|
||||
std::vector<queued_command> commands = filter_command_queue();
|
||||
for(const queued_command& cmd : commands) {
|
||||
execute_command_wrap(cmd);
|
||||
}
|
||||
|
||||
return !commands.empty();
|
||||
}
|
||||
|
||||
void command_executor_default::recalculate_minimap()
|
||||
|
|
|
@ -135,7 +135,7 @@ public:
|
|||
|
||||
virtual bool can_execute_command(const hotkey_command& command, int index=-1) const = 0;
|
||||
void queue_command(const SDL_Event& event, int index = -1);
|
||||
void run_queued_commands();
|
||||
bool run_queued_commands();
|
||||
void execute_quit_command()
|
||||
{
|
||||
const hotkey_command& quit_hotkey = hotkey_command::get_command_by_command(hotkey::HOTKEY_QUIT_GAME);
|
||||
|
|
Loading…
Add table
Reference in a new issue