2022-08-22 07:12:54 +10:00
|
|
|
#include <string.h>
|
|
|
|
#include "sway/commands.h"
|
|
|
|
#include "sway/config.h"
|
2022-12-01 12:22:39 +11:00
|
|
|
#include "sway/tree/container.h"
|
2022-08-22 07:12:54 +10:00
|
|
|
#include "log.h"
|
|
|
|
|
2023-05-20 05:14:06 +10:00
|
|
|
bool cmd_corner_radius_parse_value(char *arg, int* result) {
|
|
|
|
char *inv;
|
|
|
|
int value = strtol(arg, &inv, 10);
|
|
|
|
if (*inv != '\0' || value < 0 || value > 99) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
*result = value;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2022-08-22 07:12:54 +10:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2023-05-20 05:14:06 +10:00
|
|
|
int value = 0;
|
|
|
|
if (!cmd_corner_radius_parse_value(argv[0], &value)) {
|
2022-08-22 07:12:54 +10:00
|
|
|
return cmd_results_new(CMD_FAILURE, "Invalid size specified");
|
|
|
|
}
|
|
|
|
|
|
|
|
config->corner_radius = value;
|
|
|
|
|
2022-12-01 12:22:39 +11:00
|
|
|
/*
|
|
|
|
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;
|
|
|
|
}
|
2022-08-22 07:12:54 +10:00
|
|
|
|
|
|
|
return cmd_results_new(CMD_SUCCESS, NULL);
|
|
|
|
}
|