aboutsummaryrefslogtreecommitdiffstats
path: root/sway/commands/output
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/commands/output
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/commands/output')
-rw-r--r--sway/commands/output/subpixel.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/sway/commands/output/subpixel.c b/sway/commands/output/subpixel.c
new file mode 100644
index 00000000..63191ee6
--- /dev/null
+++ b/sway/commands/output/subpixel.c
@@ -0,0 +1,36 @@
1#include <string.h>
2#include "log.h"
3#include "sway/commands.h"
4#include "sway/config.h"
5#include "sway/output.h"
6
7struct cmd_results *output_cmd_subpixel(int argc, char **argv) {
8 if (!config->handler_context.output_config) {
9 return cmd_results_new(CMD_FAILURE, "Missing output config");
10 }
11 if (!argc) {
12 return cmd_results_new(CMD_INVALID, "Missing subpixel argument.");
13 }
14 enum wl_output_subpixel subpixel;
15
16 if (strcmp(*argv, "rgb") == 0) {
17 subpixel = WL_OUTPUT_SUBPIXEL_HORIZONTAL_RGB;
18 } else if (strcmp(*argv, "bgr") == 0) {
19 subpixel = WL_OUTPUT_SUBPIXEL_HORIZONTAL_BGR;
20 } else if (strcmp(*argv, "vrgb") == 0) {
21 subpixel = WL_OUTPUT_SUBPIXEL_VERTICAL_RGB;
22 } else if (strcmp(*argv, "vbgr") == 0) {
23 subpixel = WL_OUTPUT_SUBPIXEL_VERTICAL_BGR;
24 } else if (strcmp(*argv, "none") == 0) {
25 subpixel = WL_OUTPUT_SUBPIXEL_NONE;
26 } else {
27 return cmd_results_new(CMD_INVALID, "Invalid output subpixel.");
28 }
29
30 struct output_config *oc = config->handler_context.output_config;
31 config->handler_context.leftovers.argc = argc - 1;
32 config->handler_context.leftovers.argv = argv + 1;
33
34 oc->subpixel = subpixel;
35 return NULL;
36}