diff options
Diffstat (limited to 'sway')
-rw-r--r-- | sway/commands/output/power.c | 10 | ||||
-rw-r--r-- | sway/config/output.c | 23 | ||||
-rw-r--r-- | sway/desktop/output.c | 6 |
3 files changed, 20 insertions, 19 deletions
diff --git a/sway/commands/output/power.c b/sway/commands/output/power.c index c783e69b..e6ae2852 100644 --- a/sway/commands/output/power.c +++ b/sway/commands/output/power.c | |||
@@ -12,7 +12,7 @@ struct cmd_results *output_cmd_power(int argc, char **argv) { | |||
12 | return cmd_results_new(CMD_INVALID, "Missing power argument"); | 12 | return cmd_results_new(CMD_INVALID, "Missing power argument"); |
13 | } | 13 | } |
14 | 14 | ||
15 | enum config_dpms current_dpms = DPMS_ON; | 15 | bool current = true; |
16 | if (strcasecmp(argv[0], "toggle") == 0) { | 16 | if (strcasecmp(argv[0], "toggle") == 0) { |
17 | const char *oc_name = config->handler_context.output_config->name; | 17 | const char *oc_name = config->handler_context.output_config->name; |
18 | if (strcmp(oc_name, "*") == 0) { | 18 | if (strcmp(oc_name, "*") == 0) { |
@@ -27,14 +27,14 @@ struct cmd_results *output_cmd_power(int argc, char **argv) { | |||
27 | } | 27 | } |
28 | 28 | ||
29 | if (sway_output->enabled && !sway_output->wlr_output->enabled) { | 29 | if (sway_output->enabled && !sway_output->wlr_output->enabled) { |
30 | current_dpms = DPMS_OFF; | 30 | current = false; |
31 | } | 31 | } |
32 | } | 32 | } |
33 | 33 | ||
34 | if (parse_boolean(argv[0], current_dpms == DPMS_ON)) { | 34 | if (parse_boolean(argv[0], current)) { |
35 | config->handler_context.output_config->dpms_state = DPMS_ON; | 35 | config->handler_context.output_config->power = 1; |
36 | } else { | 36 | } else { |
37 | config->handler_context.output_config->dpms_state = DPMS_OFF; | 37 | config->handler_context.output_config->power = 0; |
38 | } | 38 | } |
39 | 39 | ||
40 | config->handler_context.leftovers.argc = argc - 1; | 40 | config->handler_context.leftovers.argc = argc - 1; |
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) { | |||
590 | static void default_output_config(struct output_config *oc, | 591 | static 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 |
diff --git a/sway/desktop/output.c b/sway/desktop/output.c index 5b7ad4ee..7bb9dab2 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c | |||
@@ -763,7 +763,7 @@ static void update_output_manager_config(struct sway_server *server) { | |||
763 | struct wlr_box output_box; | 763 | struct wlr_box output_box; |
764 | wlr_output_layout_get_box(root->output_layout, | 764 | wlr_output_layout_get_box(root->output_layout, |
765 | output->wlr_output, &output_box); | 765 | output->wlr_output, &output_box); |
766 | // We mark the output enabled even if it is switched off by DPMS | 766 | // We mark the output enabled when it's switched off but not disabled |
767 | config_head->state.enabled = output->current_mode != NULL && output->enabled; | 767 | config_head->state.enabled = output->current_mode != NULL && output->enabled; |
768 | config_head->state.mode = output->current_mode; | 768 | config_head->state.mode = output->current_mode; |
769 | if (!wlr_box_empty(&output_box)) { | 769 | if (!wlr_box_empty(&output_box)) { |
@@ -1028,10 +1028,10 @@ void handle_output_power_manager_set_mode(struct wl_listener *listener, | |||
1028 | struct output_config *oc = new_output_config(output->wlr_output->name); | 1028 | struct output_config *oc = new_output_config(output->wlr_output->name); |
1029 | switch (event->mode) { | 1029 | switch (event->mode) { |
1030 | case ZWLR_OUTPUT_POWER_V1_MODE_OFF: | 1030 | case ZWLR_OUTPUT_POWER_V1_MODE_OFF: |
1031 | oc->dpms_state = DPMS_OFF; | 1031 | oc->power = 0; |
1032 | break; | 1032 | break; |
1033 | case ZWLR_OUTPUT_POWER_V1_MODE_ON: | 1033 | case ZWLR_OUTPUT_POWER_V1_MODE_ON: |
1034 | oc->dpms_state = DPMS_ON; | 1034 | oc->power = 1; |
1035 | break; | 1035 | break; |
1036 | } | 1036 | } |
1037 | oc = store_output_config(oc); | 1037 | oc = store_output_config(oc); |