mirror of
https://github.com/swaywm/sway.git
synced 2026-04-21 06:46:22 -04:00
Use fixed titlebar heights
Use fixed titlebar heights. The default height is calculated based on font metrics for the configured font and current locale. Some testing with titles with emoji and CJK characters (which are substantially higher in my setup) shows that the titlebars retain their initial value, text does shift up or down, and all titlebars always remain aligned. Also drop some also now-unecessary title_height calculations. Makes also needed to be updated, since they should be positioned with the same rules.
This commit is contained in:
parent
bb3fd0abc5
commit
62d90a8e95
11 changed files with 49 additions and 66 deletions
|
|
@ -991,31 +991,11 @@ int workspace_output_cmp_workspace(const void *a, const void *b) {
|
|||
return lenient_strcmp(wsa->workspace, wsb->workspace);
|
||||
}
|
||||
|
||||
static void find_font_height_iterator(struct sway_container *con, void *data) {
|
||||
size_t amount_below_baseline = con->title_height - con->title_baseline;
|
||||
size_t extended_height = config->font_baseline + amount_below_baseline;
|
||||
if (extended_height > config->font_height) {
|
||||
config->font_height = extended_height;
|
||||
}
|
||||
}
|
||||
|
||||
static void find_baseline_iterator(struct sway_container *con, void *data) {
|
||||
bool *recalculate = data;
|
||||
if (*recalculate) {
|
||||
container_calculate_title_height(con);
|
||||
}
|
||||
if (con->title_baseline > config->font_baseline) {
|
||||
config->font_baseline = con->title_baseline;
|
||||
}
|
||||
}
|
||||
void config_update_font_height(void) {
|
||||
int prev_max_height = config->font_height;
|
||||
|
||||
void config_update_font_height(bool recalculate) {
|
||||
size_t prev_max_height = config->font_height;
|
||||
config->font_height = 0;
|
||||
config->font_baseline = 0;
|
||||
|
||||
root_for_each_container(find_baseline_iterator, &recalculate);
|
||||
root_for_each_container(find_font_height_iterator, NULL);
|
||||
get_text_metrics(config->font, &config->font_height, &config->font_baseline);
|
||||
|
||||
if (config->font_height != prev_max_height) {
|
||||
arrange_root();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue