aboutsummaryrefslogtreecommitdiffstats
path: root/sway/config/output.c
diff options
context:
space:
mode:
authorLibravatar Geoff Greer <geoff@greer.fm>2019-02-10 16:56:57 -0800
committerLibravatar emersion <contact@emersion.fr>2019-03-24 09:37:24 +0200
commit6e3046878d4dced3f2e503973ad31d7921c0c400 (patch)
tree6a8b5b2204624848edb0b37ecfad8c7764bd2633 /sway/config/output.c
parentAllow for workspace renaming during exec handling (diff)
downloadsway-6e3046878d4dced3f2e503973ad31d7921c0c400.tar.gz
sway-6e3046878d4dced3f2e503973ad31d7921c0c400.tar.zst
sway-6e3046878d4dced3f2e503973ad31d7921c0c400.zip
Add support for manually setting subpixel hinting on outputs.
Many laptop screens report unknown subpixel order. Allow users to manually set subpixel hinting to work around this. Addresses https://github.com/swaywm/sway/issues/3163
Diffstat (limited to 'sway/config/output.c')
-rw-r--r--sway/config/output.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/sway/config/output.c b/sway/config/output.c
index 44aae03a..d06051b3 100644
--- a/sway/config/output.c
+++ b/sway/config/output.c
@@ -8,10 +8,11 @@
8#include <unistd.h> 8#include <unistd.h>
9#include <wlr/types/wlr_output_layout.h> 9#include <wlr/types/wlr_output_layout.h>
10#include <wlr/types/wlr_output.h> 10#include <wlr/types/wlr_output.h>
11#include "log.h"
12#include "sway/config.h" 11#include "sway/config.h"
13#include "sway/output.h" 12#include "sway/output.h"
14#include "sway/tree/root.h" 13#include "sway/tree/root.h"
14#include "log.h"
15#include "util.h"
15 16
16int output_name_cmp(const void *item, const void *data) { 17int output_name_cmp(const void *item, const void *data) {
17 const struct output_config *output = item; 18 const struct output_config *output = item;
@@ -43,6 +44,7 @@ struct output_config *new_output_config(const char *name) {
43 oc->x = oc->y = -1; 44 oc->x = oc->y = -1;
44 oc->scale = -1; 45 oc->scale = -1;
45 oc->transform = -1; 46 oc->transform = -1;
47 oc->subpixel = WL_OUTPUT_SUBPIXEL_UNKNOWN;
46 return oc; 48 return oc;
47} 49}
48 50
@@ -65,6 +67,9 @@ void merge_output_config(struct output_config *dst, struct output_config *src) {
65 if (src->scale != -1) { 67 if (src->scale != -1) {
66 dst->scale = src->scale; 68 dst->scale = src->scale;
67 } 69 }
70 if (src->subpixel != WL_OUTPUT_SUBPIXEL_UNKNOWN) {
71 dst->subpixel = src->subpixel;
72 }
68 if (src->refresh_rate != -1) { 73 if (src->refresh_rate != -1) {
69 dst->refresh_rate = src->refresh_rate; 74 dst->refresh_rate = src->refresh_rate;
70 } 75 }
@@ -187,10 +192,10 @@ struct output_config *store_output_config(struct output_config *oc) {
187 } 192 }
188 193
189 sway_log(SWAY_DEBUG, "Config stored for output %s (enabled: %d) (%dx%d@%fHz " 194 sway_log(SWAY_DEBUG, "Config stored for output %s (enabled: %d) (%dx%d@%fHz "
190 "position %d,%d scale %f transform %d) (bg %s %s) (dpms %d)", 195 "position %d,%d scale %f subpixel %s transform %d) (bg %s %s) (dpms %d)",
191 oc->name, oc->enabled, oc->width, oc->height, oc->refresh_rate, 196 oc->name, oc->enabled, oc->width, oc->height, oc->refresh_rate,
192 oc->x, oc->y, oc->scale, oc->transform, oc->background, 197 oc->x, oc->y, oc->scale, sway_wl_output_subpixel_to_string(oc->subpixel),
193 oc->background_option, oc->dpms_state); 198 oc->transform, oc->background, oc->background_option, oc->dpms_state);
194 199
195 return oc; 200 return oc;
196} 201}
@@ -363,6 +368,14 @@ bool apply_output_config(struct output_config *oc, struct sway_output *output) {
363 sway_log(SWAY_DEBUG, "Set %s scale to %f", oc->name, oc->scale); 368 sway_log(SWAY_DEBUG, "Set %s scale to %f", oc->name, oc->scale);
364 wlr_output_set_scale(wlr_output, oc->scale); 369 wlr_output_set_scale(wlr_output, oc->scale);
365 } 370 }
371
372 if (oc && (oc->subpixel != WL_OUTPUT_SUBPIXEL_UNKNOWN || config->reloading)) {
373 sway_log(SWAY_DEBUG, "Set %s subpixel to %s", oc->name,
374 sway_wl_output_subpixel_to_string(oc->subpixel));
375 wlr_output_set_subpixel(wlr_output, oc->subpixel);
376 output_damage_whole(output);
377 }
378
366 if (oc && oc->transform >= 0) { 379 if (oc && oc->transform >= 0) {
367 sway_log(SWAY_DEBUG, "Set %s transform to %d", oc->name, oc->transform); 380 sway_log(SWAY_DEBUG, "Set %s transform to %d", oc->name, oc->transform);
368 wlr_output_set_transform(wlr_output, oc->transform); 381 wlr_output_set_transform(wlr_output, oc->transform);
@@ -424,6 +437,8 @@ static void default_output_config(struct output_config *oc,
424 } 437 }
425 oc->x = oc->y = -1; 438 oc->x = oc->y = -1;
426 oc->scale = 1; 439 oc->scale = 1;
440 struct sway_output *output = wlr_output->data;
441 oc->subpixel = output->detected_subpixel;
427 oc->transform = WL_OUTPUT_TRANSFORM_NORMAL; 442 oc->transform = WL_OUTPUT_TRANSFORM_NORMAL;
428 oc->dpms_state = DPMS_ON; 443 oc->dpms_state = DPMS_ON;
429} 444}