diff options
author | Erik Reider <[email protected]> | 2022-11-12 01:38:09 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2022-11-11 19:38:09 -0500 |
commit | 1881b01d3fe1805d371589969b4a75b9cccd8d26 (patch) | |
tree | 9fab0420f88fa980e74f90e58d90a0c36952a880 /sway/commands/saturation.c | |
parent | 8c907a0bcb75d0e2f8629a9c7a73048bf7594e83 (diff) |
Per application color saturation support (#21)
* Initial implementation without fullscreen support
* Limit saturation to 2
* Fixed saturation not working for fullscreen applications like CSGO
* Fixed saturation ignoring border radius
* Updated README and sway.5 man page
* Rebased from Master
* Added command to README
* Fixed nitpicks
Diffstat (limited to 'sway/commands/saturation.c')
-rw-r--r-- | sway/commands/saturation.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/sway/commands/saturation.c b/sway/commands/saturation.c new file mode 100644 index 00000000..35f02128 --- /dev/null +++ b/sway/commands/saturation.c @@ -0,0 +1,43 @@ +#include <assert.h> +#include <stdio.h> +#include <stdlib.h> +#include <strings.h> +#include "sway/commands.h" +#include "sway/tree/view.h" +#include "log.h" + +struct cmd_results *cmd_saturation(int argc, char **argv) { + struct cmd_results *error = NULL; + if ((error = checkarg(argc, "saturation", EXPECTED_AT_LEAST, 1))) { + return error; + } + + struct sway_container *con = config->handler_context.container; + + if (con == NULL) { + return cmd_results_new(CMD_FAILURE, "No current container"); + } + + char *err; + float val = strtof(argc == 1 ? argv[0] : argv[1], &err); + if (*err) { + return cmd_results_new(CMD_INVALID, "saturation float invalid"); + } + + if (!strcasecmp(argv[0], "plus")) { + val = con->saturation + val; + } else if (!strcasecmp(argv[0], "minus")) { + val = con->saturation - val; + } else if (argc > 1 && strcasecmp(argv[0], "set")) { + return cmd_results_new(CMD_INVALID, + "Expected: set|plus|minus <0..2>: %s", argv[0]); + } + + if (val < 0 || val > 2) { + return cmd_results_new(CMD_FAILURE, "saturation value out of bounds"); + } + + con->saturation = val; + container_damage_whole(con); + return cmd_results_new(CMD_SUCCESS, NULL); +} |