Merge pull request #2209 from Airblader/feature-2208

Allow "modifier none" in i3bar to disable the modifier.
This commit is contained in:
Michael Stapelberg 2016-02-15 08:14:26 +01:00
commit d6aece03ee
6 changed files with 18 additions and 14 deletions

View File

@ -1238,7 +1238,7 @@ the windows key). The default value for the hidden_state is hide.
-------------------------
mode dock|hide|invisible
hidden_state hide|show
modifier <Modifier>
modifier <Modifier>|none
------------------------
*Example*:
@ -1250,7 +1250,8 @@ bar {
}
----------------
Available modifiers are Mod1-Mod5, Shift, Control (see +xmodmap(1)+).
Available modifiers are Mod1-Mod5, Shift, Control (see +xmodmap(1)+). You can
also use "none" if you don't want any modifier to trigger this behavior.
=== Mouse button commands

View File

@ -121,6 +121,11 @@ static int config_string_cb(void *params_, const unsigned char *val, size_t _len
if (!strcmp(cur_key, "modifier")) {
DLOG("modifier = %.*s\n", len, val);
if (len == 4 && !strncmp((const char *)val, "none", strlen("none"))) {
config.modifier = XCB_NONE;
return 1;
}
if (len == 5 && !strncmp((const char *)val, "shift", strlen("shift"))) {
config.modifier = ShiftMask;
return 1;
@ -140,16 +145,12 @@ static int config_string_cb(void *params_, const unsigned char *val, size_t _len
case '3':
config.modifier = Mod3Mask;
return 1;
/*
case '4':
config.modifier = Mod4Mask;
return 1;
*/
case '5':
config.modifier = Mod5Mask;
return 1;
}
}
config.modifier = Mod4Mask;
return 1;
}

View File

@ -1094,7 +1094,7 @@ void xcb_chk_cb(struct ev_loop *loop, ev_check *watcher, int revents) {
DLOG("received an xkb event\n");
xcb_xkb_state_notify_event_t *state = (xcb_xkb_state_notify_event_t *)event;
if (state->xkbType == XCB_XKB_STATE_NOTIFY) {
if (state->xkbType == XCB_XKB_STATE_NOTIFY && config.modifier != XCB_NONE) {
int modstate = state->mods & config.modifier;
#define DLOGMOD(modmask, status) \

View File

@ -453,7 +453,7 @@ state BAR_ID:
-> call cfg_bar_id($bar_id); BAR
state BAR_MODIFIER:
modifier = 'Mod1', 'Mod2', 'Mod3', 'Mod4', 'Mod5', 'Control', 'Ctrl', 'Shift'
modifier = 'Mod1', 'Mod2', 'Mod3', 'Mod4', 'Mod5', 'Control', 'Ctrl', 'Shift', 'none', 'off'
-> call cfg_bar_modifier($modifier); BAR
state BAR_WHEEL_UP_CMD:

View File

@ -446,6 +446,9 @@ CFGFUN(bar_modifier, const char *modifier) {
current_bar->modifier = M_CONTROL;
else if (strcmp(modifier, "Shift") == 0)
current_bar->modifier = M_SHIFT;
else if (strcmp(modifier, "none") == 0 ||
strcmp(modifier, "off") == 0)
current_bar->modifier = M_NONE;
}
static void bar_configure_binding(const char *button, const char *command) {
@ -575,6 +578,7 @@ CFGFUN(bar_start) {
TAILQ_INIT(&(current_bar->bar_bindings));
TAILQ_INIT(&(current_bar->tray_outputs));
current_bar->tray_padding = 2;
current_bar->modifier = M_MOD4;
}
CFGFUN(bar_finish) {

View File

@ -611,6 +611,9 @@ static void dump_bar_config(yajl_gen gen, Barconfig *config) {
ystr("modifier");
switch (config->modifier) {
case M_NONE:
ystr("none");
break;
case M_CONTROL:
ystr("ctrl");
break;
@ -626,11 +629,6 @@ static void dump_bar_config(yajl_gen gen, Barconfig *config) {
case M_MOD3:
ystr("Mod3");
break;
/*
case M_MOD4:
ystr("Mod4");
break;
*/
case M_MOD5:
ystr("Mod5");
break;