From ca862a5bd45ef094d0f0de5a0765224524b74c48 Mon Sep 17 00:00:00 2001 From: "S. Christoffer Eliesen" Date: Wed, 21 Oct 2015 16:34:12 +0200 Subject: config: Apply output config also during config reload. --- sway/config.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'sway/config.c') diff --git a/sway/config.c b/sway/config.c index 46a26424..b5d442c5 100644 --- a/sway/config.c +++ b/sway/config.c @@ -283,6 +283,35 @@ bool read_config(FILE *file, bool is_active) { return success; } +void apply_output_config(struct output_config *oc, swayc_t *output) { + if (oc && oc->width != -1 && oc->height != -1) { + output->width = oc->width; + output->height = oc->height; + + sway_log(L_DEBUG, "Set %s size to %ix%i", oc->name, oc->width, oc->height); + struct wlc_size new_size = { .w = oc->width, .h = oc->height }; + wlc_output_set_resolution(output->handle, &new_size); + } + + // Find position for it + if (oc && oc->x != -1 && oc->y != -1) { + sway_log(L_DEBUG, "Set %s position to %d, %d", oc->name, oc->x, oc->y); + output->x = oc->x; + output->y = oc->y; + } else { + int x = 0; + for (int i = 0; i < root_container.children->length; ++i) { + swayc_t *c = root_container.children->items[i]; + if (c->type == C_OUTPUT) { + if (c->width + c->x > x) { + x = c->width + c->x; + } + } + } + output->x = x; + } +} + char *do_var_replacement(char *str) { int i; char *find = str; -- cgit v1.2.3 From 4fea92ef0ce38661156e8605211b5a7fa9550745 Mon Sep 17 00:00:00 2001 From: "S. Christoffer Eliesen" Date: Wed, 21 Oct 2015 23:59:01 +0200 Subject: config: Don't try to apply bad output resolution. --- sway/config.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sway/config.c') diff --git a/sway/config.c b/sway/config.c index b5d442c5..bce074b9 100644 --- a/sway/config.c +++ b/sway/config.c @@ -284,7 +284,7 @@ bool read_config(FILE *file, bool is_active) { } void apply_output_config(struct output_config *oc, swayc_t *output) { - if (oc && oc->width != -1 && oc->height != -1) { + if (oc && oc->width > 0 && oc->height > 0) { output->width = oc->width; output->height = oc->height; -- cgit v1.2.3