The Battle for Wesnoth  1.15.0-dev
Classes | Typedefs | Functions | Variables
events Namespace Reference

Handling of system events. More...

Classes

class  chat_command_handler
 
class  chat_handler
 
class  cmd_arg_parser
 
struct  command_disabler
 
class  console_handler
 
class  context
 
struct  event_context
 
class  generic_event
 
class  map_command_handler
 
class  menu_handler
 
class  mouse_handler
 
class  mouse_handler_base
 
class  observer
 
struct  pump_info
 
class  pump_monitor
 
struct  save_id_matches
 
class  sdl_handler
 

Typedefs

typedef std::list< sdl_handler * > handler_list
 

Functions

std::deque< contextevent_contexts (1)
 
void focus_handler (const sdl_handler *ptr)
 
bool has_focus (const sdl_handler *hand, const SDL_Event *event)
 
static bool remove_on_resize (const SDL_Event &a)
 
void initialise ()
 
void finalize ()
 
void run_event_loop ()
 
void raise_process_event ()
 
void raise_resize_event ()
 
void raise_draw_event ()
 
void raise_draw_all_event ()
 
bool is_input (const SDL_Event &event)
 Is the event an input event? More...
 
void discard_input ()
 Discards all input events. More...
 
void peek_for_resize ()
 
void call_in_main_thread (const std::function< void(void)> &f)
 
static bool command_active ()
 

Variables

std::vector< pump_monitor * > pump_monitors
 
const uint32_t resize_timeout = 100
 
SDL_Event last_resize_event
 
bool last_resize_event_used = true
 
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 33 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 705 of file events.cpp.

References INPUT_MAX, and INPUT_MIN.

Referenced by game_launcher::play_multiplayer(), and game_launcher::play_multiplayer_commandline().

◆ event_contexts()

std::deque<context> events::event_contexts ( )

◆ finalize()

void events::finalize ( )

◆ focus_handler()

void events::focus_handler ( const sdl_handler ptr)

Definition at line 351 of file events.cpp.

Referenced by has_focus(), and gui::widget::set_focus().

◆ has_focus()

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

Definition at line 358 of file events.cpp.

References focus_handler(), i, and events::sdl_handler::requires_event_focus().

Referenced by gui::widget::focus().

◆ initialise()

void events::initialise ( )

Definition at line 423 of file events.cpp.

Referenced by do_gameloop().

◆ 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 700 of file events.cpp.

References INPUT_MAX, and INPUT_MIN.

Referenced by run_event_loop().

◆ peek_for_resize()

void events::peek_for_resize ( )

Definition at line 710 of file events.cpp.

References i.

Referenced by run_event_loop().

◆ raise_draw_all_event()

void events::raise_draw_all_event ( )

Definition at line 678 of file events.cpp.

References events::context::handlers.

◆ raise_draw_event()

void events::raise_draw_event ( )

Definition at line 665 of file events.cpp.

Referenced by run_event_loop().

◆ raise_process_event()

void events::raise_process_event ( )

Definition at line 642 of file events.cpp.

Referenced by controller_base::play_slice().

◆ raise_resize_event()

void events::raise_resize_event ( )

Definition at line 653 of file events.cpp.

References CVideo::get_height(), CVideo::get_singleton(), and CVideo::get_width().

Referenced by CVideo::set_resolution().

◆ remove_on_resize()

static bool events::remove_on_resize ( const SDL_Event &  a)
static

Definition at line 406 of file events.cpp.

References SHOW_HELPTIP_EVENT.

Referenced by run_event_loop().

◆ run_event_loop()

void events::run_event_loop ( )

Variable Documentation

◆ commands_disabled

int events::commands_disabled = 0

◆ last_resize_event

SDL_Event events::last_resize_event

Definition at line 403 of file events.cpp.

Referenced by run_event_loop().

◆ last_resize_event_used

bool events::last_resize_event_used = true

Definition at line 404 of file events.cpp.

Referenced by run_event_loop().

◆ main_thread

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

Definition at line 434 of file events.cpp.

◆ pump_monitors

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

Definition at line 208 of file events.cpp.

◆ resize_timeout

const uint32_t events::resize_timeout = 100

Definition at line 402 of file events.cpp.