i3
Macros | Functions | Variables
bindings.c File Reference
#include "all.h"
Include dependency graph for bindings.c:

Go to the source code of this file.

Macros

#define GRAB_KEY(modifier)
 

Functions

static struct Modemode_from_name (const char *name)
 
Bindingconfigure_binding (const char *bindtype, const char *modifiers, const char *input_code, const char *release, const char *command, const char *modename)
 Adds a binding from config parameters given as strings and returns a pointer to the binding structure. More...
 
static void grab_keycode_for_binding (xcb_connection_t *conn, Binding *bind, uint32_t keycode)
 
void grab_all_keys (xcb_connection_t *conn, bool bind_mode_switch)
 Grab the bound keys (tell X to send us keypress events for those keycodes) More...
 
static Bindingget_binding (uint16_t modifiers, bool is_release, uint16_t input_code, input_type_t input_type)
 
Bindingget_binding_from_xcb_event (xcb_generic_event_t *event)
 Returns a pointer to the Binding that matches the given xcb event or NULL if no such binding exists. More...
 
void translate_keysyms (void)
 Translates keysymbols to keycodes for all bindings which use keysyms. More...
 
void switch_mode (const char *new_mode)
 Switches the key bindings to the given mode, if the mode exists. More...
 
void check_for_duplicate_bindings (struct context *context)
 Checks for duplicate key bindings (the same keycode or keysym is configured more than once). More...
 
CommandResultrun_binding (Binding *bind)
 Runs the given binding and handles parse errors. More...
 

Variables

pid_t command_error_nagbar_pid = -1
 
const char * DEFAULT_BINDING_MODE = "default"
 

Macro Definition Documentation

#define GRAB_KEY (   modifier)
Value:
do { \
xcb_grab_key(conn, 0, root, modifier, keycode, XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC); \
} while (0)
xcb_connection_t * conn
Definition: main.c:47
xcb_window_t root
Definition: main.c:60

Referenced by grab_keycode_for_binding().

Function Documentation

void check_for_duplicate_bindings ( struct context context)

Checks for duplicate key bindings (the same keycode or keysym is configured more than once).

If a duplicate binding is found, a message is printed to stderr and the has_errors variable is set to true, which will start i3-nagbar.

Definition at line 335 of file bindings.c.

References bindings, Binding::command, ELOG, context::has_errors, Binding::input_type, Binding::keycode, Binding::mods, Binding::release, Binding::symbol, and TAILQ_FOREACH.

Referenced by parse_file().

Binding* configure_binding ( const char *  bindtype,
const char *  modifiers,
const char *  input_code,
const char *  release,
const char *  command,
const char *  mode 
)

Adds a binding from config parameters given as strings and returns a pointer to the binding structure.

Returns NULL if the input code could not be parsed.

Definition at line 49 of file bindings.c.

References B_KEYBOARD, B_MOUSE, Mode::bindings, bindings, Binding::command, DLOG, ELOG, FREE, Binding::input_type, Binding::keycode, mode_from_name(), modifiers_from_str(), Binding::mods, Binding::release, scalloc(), sstrdup(), Binding::symbol, and TAILQ_INSERT_TAIL.

Referenced by CFGFUN().

Here is the call graph for this function:

static Binding* get_binding ( uint16_t  modifiers,
bool  is_release,
uint16_t  input_code,
input_type_t  input_type 
)
static
Binding* get_binding_from_xcb_event ( xcb_generic_event_t *  event)

Returns a pointer to the Binding that matches the given xcb event or NULL if no such binding exists.

Definition at line 192 of file bindings.c.

References B_KEYBOARD, B_MOUSE, BIND_MODE_SWITCH, DLOG, get_binding(), xcb_numlock_mask, and xkb_current_group.

Referenced by handle_key_press().

Here is the call graph for this function:

void grab_all_keys ( xcb_connection_t *  conn,
bool  bind_mode_switch 
)

Grab the bound keys (tell X to send us keypress events for those keycodes)

Definition at line 105 of file bindings.c.

References B_KEYBOARD, BIND_MODE_SWITCH, bindings, grab_keycode_for_binding(), Binding::input_type, Binding::keycode, Binding::mods, Binding::number_keycodes, TAILQ_FOREACH, and Binding::translated_to.

Referenced by handle_mapping_notify(), load_configuration(), main(), switch_mode(), and xkb_got_event().

Here is the call graph for this function:

static void grab_keycode_for_binding ( xcb_connection_t *  conn,
Binding bind,
uint32_t  keycode 
)
static

Definition at line 79 of file bindings.c.

References B_KEYBOARD, BIND_MODE_SWITCH, DLOG, GRAB_KEY, Binding::input_type, Binding::mods, and xcb_numlock_mask.

Referenced by grab_all_keys().

static struct Mode* mode_from_name ( const char *  name)
static

Definition at line 24 of file bindings.c.

References Mode::bindings, modes, Mode::name, scalloc(), SLIST_FOREACH, SLIST_INSERT_HEAD, sstrdup(), and TAILQ_INIT.

Referenced by configure_binding().

Here is the call graph for this function:

CommandResult* run_binding ( Binding bind)

Runs the given binding and handles parse errors.

Returns a CommandResult for running the binding's command. Caller should render tree if needs_tree_render is true. Free with command_result_free().

Definition at line 387 of file bindings.c.

References Binding::command, command_error_nagbar_pid, config, errorfilename, Config::font, CommandResult::needs_tree_render, parse_command(), CommandResult::parse_error, Font::pattern, sasprintf(), sstrdup(), start_nagbar(), and tree_render().

Referenced by handle_key_press().

Here is the call graph for this function:

void switch_mode ( const char *  new_mode)

Switches the key bindings to the given mode, if the mode exists.

Definition at line 302 of file bindings.c.

References bindings, Mode::bindings, conn, DLOG, ELOG, FREE, grab_all_keys(), ipc_send_event(), modes, Mode::name, sasprintf(), SLIST_FOREACH, translate_keysyms(), and ungrab_all_keys().

Referenced by cmd_mode().

Here is the call graph for this function:

void translate_keysyms ( void  )

Translates keysymbols to keycodes for all bindings which use keysyms.

Definition at line 242 of file bindings.c.

References B_MOUSE, BIND_MODE_SWITCH, bindings, conn, DLOG, ELOG, FREE, Binding::input_type, Binding::keycode, keysyms, Binding::mods, Binding::number_keycodes, srealloc(), Binding::symbol, TAILQ_FOREACH, and Binding::translated_to.

Referenced by handle_mapping_notify(), load_configuration(), main(), switch_mode(), and xkb_got_event().

Here is the call graph for this function:

Variable Documentation

pid_t command_error_nagbar_pid = -1

Definition at line 11 of file bindings.c.

Referenced by cmd_reload(), i3_restart(), and run_binding().

const char* DEFAULT_BINDING_MODE = "default"

Definition at line 17 of file bindings.c.

Referenced by CFGFUN().