summaryrefslogtreecommitdiff
path: root/sway/commands
diff options
context:
space:
mode:
authorWill McKinnon <[email protected]>2022-11-30 20:22:39 -0500
committerWill McKinnon <[email protected]>2022-11-30 20:22:39 -0500
commite82e4de37f5c6fe184da62f228329a37517ccd55 (patch)
tree0a247dd8dd1a20876125449bf4cf5c3fa1d5d75d /sway/commands
parentaf282928ab3123a573d9562bb24f5c471e3b4704 (diff)
fix: titlebars on containers with smart_gaps on and a large corner_radius now render as expected
Diffstat (limited to 'sway/commands')
-rw-r--r--sway/commands/corner_radius.c12
-rw-r--r--sway/commands/titlebar_padding.c25
2 files changed, 34 insertions, 3 deletions
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 <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) {
@@ -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];