aboutsummaryrefslogtreecommitdiffstats
path: root/sway/commands/output/subpixel.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/commands/output/subpixel.c')
-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}