Add keepBorder <theme> option and enable it by default

With the new keepBorder option enabled, the
ToggleDecorations action now has 3 states:

- the first time only disables the titlebar
- the second time disables the whole SSD
- the third time enables the whole SSD again

When the keepBorder action is disabled, the old 2-state
behavior is restored, e.g. the ToggleDecorations action
only toggles between on and off.

Fixes #813
This commit is contained in:
Consolatis 2023-04-14 09:01:13 +02:00
parent a6a03daae3
commit e39744f1d3
13 changed files with 91 additions and 10 deletions

View file

@ -25,13 +25,19 @@ ssd_thickness(struct view *view)
if (!view->ssd_enabled || view->fullscreen) {
return (struct border){ 0 };
}
struct theme *theme = view->server->theme;
return (struct border){
struct border thickness = {
.top = theme->title_height + theme->border_width,
.bottom = theme->border_width,
.left = theme->border_width,
.right = theme->border_width,
};
if (ssd_titlebar_is_hidden(view->ssd)) {
thickness.top -= theme->title_height;
}
return thickness;
}
struct wlr_box
@ -158,9 +164,14 @@ ssd_create(struct view *view, bool active)
ssd->view = view;
ssd->tree = wlr_scene_tree_create(view->scene_tree);
wlr_scene_node_lower_to_bottom(&ssd->tree->node);
ssd->titlebar.height = view->server->theme->title_height;
ssd_extents_create(ssd);
ssd_border_create(ssd);
ssd_titlebar_create(ssd);
if (rc.ssd_keep_border && view->ssd_titlebar_hidden) {
/* Ensure we keep the old state when exiting fullscreen */
ssd_titlebar_hide(ssd);
}
ssd->margin = ssd_thickness(view);
ssd_set_active(ssd, active);
ssd_enable_keybind_inhibit_indicator(ssd, view->inhibits_keybinds);
@ -198,6 +209,25 @@ ssd_update_geometry(struct ssd *ssd)
ssd->state.geometry = current;
}
bool
ssd_titlebar_is_hidden(struct ssd *ssd)
{
return ssd && !ssd->titlebar.tree->node.enabled;
}
void
ssd_titlebar_hide(struct ssd *ssd)
{
if (!ssd || !ssd->titlebar.tree->node.enabled) {
return;
}
wlr_scene_node_set_enabled(&ssd->titlebar.tree->node, false);
ssd->titlebar.height = 0;
ssd_border_update(ssd);
ssd_extents_update(ssd);
ssd->margin = ssd_thickness(ssd->view);
}
void
ssd_destroy(struct ssd *ssd)
{