The Battle for Wesnoth  1.19.7+dev
Classes | Typedefs | Functions | Variables
events Namespace Reference

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< contextevent_contexts
 
std::vector< pump_monitor * > pump_monitors
 
static const std::thread::id main_thread = std::this_thread::get_id()
 
int commands_disabled = 0
 

Detailed Description

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.

Note
Multiple handler objects will receive the same events, including key events.

Typedef Documentation

◆ handler_list

typedef std::list<sdl_handler*> events::handler_list

Definition at line 37 of file events.hpp.

Function Documentation

◆ call_in_main_thread()

void events::call_in_main_thread ( const std::function< void(void)> &  f)

◆ command_active()

static bool events::command_active ( )
static

◆ discard_input()

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().

◆ draw()

void events::draw ( )

◆ focus_handler()

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().

◆ has_focus()

bool events::has_focus ( const sdl_handler hand,
const SDL_Event *  event 
)

◆ is_in_main_thread()

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().

◆ is_input()

bool events::is_input ( const SDL_Event &  event)

Is the event an input event?

Returns
Whether or not the event is an input event.

Definition at line 763 of file events.cpp.

References INPUT_MAX, and INPUT_MIN.

Referenced by pump().

◆ process_tooltip_strings()

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().

◆ pump()

void events::pump ( )

◆ pump_and_draw()

void events::pump_and_draw ( )
inline

◆ raise_process_event()

void events::raise_process_event ( )

Definition at line 726 of file events.cpp.

References event_contexts.

Referenced by controller_base::play_slice().

◆ raise_resize_event()

void events::raise_resize_event ( )

◆ raise_window_event()

static void events::raise_window_event ( const SDL_Event &  event)
static

Definition at line 456 of file events.cpp.

References event_contexts, and events::context::handlers.

Referenced by pump(), and raise_resize_event().

Variable Documentation

◆ commands_disabled

int events::commands_disabled = 0

◆ event_contexts

std::deque<context> events::event_contexts

◆ main_thread

const std::thread::id events::main_thread = std::this_thread::get_id()
static

Definition at line 470 of file events.cpp.

Referenced by is_in_main_thread().

◆ pump_monitors

std::vector<pump_monitor*> events::pump_monitors