diff options
author | Ronan Pigott <rpigott@berkeley.edu> | 2019-11-13 11:23:36 -0700 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2019-11-29 18:13:37 +0100 |
commit | 6968fb3123e69f563cd01d472967a9e6ddca2ec1 (patch) | |
tree | 0e313d5e19da37762ab572e38c36ff33798f25fb /sway/config | |
parent | output: Ensure that frame_done is delayed on max_render_time (diff) | |
download | sway-6968fb3123e69f563cd01d472967a9e6ddca2ec1.tar.gz sway-6968fb3123e69f563cd01d472967a9e6ddca2ec1.tar.zst sway-6968fb3123e69f563cd01d472967a9e6ddca2ec1.zip |
add scale_filter output config option
Diffstat (limited to 'sway/config')
-rw-r--r-- | sway/config/output.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/sway/config/output.c b/sway/config/output.c index 1d5f81da..21a12b8f 100644 --- a/sway/config/output.c +++ b/sway/config/output.c | |||
@@ -29,6 +29,21 @@ void output_get_identifier(char *identifier, size_t len, | |||
29 | wlr_output->serial); | 29 | wlr_output->serial); |
30 | } | 30 | } |
31 | 31 | ||
32 | const char *sway_output_scale_filter_to_string(enum scale_filter_mode scale_filter) { | ||
33 | switch (scale_filter) { | ||
34 | case SCALE_FILTER_DEFAULT: | ||
35 | return "smart"; | ||
36 | case SCALE_FILTER_LINEAR: | ||
37 | return "linear"; | ||
38 | case SCALE_FILTER_NEAREST: | ||
39 | return "nearest"; | ||
40 | case SCALE_FILTER_SMART: | ||
41 | return "smart"; | ||
42 | } | ||
43 | sway_assert(false, "Unknown value for scale_filter."); | ||
44 | return NULL; | ||
45 | } | ||
46 | |||
32 | struct output_config *new_output_config(const char *name) { | 47 | struct output_config *new_output_config(const char *name) { |
33 | struct output_config *oc = calloc(1, sizeof(struct output_config)); | 48 | struct output_config *oc = calloc(1, sizeof(struct output_config)); |
34 | if (oc == NULL) { | 49 | if (oc == NULL) { |
@@ -45,6 +60,7 @@ struct output_config *new_output_config(const char *name) { | |||
45 | oc->custom_mode = -1; | 60 | oc->custom_mode = -1; |
46 | oc->x = oc->y = -1; | 61 | oc->x = oc->y = -1; |
47 | oc->scale = -1; | 62 | oc->scale = -1; |
63 | oc->scale_filter = SCALE_FILTER_DEFAULT; | ||
48 | oc->transform = -1; | 64 | oc->transform = -1; |
49 | oc->subpixel = WL_OUTPUT_SUBPIXEL_UNKNOWN; | 65 | oc->subpixel = WL_OUTPUT_SUBPIXEL_UNKNOWN; |
50 | oc->max_render_time = -1; | 66 | oc->max_render_time = -1; |
@@ -70,6 +86,9 @@ void merge_output_config(struct output_config *dst, struct output_config *src) { | |||
70 | if (src->scale != -1) { | 86 | if (src->scale != -1) { |
71 | dst->scale = src->scale; | 87 | dst->scale = src->scale; |
72 | } | 88 | } |
89 | if (src->scale_filter != SCALE_FILTER_DEFAULT) { | ||
90 | dst->scale_filter = src->scale_filter; | ||
91 | } | ||
73 | if (src->subpixel != WL_OUTPUT_SUBPIXEL_UNKNOWN) { | 92 | if (src->subpixel != WL_OUTPUT_SUBPIXEL_UNKNOWN) { |
74 | dst->subpixel = src->subpixel; | 93 | dst->subpixel = src->subpixel; |
75 | } | 94 | } |
@@ -297,6 +316,24 @@ bool apply_output_config(struct output_config *oc, struct sway_output *output) { | |||
297 | if (oc && oc->scale > 0) { | 316 | if (oc && oc->scale > 0) { |
298 | sway_log(SWAY_DEBUG, "Set %s scale to %f", oc->name, oc->scale); | 317 | sway_log(SWAY_DEBUG, "Set %s scale to %f", oc->name, oc->scale); |
299 | wlr_output_set_scale(wlr_output, oc->scale); | 318 | wlr_output_set_scale(wlr_output, oc->scale); |
319 | |||
320 | enum scale_filter_mode scale_filter_old = output->scale_filter; | ||
321 | switch (oc->scale_filter) { | ||
322 | case SCALE_FILTER_DEFAULT: | ||
323 | case SCALE_FILTER_SMART: | ||
324 | output->scale_filter = ceilf(wlr_output->scale) == wlr_output->scale ? | ||
325 | SCALE_FILTER_NEAREST : SCALE_FILTER_LINEAR; | ||
326 | break; | ||
327 | case SCALE_FILTER_LINEAR: | ||
328 | case SCALE_FILTER_NEAREST: | ||
329 | output->scale_filter = oc->scale_filter; | ||
330 | break; | ||
331 | } | ||
332 | if (scale_filter_old != output->scale_filter) { | ||
333 | sway_log(SWAY_DEBUG, "Set %s scale_filter to %s", oc->name, | ||
334 | sway_output_scale_filter_to_string(output->scale_filter)); | ||
335 | output_damage_whole(output); | ||
336 | } | ||
300 | } | 337 | } |
301 | 338 | ||
302 | if (oc && (oc->subpixel != WL_OUTPUT_SUBPIXEL_UNKNOWN || config->reloading)) { | 339 | if (oc && (oc->subpixel != WL_OUTPUT_SUBPIXEL_UNKNOWN || config->reloading)) { |
@@ -352,6 +389,7 @@ static void default_output_config(struct output_config *oc, | |||
352 | } | 389 | } |
353 | oc->x = oc->y = -1; | 390 | oc->x = oc->y = -1; |
354 | oc->scale = 1; | 391 | oc->scale = 1; |
392 | oc->scale_filter = SCALE_FILTER_DEFAULT; | ||
355 | struct sway_output *output = wlr_output->data; | 393 | struct sway_output *output = wlr_output->data; |
356 | oc->subpixel = output->detected_subpixel; | 394 | oc->subpixel = output->detected_subpixel; |
357 | oc->transform = WL_OUTPUT_TRANSFORM_NORMAL; | 395 | oc->transform = WL_OUTPUT_TRANSFORM_NORMAL; |