diff options
Diffstat (limited to 'sway/config/output.c')
-rw-r--r-- | sway/config/output.c | 47 |
1 files changed, 20 insertions, 27 deletions
diff --git a/sway/config/output.c b/sway/config/output.c index 65f09258..aa53fc46 100644 --- a/sway/config/output.c +++ b/sway/config/output.c | |||
@@ -174,21 +174,16 @@ void terminate_swaybg(pid_t pid) { | |||
174 | } | 174 | } |
175 | } | 175 | } |
176 | 176 | ||
177 | void apply_output_config(struct output_config *oc, struct sway_container *output) { | 177 | void apply_output_config(struct output_config *oc, struct sway_output *output) { |
178 | assert(output->type == C_OUTPUT); | 178 | struct wlr_output *wlr_output = output->wlr_output; |
179 | |||
180 | struct wlr_output_layout *output_layout = | ||
181 | root_container.sway_root->output_layout; | ||
182 | struct wlr_output *wlr_output = output->sway_output->wlr_output; | ||
183 | 179 | ||
184 | if (oc && oc->enabled == 0) { | 180 | if (oc && oc->enabled == 0) { |
185 | if (output->sway_output->bg_pid != 0) { | 181 | if (output->bg_pid != 0) { |
186 | terminate_swaybg(output->sway_output->bg_pid); | 182 | terminate_swaybg(output->bg_pid); |
187 | output->sway_output->bg_pid = 0; | 183 | output->bg_pid = 0; |
188 | } | 184 | } |
189 | output_begin_destroy(output); | 185 | output_disable(output); |
190 | wlr_output_layout_remove(root_container.sway_root->output_layout, | 186 | wlr_output_layout_remove(root->output_layout, wlr_output); |
191 | wlr_output); | ||
192 | return; | 187 | return; |
193 | } | 188 | } |
194 | 189 | ||
@@ -213,21 +208,21 @@ void apply_output_config(struct output_config *oc, struct sway_container *output | |||
213 | // Find position for it | 208 | // Find position for it |
214 | if (oc && (oc->x != -1 || oc->y != -1)) { | 209 | if (oc && (oc->x != -1 || oc->y != -1)) { |
215 | wlr_log(WLR_DEBUG, "Set %s position to %d, %d", oc->name, oc->x, oc->y); | 210 | wlr_log(WLR_DEBUG, "Set %s position to %d, %d", oc->name, oc->x, oc->y); |
216 | wlr_output_layout_add(output_layout, wlr_output, oc->x, oc->y); | 211 | wlr_output_layout_add(root->output_layout, wlr_output, oc->x, oc->y); |
217 | } else { | 212 | } else { |
218 | wlr_output_layout_add_auto(output_layout, wlr_output); | 213 | wlr_output_layout_add_auto(root->output_layout, wlr_output); |
219 | } | 214 | } |
220 | 215 | ||
221 | int output_i; | 216 | int output_i; |
222 | for (output_i = 0; output_i < root_container.children->length; ++output_i) { | 217 | for (output_i = 0; output_i < root->outputs->length; ++output_i) { |
223 | if (root_container.children->items[output_i] == output) { | 218 | if (root->outputs->items[output_i] == output) { |
224 | break; | 219 | break; |
225 | } | 220 | } |
226 | } | 221 | } |
227 | 222 | ||
228 | if (oc && oc->background) { | 223 | if (oc && oc->background) { |
229 | if (output->sway_output->bg_pid != 0) { | 224 | if (output->bg_pid != 0) { |
230 | terminate_swaybg(output->sway_output->bg_pid); | 225 | terminate_swaybg(output->bg_pid); |
231 | } | 226 | } |
232 | 227 | ||
233 | wlr_log(WLR_DEBUG, "Setting background for output %d to %s", | 228 | wlr_log(WLR_DEBUG, "Setting background for output %d to %s", |
@@ -249,8 +244,8 @@ void apply_output_config(struct output_config *oc, struct sway_container *output | |||
249 | wlr_log(WLR_DEBUG, "-> %s", command); | 244 | wlr_log(WLR_DEBUG, "-> %s", command); |
250 | 245 | ||
251 | char *const cmd[] = { "sh", "-c", command, NULL }; | 246 | char *const cmd[] = { "sh", "-c", command, NULL }; |
252 | output->sway_output->bg_pid = fork(); | 247 | output->bg_pid = fork(); |
253 | if (output->sway_output->bg_pid == 0) { | 248 | if (output->bg_pid == 0) { |
254 | execvp(cmd[0], cmd); | 249 | execvp(cmd[0], cmd); |
255 | } else { | 250 | } else { |
256 | free(command); | 251 | free(command); |
@@ -293,12 +288,11 @@ void apply_output_config_to_outputs(struct output_config *oc) { | |||
293 | bool wildcard = strcmp(oc->name, "*") == 0; | 288 | bool wildcard = strcmp(oc->name, "*") == 0; |
294 | char id[128]; | 289 | char id[128]; |
295 | struct sway_output *sway_output; | 290 | struct sway_output *sway_output; |
296 | wl_list_for_each(sway_output, | 291 | wl_list_for_each(sway_output, &root->all_outputs, link) { |
297 | &root_container.sway_root->all_outputs, link) { | ||
298 | char *name = sway_output->wlr_output->name; | 292 | char *name = sway_output->wlr_output->name; |
299 | output_get_identifier(id, sizeof(id), sway_output); | 293 | output_get_identifier(id, sizeof(id), sway_output); |
300 | if (wildcard || !strcmp(name, oc->name) || !strcmp(id, oc->name)) { | 294 | if (wildcard || !strcmp(name, oc->name) || !strcmp(id, oc->name)) { |
301 | if (!sway_output->swayc) { | 295 | if (!sway_output->enabled) { |
302 | if (!oc->enabled) { | 296 | if (!oc->enabled) { |
303 | if (!wildcard) { | 297 | if (!wildcard) { |
304 | break; | 298 | break; |
@@ -306,7 +300,7 @@ void apply_output_config_to_outputs(struct output_config *oc) { | |||
306 | continue; | 300 | continue; |
307 | } | 301 | } |
308 | 302 | ||
309 | output_enable(sway_output); | 303 | output_enable(sway_output, oc); |
310 | } | 304 | } |
311 | 305 | ||
312 | struct output_config *current = oc; | 306 | struct output_config *current = oc; |
@@ -316,7 +310,7 @@ void apply_output_config_to_outputs(struct output_config *oc) { | |||
316 | current = tmp; | 310 | current = tmp; |
317 | } | 311 | } |
318 | } | 312 | } |
319 | apply_output_config(current, sway_output->swayc); | 313 | apply_output_config(current, sway_output); |
320 | 314 | ||
321 | if (!wildcard) { | 315 | if (!wildcard) { |
322 | // Stop looking if the output config isn't applicable to all | 316 | // Stop looking if the output config isn't applicable to all |
@@ -354,8 +348,7 @@ static void default_output_config(struct output_config *oc, | |||
354 | 348 | ||
355 | void create_default_output_configs(void) { | 349 | void create_default_output_configs(void) { |
356 | struct sway_output *sway_output; | 350 | struct sway_output *sway_output; |
357 | wl_list_for_each(sway_output, | 351 | wl_list_for_each(sway_output, &root->all_outputs, link) { |
358 | &root_container.sway_root->all_outputs, link) { | ||
359 | char *name = sway_output->wlr_output->name; | 352 | char *name = sway_output->wlr_output->name; |
360 | struct output_config *oc = new_output_config(name); | 353 | struct output_config *oc = new_output_config(name); |
361 | default_output_config(oc, sway_output->wlr_output); | 354 | default_output_config(oc, sway_output->wlr_output); |