swayfx/sway/commands/dim_inactive.c
famfo 9f20a52638
Implement for_window support for dim_inactive (#109)
* Implement for_window support for dim_inactive

* Update file names, add check if the container is null, add docs

* Fix typo

* Update meson.build

* Update commands.c

* Update render.c

* Update container.c

* Update render.c

* Update container.h
2023-02-14 20:19:02 -05:00

28 lines
767 B
C

#include <string.h>
#include "sway/commands.h"
#include "sway/config.h"
#include "log.h"
#include "sway/output.h"
#include "sway/tree/container.h"
struct cmd_results *cmd_dim_inactive(int argc, char **argv) {
struct cmd_results *error = NULL;
if ((error = checkarg(argc, "dim_inactive", EXPECTED_EQUAL_TO, 1))) {
return error;
}
char *err;
float val = strtof(argv[0], &err);
if (*err || val < 0.0f || val > 1.0f) {
return cmd_results_new(CMD_INVALID, "dim_inactive float invalid");
}
struct sway_container *container = config->handler_context.container;
if (!container) {
return cmd_results_new(CMD_INVALID, "cmd_dim cannot be used without a for_window rule");
}
container->dim = val;
return cmd_results_new(CMD_SUCCESS, NULL);
}