*<action name="ToggleDecorations" />*
Toggle decorations of focused window.
+ This is a 3-state action which can be executed multiple times:
+ - Only the titlebar will be hidden, borders and resize area are kept
+ - Remaining decorations will be disabled
+ - Decorations will be shown normally
+
+ By disabling the theme configuration 'keepBorder' the first step
+ will be removed and the action only toggles between on and off.
+
*<action name="ToggleFullscreen" />*
Toggle fullscreen state of focused window.
*<theme><cornerRadius>*
The radius of server side decoration top corners. Default is 8.
+*<theme><keepBorder>* [yes|no]
+ Even when disabling server side decorations via ToggleDecorations,
+ keep a small border (and resize area) around the window. Default is yes.
+
*<theme><font place="">*
The font to use for a specific element of a window, menu or OSD.
Places can be any of:
<theme>
<name></name>
<cornerRadius>8</cornerRadius>
+ <keepBorder>yes</keepBorder>
<font place="ActiveWindow">
<name>sans</name>
<size>10</size>
/* theme */
char *theme_name;
int corner_radius;
+ bool ssd_keep_border;
struct font font_activewindow;
struct font font_menuitem;
struct font font_osd;
/* The top of the view, containing buttons, title, .. */
struct {
- /* struct wlr_scene_tree *tree; unused for now */
+ int height;
+ struct wlr_scene_tree *tree;
struct ssd_sub_tree active;
struct ssd_sub_tree inactive;
} titlebar;
void ssd_update_title(struct ssd *ssd);
void ssd_update_geometry(struct ssd *ssd);
void ssd_destroy(struct ssd *ssd);
+bool ssd_titlebar_is_hidden(struct ssd *ssd);
+void ssd_titlebar_hide(struct ssd *ssd);
void ssd_enable_keybind_inhibit_indicator(struct ssd *ssd, bool enable);
bool mapped;
bool been_mapped;
bool ssd_enabled;
+ bool ssd_titlebar_hidden;
enum ssd_preference ssd_preference;
bool minimized;
bool maximized;
rc.theme_name = xstrdup(content);
} else if (!strcmp(nodename, "cornerradius.theme")) {
rc.corner_radius = atoi(content);
+ } else if (!strcasecmp(nodename, "keepBorder.theme")) {
+ set_bool(content, &rc.ssd_keep_border);
} else if (!strcmp(nodename, "name.font.theme")) {
fill_font(nodename, content, font_place);
} else if (!strcmp(nodename, "size.font.theme")) {
has_run = true;
rc.xdg_shell_server_side_deco = true;
+ rc.ssd_keep_border = true;
rc.corner_radius = 8;
init_font_defaults(&rc.font_activewindow);
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
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);
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)
{
add_scene_rect(&subtree->parts, LAB_SSD_PART_TOP, parent,
width - 2 * SSD_BUTTON_WIDTH, theme->border_width,
theme->border_width + SSD_BUTTON_WIDTH,
- -(theme->title_height + theme->border_width), color);
+ -(ssd->titlebar.height + theme->border_width), color);
} FOR_EACH_END
}
0, height);
continue;
case LAB_SSD_PART_TOP:
- wlr_scene_rect_set_size(rect,
- width - 2 * SSD_BUTTON_WIDTH,
- theme->border_width);
+ if (ssd->titlebar.height > 0) {
+ wlr_scene_rect_set_size(rect,
+ width - 2 * SSD_BUTTON_WIDTH,
+ theme->border_width);
+ wlr_scene_node_set_position(part->node,
+ theme->border_width + SSD_BUTTON_WIDTH,
+ -(ssd->titlebar.height + theme->border_width));
+ } else {
+ wlr_scene_rect_set_size(rect,
+ full_width, theme->border_width);
+ wlr_scene_node_set_position(part->node,
+ 0, -theme->border_width);
+ }
continue;
default:
continue;
wl_list_init(&ssd->extents.parts);
wlr_scene_node_set_position(&parent->node,
-(theme->border_width + extended_area),
- -(theme->title_height + theme->border_width + extended_area));
+ -(ssd->titlebar.height + theme->border_width + extended_area));
/* Initialize parts and set constant values for targeted geometry */
struct ssd_part *p;
int width = view->current.width;
int height = view->current.height;
- int full_height = height + theme->border_width * 2 + theme->title_height;
+ int full_height = height + theme->border_width * 2 + ssd->titlebar.height;
int full_width = width + 2 * theme->border_width;
int extended_area = SSD_EXTENDED_AREA;
int corner_size = extended_area + theme->border_width + SSD_BUTTON_WIDTH / 2;
struct ssd_part *part;
struct wlr_scene_rect *rect;
+ /* Make sure we update the y offset based on titlebar shown / hidden */
+ wlr_scene_node_set_position(&ssd->extents.tree->node,
+ -(theme->border_width + extended_area),
+ -(ssd->titlebar.height + theme->border_width + extended_area));
+
/* Convert usable area into layout coordinates */
struct wlr_box usable_area = view->output->usable_area;
usable_area.x += l_output->x;
struct wlr_buffer *maximize_button_unpressed;
struct wlr_buffer *close_button_unpressed;
+ ssd->titlebar.tree = wlr_scene_tree_create(ssd->tree);
+
struct ssd_sub_tree *subtree;
FOR_EACH_STATE(ssd, subtree) {
- subtree->tree = wlr_scene_tree_create(ssd->tree);
+ subtree->tree = wlr_scene_tree_create(ssd->titlebar.tree);
parent = subtree->tree;
wlr_scene_node_set_position(&parent->node, 0, -theme->title_height);
if (subtree == &ssd->titlebar.active) {
void
ssd_titlebar_destroy(struct ssd *ssd)
{
- if (!ssd->titlebar.active.tree) {
+ if (!ssd->titlebar.tree) {
return;
}
free(ssd->state.title.text);
ssd->state.title.text = NULL;
}
+
+ wlr_scene_node_destroy(&ssd->titlebar.tree->node);
+ ssd->titlebar.tree = NULL;
}
/*
view_toggle_decorations(struct view *view)
{
assert(view);
+ if (rc.ssd_keep_border && view->ssd_enabled && view->ssd
+ && !ssd_titlebar_is_hidden(view->ssd)) {
+ ssd_titlebar_hide(view->ssd);
+ view->ssd_titlebar_hidden = true;
+ if (!view_is_floating(view)) {
+ view_apply_special_geometry(view);
+ }
+ return;
+ }
view_set_decorations(view, !view->ssd_enabled);
}
decorate(view);
} else {
undecorate(view);
+ view->ssd_titlebar_hidden = false;
}
if (!view_is_floating(view)) {
view_apply_special_geometry(view);