aboutsummaryrefslogtreecommitdiffstats
path: root/sway/commands/output.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/commands/output.c')
-rw-r--r--sway/commands/output.c54
1 files changed, 7 insertions, 47 deletions
diff --git a/sway/commands/output.c b/sway/commands/output.c
index f955bf90..ef1b7a69 100644
--- a/sway/commands/output.c
+++ b/sway/commands/output.c
@@ -29,7 +29,7 @@ struct cmd_results *cmd_output(int argc, char **argv) {
29 29
30 struct output_config *output = new_output_config(argv[0]); 30 struct output_config *output = new_output_config(argv[0]);
31 if (!output) { 31 if (!output) {
32 wlr_log(L_ERROR, "Failed to allocate output config"); 32 wlr_log(WLR_ERROR, "Failed to allocate output config");
33 return NULL; 33 return NULL;
34 } 34 }
35 argc--; argv++; 35 argc--; argv++;
@@ -60,53 +60,13 @@ struct cmd_results *cmd_output(int argc, char **argv) {
60 config->handler_context.leftovers.argc = 0; 60 config->handler_context.leftovers.argc = 0;
61 config->handler_context.leftovers.argv = NULL; 61 config->handler_context.leftovers.argv = NULL;
62 62
63 int i = list_seq_find(config->output_configs, output_name_cmp, output->name); 63 output = store_output_config(output);
64 if (i >= 0) {
65 // Merge existing config
66 struct output_config *current = config->output_configs->items[i];
67 merge_output_config(current, output);
68 free_output_config(output);
69 output = current;
70 } else {
71 list_add(config->output_configs, output);
72 }
73
74 wlr_log(L_DEBUG, "Config stored for output %s (enabled: %d) (%dx%d@%fHz "
75 "position %d,%d scale %f transform %d) (bg %s %s) (dpms %d)",
76 output->name, output->enabled, output->width, output->height,
77 output->refresh_rate, output->x, output->y, output->scale,
78 output->transform, output->background, output->background_option, output->dpms_state);
79
80 // Try to find the output container and apply configuration now. If
81 // this is during startup then there will be no container and config
82 // will be applied during normal "new output" event from wlroots.
83 char identifier[128];
84 bool all = strcmp(output->name, "*") == 0;
85 struct sway_output *sway_output;
86 wl_list_for_each(sway_output, &root_container.sway_root->outputs, link) {
87 output_get_identifier(identifier, sizeof(identifier), sway_output);
88 wlr_log(L_DEBUG, "Checking identifier %s", identifier);
89 if (all || strcmp(sway_output->wlr_output->name, output->name) == 0
90 || strcmp(identifier, output->name) == 0) {
91 if (!sway_output->swayc) {
92 if (!output->enabled) {
93 if (!all) {
94 break;
95 }
96 continue;
97 }
98 64
99 output_enable(sway_output); 65 // If reloading, the output configs will be applied after reading the
100 } 66 // entire config and before the deferred commands so that an auto generated
101 67 // workspace name is not given to re-enabled outputs.
102 apply_output_config(output, sway_output->swayc); 68 if (!config->reloading) {
103 69 apply_output_config_to_outputs(output);
104 if (!all) {
105 // Stop looking if the output config isn't applicable to all
106 // outputs
107 break;
108 }
109 }
110 } 70 }
111 71
112 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 72 return cmd_results_new(CMD_SUCCESS, NULL, NULL);