alternate = true;
(*args)++;
}
- if (parse_client_state(*args, &cst)) {
- if (alternate && trg.node != NULL && trg.node->client != NULL &&
- trg.node->client->state == cst) {
+ if (alternate && (*args)[0] == '\0') {
+ if (trg.node != NULL && trg.node->client != NULL) {
cst = trg.node->client->last_state;
- }
- if (!set_state(trg.monitor, trg.desktop, trg.node, cst)) {
+ } else {
fail(rsp, "");
break;
}
- changed = true;
+ } else if (parse_client_state(*args, &cst)) {
+ if (alternate && trg.node != NULL && trg.node->client != NULL &&
+ trg.node->client->state == cst) {
+ cst = trg.node->client->last_state;
+ }
} else {
fail(rsp, "node %s: Invalid argument: '%s'.\n", *(args - 1), *args);
break;
}
+ if (!set_state(trg.monitor, trg.desktop, trg.node, cst)) {
+ fail(rsp, "");
+ break;
+ }
+ changed = true;
} else if (streq("-g", *args) || streq("--flag", *args)) {
num--, args++;
if (num < 1) {
fail(rsp, "node %s: Invalid resize handle argument: '%s'.\n", *(args - 1), *args);
break;
}
+ } else if (streq("-y", *args) || streq("--type", *args)) {
+ num--, args++;
+ if (num < 1) {
+ fail(rsp, "node %s: Not enough arguments.\n", *(args - 1));
+ break;
+ }
+ if (trg.node == NULL) {
+ fail(rsp, "");
+ break;
+ }
+ split_type_t typ;
+ if (parse_split_type(*args, &typ)) {
+ set_type(trg.node, typ);
+ changed = true;
+ } else {
+ fail(rsp, "");
+ break;
+ }
} else if (streq("-r", *args) || streq("--ratio", *args)) {
num--, args++;
if (num < 1) {
layout_t lyt;
cycle_dir_t cyc;
if (parse_cycle_direction(*args, &cyc)) {
- ret = set_layout(trg.monitor, trg.desktop, (trg.desktop->layout + 1) % 2);
+ ret = set_layout(trg.monitor, trg.desktop, (trg.desktop->user_layout + 1) % 2, true);
} else if (parse_layout(*args, &lyt)) {
- ret = set_layout(trg.monitor, trg.desktop, lyt);
+ ret = set_layout(trg.monitor, trg.desktop, lyt, true);
} else {
fail(rsp, "desktop %s: Invalid argument: '%s'.\n", *(args - 1), *args);
break;
void cmd_query(char **args, int num, FILE *rsp)
{
- coordinates_t ref = {mon, mon->desk, mon->desk->focus};
+ coordinates_t monitor_ref = {mon, NULL, NULL};
+ coordinates_t desktop_ref = {mon, mon->desk, NULL};
+ coordinates_t node_ref = {mon, mon->desk, mon->desk->focus};
coordinates_t trg = {NULL, NULL, NULL};
monitor_select_t *monitor_sel = NULL;
desktop_select_t *desktop_sel = NULL;
if (num > 1 && *(args + 1)[0] != OPT_CHR) {
num--, args++;
int ret;
- coordinates_t tmp = ref;
- if ((ret = monitor_from_desc(*args, &tmp, &ref)) != SELECTOR_OK) {
+ coordinates_t tmp = monitor_ref;
+ monitor_ref.desktop = NULL;
+ monitor_ref.node = NULL;
+ if ((ret = monitor_from_desc(*args, &tmp, &monitor_ref)) != SELECTOR_OK) {
handle_failure(ret, "query -M", *args, rsp);
goto end;
}
if (num > 1 && *(args + 1)[0] != OPT_CHR) {
num--, args++;
int ret;
- coordinates_t tmp = ref;
- if ((ret = desktop_from_desc(*args, &tmp, &ref)) != SELECTOR_OK) {
+ coordinates_t tmp = desktop_ref;
+ desktop_ref.node = NULL;
+ if ((ret = desktop_from_desc(*args, &tmp, &desktop_ref)) != SELECTOR_OK) {
handle_failure(ret, "query -D", *args, rsp);
goto end;
}
if (num > 1 && *(args + 1)[0] != OPT_CHR) {
num--, args++;
int ret;
- coordinates_t tmp = ref;
- if ((ret = node_from_desc(*args, &tmp, &ref)) != SELECTOR_OK) {
+ coordinates_t tmp = node_ref;
+ if ((ret = node_from_desc(*args, &tmp, &node_ref)) != SELECTOR_OK) {
handle_failure(ret, "query -N", *args, rsp);
goto end;
}
goto end;
}
free(desc);
- } else if ((ret = monitor_from_desc(*args, &ref, &trg)) != SELECTOR_OK) {
+ } else if ((ret = monitor_from_desc(*args, &monitor_ref, &trg)) != SELECTOR_OK) {
handle_failure(ret, "query -m", *args, rsp);
goto end;
}
} else {
- trg.monitor = ref.monitor;
+ trg = monitor_ref;
}
} else if (streq("-d", *args) || streq("--desktop", *args)) {
if (num > 1 && *(args + 1)[0] != OPT_CHR) {
goto end;
}
free(desc);
- } else if ((ret = desktop_from_desc(*args, &ref, &trg)) != SELECTOR_OK) {
+ } else if ((ret = desktop_from_desc(*args, &desktop_ref, &trg)) != SELECTOR_OK) {
handle_failure(ret, "query -d", *args, rsp);
goto end;
}
} else {
- trg.monitor = ref.monitor;
- trg.desktop = ref.desktop;
+ trg = desktop_ref;
}
} else if (streq("-n", *args) || streq("--node", *args)) {
if (num > 1 && *(args + 1)[0] != OPT_CHR) {
goto end;
}
free(desc);
- } else if ((ret = node_from_desc(*args, &ref, &trg)) != SELECTOR_OK) {
+ } else if ((ret = node_from_desc(*args, &node_ref, &trg)) != SELECTOR_OK) {
handle_failure(ret, "query -n", *args, rsp);
goto end;
}
} else {
- trg = ref;
- if (ref.node == NULL) {
+ trg = node_ref;
+ if (trg.node == NULL) {
fail(rsp, "");
goto end;
}
goto end;
}
+ if ((dom == DOMAIN_MONITOR && (desktop_sel != NULL || node_sel != NULL)) ||
+ (dom == DOMAIN_DESKTOP && node_sel != NULL)) {
+ fail(rsp, "query -%c: Incompatible descriptor-free constraints.\n", dom == DOMAIN_MONITOR ? 'M' : 'D');
+ goto end;
+ }
+
if (dom == DOMAIN_NODE) {
- if (query_node_ids(&ref, &trg, node_sel, rsp) < 1) {
+ if (query_node_ids(&monitor_ref, &desktop_ref, &node_ref, &trg, monitor_sel, desktop_sel, node_sel, rsp) < 1) {
fail(rsp, "");
}
} else if (dom == DOMAIN_DESKTOP) {
- if (query_desktop_ids(&ref, &trg, desktop_sel, print_ids ? fprint_desktop_id : fprint_desktop_name, rsp) < 1) {
+ if (query_desktop_ids(&monitor_ref, &desktop_ref, &trg, monitor_sel, desktop_sel, print_ids ? fprint_desktop_id : fprint_desktop_name, rsp) < 1) {
fail(rsp, "");
}
} else if (dom == DOMAIN_MONITOR) {
- if (query_monitor_ids(&ref, &trg, monitor_sel, print_ids ? fprint_monitor_id : fprint_monitor_name, rsp) < 1) {
+ if (query_monitor_ids(&monitor_ref, &trg, monitor_sel, print_ids ? fprint_monitor_id : fprint_monitor_name, rsp) < 1) {
fail(rsp, "");
}
} else {
rule_t *rule = make_rule();
char *class_name = strtok(*args, COL_TOK);
char *instance_name = strtok(NULL, COL_TOK);
+ char *name = strtok(NULL, COL_TOK);
snprintf(rule->class_name, sizeof(rule->class_name), "%s", class_name);
snprintf(rule->instance_name, sizeof(rule->instance_name), "%s", instance_name==NULL?MATCH_ANY:instance_name);
+ snprintf(rule->name, sizeof(rule->name), "%s", name==NULL?MATCH_ANY:name);
num--, args++;
size_t i = 0;
while (num > 0) {
while (num > 0) {
if (streq("-d", *args) || streq("--dump-state", *args)) {
- query_tree(rsp);
+ query_state(rsp);
fprintf(rsp, "\n");
} else if (streq("-l", *args) || streq("--load-state", *args)) {
num--, args++;
fail(rsp, "wm %s: Not enough arguments.\n", *(args - 1));
break;
}
- if (!restore_tree(*args)) {
+ if (!restore_state(*args)) {
fail(rsp, "");
break;
}
fail(rsp, "wm %s: Invalid argument: '%s'.\n", *(args - 1), *args);
break;
}
+ } else if (streq("-r", *args) || streq("--restart", *args)) {
+ running = false;
+ restart = true;
+ break;
} else {
fail(rsp, "wm: Unknown command: '%s'.\n", *args);
break;
}
}
- add_subscriber(stream, fifo_path, field, count);
+ subscriber_list_t *sb = make_subscriber(stream, fifo_path, field, count);
+ add_subscriber(sb);
return;
failed:
}
SET_DEF_MON_DESK(padding.left, lp)
#undef SET_DEF_MON_DESK
+ } else if (streq("top_monocle_padding", name)) {
+ if (sscanf(value, "%i", &monocle_padding.top) != 1) {
+ fail(rsp, "config: %s: Invalid value: '%s'.\n", name, value);
+ }
+ } else if (streq("right_monocle_padding", name)) {
+ if (sscanf(value, "%i", &monocle_padding.right) != 1) {
+ fail(rsp, "config: %s: Invalid value: '%s'.\n", name, value);
+ }
+ } else if (streq("bottom_monocle_padding", name)) {
+ if (sscanf(value, "%i", &monocle_padding.bottom) != 1) {
+ fail(rsp, "config: %s: Invalid value: '%s'.\n", name, value);
+ }
+ } else if (streq("left_monocle_padding", name)) {
+ if (sscanf(value, "%i", &monocle_padding.left) != 1) {
+ fail(rsp, "config: %s: Invalid value: '%s'.\n", name, value);
+ }
#define SET_STR(s) \
} else if (streq(#s, name)) { \
if (snprintf(s, sizeof(s), "%s", value) < 0) { \
fail(rsp, "config: %s: Invalid value: '%s'.\n", name, value);
return;
}
+ } else if (streq("automatic_scheme", name)) {
+ automatic_scheme_t a;
+ if (parse_automatic_scheme(value, &a)) {
+ automatic_scheme = a;
+ } else {
+ fail(rsp, "config: %s: Invalid value: '%s'.\n", name, value);
+ return;
+ }
} else if (streq("mapping_events_count", name)) {
if (sscanf(value, "%" SCNi8, &mapping_events_count) != 1) {
fail(rsp, "config: %s: Invalid value: '%s'.\n", name, value);
fail(rsp, "config: %s: Invalid value: '%s'.\n", name, value);
return;
}
+ } else if (streq("single_monocle", name)) {
+ bool b;
+ if (parse_bool(value, &b)) {
+ if (b == single_monocle) {
+ fail(rsp, "");
+ return;
+ }
+ single_monocle = b;
+ for (monitor_t *m = mon_head; m != NULL; m = m->next) {
+ for (desktop_t *d = m->desk_head; d != NULL; d = d->next) {
+ layout_t l = (single_monocle && tiled_count(d->root, true) <= 1) ? LAYOUT_MONOCLE : d->user_layout;
+ set_layout(m, d, l, false);
+ }
+ }
+ } else {
+ fail(rsp, "config: %s: Invalid value: '%s'.\n", name, value);
+ return;
+ }
} else if (streq("focus_follows_pointer", name)) {
bool b;
if (parse_bool(value, &b)) {
fail(rsp, "config: %s: Invalid value: '%s'.\n", name, value); \
return; \
}
+ SET_BOOL(presel_feedback)
SET_BOOL(borderless_monocle)
SET_BOOL(gapless_monocle)
- SET_BOOL(paddingless_monocle)
- SET_BOOL(single_monocle)
+ SET_BOOL(borderless_singleton)
SET_BOOL(swallow_first_click)
SET_BOOL(pointer_follows_focus)
SET_BOOL(pointer_follows_monitor)
SET_BOOL(ignore_ewmh_focus)
+ SET_BOOL(ignore_ewmh_struts)
SET_BOOL(center_pseudo_tiled)
SET_BOOL(honor_size_hints)
- SET_BOOL(cancel_birth_rotation)
+ SET_BOOL(removal_adjustment)
#undef SET_BOOL
#define SET_MON_BOOL(s) \
} else if (streq(#s, name)) { \
} else if (streq("left_padding", name)) {
GET_DEF_MON_DESK(padding.left)
#undef GET_DEF_MON_DESK
+ } else if (streq("top_monocle_padding", name)) {
+ fprintf(rsp, "%i", monocle_padding.top);
+ } else if (streq("right_monocle_padding", name)) {
+ fprintf(rsp, "%i", monocle_padding.right);
+ } else if (streq("bottom_monocle_padding", name)) {
+ fprintf(rsp, "%i", monocle_padding.bottom);
+ } else if (streq("left_monocle_padding", name)) {
+ fprintf(rsp, "%i", monocle_padding.left);
} else if (streq("external_rules_command", name)) {
fprintf(rsp, "%s", external_rules_command);
} else if (streq("status_prefix", name)) {
fprintf(rsp, "%s", status_prefix);
} else if (streq("initial_polarity", name)) {
fprintf(rsp, "%s", CHILD_POL_STR(initial_polarity));
+ } else if (streq("automatic_scheme", name)) {
+ fprintf(rsp, "%s", AUTO_SCM_STR(automatic_scheme));
} else if (streq("mapping_events_count", name)) {
fprintf(rsp, "%" PRIi8, mapping_events_count);
} else if (streq("directional_focus_tightness", name)) {
#define GET_BOOL(s) \
} else if (streq(#s, name)) { \
fprintf(rsp, "%s", BOOL_STR(s));
+ GET_BOOL(presel_feedback)
GET_BOOL(borderless_monocle)
GET_BOOL(gapless_monocle)
- GET_BOOL(paddingless_monocle)
GET_BOOL(single_monocle)
+ GET_BOOL(borderless_singleton)
GET_BOOL(swallow_first_click)
GET_BOOL(focus_follows_pointer)
GET_BOOL(pointer_follows_focus)
GET_BOOL(pointer_follows_monitor)
GET_BOOL(ignore_ewmh_focus)
+ GET_BOOL(ignore_ewmh_struts)
GET_BOOL(center_pseudo_tiled)
GET_BOOL(honor_size_hints)
- GET_BOOL(cancel_birth_rotation)
+ GET_BOOL(removal_adjustment)
GET_BOOL(remove_disabled_monitors)
GET_BOOL(remove_unplugged_monitors)
GET_BOOL(merge_overlapping_monitors)