Add '--release' flag for bindsym in the bar block

i3bar's handle_button is modified to also handle XCB_BUTTON_RELEASE
events. During these button release events, only custom commands are
checked to avoid sending multiple workspace ipc messages.

The way this patch is implemented will allow to assign a custom command
for both the press and release of the same button:
bar {
  ...
  bindsym buttonX exec command1
  bindsym --release buttonX exec command2
}

Fixes #3068.
This commit is contained in:
Orestis Floros
2017-12-08 02:23:15 +02:00
parent ee0c016091
commit 315ff17563
10 changed files with 104 additions and 18 deletions

View File

@ -264,6 +264,21 @@ static int config_string_cb(void *params_, const unsigned char *val, size_t _len
*
*/
static int config_boolean_cb(void *params_, int val) {
if (parsing_bindings) {
if (strcmp(cur_key, "release") == 0) {
binding_t *binding = TAILQ_LAST(&(config.bindings), bindings_head);
if (binding == NULL) {
ELOG("There is no binding to put the current command onto. This is a bug in i3.\n");
return 0;
}
binding->release = val;
return 1;
}
ELOG("Unknown key \"%s\" while parsing bar bindings.\n", cur_key);
}
if (!strcmp(cur_key, "binding_mode_indicator")) {
DLOG("binding_mode_indicator = %d\n", val);
config.disable_binding_mode_indicator = !val;