diff options
-rw-r--r-- | include/sway/config.h | 2 | ||||
-rw-r--r-- | include/sway/output.h | 2 | ||||
-rw-r--r-- | sway/config/output.c | 6 | ||||
-rw-r--r-- | sway/desktop/output.c | 4 | ||||
-rw-r--r-- | sway/tree/output.c | 30 |
5 files changed, 10 insertions, 34 deletions
diff --git a/include/sway/config.h b/include/sway/config.h index 46ca7cee..7c544541 100644 --- a/include/sway/config.h +++ b/include/sway/config.h | |||
@@ -585,6 +585,8 @@ bool apply_output_config(struct output_config *oc, struct sway_output *output); | |||
585 | 585 | ||
586 | struct output_config *store_output_config(struct output_config *oc); | 586 | struct output_config *store_output_config(struct output_config *oc); |
587 | 587 | ||
588 | struct output_config *find_output_config(struct sway_output *output); | ||
589 | |||
588 | void apply_output_config_to_outputs(struct output_config *oc); | 590 | void apply_output_config_to_outputs(struct output_config *oc); |
589 | 591 | ||
590 | void reset_outputs(void); | 592 | void reset_outputs(void); |
diff --git a/include/sway/output.h b/include/sway/output.h index 32ed1e28..8015f211 100644 --- a/include/sway/output.h +++ b/include/sway/output.h | |||
@@ -88,8 +88,6 @@ struct sway_output *output_by_name_or_id(const char *name_or_id); | |||
88 | 88 | ||
89 | void output_sort_workspaces(struct sway_output *output); | 89 | void output_sort_workspaces(struct sway_output *output); |
90 | 90 | ||
91 | struct output_config *output_find_config(struct sway_output *output); | ||
92 | |||
93 | void output_enable(struct sway_output *output, struct output_config *oc); | 91 | void output_enable(struct sway_output *output, struct output_config *oc); |
94 | 92 | ||
95 | void output_disable(struct sway_output *output); | 93 | void output_disable(struct sway_output *output); |
diff --git a/sway/config/output.c b/sway/config/output.c index 1f55fd6a..a20c5ad4 100644 --- a/sway/config/output.c +++ b/sway/config/output.c | |||
@@ -438,6 +438,12 @@ static struct output_config *get_output_config(char *identifier, | |||
438 | return result; | 438 | return result; |
439 | } | 439 | } |
440 | 440 | ||
441 | struct output_config *find_output_config(struct sway_output *output) { | ||
442 | char id[128]; | ||
443 | output_get_identifier(id, sizeof(id), output); | ||
444 | return get_output_config(id, output); | ||
445 | } | ||
446 | |||
441 | void apply_output_config_to_outputs(struct output_config *oc) { | 447 | void apply_output_config_to_outputs(struct output_config *oc) { |
442 | // Try to find the output container and apply configuration now. If | 448 | // Try to find the output container and apply configuration now. If |
443 | // this is during startup then there will be no container and config | 449 | // this is during startup then there will be no container and config |
diff --git a/sway/desktop/output.c b/sway/desktop/output.c index 1d9abbfd..9d0c0ef5 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c | |||
@@ -533,7 +533,7 @@ static void handle_destroy(struct wl_listener *listener, void *data) { | |||
533 | static void handle_mode(struct wl_listener *listener, void *data) { | 533 | static void handle_mode(struct wl_listener *listener, void *data) { |
534 | struct sway_output *output = wl_container_of(listener, output, mode); | 534 | struct sway_output *output = wl_container_of(listener, output, mode); |
535 | if (!output->configured && !output->enabled) { | 535 | if (!output->configured && !output->enabled) { |
536 | struct output_config *oc = output_find_config(output); | 536 | struct output_config *oc = find_output_config(output); |
537 | if (output->wlr_output->current_mode != NULL && | 537 | if (output->wlr_output->current_mode != NULL && |
538 | (!oc || oc->enabled)) { | 538 | (!oc || oc->enabled)) { |
539 | // We want to enable this output, but it didn't work last time, | 539 | // We want to enable this output, but it didn't work last time, |
@@ -634,7 +634,7 @@ void handle_new_output(struct wl_listener *listener, void *data) { | |||
634 | output->damage_destroy.notify = damage_handle_destroy; | 634 | output->damage_destroy.notify = damage_handle_destroy; |
635 | wl_list_init(&output->swaybg_client_destroy.link); | 635 | wl_list_init(&output->swaybg_client_destroy.link); |
636 | 636 | ||
637 | struct output_config *oc = output_find_config(output); | 637 | struct output_config *oc = find_output_config(output); |
638 | if (!oc || oc->enabled) { | 638 | if (!oc || oc->enabled) { |
639 | output_enable(output, oc); | 639 | output_enable(output, oc); |
640 | } else { | 640 | } else { |
diff --git a/sway/tree/output.c b/sway/tree/output.c index 227d487c..1202ba3c 100644 --- a/sway/tree/output.c +++ b/sway/tree/output.c | |||
@@ -267,36 +267,6 @@ void output_begin_destroy(struct sway_output *output) { | |||
267 | output->wlr_output = NULL; | 267 | output->wlr_output = NULL; |
268 | } | 268 | } |
269 | 269 | ||
270 | struct output_config *output_find_config(struct sway_output *output) { | ||
271 | const char *name = output->wlr_output->name; | ||
272 | char identifier[128]; | ||
273 | output_get_identifier(identifier, sizeof(identifier), output); | ||
274 | |||
275 | struct output_config *oc = NULL, *all = NULL; | ||
276 | for (int i = 0; i < config->output_configs->length; ++i) { | ||
277 | struct output_config *cur = config->output_configs->items[i]; | ||
278 | |||
279 | if (strcasecmp(name, cur->name) == 0 || | ||
280 | strcasecmp(identifier, cur->name) == 0) { | ||
281 | sway_log(SWAY_DEBUG, "Matched output config for %s", name); | ||
282 | oc = cur; | ||
283 | } | ||
284 | if (strcasecmp("*", cur->name) == 0) { | ||
285 | sway_log(SWAY_DEBUG, "Matched wildcard output config for %s", name); | ||
286 | all = cur; | ||
287 | } | ||
288 | |||
289 | if (oc && all) { | ||
290 | break; | ||
291 | } | ||
292 | } | ||
293 | if (!oc) { | ||
294 | oc = all; | ||
295 | } | ||
296 | |||
297 | return oc; | ||
298 | } | ||
299 | |||
300 | struct sway_output *output_from_wlr_output(struct wlr_output *output) { | 270 | struct sway_output *output_from_wlr_output(struct wlr_output *output) { |
301 | return output->data; | 271 | return output->data; |
302 | } | 272 | } |