2014-01-28 04:45:01 +01:00
|
|
|
|
/*
|
|
|
|
|
* vim:ts=4:sw=4:expandtab
|
|
|
|
|
*
|
|
|
|
|
* i3 - an improved dynamic tiling window manager
|
2015-04-04 02:17:56 +02:00
|
|
|
|
* © 2009 Michael Stapelberg and contributors (see also: LICENSE)
|
2014-01-28 04:45:01 +01:00
|
|
|
|
*
|
|
|
|
|
* bindings.h: Functions for configuring, finding, and running bindings.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2014-05-31 17:00:02 +02:00
|
|
|
|
extern pid_t command_error_nagbar_pid;
|
|
|
|
|
|
2014-01-28 04:45:01 +01:00
|
|
|
|
/**
|
|
|
|
|
* The name of the default mode.
|
|
|
|
|
*
|
|
|
|
|
*/
|
2016-01-08 19:56:32 +01:00
|
|
|
|
extern const char *DEFAULT_BINDING_MODE;
|
2014-01-28 04:45:01 +01:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
Binding *configure_binding(const char *bindtype, const char *modifiers, const char *input_code,
|
2015-04-02 03:43:46 +02:00
|
|
|
|
const char *release, const char *border, const char *whole_window,
|
2015-10-12 23:43:47 +02:00
|
|
|
|
const char *command, const char *mode, bool pango_markup);
|
2014-02-15 00:38:01 +01:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Grab the bound keys (tell X to send us keypress events for those keycodes)
|
|
|
|
|
*
|
|
|
|
|
*/
|
Use libxkbcommon for translating keysyms, support all XKB groups.
fixes #1835
This commit improves the translation of keysyms to keycodes by loading
keymaps using libxkbcommon-x11 and using libxkbcommon for figuring out
the keymap, depending on each keybinding’s modifiers. This way, the
upper layers of complex layouts are now usable with i3’s bindsym
directive, such as de_neo’s layer 3 and higher.
Furthermore, the commit generalizes the handling of different XKB
groups. We formerly had support only for two separate groups, the
default group 1, and group 2. While Mode_switch is only one way to
switch to group 2, we called the binding option Mode_switch. With this
commit, the new names Group1, Group2 (an alias for Mode_switch), Group3
and Group4 are introduced for configuring bindings. This is only useful
for advanced keyboard layouts, such as people loading two keyboard
layouts and switching between them (us, ru seems to be a popular
combination).
When grabbing keys, one can only specify the modifier mask, but not an
XKB state mask (or value), so we still dynamically unbind and re-bind
keys whenever the XKB group changes.
The commit was manually tested using the following i3 config:
bindsym Group4+n nop heya from group 4
bindsym Group3+n nop heya from group 3
bindsym Group2+n nop heya from group 2
bindsym n nop heya
bindsym shift+N nop explicit shift binding
bindsym shift+r nop implicit shift binding
bindcode Group2+38 nop fallback overwritten in group 2 only
bindcode 38 nop fallback
…with the following layout:
setxkbmap -layout "us,ua,ru,de" -variant ",winkeys,,neo" \
-option "grp:shift_caps_toggle,grp_led:scroll" \
-model pc104 -rules evdev
By default (xkb group 1, us layout), pressing “n” will result in the
“heya” message appearing. Pressing “a” will result in the “fallback”
message appearing. “j” is not triggered.
By pressing Shift+CapsLock you switch to the next group (xkb group 2, ua
layout). Pressing “a” will result in the “fallback overwritten in group
2 only” message, pressing “n” will still result in “heya”. “j” is not
triggered.
In the next group (xkb group 3, ru layout), pressing “a” will result in
the “fallback” message again, pressing “n” will result in “heya”,
“j” is not triggered.
In the last group (xkb group 4, de_neo layout), pressing “a” will still
result in “fallback”, pressing “n” will result in “heya”, pressing “j”
will result in “heya from group 4”.
Pressing shift+n results in “explicit shift binding”, pressing shift+r
results in “implicit shift binding”. This ensures that keysym
translation falls back to looking at non-shift keys (“r” can be used
instead of ”R”) and that the order of keybindings doesn’t play a role
(“bindsym n” does not override “bindsym shift+n”, even though it’s
specified earlier in the config).
The fallback behavior ensures use-cases such as ticket #1775 are still
covered.
Only binding keys when the X server is in the corresponding XKB group
ensures use-cases such as ticket #585 are still covered.
2015-08-23 22:49:32 +02:00
|
|
|
|
void grab_all_keys(xcb_connection_t *conn);
|
2014-02-22 01:10:21 +01:00
|
|
|
|
|
2015-11-11 20:40:25 +01:00
|
|
|
|
/**
|
|
|
|
|
* Release the button grabs on all managed windows and regrab them,
|
|
|
|
|
* reevaluating which buttons need to be grabbed.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
void regrab_all_buttons(xcb_connection_t *conn);
|
|
|
|
|
|
2014-02-22 01:10:21 +01:00
|
|
|
|
/**
|
2014-05-02 16:22:40 +02:00
|
|
|
|
* Returns a pointer to the Binding that matches the given xcb event or NULL if
|
|
|
|
|
* no such binding exists.
|
2014-02-22 01:10:21 +01:00
|
|
|
|
*
|
|
|
|
|
*/
|
2014-05-02 16:22:40 +02:00
|
|
|
|
Binding *get_binding_from_xcb_event(xcb_generic_event_t *event);
|
2014-03-13 13:02:07 +01:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Translates keysymbols to keycodes for all bindings which use keysyms.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
void translate_keysyms(void);
|
2014-04-14 20:52:56 +02:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Switches the key bindings to the given mode, if the mode exists
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
void switch_mode(const char *new_mode);
|
2014-04-23 03:41:28 +02:00
|
|
|
|
|
Use libxkbcommon for translating keysyms, support all XKB groups.
fixes #1835
This commit improves the translation of keysyms to keycodes by loading
keymaps using libxkbcommon-x11 and using libxkbcommon for figuring out
the keymap, depending on each keybinding’s modifiers. This way, the
upper layers of complex layouts are now usable with i3’s bindsym
directive, such as de_neo’s layer 3 and higher.
Furthermore, the commit generalizes the handling of different XKB
groups. We formerly had support only for two separate groups, the
default group 1, and group 2. While Mode_switch is only one way to
switch to group 2, we called the binding option Mode_switch. With this
commit, the new names Group1, Group2 (an alias for Mode_switch), Group3
and Group4 are introduced for configuring bindings. This is only useful
for advanced keyboard layouts, such as people loading two keyboard
layouts and switching between them (us, ru seems to be a popular
combination).
When grabbing keys, one can only specify the modifier mask, but not an
XKB state mask (or value), so we still dynamically unbind and re-bind
keys whenever the XKB group changes.
The commit was manually tested using the following i3 config:
bindsym Group4+n nop heya from group 4
bindsym Group3+n nop heya from group 3
bindsym Group2+n nop heya from group 2
bindsym n nop heya
bindsym shift+N nop explicit shift binding
bindsym shift+r nop implicit shift binding
bindcode Group2+38 nop fallback overwritten in group 2 only
bindcode 38 nop fallback
…with the following layout:
setxkbmap -layout "us,ua,ru,de" -variant ",winkeys,,neo" \
-option "grp:shift_caps_toggle,grp_led:scroll" \
-model pc104 -rules evdev
By default (xkb group 1, us layout), pressing “n” will result in the
“heya” message appearing. Pressing “a” will result in the “fallback”
message appearing. “j” is not triggered.
By pressing Shift+CapsLock you switch to the next group (xkb group 2, ua
layout). Pressing “a” will result in the “fallback overwritten in group
2 only” message, pressing “n” will still result in “heya”. “j” is not
triggered.
In the next group (xkb group 3, ru layout), pressing “a” will result in
the “fallback” message again, pressing “n” will result in “heya”,
“j” is not triggered.
In the last group (xkb group 4, de_neo layout), pressing “a” will still
result in “fallback”, pressing “n” will result in “heya”, pressing “j”
will result in “heya from group 4”.
Pressing shift+n results in “explicit shift binding”, pressing shift+r
results in “implicit shift binding”. This ensures that keysym
translation falls back to looking at non-shift keys (“r” can be used
instead of ”R”) and that the order of keybindings doesn’t play a role
(“bindsym n” does not override “bindsym shift+n”, even though it’s
specified earlier in the config).
The fallback behavior ensures use-cases such as ticket #1775 are still
covered.
Only binding keys when the X server is in the corresponding XKB group
ensures use-cases such as ticket #585 are still covered.
2015-08-23 22:49:32 +02:00
|
|
|
|
/**
|
|
|
|
|
* 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.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
void reorder_bindings(void);
|
|
|
|
|
|
2014-04-23 03:41:28 +02:00
|
|
|
|
/**
|
|
|
|
|
* 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.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
void check_for_duplicate_bindings(struct context *context);
|
2014-05-31 17:00:02 +02:00
|
|
|
|
|
2014-11-10 06:04:47 +01:00
|
|
|
|
/**
|
|
|
|
|
* Frees the binding. If bind is null, it simply returns.
|
|
|
|
|
*/
|
|
|
|
|
void binding_free(Binding *bind);
|
|
|
|
|
|
2014-05-31 17:00:02 +02:00
|
|
|
|
/**
|
2014-06-17 15:34:13 +02:00
|
|
|
|
* 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().
|
2014-05-31 17:00:02 +02:00
|
|
|
|
*
|
|
|
|
|
*/
|
2014-06-17 15:34:13 +02:00
|
|
|
|
CommandResult *run_binding(Binding *bind, Con *con);
|
Use libxkbcommon for translating keysyms, support all XKB groups.
fixes #1835
This commit improves the translation of keysyms to keycodes by loading
keymaps using libxkbcommon-x11 and using libxkbcommon for figuring out
the keymap, depending on each keybinding’s modifiers. This way, the
upper layers of complex layouts are now usable with i3’s bindsym
directive, such as de_neo’s layer 3 and higher.
Furthermore, the commit generalizes the handling of different XKB
groups. We formerly had support only for two separate groups, the
default group 1, and group 2. While Mode_switch is only one way to
switch to group 2, we called the binding option Mode_switch. With this
commit, the new names Group1, Group2 (an alias for Mode_switch), Group3
and Group4 are introduced for configuring bindings. This is only useful
for advanced keyboard layouts, such as people loading two keyboard
layouts and switching between them (us, ru seems to be a popular
combination).
When grabbing keys, one can only specify the modifier mask, but not an
XKB state mask (or value), so we still dynamically unbind and re-bind
keys whenever the XKB group changes.
The commit was manually tested using the following i3 config:
bindsym Group4+n nop heya from group 4
bindsym Group3+n nop heya from group 3
bindsym Group2+n nop heya from group 2
bindsym n nop heya
bindsym shift+N nop explicit shift binding
bindsym shift+r nop implicit shift binding
bindcode Group2+38 nop fallback overwritten in group 2 only
bindcode 38 nop fallback
…with the following layout:
setxkbmap -layout "us,ua,ru,de" -variant ",winkeys,,neo" \
-option "grp:shift_caps_toggle,grp_led:scroll" \
-model pc104 -rules evdev
By default (xkb group 1, us layout), pressing “n” will result in the
“heya” message appearing. Pressing “a” will result in the “fallback”
message appearing. “j” is not triggered.
By pressing Shift+CapsLock you switch to the next group (xkb group 2, ua
layout). Pressing “a” will result in the “fallback overwritten in group
2 only” message, pressing “n” will still result in “heya”. “j” is not
triggered.
In the next group (xkb group 3, ru layout), pressing “a” will result in
the “fallback” message again, pressing “n” will result in “heya”,
“j” is not triggered.
In the last group (xkb group 4, de_neo layout), pressing “a” will still
result in “fallback”, pressing “n” will result in “heya”, pressing “j”
will result in “heya from group 4”.
Pressing shift+n results in “explicit shift binding”, pressing shift+r
results in “implicit shift binding”. This ensures that keysym
translation falls back to looking at non-shift keys (“r” can be used
instead of ”R”) and that the order of keybindings doesn’t play a role
(“bindsym n” does not override “bindsym shift+n”, even though it’s
specified earlier in the config).
The fallback behavior ensures use-cases such as ticket #1775 are still
covered.
Only binding keys when the X server is in the corresponding XKB group
ensures use-cases such as ticket #585 are still covered.
2015-08-23 22:49:32 +02:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Loads the XKB keymap from the X11 server and feeds it to xkbcommon.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
bool load_keymap(void);
|
2015-11-11 20:40:25 +01:00
|
|
|
|
|
|
|
|
|
/**
|
2016-04-13 19:45:57 +02:00
|
|
|
|
* Returns a list of buttons that should be grabbed on a window.
|
|
|
|
|
* This list will always contain 1–3, all higher buttons will only be returned
|
|
|
|
|
* if there is a whole-window binding for it on some window in the current
|
|
|
|
|
* config.
|
|
|
|
|
* The list is terminated by a 0.
|
2015-11-11 20:40:25 +01:00
|
|
|
|
*/
|
2016-04-13 19:45:57 +02:00
|
|
|
|
int *bindings_get_buttons_to_grab(void);
|