fix: titlebars on containers with smart_gaps on and a large corner_radius now render as expected
This commit is contained in:
parent
af282928ab
commit
e82e4de37f
|
@ -1,6 +1,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "sway/commands.h"
|
#include "sway/commands.h"
|
||||||
#include "sway/config.h"
|
#include "sway/config.h"
|
||||||
|
#include "sway/tree/container.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
struct cmd_results *cmd_corner_radius(int argc, char **argv) {
|
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;
|
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);
|
return cmd_results_new(CMD_SUCCESS, NULL);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#include "sway/commands.h"
|
#include "sway/commands.h"
|
||||||
#include "sway/config.h"
|
#include "sway/config.h"
|
||||||
#include "sway/output.h"
|
#include "sway/output.h"
|
||||||
|
#include "sway/swaynag.h"
|
||||||
#include "sway/tree/arrange.h"
|
#include "sway/tree/arrange.h"
|
||||||
#include "log.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) {
|
for (int i = 0; i < root->outputs->length; ++i) {
|
||||||
struct sway_output *output = root->outputs->items[i];
|
struct sway_output *output = root->outputs->items[i];
|
||||||
|
|
|
@ -563,14 +563,10 @@ static void render_titlebar(struct sway_output *output,
|
||||||
double output_x = output->lx;
|
double output_x = output->lx;
|
||||||
double output_y = output->ly;
|
double output_y = output->ly;
|
||||||
int titlebar_border_thickness = config->titlebar_border_thickness;
|
int titlebar_border_thickness = config->titlebar_border_thickness;
|
||||||
|
int titlebar_h_padding = config->titlebar_h_padding;
|
||||||
|
int titlebar_v_padding = config->titlebar_v_padding;
|
||||||
enum alignment title_align = config->title_align;
|
enum alignment title_align = config->title_align;
|
||||||
|
|
||||||
// titlebar padding should account for corner radius
|
|
||||||
int titlebar_h_padding = corner_radius > config->titlebar_h_padding ?
|
|
||||||
corner_radius : config->titlebar_h_padding;
|
|
||||||
float titlebar_v_padding = corner_radius == (int)container_titlebar_height() ?
|
|
||||||
(container_titlebar_height() - config->font_height) / 2.0 : config->titlebar_v_padding;
|
|
||||||
|
|
||||||
// Single pixel bar above title
|
// Single pixel bar above title
|
||||||
memcpy(&color, colors->border, sizeof(float) * 4);
|
memcpy(&color, colors->border, sizeof(float) * 4);
|
||||||
premultiply_alpha(color, alpha);
|
premultiply_alpha(color, alpha);
|
||||||
|
|
|
@ -676,9 +676,7 @@ void container_update_representation(struct sway_container *con) {
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t container_titlebar_height(void) {
|
size_t container_titlebar_height(void) {
|
||||||
int config_titlebar_height = config->font_height + config->titlebar_v_padding * 2;
|
return config->font_height + config->titlebar_v_padding * 2;
|
||||||
return config->corner_radius > config_titlebar_height ?
|
|
||||||
config->corner_radius : config_titlebar_height;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void floating_calculate_constraints(int *min_width, int *max_width,
|
void floating_calculate_constraints(int *min_width, int *max_width,
|
||||||
|
|
Loading…
Reference in a new issue