i3
Functions | Variables
bindings.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

Bindingconfigure_binding (const char *bindtype, const char *modifiers, const char *input_code, const char *release, const char *border, const char *whole_window, const char *command, const char *mode, bool pango_markup)
 Adds a binding from config parameters given as strings and returns a pointer to the binding structure. More...
 
void grab_all_keys (xcb_connection_t *conn)
 Grab the bound keys (tell X to send us keypress events for those keycodes) More...
 
void regrab_all_buttons (xcb_connection_t *conn)
 Release the button grabs on all managed windows and regrab them, reevaluating which buttons need to be grabbed. More...
 
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 reorder_bindings (void)
 Reorders bindings by event_state_mask descendingly so that get_binding() correctly matches more specific bindings before more generic bindings. 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...
 
void binding_free (Binding *bind)
 Frees the binding. More...
 
CommandResultrun_binding (Binding *bind, Con *con)
 Runs the given binding and handles parse errors. More...
 
bool load_keymap (void)
 Loads the XKB keymap from the X11 server and feeds it to xkbcommon. More...
 
bool bindings_should_grab_scrollwheel_buttons (void)
 Returns true if the current config has any binding to a scroll wheel button (4 or 5) which is a whole-window binding. More...
 

Variables

pid_t command_error_nagbar_pid
 
const char * DEFAULT_BINDING_MODE
 The name of the default mode. More...
 

Function Documentation

void binding_free ( Binding bind)

Frees the binding.

If bind is null, it simply returns.

Definition at line 628 of file bindings.c.

References Binding::command, FREE, Binding::symbol, and Binding::translated_to.

Referenced by load_configuration(), and run_binding().

bool bindings_should_grab_scrollwheel_buttons ( void  )

Returns true if the current config has any binding to a scroll wheel button (4 or 5) which is a whole-window binding.

We need this to figure out whether we should grab all buttons or just 1-3 when managing a window. See #2049.

Definition at line 820 of file bindings.c.

References B_MOUSE, bindings, ELOG, Binding::input_type, Binding::symbol, TAILQ_FOREACH, and Binding::whole_window.

Referenced by manage_window(), and regrab_all_buttons().

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 564 of file bindings.c.

References bindings, Binding::command, ELOG, Binding::event_state_mask, context::has_errors, Binding::input_type, Binding::keycode, 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 *  border,
const char *  whole_window,
const char *  command,
const char *  mode,
bool  pango_markup 
)

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 56 of file bindings.c.

References B_KEYBOARD, B_MOUSE, bindings, Mode::bindings, Binding::border, Binding::command, DLOG, ELOG, event_state_from_str(), Binding::event_state_mask, FREE, I3_XKB_GROUP_MASK_1, I3_XKB_GROUP_MASK_2, I3_XKB_GROUP_MASK_3, I3_XKB_GROUP_MASK_4, Binding::input_type, Binding::keycode, mode_from_name(), Binding::release, scalloc(), sstrdup(), Binding::symbol, TAILQ_INSERT_TAIL, and Binding::whole_window.

Referenced by CFGFUN().

Here is the call graph for this function:

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 259 of file bindings.c.

References B_KEYBOARD, B_MOUSE, DLOG, get_binding(), I3_XKB_GROUP_MASK_1, I3_XKB_GROUP_MASK_2, I3_XKB_GROUP_MASK_3, I3_XKB_GROUP_MASK_4, and xcb_numlock_mask.

Referenced by handle_button_press(), handle_key_press(), and route_click().

Here is the call graph for this function:

void grab_all_keys ( xcb_connection_t *  conn)

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

Definition at line 132 of file bindings.c.

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

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

Here is the call graph for this function:

bool load_keymap ( void  )

Loads the XKB keymap from the X11 server and feeds it to xkbcommon.

Definition at line 764 of file bindings.c.

References conn, ELOG, fill_rmlvo_from_root(), LOG, xkb_context, xkb_keymap, and xkb_supported.

Referenced by handle_event(), and main().

Here is the call graph for this function:

void regrab_all_buttons ( xcb_connection_t *  conn)

Release the button grabs on all managed windows and regrab them, reevaluating which buttons need to be grabbed.

Definition at line 154 of file bindings.c.

References all_cons, bindings_should_grab_scrollwheel_buttons(), Window::id, TAILQ_FOREACH, Con::window, and xcb_grab_buttons().

Referenced by load_configuration().

Here is the call graph for this function:

void reorder_bindings ( void  )

Reorders bindings by event_state_mask descendingly so that get_binding() correctly matches more specific bindings before more generic bindings.

Take the following binding configuration as an example:

bindsym n nop lower-case n pressed bindsym Shift+n nop upper-case n pressed

Without reordering, the first binding’s event_state_mask of 0x0 would match the actual event_stat_mask of 0x1 and hence trigger instead of the second keybinding.

Definition at line 547 of file bindings.c.

References bindings, Mode::bindings, current_mode, modes, reorder_bindings_of_mode(), and SLIST_FOREACH.

Referenced by parse_file().

Here is the call graph for this function:

CommandResult* run_binding ( Binding bind,
Con con 
)

Runs the given binding and handles parse errors.

If con is passed, it will execute the command binding with that container selected by criteria. 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 646 of file bindings.c.

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

Referenced by handle_button_press(), handle_key_press(), and route_click().

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 466 of file bindings.c.

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

Referenced by cmd_mode(), and load_configuration().

Here is the call graph for this function:

void translate_keysyms ( void  )

Variable Documentation

pid_t command_error_nagbar_pid

Definition at line 17 of file bindings.c.

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

const char* DEFAULT_BINDING_MODE

The name of the default mode.

Definition at line 23 of file bindings.c.

Referenced by CFGFUN().