Handling of system events. More...
Classes | |
class | chat_command_handler |
class | chat_handler |
class | context |
class | sdl_handler |
struct | event_context |
class | pump_monitor |
class | observer |
class | generic_event |
class | cmd_arg_parser |
class | map_command_handler |
class | console_handler |
struct | save_id_matches |
class | menu_handler |
class | mouse_handler |
struct | command_disabler |
class | mouse_handler_base |
Typedefs | |
typedef std::list< sdl_handler * > | handler_list |
Functions | |
void | focus_handler (const sdl_handler *ptr) |
bool | has_focus (const sdl_handler *hand, const SDL_Event *event) |
static void | raise_window_event (const SDL_Event &event) |
bool | is_in_main_thread () |
void | pump () |
Process all events currently in the queue. More... | |
void | draw () |
Trigger a draw cycle. More... | |
void | raise_process_event () |
void | raise_resize_event () |
void | process_tooltip_strings (int mousex, int mousey) |
Triggered by mouse-motion, sends the cursor position to all handlers to check whether a tooltip should be shown. More... | |
bool | is_input (const SDL_Event &event) |
Is the event an input event? More... | |
void | discard_input () |
Discards all input events. More... | |
void | call_in_main_thread (const std::function< void(void)> &f) |
void | pump_and_draw () |
pump() then immediately draw() More... | |
static bool | command_active () |
Variables | |
std::deque< context > | event_contexts |
std::vector< pump_monitor * > | pump_monitors |
static const std::thread::id | main_thread = std::this_thread::get_id() |
int | commands_disabled = 0 |
Handling of system events.
System events include mouse and key events, and other events which are not domain specific. The program maintains a stack of event_context objects, the top of the stack being the active event_context.
When an object of a type inheriting from handler is instantiated, it will be associated with the active event_context (unless auto_join has been set false, in which case it can manually be instructed to join a later context). As long as its event_context remains active, and only then, it will receive all system events.
typedef std::list<sdl_handler*> events::handler_list |
Definition at line 37 of file events.hpp.
void events::call_in_main_thread | ( | const std::function< void(void)> & | f | ) |
Definition at line 773 of file events.cpp.
References f, INVOKE_FUNCTION_EVENT, and is_in_main_thread().
Referenced by game_config_manager::init_game_config(), game_config_manager::load_addons_cfg(), game_config_manager::load_game_config(), and game_config_manager::load_game_config_for_game().
|
static |
Definition at line 44 of file mouse_handler_base.cpp.
Referenced by events::mouse_handler_base::is_left_click(), and events::mouse_handler_base::is_right_click().
void events::discard_input | ( | ) |
Discards all input events.
Definition at line 768 of file events.cpp.
References INPUT_MAX, and INPUT_MIN.
Referenced by game_launcher::play_multiplayer(), and game_launcher::play_multiplayer_commandline().
void events::draw | ( | ) |
Trigger a draw cycle.
Definition at line 721 of file events.cpp.
References draw_manager::sparkle().
Referenced by display::fade_to(), controller_base::play_slice(), pump_and_draw(), gui2::window::render(), display::scroll_to_xy(), gui2::window::show(), gui2::dialogs::file_progress::update_progress(), and gui2::window::update_render_textures().
void events::focus_handler | ( | const sdl_handler * | ptr | ) |
Definition at line 405 of file events.cpp.
References event_contexts.
Referenced by gui::textbox::handle_event(), has_focus(), and gui::widget::set_focus().
bool events::has_focus | ( | const sdl_handler * | hand, |
const SDL_Event * | event | ||
) |
Definition at line 412 of file events.cpp.
References event_contexts, focus_handler(), i, and events::sdl_handler::requires_event_focus().
Referenced by gui::widget::focus().
bool events::is_in_main_thread | ( | ) |
Definition at line 474 of file events.cpp.
References main_thread.
Referenced by call_in_main_thread(), pump(), and gui2::dialogs::loading_screen::spin().
bool events::is_input | ( | const SDL_Event & | event | ) |
Is the event an input event?
Definition at line 763 of file events.cpp.
References INPUT_MAX, and INPUT_MIN.
Referenced by pump().
void events::process_tooltip_strings | ( | int | mousex, |
int | mousey | ||
) |
Triggered by mouse-motion, sends the cursor position to all handlers to check whether a tooltip should be shown.
Definition at line 750 of file events.cpp.
References event_contexts.
Referenced by pump().
void events::pump | ( | ) |
Process all events currently in the queue.
Definition at line 479 of file events.cpp.
References c, DOUBLE_CLICK_EVENT, event_contexts, video::game_canvas_size(), prefs::get(), h, windows_tray_notification::handle_system_event(), i, draw_manager::invalidate_all(), INVOKE_FUNCTION_EVENT, is_in_main_thread(), is_input(), LOG_DP, LOG_EV, process_tooltip_strings(), pump_monitors, quit_confirmation::quit_to_desktop(), raise_window_event(), cursor::set_focus(), prefs::set_resolution(), video::update_buffers(), and video::window_size().
Referenced by actions::place_recruit(), controller_base::play_slice(), pump_and_draw(), display::scroll_to_xy(), gui2::window::show(), and SYNCED_COMMAND_HANDLER_FUNCTION().
|
inline |
pump() then immediately draw()
Definition at line 150 of file events.hpp.
References draw(), and pump().
Referenced by display::fade_to(), display::fade_tod_mask(), gui2::dialogs::loading_screen::progress(), gui2::window::show_non_modal(), and gui2::dialogs::loading_screen::spin().
void events::raise_process_event | ( | ) |
Definition at line 726 of file events.cpp.
References event_contexts.
Referenced by controller_base::play_slice().
void events::raise_resize_event | ( | ) |
Definition at line 737 of file events.cpp.
References raise_window_event(), utf8::size(), and video::window_size().
Referenced by gui2::dialogs::preferences_dialog::apply_pixel_scale().
|
static |
Definition at line 456 of file events.cpp.
References event_contexts, and events::context::handlers.
Referenced by pump(), and raise_resize_event().
int events::commands_disabled = 0 |
Definition at line 42 of file mouse_handler_base.cpp.
Referenced by replay_controller::can_execute_command(), playsingle_controller::hotkey_handler::can_execute_command(), play_controller::hotkey_handler::can_execute_command(), play_controller::can_redo(), play_controller::can_undo(), play_controller::can_use_synced_wml_menu(), events::command_disabler::command_disabler(), events::console_handler::do_unit(), events::mouse_handler::move_action(), playmp_controller::play_human_turn(), events::mouse_handler::select_hex(), game_events::WML_HANDLER_FUNCTION(), and events::command_disabler::~command_disabler().
std::deque<context> events::event_contexts |
Definition at line 218 of file events.cpp.
Referenced by events::event_context::event_context(), focus_handler(), has_focus(), events::sdl_handler::join(), events::sdl_handler::join_global(), events::sdl_handler::join_same(), events::sdl_handler::leave(), events::sdl_handler::leave_global(), events::sdl_handler::operator=(), process_tooltip_strings(), pump(), raise_process_event(), raise_window_event(), events::sdl_handler::sdl_handler(), and events::event_context::~event_context().
|
static |
Definition at line 470 of file events.cpp.
Referenced by is_in_main_thread().
std::vector<pump_monitor*> events::pump_monitors |
Definition at line 220 of file events.cpp.
Referenced by pump(), events::pump_monitor::pump_monitor(), and events::pump_monitor::~pump_monitor().