summaryrefslogtreecommitdiff
path: root/sway/commands/corner_radius.c
blob: ab216f6e84fc8f678204de2963e22b6a84efac29 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <string.h>
#include "sway/commands.h"
#include "sway/config.h"
#include "sway/tree/container.h"
#include "log.h"

struct cmd_results *cmd_corner_radius(int argc, char **argv) {
	struct cmd_results *error = NULL;
	if ((error = checkarg(argc, "corner_radius", EXPECTED_EQUAL_TO, 1))) {
		return error;
	}

	char *inv;
	int value = strtol(argv[0], &inv, 10);
	if (*inv != '\0' || value < 0 || value > 99) {
		return cmd_results_new(CMD_FAILURE, "Invalid size specified");
	}

	config->corner_radius = value;

	/*
	 titlebar padding depends on corner_radius to
	 ensure that titlebars are rendered nicely
	*/
	if (value > config->titlebar_h_padding) {
		config->titlebar_h_padding = value;
	}
	if (value > (int)container_titlebar_height()) {
		config->titlebar_v_padding = (value - config->font_height) / 2;
	}

	return cmd_results_new(CMD_SUCCESS, NULL);
}