aboutsummaryrefslogtreecommitdiffstats
path: root/sway/config/output.c
diff options
context:
space:
mode:
authorLibravatar Simon Ser <contact@emersion.fr>2022-06-23 21:03:32 +0200
committerLibravatar Kirill Primak <vyivel@eclair.cafe>2022-07-04 21:58:24 +0300
commitb69d637f7a34e239e48a4267ae94a5e7087b5834 (patch)
tree63e33a9a15a08c5ebe9bf68183a10bad86997ce7 /sway/config/output.c
parentconfig.in: switch to `output power` (diff)
downloadsway-b69d637f7a34e239e48a4267ae94a5e7087b5834.tar.gz
sway-b69d637f7a34e239e48a4267ae94a5e7087b5834.tar.zst
sway-b69d637f7a34e239e48a4267ae94a5e7087b5834.zip
Remove internal references to DPMS
While at it, use an int for the config field, just like we do for all other fields.
Diffstat (limited to 'sway/config/output.c')
-rw-r--r--sway/config/output.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/sway/config/output.c b/sway/config/output.c
index 85b3f8bd..b3e8371e 100644
--- a/sway/config/output.c
+++ b/sway/config/output.c
@@ -71,6 +71,7 @@ struct output_config *new_output_config(const char *name) {
71 oc->max_render_time = -1; 71 oc->max_render_time = -1;
72 oc->adaptive_sync = -1; 72 oc->adaptive_sync = -1;
73 oc->render_bit_depth = RENDER_BIT_DEPTH_DEFAULT; 73 oc->render_bit_depth = RENDER_BIT_DEPTH_DEFAULT;
74 oc->power = -1;
74 return oc; 75 return oc;
75} 76}
76 77
@@ -132,8 +133,8 @@ void merge_output_config(struct output_config *dst, struct output_config *src) {
132 free(dst->background_fallback); 133 free(dst->background_fallback);
133 dst->background_fallback = strdup(src->background_fallback); 134 dst->background_fallback = strdup(src->background_fallback);
134 } 135 }
135 if (src->dpms_state != 0) { 136 if (src->power != -1) {
136 dst->dpms_state = src->dpms_state; 137 dst->power = src->power;
137 } 138 }
138} 139}
139 140
@@ -192,11 +193,11 @@ static void merge_id_on_name(struct output_config *oc) {
192 list_add(config->output_configs, ion_oc); 193 list_add(config->output_configs, ion_oc);
193 sway_log(SWAY_DEBUG, "Generated id on name output config \"%s\"" 194 sway_log(SWAY_DEBUG, "Generated id on name output config \"%s\""
194 " (enabled: %d) (%dx%d@%fHz position %d,%d scale %f " 195 " (enabled: %d) (%dx%d@%fHz position %d,%d scale %f "
195 "transform %d) (bg %s %s) (dpms %d) (max render time: %d)", 196 "transform %d) (bg %s %s) (power %d) (max render time: %d)",
196 ion_oc->name, ion_oc->enabled, ion_oc->width, ion_oc->height, 197 ion_oc->name, ion_oc->enabled, ion_oc->width, ion_oc->height,
197 ion_oc->refresh_rate, ion_oc->x, ion_oc->y, ion_oc->scale, 198 ion_oc->refresh_rate, ion_oc->x, ion_oc->y, ion_oc->scale,
198 ion_oc->transform, ion_oc->background, 199 ion_oc->transform, ion_oc->background,
199 ion_oc->background_option, ion_oc->dpms_state, 200 ion_oc->background_option, ion_oc->power,
200 ion_oc->max_render_time); 201 ion_oc->max_render_time);
201 } 202 }
202 } 203 }
@@ -237,11 +238,11 @@ struct output_config *store_output_config(struct output_config *oc) {
237 } 238 }
238 239
239 sway_log(SWAY_DEBUG, "Config stored for output %s (enabled: %d) (%dx%d@%fHz " 240 sway_log(SWAY_DEBUG, "Config stored for output %s (enabled: %d) (%dx%d@%fHz "
240 "position %d,%d scale %f subpixel %s transform %d) (bg %s %s) (dpms %d) " 241 "position %d,%d scale %f subpixel %s transform %d) (bg %s %s) (power %d) "
241 "(max render time: %d)", 242 "(max render time: %d)",
242 oc->name, oc->enabled, oc->width, oc->height, oc->refresh_rate, 243 oc->name, oc->enabled, oc->width, oc->height, oc->refresh_rate,
243 oc->x, oc->y, oc->scale, sway_wl_output_subpixel_to_string(oc->subpixel), 244 oc->x, oc->y, oc->scale, sway_wl_output_subpixel_to_string(oc->subpixel),
244 oc->transform, oc->background, oc->background_option, oc->dpms_state, 245 oc->transform, oc->background, oc->background_option, oc->power,
245 oc->max_render_time); 246 oc->max_render_time);
246 247
247 return oc; 248 return oc;
@@ -385,7 +386,7 @@ static void queue_output_config(struct output_config *oc,
385 386
386 struct wlr_output *wlr_output = output->wlr_output; 387 struct wlr_output *wlr_output = output->wlr_output;
387 388
388 if (oc && (!oc->enabled || oc->dpms_state == DPMS_OFF)) { 389 if (oc && (!oc->enabled || oc->power == 0)) {
389 sway_log(SWAY_DEBUG, "Turning off output %s", wlr_output->name); 390 sway_log(SWAY_DEBUG, "Turning off output %s", wlr_output->name);
390 wlr_output_state_set_enabled(pending, false); 391 wlr_output_state_set_enabled(pending, false);
391 return; 392 return;
@@ -494,7 +495,7 @@ bool apply_output_config(struct output_config *oc, struct sway_output *output) {
494 struct wlr_output_state pending = {0}; 495 struct wlr_output_state pending = {0};
495 queue_output_config(oc, output, &pending); 496 queue_output_config(oc, output, &pending);
496 497
497 if (!oc || oc->dpms_state != DPMS_OFF) { 498 if (!oc || oc->power != 0) {
498 output->current_mode = pending.mode; 499 output->current_mode = pending.mode;
499 } 500 }
500 501
@@ -590,6 +591,7 @@ bool test_output_config(struct output_config *oc, struct sway_output *output) {
590static void default_output_config(struct output_config *oc, 591static void default_output_config(struct output_config *oc,
591 struct wlr_output *wlr_output) { 592 struct wlr_output *wlr_output) {
592 oc->enabled = 1; 593 oc->enabled = 1;
594 oc->power = 1;
593 struct wlr_output_mode *mode = wlr_output_preferred_mode(wlr_output); 595 struct wlr_output_mode *mode = wlr_output_preferred_mode(wlr_output);
594 if (mode != NULL) { 596 if (mode != NULL) {
595 oc->width = mode->width; 597 oc->width = mode->width;
@@ -602,7 +604,6 @@ static void default_output_config(struct output_config *oc,
602 struct sway_output *output = wlr_output->data; 604 struct sway_output *output = wlr_output->data;
603 oc->subpixel = output->detected_subpixel; 605 oc->subpixel = output->detected_subpixel;
604 oc->transform = WL_OUTPUT_TRANSFORM_NORMAL; 606 oc->transform = WL_OUTPUT_TRANSFORM_NORMAL;
605 oc->dpms_state = DPMS_ON;
606 oc->max_render_time = 0; 607 oc->max_render_time = 0;
607} 608}
608 609
@@ -657,10 +658,10 @@ static struct output_config *get_output_config(char *identifier,
657 658
658 sway_log(SWAY_DEBUG, "Generated output config \"%s\" (enabled: %d)" 659 sway_log(SWAY_DEBUG, "Generated output config \"%s\" (enabled: %d)"
659 " (%dx%d@%fHz position %d,%d scale %f transform %d) (bg %s %s)" 660 " (%dx%d@%fHz position %d,%d scale %f transform %d) (bg %s %s)"
660 " (dpms %d) (max render time: %d)", result->name, result->enabled, 661 " (power %d) (max render time: %d)", result->name, result->enabled,
661 result->width, result->height, result->refresh_rate, 662 result->width, result->height, result->refresh_rate,
662 result->x, result->y, result->scale, result->transform, 663 result->x, result->y, result->scale, result->transform,
663 result->background, result->background_option, result->dpms_state, 664 result->background, result->background_option, result->power,
664 result->max_render_time); 665 result->max_render_time);
665 } else if (oc_name) { 666 } else if (oc_name) {
666 // No identifier config, just return a copy of the name config 667 // No identifier config, just return a copy of the name config