diff options
Diffstat (limited to 'sway/commands/output.c')
-rw-r--r-- | sway/commands/output.c | 62 |
1 files changed, 7 insertions, 55 deletions
diff --git a/sway/commands/output.c b/sway/commands/output.c index 4d98162b..ef1b7a69 100644 --- a/sway/commands/output.c +++ b/sway/commands/output.c | |||
@@ -21,60 +21,6 @@ static struct cmd_handler output_handlers[] = { | |||
21 | { "transform", output_cmd_transform }, | 21 | { "transform", output_cmd_transform }, |
22 | }; | 22 | }; |
23 | 23 | ||
24 | static struct output_config *get_output_config(char *name, char *identifier) { | ||
25 | int i = list_seq_find(config->output_configs, output_name_cmp, name); | ||
26 | if (i >= 0) { | ||
27 | return config->output_configs->items[i]; | ||
28 | } | ||
29 | |||
30 | i = list_seq_find(config->output_configs, output_name_cmp, identifier); | ||
31 | if (i >= 0) { | ||
32 | return config->output_configs->items[i]; | ||
33 | } | ||
34 | |||
35 | return NULL; | ||
36 | } | ||
37 | |||
38 | static void apply_output_config_to_outputs(struct output_config *oc) { | ||
39 | // Try to find the output container and apply configuration now. If | ||
40 | // this is during startup then there will be no container and config | ||
41 | // will be applied during normal "new output" event from wlroots. | ||
42 | bool wildcard = strcmp(oc->name, "*") == 0; | ||
43 | char id[128]; | ||
44 | struct sway_output *sway_output; | ||
45 | wl_list_for_each(sway_output, &root_container.sway_root->outputs, link) { | ||
46 | char *name = sway_output->wlr_output->name; | ||
47 | output_get_identifier(id, sizeof(id), sway_output); | ||
48 | if (wildcard || !strcmp(name, oc->name) || !strcmp(id, oc->name)) { | ||
49 | if (!sway_output->swayc) { | ||
50 | if (!oc->enabled) { | ||
51 | if (!wildcard) { | ||
52 | break; | ||
53 | } | ||
54 | continue; | ||
55 | } | ||
56 | |||
57 | output_enable(sway_output); | ||
58 | } | ||
59 | |||
60 | struct output_config *current = oc; | ||
61 | if (wildcard) { | ||
62 | struct output_config *tmp = get_output_config(name, id); | ||
63 | if (tmp) { | ||
64 | current = tmp; | ||
65 | } | ||
66 | } | ||
67 | apply_output_config(current, sway_output->swayc); | ||
68 | |||
69 | if (!wildcard) { | ||
70 | // Stop looking if the output config isn't applicable to all | ||
71 | // outputs | ||
72 | break; | ||
73 | } | ||
74 | } | ||
75 | } | ||
76 | } | ||
77 | |||
78 | struct cmd_results *cmd_output(int argc, char **argv) { | 24 | struct cmd_results *cmd_output(int argc, char **argv) { |
79 | struct cmd_results *error = checkarg(argc, "output", EXPECTED_AT_LEAST, 1); | 25 | struct cmd_results *error = checkarg(argc, "output", EXPECTED_AT_LEAST, 1); |
80 | if (error != NULL) { | 26 | if (error != NULL) { |
@@ -115,7 +61,13 @@ struct cmd_results *cmd_output(int argc, char **argv) { | |||
115 | config->handler_context.leftovers.argv = NULL; | 61 | config->handler_context.leftovers.argv = NULL; |
116 | 62 | ||
117 | output = store_output_config(output); | 63 | output = store_output_config(output); |
118 | apply_output_config_to_outputs(output); | 64 | |
65 | // If reloading, the output configs will be applied after reading the | ||
66 | // entire config and before the deferred commands so that an auto generated | ||
67 | // workspace name is not given to re-enabled outputs. | ||
68 | if (!config->reloading) { | ||
69 | apply_output_config_to_outputs(output); | ||
70 | } | ||
119 | 71 | ||
120 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 72 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
121 | 73 | ||