aboutsummaryrefslogtreecommitdiffstats
path: root/sway/config/output.c
diff options
context:
space:
mode:
authorLibravatar Brian Ashworth <bosrsf04@gmail.com>2018-07-20 22:17:20 -0400
committerLibravatar Brian Ashworth <bosrsf04@gmail.com>2018-07-20 22:17:20 -0400
commitbc7d3321093339d34839718b35af034de4aeb9f1 (patch)
treed125902e937c72b566a09b2a91d78040f82906b8 /sway/config/output.c
parentMerge pull request #2317 from RyanDwyer/force-display-urgency-hint (diff)
downloadsway-bc7d3321093339d34839718b35af034de4aeb9f1.tar.gz
sway-bc7d3321093339d34839718b35af034de4aeb9f1.tar.zst
sway-bc7d3321093339d34839718b35af034de4aeb9f1.zip
Reset outputs on reload
Diffstat (limited to 'sway/config/output.c')
-rw-r--r--sway/config/output.c80
1 files changed, 80 insertions, 0 deletions
diff --git a/sway/config/output.c b/sway/config/output.c
index 505fa745..504c48c6 100644
--- a/sway/config/output.c
+++ b/sway/config/output.c
@@ -263,6 +263,60 @@ void apply_output_config(struct output_config *oc, struct sway_container *output
263 } 263 }
264} 264}
265 265
266static struct output_config *get_output_config(char *name, char *identifier) {
267 int i = list_seq_find(config->output_configs, output_name_cmp, name);
268 if (i >= 0) {
269 return config->output_configs->items[i];
270 }
271
272 i = list_seq_find(config->output_configs, output_name_cmp, identifier);
273 if (i >= 0) {
274 return config->output_configs->items[i];
275 }
276
277 return NULL;
278}
279
280void apply_output_config_to_outputs(struct output_config *oc) {
281 // Try to find the output container and apply configuration now. If
282 // this is during startup then there will be no container and config
283 // will be applied during normal "new output" event from wlroots.
284 bool wildcard = strcmp(oc->name, "*") == 0;
285 char id[128];
286 struct sway_output *sway_output;
287 wl_list_for_each(sway_output, &root_container.sway_root->outputs, link) {
288 char *name = sway_output->wlr_output->name;
289 output_get_identifier(id, sizeof(id), sway_output);
290 if (wildcard || !strcmp(name, oc->name) || !strcmp(id, oc->name)) {
291 if (!sway_output->swayc) {
292 if (!oc->enabled) {
293 if (!wildcard) {
294 break;
295 }
296 continue;
297 }
298
299 output_enable(sway_output);
300 }
301
302 struct output_config *current = oc;
303 if (wildcard) {
304 struct output_config *tmp = get_output_config(name, id);
305 if (tmp) {
306 current = tmp;
307 }
308 }
309 apply_output_config(current, sway_output->swayc);
310
311 if (!wildcard) {
312 // Stop looking if the output config isn't applicable to all
313 // outputs
314 break;
315 }
316 }
317 }
318}
319
266void free_output_config(struct output_config *oc) { 320void free_output_config(struct output_config *oc) {
267 if (!oc) { 321 if (!oc) {
268 return; 322 return;
@@ -272,3 +326,29 @@ void free_output_config(struct output_config *oc) {
272 free(oc->background_option); 326 free(oc->background_option);
273 free(oc); 327 free(oc);
274} 328}
329
330static void default_output_config(struct output_config *oc,
331 struct wlr_output *wlr_output) {
332 oc->enabled = 1;
333 if (!wl_list_empty(&wlr_output->modes)) {
334 struct wlr_output_mode *mode =
335 wl_container_of(wlr_output->modes.prev, mode, link);
336 oc->width = mode->width;
337 oc->height = mode->height;
338 oc->refresh_rate = mode->refresh;
339 }
340 oc->x = oc->y = -1;
341 oc->scale = 1;
342 oc->transform = WL_OUTPUT_TRANSFORM_NORMAL;
343}
344
345void create_default_output_configs(void) {
346 struct sway_output *sway_output;
347 wl_list_for_each(sway_output, &root_container.sway_root->outputs, link) {
348 char *name = sway_output->wlr_output->name;
349 struct output_config *oc = new_output_config(name);
350 default_output_config(oc, sway_output->wlr_output);
351 list_add(config->output_configs, oc);
352 }
353}
354