diff options
Diffstat (limited to 'sway/commands/max_render_time.c')
-rw-r--r-- | sway/commands/max_render_time.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/sway/commands/max_render_time.c b/sway/commands/max_render_time.c new file mode 100644 index 00000000..ec3282f1 --- /dev/null +++ b/sway/commands/max_render_time.c | |||
@@ -0,0 +1,32 @@ | |||
1 | #include <strings.h> | ||
2 | #include "sway/commands.h" | ||
3 | #include "sway/config.h" | ||
4 | #include "sway/tree/view.h" | ||
5 | |||
6 | struct cmd_results *cmd_max_render_time(int argc, char **argv) { | ||
7 | if (!argc) { | ||
8 | return cmd_results_new(CMD_INVALID, "Missing max render time argument."); | ||
9 | } | ||
10 | |||
11 | int max_render_time; | ||
12 | if (!strcmp(*argv, "off")) { | ||
13 | max_render_time = 0; | ||
14 | } else { | ||
15 | char *end; | ||
16 | max_render_time = strtol(*argv, &end, 10); | ||
17 | if (*end || max_render_time <= 0) { | ||
18 | return cmd_results_new(CMD_INVALID, "Invalid max render time."); | ||
19 | } | ||
20 | } | ||
21 | |||
22 | struct sway_container *container = config->handler_context.container; | ||
23 | if (!container || !container->view) { | ||
24 | return cmd_results_new(CMD_INVALID, | ||
25 | "Only views can have a max_render_time"); | ||
26 | } | ||
27 | |||
28 | struct sway_view *view = container->view; | ||
29 | view->max_render_time = max_render_time; | ||
30 | |||
31 | return cmd_results_new(CMD_SUCCESS, NULL); | ||
32 | } | ||