diff --git a/docs/labwc-actions.5.scd b/docs/labwc-actions.5.scd
index c847789e..bf28ebba 100644
--- a/docs/labwc-actions.5.scd
+++ b/docs/labwc-actions.5.scd
@@ -126,6 +126,23 @@ Actions are used in menus and keyboard/mouse bindings.
**
Disable server side decorations of focused window.
+**
+ Toggle titlebar of focused window.
+
+ If the 'keepBorder' configuration option is enabled (as in the default
+ configuraton), then a border will be left as the only decorations around the
+ window.
+
+ This has no effect on windows that do not have server side decorations.
+
+**
+ Hide titlebar of focused window.
+ See 'ToggleTitlebar' for details.
+
+**
+ Show titlebar of focused window.
+ See 'ToggleTitlebar' for details.
+
**
Toggle fullscreen state of focused window.
diff --git a/include/ssd.h b/include/ssd.h
index 5d0a32ee..c0ed37bd 100644
--- a/include/ssd.h
+++ b/include/ssd.h
@@ -65,7 +65,7 @@ void ssd_set_active(struct ssd *ssd, bool active);
void ssd_update_title(struct ssd *ssd);
void ssd_update_geometry(struct ssd *ssd);
void ssd_destroy(struct ssd *ssd);
-void ssd_titlebar_hide(struct ssd *ssd);
+void ssd_set_titlebar(struct ssd *ssd, bool enabled);
void ssd_enable_keybind_inhibit_indicator(struct ssd *ssd, bool enable);
void ssd_enable_shade(struct ssd *ssd, bool enable);
diff --git a/include/view.h b/include/view.h
index 11e4b5f5..841848c9 100644
--- a/include/view.h
+++ b/include/view.h
@@ -452,6 +452,7 @@ bool view_is_tiled(struct view *view);
bool view_is_floating(struct view *view);
void view_move_to_workspace(struct view *view, struct workspace *workspace);
void view_set_decorations(struct view *view, bool decorations);
+void view_set_titlebar(struct view *view, bool enabled);
void view_toggle_fullscreen(struct view *view);
void view_invalidate_last_layout_geometry(struct view *view);
void view_adjust_for_layout_change(struct view *view);
diff --git a/src/action.c b/src/action.c
index 4fd21d6a..75ee7b47 100644
--- a/src/action.c
+++ b/src/action.c
@@ -81,6 +81,9 @@ enum action_type {
ACTION_TYPE_TOGGLE_DECORATIONS,
ACTION_TYPE_DECORATE,
ACTION_TYPE_UNDECORATE,
+ ACTION_TYPE_TOGGLE_TITLEBAR,
+ ACTION_TYPE_SHOW_TITLEBAR,
+ ACTION_TYPE_HIDE_TITLEBAR,
ACTION_TYPE_TOGGLE_ALWAYS_ON_TOP,
ACTION_TYPE_TOGGLE_ALWAYS_ON_BOTTOM,
ACTION_TYPE_TOGGLE_OMNIPRESENT,
@@ -136,6 +139,9 @@ const char *action_names[] = {
"ToggleDecorations",
"Decorate",
"Undecorate",
+ "ToggleTitlebar",
+ "ShowTitlebar",
+ "HideTitlebar",
"ToggleAlwaysOnTop",
"ToggleAlwaysOnBottom",
"ToggleOmnipresent",
@@ -804,6 +810,21 @@ actions_run(struct view *activator, struct server *server,
view_set_decorations(view, false);
}
break;
+ case ACTION_TYPE_TOGGLE_TITLEBAR:
+ if (view) {
+ view_set_titlebar(view, view->ssd_titlebar_hidden);
+ }
+ break;
+ case ACTION_TYPE_SHOW_TITLEBAR:
+ if (view) {
+ view_set_titlebar(view, true);
+ }
+ break;
+ case ACTION_TYPE_HIDE_TITLEBAR:
+ if (view) {
+ view_set_titlebar(view, false);
+ }
+ break;
case ACTION_TYPE_TOGGLE_ALWAYS_ON_TOP:
if (view) {
view_toggle_always_on_top(view);
diff --git a/src/ssd/ssd.c b/src/ssd/ssd.c
index dd7f1b60..b910ae74 100644
--- a/src/ssd/ssd.c
+++ b/src/ssd/ssd.c
@@ -190,7 +190,7 @@ ssd_create(struct view *view, bool active)
ssd_titlebar_create(ssd);
if (view->ssd_titlebar_hidden) {
/* Ensure we keep the old state on Reconfigure or when exiting fullscreen */
- ssd_titlebar_hide(ssd);
+ ssd_set_titlebar(ssd, false);
}
ssd->margin = ssd_thickness(view);
ssd_set_active(ssd, active);
@@ -254,13 +254,13 @@ ssd_update_geometry(struct ssd *ssd)
}
void
-ssd_titlebar_hide(struct ssd *ssd)
+ssd_set_titlebar(struct ssd *ssd, bool enabled)
{
- if (!ssd || !ssd->titlebar.tree->node.enabled) {
+ if (!ssd || ssd->titlebar.tree->node.enabled == enabled) {
return;
}
- wlr_scene_node_set_enabled(&ssd->titlebar.tree->node, false);
- ssd->titlebar.height = 0;
+ wlr_scene_node_set_enabled(&ssd->titlebar.tree->node, enabled);
+ ssd->titlebar.height = enabled ? ssd->view->server->theme->title_height : 0;
ssd_border_update(ssd);
ssd_extents_update(ssd);
ssd->margin = ssd_thickness(ssd->view);
diff --git a/src/view.c b/src/view.c
index a00ef89a..b8cbec3a 100644
--- a/src/view.c
+++ b/src/view.c
@@ -1294,6 +1294,30 @@ view_set_decorations(struct view *view, bool decorations)
}
}
+void
+view_set_titlebar(struct view *view, bool enabled)
+{
+ /* Reject decoration toggles when shaded */
+ if (view->shaded) {
+ return;
+ }
+
+ if (enabled == !view->ssd_titlebar_hidden) {
+ return;
+ }
+
+ /*
+ * ssd_titlebar_hidden has to be set before calling
+ * ssd_titlebar_hide() to make ssd_thickness() happy.
+ */
+ view->ssd_titlebar_hidden = !enabled;
+ ssd_set_titlebar(view->ssd, enabled);
+
+ if (!view_is_floating(view)) {
+ view_apply_special_geometry(view);
+ }
+}
+
void
view_toggle_fullscreen(struct view *view)
{