From e82e4de37f5c6fe184da62f228329a37517ccd55 Mon Sep 17 00:00:00 2001 From: Will McKinnon Date: Wed, 30 Nov 2022 20:22:39 -0500 Subject: fix: titlebars on containers with smart_gaps on and a large corner_radius now render as expected --- sway/commands/corner_radius.c | 12 +++++++++++- sway/commands/titlebar_padding.c | 25 +++++++++++++++++++++++-- 2 files changed, 34 insertions(+), 3 deletions(-) (limited to 'sway/commands') diff --git a/sway/commands/corner_radius.c b/sway/commands/corner_radius.c index ce1eff88..ab216f6e 100644 --- a/sway/commands/corner_radius.c +++ b/sway/commands/corner_radius.c @@ -1,6 +1,7 @@ #include #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) { @@ -17,7 +18,16 @@ struct cmd_results *cmd_corner_radius(int argc, char **argv) { config->corner_radius = value; - // TODO: rerender windows (see opacity cmd) + /* + 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); } diff --git a/sway/commands/titlebar_padding.c b/sway/commands/titlebar_padding.c index 29ce59ff..affb6b50 100644 --- a/sway/commands/titlebar_padding.c +++ b/sway/commands/titlebar_padding.c @@ -2,6 +2,7 @@ #include "sway/commands.h" #include "sway/config.h" #include "sway/output.h" +#include "sway/swaynag.h" #include "sway/tree/arrange.h" #include "log.h" @@ -27,8 +28,28 @@ struct cmd_results *cmd_titlebar_padding(int argc, char **argv) { } } - config->titlebar_v_padding = v_value; - config->titlebar_h_padding = h_value; + /* + titlebar padding depends on corner_radius to + ensure that titlebars are rendered nicely + */ + if (v_value > (config->corner_radius - config->font_height) / 2) { + config->titlebar_v_padding = v_value; + } else { + config_add_swaynag_warning( + "titlebar_v_padding (%d) is too small for the current corner radius (%d)", + v_value, config->corner_radius + ); + return cmd_results_new(CMD_FAILURE, NULL); + } + if (h_value > config->corner_radius) { + config->titlebar_h_padding = h_value; + } else { + config_add_swaynag_warning( + "titlebar_h_padding (%d) is too small for the current corner radius (%d)", + h_value, config->corner_radius + ); + return cmd_results_new(CMD_FAILURE, NULL); + } for (int i = 0; i < root->outputs->length; ++i) { struct sway_output *output = root->outputs->items[i]; -- cgit v1.2.3