From 9b5844b5338cc5542676b4c17b48c636c527d30d Mon Sep 17 00:00:00 2001 From: Guilhem Saurel Date: Fri, 29 Dec 2023 13:12:56 +0100 Subject: [PATCH] add --smart-titles flag to hide_edge_borders to hide the title bar on workspaces with one child, fix #7409 --- include/sway/config.h | 1 + sway/commands/hide_edge_borders.c | 9 ++++++++- sway/config.c | 1 + sway/sway.5.scd | 5 +++-- sway/tree/view.c | 10 ++++++++-- 5 files changed, 21 insertions(+), 5 deletions(-) diff --git a/include/sway/config.h b/include/sway/config.h index 71721393e..8d8d3ca0a 100644 --- a/include/sway/config.h +++ b/include/sway/config.h @@ -562,6 +562,7 @@ struct sway_config { enum edge_border_types hide_edge_borders; enum edge_border_smart_types hide_edge_borders_smart; bool hide_lone_tab; + bool hide_lone_title; // border colors struct { diff --git a/sway/commands/hide_edge_borders.c b/sway/commands/hide_edge_borders.c index 43bd6dc86..a3ebc8562 100644 --- a/sway/commands/hide_edge_borders.c +++ b/sway/commands/hide_edge_borders.c @@ -13,7 +13,13 @@ struct cmd_results *cmd_hide_edge_borders(int argc, char **argv) { } bool hide_lone_tab = false; - if (strcmp(*argv, "--i3") == 0) { + bool hide_lone_title = false; + if (strcmp(*argv, "--smart-titles") == 0) { + hide_lone_tab = true; + hide_lone_title = true; + ++argv; + --argc; + } else if (strcmp(*argv, "--i3") == 0) { hide_lone_tab = true; ++argv; --argc; @@ -41,6 +47,7 @@ struct cmd_results *cmd_hide_edge_borders(int argc, char **argv) { return cmd_results_new(CMD_INVALID, "%s", expected_syntax); } config->hide_lone_tab = hide_lone_tab; + config->hide_lone_title = hide_lone_title; arrange_root(); diff --git a/sway/config.c b/sway/config.c index 1090edc5c..5e48c6ec1 100644 --- a/sway/config.c +++ b/sway/config.c @@ -307,6 +307,7 @@ static void config_defaults(struct sway_config *config) { config->hide_edge_borders = E_NONE; config->hide_edge_borders_smart = ESMART_OFF; config->hide_lone_tab = false; + config->hide_lone_title = false; config->has_focused_tab_title = false; diff --git a/sway/sway.5.scd b/sway/sway.5.scd index bb958ebfd..ff65adbf4 100644 --- a/sway/sway.5.scd +++ b/sway/sway.5.scd @@ -764,10 +764,11 @@ The default colors are: This affects new workspaces only, and is used when the workspace doesn't have its own gaps settings (see: workspace gaps ...). -*hide_edge_borders* [--i3] none|vertical|horizontal|both|smart|smart_no_gaps +*hide_edge_borders* [--i3 | --smart-titles] none|vertical|horizontal|both|smart|smart_no_gaps Hides window borders adjacent to the screen edges. Default is _none_. The _--i3_ option enables i3-compatible behavior to hide the title bar on - tabbed and stacked containers with one child. The _smart_|_smart_no_gaps_ + tabbed and stacked containers with one child. The --smart-titles option + hide the title bar on workspaces with only one child. The _smart_|_smart_no_gaps_ options are equivalent to setting _smart_borders_ smart|no_gaps and _hide_edge_borders_ none. diff --git a/sway/tree/view.c b/sway/tree/view.c index 492095b93..07dd38701 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c @@ -355,8 +355,14 @@ void view_autoconfigure(struct sway_view *view) { height = con->pending.height - y_offset - con->pending.border_thickness * con->pending.border_bottom; } else { - y = con->pending.y + container_titlebar_height(); - height = con->pending.height - container_titlebar_height() + int titlebar_height; + if (config->hide_lone_title && view_is_only_visible(view)) { + titlebar_height = con->pending.border_thickness * con->pending.border_top + y_offset; + } else { + titlebar_height = container_titlebar_height(); + } + y = con->pending.y + titlebar_height; + height = con->pending.height - titlebar_height - con->pending.border_thickness * con->pending.border_bottom; } break;