Pressed modifiers are determined like in click.c:handle_button_press.
Fixes #3234.
} tray_output_t;
typedef struct config_t {
- int modifier;
+ uint32_t modifier;
TAILQ_HEAD(bindings_head, binding_t)
bindings;
return 1;
}
+ /* Kept for backwards compatibility. */
if (!strcmp(cur_key, "modifier")) {
DLOG("modifier = %.*s\n", len, val);
if (len == strlen("none") && !strncmp((const char *)val, "none", strlen("none"))) {
return 1;
}
+ if (!strcmp(cur_key, "modifier")) {
+ DLOG("modifier = %lld\n", val);
+ config.modifier = (uint32_t)val;
+ return 1;
+ }
+
return 0;
}
/* These are only relevant for XKB, which we only need for grabbing modifiers */
int xkb_base;
-int mod_pressed = 0;
+bool mod_pressed = 0;
/* Event watchers, to interact with the user */
ev_prepare *xcb_prep;
DLOG("received an xkb event\n");
xcb_xkb_state_notify_event_t *state = (xcb_xkb_state_notify_event_t *)event;
+ const uint32_t mod = (config.modifier & 0xFFFF);
+ mod_pressed = (mod != 0 && (state->mods & mod) == mod);
if (state->xkbType == XCB_XKB_STATE_NOTIFY && config.modifier != XCB_NONE) {
- int modstate = state->mods & config.modifier;
-
-#define DLOGMOD(modmask, status) \
- do { \
- switch (modmask) { \
- case ShiftMask: \
- DLOG("ShiftMask got " #status "!\n"); \
- break; \
- case ControlMask: \
- DLOG("ControlMask got " #status "!\n"); \
- break; \
- case Mod1Mask: \
- DLOG("Mod1Mask got " #status "!\n"); \
- break; \
- case Mod2Mask: \
- DLOG("Mod2Mask got " #status "!\n"); \
- break; \
- case Mod3Mask: \
- DLOG("Mod3Mask got " #status "!\n"); \
- break; \
- case Mod4Mask: \
- DLOG("Mod4Mask got " #status "!\n"); \
- break; \
- case Mod5Mask: \
- DLOG("Mod5Mask got " #status "!\n"); \
- break; \
- } \
- } while (0)
-
- if (modstate != mod_pressed) {
- if (modstate == 0) {
- DLOGMOD(config.modifier, released);
- if (!activated_mode)
- hide_bars();
- } else {
- DLOGMOD(config.modifier, pressed);
- activated_mode = false;
- unhide_bars();
- }
- mod_pressed = modstate;
+ if (mod_pressed) {
+ activated_mode = false;
+ unhide_bars();
+ } else if (!activated_mode) {
+ hide_bars();
}
-#undef DLOGMOD
}
free(event);
CFGFUN(bar_id, const char *bar_id);
CFGFUN(bar_output, const char *output);
CFGFUN(bar_verbose, const char *verbose);
-CFGFUN(bar_modifier, const char *modifier);
+CFGFUN(bar_modifier, const char *modifiers);
CFGFUN(bar_wheel_up_cmd, const char *command);
CFGFUN(bar_wheel_down_cmd, const char *command);
CFGFUN(bar_bindsym, const char *button, const char *release, const char *command);
S_SHOW = 1 } hidden_state;
/** Bar modifier (to show bar when in hide mode). */
- enum {
- M_NONE = 0,
- M_CONTROL = 1,
- M_SHIFT = 2,
- M_MOD1 = 3,
- M_MOD2 = 4,
- M_MOD3 = 5,
- M_MOD4 = 6,
- M_MOD5 = 7
- } modifier;
+ uint32_t modifier;
TAILQ_HEAD(bar_bindings_head, Barbinding)
bar_bindings;
-> call cfg_bar_id($bar_id); BAR
state BAR_MODIFIER:
- modifier = 'Mod1', 'Mod2', 'Mod3', 'Mod4', 'Mod5', 'Control', 'Ctrl', 'Shift', 'none', 'off'
- -> call cfg_bar_modifier($modifier); BAR
+ 'off', 'none'
+ -> call cfg_bar_modifier(NULL); BAR
+ modifiers = 'Mod1', 'Mod2', 'Mod3', 'Mod4', 'Mod5', 'Shift', 'Control', 'Ctrl'
+ ->
+ '+'
+ ->
+ end
+ -> call cfg_bar_modifier($modifiers); BAR
state BAR_WHEEL_UP_CMD:
command = string
current_bar->verbose = eval_boolstr(verbose);
}
-CFGFUN(bar_modifier, const char *modifier) {
- if (strcmp(modifier, "Mod1") == 0)
- current_bar->modifier = M_MOD1;
- else if (strcmp(modifier, "Mod2") == 0)
- current_bar->modifier = M_MOD2;
- else if (strcmp(modifier, "Mod3") == 0)
- current_bar->modifier = M_MOD3;
- else if (strcmp(modifier, "Mod4") == 0)
- current_bar->modifier = M_MOD4;
- else if (strcmp(modifier, "Mod5") == 0)
- current_bar->modifier = M_MOD5;
- else if (strcmp(modifier, "Control") == 0 ||
- strcmp(modifier, "Ctrl") == 0)
- 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;
+CFGFUN(bar_modifier, const char *modifiers) {
+ current_bar->modifier = modifiers ? event_state_from_str(modifiers) : XCB_NONE;
}
static void bar_configure_binding(const char *button, const char *release, const char *command) {
TAILQ_INIT(&(current_bar->bar_bindings));
TAILQ_INIT(&(current_bar->tray_outputs));
current_bar->tray_padding = 2;
- current_bar->modifier = M_MOD4;
+ current_bar->modifier = XCB_KEY_BUT_MASK_MOD_4;
}
CFGFUN(bar_finish) {
}
ystr("modifier");
- switch (config->modifier) {
- case M_NONE:
- ystr("none");
- break;
- case M_CONTROL:
- ystr("ctrl");
- break;
- case M_SHIFT:
- ystr("shift");
- break;
- case M_MOD1:
- ystr("Mod1");
- break;
- case M_MOD2:
- ystr("Mod2");
- break;
- case M_MOD3:
- ystr("Mod3");
- break;
- case M_MOD5:
- ystr("Mod5");
- break;
- default:
- ystr("Mod4");
- break;
- }
+ y(integer, config->modifier);
dump_bar_bindings(gen, config);