Skip to content

Commit

Permalink
fix hiding lone titlebar
Browse files Browse the repository at this point in the history
  • Loading branch information
svalaskevicius committed Mar 8, 2024
1 parent 82e4a4c commit ecc2e16
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions sway/desktop/transaction.c
Expand Up @@ -287,14 +287,13 @@ static void arrange_container(struct sway_container *con,

static void arrange_children(enum sway_container_layout layout, list_t *children,
struct sway_container *active, struct wlr_scene_tree *content,
int width, int height, int gaps) {
int width, int height, int gaps, bool parent_asks_for_title_bars) {
int title_bar_height = container_titlebar_height();

if (layout == L_TABBED) {
struct sway_container *first = children->length == 1 ?
((struct sway_container *)children->items[0]) : NULL;
if (config->hide_lone_tab && first && first->view &&
first->current.border != B_NORMAL) {
bool show_titlebar = parent_asks_for_title_bars || !config->hide_lone_tab ||
(children->length > 1);
if (!show_titlebar) {
title_bar_height = 0;
}

Expand All @@ -312,19 +311,17 @@ static void arrange_children(enum sway_container_layout layout, list_t *children
wlr_scene_node_reparent(&child->scene_tree->node, content);

if (activated) {
arrange_container(child, width, height - title_bar_height,
false, 0);
arrange_container(child, width, height - title_bar_height, false, 0);
} else {
disable_container(child);
}

title_offset = next_title_offset;
}
} else if (layout == L_STACKED) {
struct sway_container *first = children->length == 1 ?
((struct sway_container *)children->items[0]) : NULL;
if (config->hide_lone_tab && first && first->view &&
first->current.border != B_NORMAL) {
bool show_titlebar = parent_asks_for_title_bars || !config->hide_lone_tab ||
(children->length > 1);
if (!show_titlebar) {
title_bar_height = 0;
}

Expand All @@ -341,8 +338,7 @@ static void arrange_children(enum sway_container_layout layout, list_t *children
wlr_scene_node_reparent(&child->scene_tree->node, content);

if (activated) {
arrange_container(child, width, height - title_height,
false, 0);
arrange_container(child, width, height - title_height, false, 0);
} else {
disable_container(child);
}
Expand All @@ -351,7 +347,8 @@ static void arrange_children(enum sway_container_layout layout, list_t *children
}
} else if (layout == L_VERT) {
int off = 0;
bool show_titlebar = !config->hide_lone_tab || (children->length > 1);
bool show_titlebar = parent_asks_for_title_bars || !config->hide_lone_tab ||
(children->length > 1);
for (int i = 0; i < children->length; i++) {
struct sway_container *child = children->items[i];
int cheight = child->current.height;
Expand All @@ -364,7 +361,8 @@ static void arrange_children(enum sway_container_layout layout, list_t *children
}
} else if (layout == L_HORIZ) {
int off = 0;
bool show_titlebar = !config->hide_lone_tab || (children->length > 1);
bool show_titlebar = parent_asks_for_title_bars || !config->hide_lone_tab ||
(children->length > 1);
for (int i = 0; i < children->length; i++) {
struct sway_container *child = children->items[i];
int cwidth = child->current.width;
Expand Down Expand Up @@ -454,7 +452,7 @@ static void arrange_container(struct sway_container *con,

arrange_children(con->current.layout, con->current.children,
con->current.focused_inactive_child, con->content_tree,
width, height, gaps);
width, height, gaps, title_bar);
}
}

Expand Down Expand Up @@ -534,7 +532,7 @@ static void arrange_workspace_tiling(struct sway_workspace *ws,
int width, int height) {
arrange_children(ws->current.layout, ws->current.tiling,
ws->current.focused_inactive_child, ws->layers.tiling,
width, height, ws->gaps_inner);
width, height, ws->gaps_inner, false);
}

static void disable_workspace(struct sway_workspace *ws) {
Expand Down

0 comments on commit ecc2e16

Please sign in to comment.