Allow different modifier keys for showing hidden i3bar.

This commit is contained in:
dbp
2011-12-11 21:58:57 -08:00
committed by Michael Stapelberg
parent f88c779457
commit a3081c488a
7 changed files with 152 additions and 7 deletions

View File

@ -15,6 +15,8 @@
#include <yajl/yajl_parse.h>
#include <yajl/yajl_version.h>
#include <X11/Xlib.h>
#include "common.h"
static char *cur_key;
@ -75,6 +77,41 @@ static int config_string_cb(void *params_, const unsigned char *val, unsigned in
return 1;
}
if (!strcmp(cur_key, "modifier")) {
DLOG("modifier = %.*s\n", len, val);
if (len == 5 && !strncmp((const char*)val, "shift", strlen("shift"))) {
config.modifier = ShiftMask;
return 1;
}
if (len == 4 && !strncmp((const char*)val, "ctrl", strlen("ctrl"))) {
config.modifier = ControlMask;
return 1;
}
if (len == 4 && !strncmp((const char*)val, "Mod", strlen("Mod"))) {
switch (val[3]) {
case '1':
config.modifier = Mod1Mask;
return 1;
case '2':
config.modifier = Mod2Mask;
return 1;
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;
}
if (!strcmp(cur_key, "position")) {
DLOG("position = %.*s\n", len, val);
config.position = (len == 3 && !strncmp((const char*)val, "top", strlen("top")) ? POS_TOP : POS_BOT);

View File

@ -684,19 +684,47 @@ void xkb_io_cb(struct ev_loop *loop, ev_io *watcher, int revents) {
}
unsigned int mods = ev.state.mods;
modstate = mods & Mod4Mask;
modstate = mods & config.modifier;
}
#define DLOGMOD(modmask, status, barfunc) \
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; \
} \
barfunc(); \
} while (0)
if (modstate != mod_pressed) {
if (modstate == 0) {
DLOG("Mod4 got released!\n");
hide_bars();
DLOGMOD(config.modifier, released, hide_bars);
} else {
DLOG("Mod4 got pressed!\n");
unhide_bars();
DLOGMOD(config.modifier, pressed, unhide_bars);
}
mod_pressed = modstate;
}
#undef DLOGMOD
}
/*