diff options
| -rw-r--r-- | src/defs.h | 2 | ||||
| -rw-r--r-- | src/parser.c | 30 | ||||
| -rw-r--r-- | src/sxwm.c | 11 |
3 files changed, 34 insertions, 9 deletions
@@ -87,7 +87,7 @@ typedef struct { int snap_distance; int bindsn; Binding binds[256]; - char *should_float[256]; + char **should_float[256]; } Config; typedef struct { diff --git a/src/parser.c b/src/parser.c index 1ceb7e0..e5f7944 100644 --- a/src/parser.c +++ b/src/parser.c @@ -228,7 +228,7 @@ found: cfg->snap_distance = atoi(rest); } else if (!strcmp(key, "should_float")) { - // should_float: <window> + // should_float: binary --arg,binary2 parameter --arg,binary3 if (should_floatn >= 256) { fprintf(stderr, "sxwmrc:%d: too many should_float entries\n", lineno); @@ -237,13 +237,31 @@ found: char *win = strip(rest); - cfg->should_float[should_floatn] = malloc(strlen(win) + 1); - if (!cfg->should_float[should_floatn]) { - fprintf(stderr, "sxwmrc:%d: out of memory\n", lineno); - break; + int count = 0; + for (char *p = win; *p; p++) { + if (*p == ',') { + count++; + } + } + + cfg->should_float[should_floatn] = malloc((count + 2) * sizeof(char *)); + + // split by commas + char *comma = strtok(win, ","); + + int i = 0; + + while (comma) { + if (should_floatn < 256) { + cfg->should_float[should_floatn][i] = strdup(comma); + i++; + } else { + fprintf(stderr, "sxwmrc:%d: too many should_float entries\n", lineno); + break; + } + comma = strtok(NULL, ","); } - strcpy(cfg->should_float[should_floatn], win); should_floatn++; } else if (!strcmp(key, "call") || !strcmp(key, "bind")) { @@ -591,8 +591,15 @@ void hdl_keypress(XEvent *xev) switch (b->type) { case TYPE_CMD: spawn(b->action.cmd); - for (int j = 0; j < 256; j++) { - if (user_config.should_float[j] && !strcmp(user_config.should_float[j], b->action.cmd[0])) { + for (int j = 0; j < 256; j++) { + Bool valid = False; + for (int k = 0; user_config.should_float[j] && user_config.should_float[j][k] && b->action.cmd[k]; k++) { + if (!strcmp(b->action.cmd[k], user_config.should_float[j][k])) { + valid = True; + break; + } + } + if (valid) { next_should_float = True; break; } |
