diff options
author | Simon Ser <contact@emersion.fr> | 2022-06-23 21:03:32 +0200 |
---|---|---|
committer | Kirill Primak <vyivel@eclair.cafe> | 2022-07-04 21:58:24 +0300 |
commit | b69d637f7a34e239e48a4267ae94a5e7087b5834 (patch) | |
tree | 63e33a9a15a08c5ebe9bf68183a10bad86997ce7 | |
parent | 798e3c8858fdddb0e548d649cc61b6777565de98 (diff) |
Remove internal references to DPMS
While at it, use an int for the config field, just like we do for
all other fields.
-rw-r--r-- | include/sway/config.h | 8 | ||||
-rw-r--r-- | include/sway/output.h | 2 | ||||
-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 |
5 files changed, 22 insertions, 27 deletions
diff --git a/include/sway/config.h b/include/sway/config.h index 2b4aa972..68c06846 100644 --- a/include/sway/config.h +++ b/include/sway/config.h @@ -247,12 +247,6 @@ struct seat_config { } xcursor_theme; }; -enum config_dpms { - DPMS_IGNORE, - DPMS_ON, - DPMS_OFF, -}; - enum scale_filter_mode { SCALE_FILTER_DEFAULT, // the default is currently smart SCALE_FILTER_LINEAR, @@ -274,6 +268,7 @@ enum render_bit_depth { struct output_config { char *name; int enabled; + int power; int width, height; float refresh_rate; int custom_mode; @@ -290,7 +285,6 @@ struct output_config { char *background; char *background_option; char *background_fallback; - enum config_dpms dpms_state; }; /** diff --git a/include/sway/output.h b/include/sway/output.h index 26b9709f..6d8319bf 100644 --- a/include/sway/output.h +++ b/include/sway/output.h @@ -32,7 +32,7 @@ struct sway_output { int width, height; // transformed buffer size enum wl_output_subpixel detected_subpixel; enum scale_filter_mode scale_filter; - // last applied mode when the output is DPMS'ed + // last applied mode when the output is powered off struct wlr_output_mode *current_mode; bool enabling, enabled; 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) { return cmd_results_new(CMD_INVALID, "Missing power argument"); } - enum config_dpms current_dpms = DPMS_ON; + bool current = true; if (strcasecmp(argv[0], "toggle") == 0) { const char *oc_name = config->handler_context.output_config->name; if (strcmp(oc_name, "*") == 0) { @@ -27,14 +27,14 @@ struct cmd_results *output_cmd_power(int argc, char **argv) { } if (sway_output->enabled && !sway_output->wlr_output->enabled) { - current_dpms = DPMS_OFF; + current = false; } } - if (parse_boolean(argv[0], current_dpms == DPMS_ON)) { - config->handler_context.output_config->dpms_state = DPMS_ON; + if (parse_boolean(argv[0], current)) { + config->handler_context.output_config->power = 1; } else { - config->handler_context.output_config->dpms_state = DPMS_OFF; + config->handler_context.output_config->power = 0; } 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) { oc->max_render_time = -1; oc->adaptive_sync = -1; oc->render_bit_depth = RENDER_BIT_DEPTH_DEFAULT; + oc->power = -1; return oc; } @@ -132,8 +133,8 @@ void merge_output_config(struct output_config *dst, struct output_config *src) { free(dst->background_fallback); dst->background_fallback = strdup(src->background_fallback); } - if (src->dpms_state != 0) { - dst->dpms_state = src->dpms_state; + if (src->power != -1) { + dst->power = src->power; } } @@ -192,11 +193,11 @@ static void merge_id_on_name(struct output_config *oc) { list_add(config->output_configs, ion_oc); sway_log(SWAY_DEBUG, "Generated id on name output config \"%s\"" " (enabled: %d) (%dx%d@%fHz position %d,%d scale %f " - "transform %d) (bg %s %s) (dpms %d) (max render time: %d)", + "transform %d) (bg %s %s) (power %d) (max render time: %d)", ion_oc->name, ion_oc->enabled, ion_oc->width, ion_oc->height, ion_oc->refresh_rate, ion_oc->x, ion_oc->y, ion_oc->scale, ion_oc->transform, ion_oc->background, - ion_oc->background_option, ion_oc->dpms_state, + ion_oc->background_option, ion_oc->power, ion_oc->max_render_time); } } @@ -237,11 +238,11 @@ struct output_config *store_output_config(struct output_config *oc) { } sway_log(SWAY_DEBUG, "Config stored for output %s (enabled: %d) (%dx%d@%fHz " - "position %d,%d scale %f subpixel %s transform %d) (bg %s %s) (dpms %d) " + "position %d,%d scale %f subpixel %s transform %d) (bg %s %s) (power %d) " "(max render time: %d)", oc->name, oc->enabled, oc->width, oc->height, oc->refresh_rate, oc->x, oc->y, oc->scale, sway_wl_output_subpixel_to_string(oc->subpixel), - oc->transform, oc->background, oc->background_option, oc->dpms_state, + oc->transform, oc->background, oc->background_option, oc->power, oc->max_render_time); return oc; @@ -385,7 +386,7 @@ static void queue_output_config(struct output_config *oc, struct wlr_output *wlr_output = output->wlr_output; - if (oc && (!oc->enabled || oc->dpms_state == DPMS_OFF)) { + if (oc && (!oc->enabled || oc->power == 0)) { sway_log(SWAY_DEBUG, "Turning off output %s", wlr_output->name); wlr_output_state_set_enabled(pending, false); return; @@ -494,7 +495,7 @@ bool apply_output_config(struct output_config *oc, struct sway_output *output) { struct wlr_output_state pending = {0}; queue_output_config(oc, output, &pending); - if (!oc || oc->dpms_state != DPMS_OFF) { + if (!oc || oc->power != 0) { output->current_mode = pending.mode; } @@ -590,6 +591,7 @@ bool test_output_config(struct output_config *oc, struct sway_output *output) { static void default_output_config(struct output_config *oc, struct wlr_output *wlr_output) { oc->enabled = 1; + oc->power = 1; struct wlr_output_mode *mode = wlr_output_preferred_mode(wlr_output); if (mode != NULL) { oc->width = mode->width; @@ -602,7 +604,6 @@ static void default_output_config(struct output_config *oc, struct sway_output *output = wlr_output->data; oc->subpixel = output->detected_subpixel; oc->transform = WL_OUTPUT_TRANSFORM_NORMAL; - oc->dpms_state = DPMS_ON; oc->max_render_time = 0; } @@ -657,10 +658,10 @@ static struct output_config *get_output_config(char *identifier, sway_log(SWAY_DEBUG, "Generated output config \"%s\" (enabled: %d)" " (%dx%d@%fHz position %d,%d scale %f transform %d) (bg %s %s)" - " (dpms %d) (max render time: %d)", result->name, result->enabled, + " (power %d) (max render time: %d)", result->name, result->enabled, result->width, result->height, result->refresh_rate, result->x, result->y, result->scale, result->transform, - result->background, result->background_option, result->dpms_state, + result->background, result->background_option, result->power, result->max_render_time); } else if (oc_name) { // 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) { struct wlr_box output_box; wlr_output_layout_get_box(root->output_layout, output->wlr_output, &output_box); - // We mark the output enabled even if it is switched off by DPMS + // We mark the output enabled when it's switched off but not disabled config_head->state.enabled = output->current_mode != NULL && output->enabled; config_head->state.mode = output->current_mode; if (!wlr_box_empty(&output_box)) { @@ -1028,10 +1028,10 @@ void handle_output_power_manager_set_mode(struct wl_listener *listener, struct output_config *oc = new_output_config(output->wlr_output->name); switch (event->mode) { case ZWLR_OUTPUT_POWER_V1_MODE_OFF: - oc->dpms_state = DPMS_OFF; + oc->power = 0; break; case ZWLR_OUTPUT_POWER_V1_MODE_ON: - oc->dpms_state = DPMS_ON; + oc->power = 1; break; } oc = store_output_config(oc); |