void apply_output_config(struct output_config *oc, swayc_t *output) { if (oc && oc->width > 0 && oc->height > 0) { 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; } if (oc && oc->background) { int i; for (i = 0; i < root_container.children->length; ++i) { if (root_container.children->items[i] == output) { break; } } sway_log(L_DEBUG, "Setting background for output %d to %s", i, oc->background); size_t bufsize = 4; char output_id[bufsize]; snprintf(output_id, bufsize, "%d", i); output_id[bufsize-1] = 0; char *const cmd[] = { "swaybg", output_id, oc->background, oc->background_option, NULL, }; if (fork() == 0) { execvp(cmd[0], cmd); } } }
void apply_output_config(struct output_config *oc, swayc_t *output) { if (oc && oc->enabled == 0) { destroy_output(output); return; } if (oc && oc->width > 0 && oc->height > 0) { output->width = oc->width; output->height = oc->height; sway_log(L_DEBUG, "Set %s size to %ix%i (%d)", oc->name, oc->width, oc->height, oc->scale); struct wlc_size new_size = { .w = oc->width, .h = oc->height }; wlc_output_set_resolution(output->handle, &new_size, (uint32_t)oc->scale); } else if (oc && oc->scale != 1) {