diff options
author | Ivan Molodetskikh <yalterz@gmail.com> | 2019-09-25 13:58:27 +0300 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2019-11-17 20:18:42 +0100 |
commit | 022df2542baa057b1965a7c7ee9c32e738f637d2 (patch) | |
tree | e650befe8f210c0fc44eb8fadf3b125c70a1b01f /sway/commands | |
parent | Add -Wno-missing-braces (diff) | |
download | sway-022df2542baa057b1965a7c7ee9c32e738f637d2.tar.gz sway-022df2542baa057b1965a7c7ee9c32e738f637d2.tar.zst sway-022df2542baa057b1965a7c7ee9c32e738f637d2.zip |
output: add max_render_time
Diffstat (limited to 'sway/commands')
-rw-r--r-- | sway/commands/output.c | 1 | ||||
-rw-r--r-- | sway/commands/output/max_render_time.c | 28 |
2 files changed, 29 insertions, 0 deletions
diff --git a/sway/commands/output.c b/sway/commands/output.c index 59bc598c..db2acb50 100644 --- a/sway/commands/output.c +++ b/sway/commands/output.c | |||
@@ -12,6 +12,7 @@ static struct cmd_handler output_handlers[] = { | |||
12 | { "disable", output_cmd_disable }, | 12 | { "disable", output_cmd_disable }, |
13 | { "dpms", output_cmd_dpms }, | 13 | { "dpms", output_cmd_dpms }, |
14 | { "enable", output_cmd_enable }, | 14 | { "enable", output_cmd_enable }, |
15 | { "max_render_time", output_cmd_max_render_time }, | ||
15 | { "mode", output_cmd_mode }, | 16 | { "mode", output_cmd_mode }, |
16 | { "pos", output_cmd_position }, | 17 | { "pos", output_cmd_position }, |
17 | { "position", output_cmd_position }, | 18 | { "position", output_cmd_position }, |
diff --git a/sway/commands/output/max_render_time.c b/sway/commands/output/max_render_time.c new file mode 100644 index 00000000..2d3cebe3 --- /dev/null +++ b/sway/commands/output/max_render_time.c | |||
@@ -0,0 +1,28 @@ | |||
1 | #include <strings.h> | ||
2 | #include "sway/commands.h" | ||
3 | #include "sway/config.h" | ||
4 | |||
5 | struct cmd_results *output_cmd_max_render_time(int argc, char **argv) { | ||
6 | if (!config->handler_context.output_config) { | ||
7 | return cmd_results_new(CMD_FAILURE, "Missing output config"); | ||
8 | } | ||
9 | if (!argc) { | ||
10 | return cmd_results_new(CMD_INVALID, "Missing max render time argument."); | ||
11 | } | ||
12 | |||
13 | int max_render_time; | ||
14 | if (!strcmp(*argv, "off")) { | ||
15 | max_render_time = 0; | ||
16 | } else { | ||
17 | char *end; | ||
18 | max_render_time = strtol(*argv, &end, 10); | ||
19 | if (*end || max_render_time <= 0) { | ||
20 | return cmd_results_new(CMD_INVALID, "Invalid max render time."); | ||
21 | } | ||
22 | } | ||
23 | config->handler_context.output_config->max_render_time = max_render_time; | ||
24 | |||
25 | config->handler_context.leftovers.argc = argc - 1; | ||
26 | config->handler_context.leftovers.argv = argv + 1; | ||
27 | return NULL; | ||
28 | } | ||