2022-12-07 16:10:11 +11:00
|
|
|
#include <string.h>
|
|
|
|
#include "sway/commands.h"
|
|
|
|
#include "sway/config.h"
|
|
|
|
#include "log.h"
|
|
|
|
#include "sway/output.h"
|
2023-02-15 12:19:02 +11:00
|
|
|
#include "sway/tree/container.h"
|
2022-12-07 16:10:11 +11:00
|
|
|
|
|
|
|
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");
|
|
|
|
}
|
|
|
|
|
2023-02-15 12:19:02 +11:00
|
|
|
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");
|
|
|
|
}
|
2022-12-07 16:10:11 +11:00
|
|
|
|
2023-02-15 12:19:02 +11:00
|
|
|
container->dim = val;
|
2022-12-07 16:10:11 +11:00
|
|
|
return cmd_results_new(CMD_SUCCESS, NULL);
|
|
|
|
}
|