summaryrefslogtreecommitdiff
path: root/sway/config
diff options
context:
space:
mode:
authorGeoff Greer <[email protected]>2019-02-10 16:56:57 -0800
committeremersion <[email protected]>2019-03-24 09:37:24 +0200
commit6e3046878d4dced3f2e503973ad31d7921c0c400 (patch)
tree6a8b5b2204624848edb0b37ecfad8c7764bd2633 /sway/config
parent200833caaea36dd65324e5460520731f5c98ff8a (diff)
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')
-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 @@
#include <unistd.h>
#include <wlr/types/wlr_output_layout.h>
#include <wlr/types/wlr_output.h>
-#include "log.h"
#include "sway/config.h"
#include "sway/output.h"
#include "sway/tree/root.h"
+#include "log.h"
+#include "util.h"
int output_name_cmp(const void *item, const void *data) {
const struct output_config *output = item;
@@ -43,6 +44,7 @@ struct output_config *new_output_config(const char *name) {
oc->x = oc->y = -1;
oc->scale = -1;
oc->transform = -1;
+ oc->subpixel = WL_OUTPUT_SUBPIXEL_UNKNOWN;
return oc;
}
@@ -65,6 +67,9 @@ void merge_output_config(struct output_config *dst, struct output_config *src) {
if (src->scale != -1) {
dst->scale = src->scale;
}
+ if (src->subpixel != WL_OUTPUT_SUBPIXEL_UNKNOWN) {
+ dst->subpixel = src->subpixel;
+ }
if (src->refresh_rate != -1) {
dst->refresh_rate = src->refresh_rate;
}
@@ -187,10 +192,10 @@ 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 transform %d) (bg %s %s) (dpms %d)",
+ "position %d,%d scale %f subpixel %s transform %d) (bg %s %s) (dpms %d)",
oc->name, oc->enabled, oc->width, oc->height, oc->refresh_rate,
- oc->x, oc->y, oc->scale, oc->transform, oc->background,
- oc->background_option, oc->dpms_state);
+ oc->x, oc->y, oc->scale, sway_wl_output_subpixel_to_string(oc->subpixel),
+ oc->transform, oc->background, oc->background_option, oc->dpms_state);
return oc;
}
@@ -363,6 +368,14 @@ bool apply_output_config(struct output_config *oc, struct sway_output *output) {
sway_log(SWAY_DEBUG, "Set %s scale to %f", oc->name, oc->scale);
wlr_output_set_scale(wlr_output, oc->scale);
}
+
+ if (oc && (oc->subpixel != WL_OUTPUT_SUBPIXEL_UNKNOWN || config->reloading)) {
+ sway_log(SWAY_DEBUG, "Set %s subpixel to %s", oc->name,
+ sway_wl_output_subpixel_to_string(oc->subpixel));
+ wlr_output_set_subpixel(wlr_output, oc->subpixel);
+ output_damage_whole(output);
+ }
+
if (oc && oc->transform >= 0) {
sway_log(SWAY_DEBUG, "Set %s transform to %d", oc->name, oc->transform);
wlr_output_set_transform(wlr_output, oc->transform);
@@ -424,6 +437,8 @@ static void default_output_config(struct output_config *oc,
}
oc->x = oc->y = -1;
oc->scale = 1;
+ struct sway_output *output = wlr_output->data;
+ oc->subpixel = output->detected_subpixel;
oc->transform = WL_OUTPUT_TRANSFORM_NORMAL;
oc->dpms_state = DPMS_ON;
}