diff options
author | Brian Ashworth <bosrsf04@gmail.com> | 2018-07-20 12:32:29 -0400 |
---|---|---|
committer | Brian Ashworth <bosrsf04@gmail.com> | 2018-07-20 12:32:29 -0400 |
commit | 9605ab45f1c863076bd68acfb1d2e5d25c1b285d (patch) | |
tree | 51d76189b5a38150001c16d520ad72ed4876874f /sway/config/output.c | |
parent | Merge pull request #2313 from minus7/swaybar-hotspot-input-fix (diff) | |
download | sway-9605ab45f1c863076bd68acfb1d2e5d25c1b285d.tar.gz sway-9605ab45f1c863076bd68acfb1d2e5d25c1b285d.tar.zst sway-9605ab45f1c863076bd68acfb1d2e5d25c1b285d.zip |
Fix output wildcard handling
Diffstat (limited to 'sway/config/output.c')
-rw-r--r-- | sway/config/output.c | 64 |
1 files changed, 50 insertions, 14 deletions
diff --git a/sway/config/output.c b/sway/config/output.c index 1bf9e5f1..505fa745 100644 --- a/sway/config/output.c +++ b/sway/config/output.c | |||
@@ -45,10 +45,6 @@ struct output_config *new_output_config(const char *name) { | |||
45 | } | 45 | } |
46 | 46 | ||
47 | void merge_output_config(struct output_config *dst, struct output_config *src) { | 47 | void merge_output_config(struct output_config *dst, struct output_config *src) { |
48 | if (src->name) { | ||
49 | free(dst->name); | ||
50 | dst->name = strdup(src->name); | ||
51 | } | ||
52 | if (src->enabled != -1) { | 48 | if (src->enabled != -1) { |
53 | dst->enabled = src->enabled; | 49 | dst->enabled = src->enabled; |
54 | } | 50 | } |
@@ -86,6 +82,56 @@ void merge_output_config(struct output_config *dst, struct output_config *src) { | |||
86 | } | 82 | } |
87 | } | 83 | } |
88 | 84 | ||
85 | static void merge_wildcard_on_all(struct output_config *wildcard) { | ||
86 | for (int i = 0; i < config->output_configs->length; i++) { | ||
87 | struct output_config *oc = config->output_configs->items[i]; | ||
88 | if (strcmp(wildcard->name, oc->name) != 0) { | ||
89 | wlr_log(WLR_DEBUG, "Merging output * config on %s", oc->name); | ||
90 | merge_output_config(oc, wildcard); | ||
91 | } | ||
92 | } | ||
93 | } | ||
94 | |||
95 | struct output_config *store_output_config(struct output_config *oc) { | ||
96 | bool wildcard = strcmp(oc->name, "*") == 0; | ||
97 | if (wildcard) { | ||
98 | merge_wildcard_on_all(oc); | ||
99 | } | ||
100 | |||
101 | int i = list_seq_find(config->output_configs, output_name_cmp, oc->name); | ||
102 | if (i >= 0) { | ||
103 | wlr_log(WLR_DEBUG, "Merging on top of existing output config"); | ||
104 | struct output_config *current = config->output_configs->items[i]; | ||
105 | merge_output_config(current, oc); | ||
106 | free_output_config(oc); | ||
107 | oc = current; | ||
108 | } else if (!wildcard) { | ||
109 | wlr_log(WLR_DEBUG, "Adding non-wildcard output config"); | ||
110 | i = list_seq_find(config->output_configs, output_name_cmp, "*"); | ||
111 | if (i >= 0) { | ||
112 | wlr_log(WLR_DEBUG, "Merging on top of output * config"); | ||
113 | struct output_config *current = new_output_config(oc->name); | ||
114 | merge_output_config(current, config->output_configs->items[i]); | ||
115 | merge_output_config(current, oc); | ||
116 | free_output_config(oc); | ||
117 | oc = current; | ||
118 | } | ||
119 | list_add(config->output_configs, oc); | ||
120 | } else { | ||
121 | // New wildcard config. Just add it | ||
122 | wlr_log(WLR_DEBUG, "Adding output * config"); | ||
123 | list_add(config->output_configs, oc); | ||
124 | } | ||
125 | |||
126 | wlr_log(WLR_DEBUG, "Config stored for output %s (enabled: %d) (%dx%d@%fHz " | ||
127 | "position %d,%d scale %f transform %d) (bg %s %s) (dpms %d)", | ||
128 | oc->name, oc->enabled, oc->width, oc->height, oc->refresh_rate, | ||
129 | oc->x, oc->y, oc->scale, oc->transform, oc->background, | ||
130 | oc->background_option, oc->dpms_state); | ||
131 | |||
132 | return oc; | ||
133 | } | ||
134 | |||
89 | static void set_mode(struct wlr_output *output, int width, int height, | 135 | static void set_mode(struct wlr_output *output, int width, int height, |
90 | float refresh_rate) { | 136 | float refresh_rate) { |
91 | int mhz = (int)(refresh_rate * 1000); | 137 | int mhz = (int)(refresh_rate * 1000); |
@@ -165,16 +211,6 @@ void apply_output_config(struct output_config *oc, struct sway_container *output | |||
165 | wlr_output_layout_add_auto(output_layout, wlr_output); | 211 | wlr_output_layout_add_auto(output_layout, wlr_output); |
166 | } | 212 | } |
167 | 213 | ||
168 | if (!oc || !oc->background) { | ||
169 | // Look for a * config for background | ||
170 | int i = list_seq_find(config->output_configs, output_name_cmp, "*"); | ||
171 | if (i >= 0) { | ||
172 | oc = config->output_configs->items[i]; | ||
173 | } else { | ||
174 | oc = NULL; | ||
175 | } | ||
176 | } | ||
177 | |||
178 | int output_i; | 214 | int output_i; |
179 | for (output_i = 0; output_i < root_container.children->length; ++output_i) { | 215 | for (output_i = 0; output_i < root_container.children->length; ++output_i) { |
180 | if (root_container.children->items[output_i] == output) { | 216 | if (root_container.children->items[output_i] == output) { |