mirror of
https://github.com/labwc/labwc.git
synced 2026-03-21 05:33:52 -04:00
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:
parent
a6a03daae3
commit
e39744f1d3
13 changed files with 91 additions and 10 deletions
|
|
@ -80,6 +80,14 @@ Actions are used in menus and keyboard/mouse bindings.
|
||||||
*<action name="ToggleDecorations" />*
|
*<action name="ToggleDecorations" />*
|
||||||
Toggle decorations of focused window.
|
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" />*
|
*<action name="ToggleFullscreen" />*
|
||||||
Toggle fullscreen state of focused window.
|
Toggle fullscreen state of focused window.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -218,6 +218,10 @@ Therefore, where multiple objects of the same kind are required (for example
|
||||||
*<theme><cornerRadius>*
|
*<theme><cornerRadius>*
|
||||||
The radius of server side decoration top corners. Default is 8.
|
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="">*
|
*<theme><font place="">*
|
||||||
The font to use for a specific element of a window, menu or OSD.
|
The font to use for a specific element of a window, menu or OSD.
|
||||||
Places can be any of:
|
Places can be any of:
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@
|
||||||
<theme>
|
<theme>
|
||||||
<name></name>
|
<name></name>
|
||||||
<cornerRadius>8</cornerRadius>
|
<cornerRadius>8</cornerRadius>
|
||||||
|
<keepBorder>yes</keepBorder>
|
||||||
<font place="ActiveWindow">
|
<font place="ActiveWindow">
|
||||||
<name>sans</name>
|
<name>sans</name>
|
||||||
<size>10</size>
|
<size>10</size>
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,7 @@ struct rcxml {
|
||||||
/* theme */
|
/* theme */
|
||||||
char *theme_name;
|
char *theme_name;
|
||||||
int corner_radius;
|
int corner_radius;
|
||||||
|
bool ssd_keep_border;
|
||||||
struct font font_activewindow;
|
struct font font_activewindow;
|
||||||
struct font font_menuitem;
|
struct font font_menuitem;
|
||||||
struct font font_osd;
|
struct font font_osd;
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,8 @@ struct ssd {
|
||||||
|
|
||||||
/* The top of the view, containing buttons, title, .. */
|
/* The top of the view, containing buttons, title, .. */
|
||||||
struct {
|
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 active;
|
||||||
struct ssd_sub_tree inactive;
|
struct ssd_sub_tree inactive;
|
||||||
} titlebar;
|
} titlebar;
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,8 @@ void ssd_set_active(struct ssd *ssd, bool active);
|
||||||
void ssd_update_title(struct ssd *ssd);
|
void ssd_update_title(struct ssd *ssd);
|
||||||
void ssd_update_geometry(struct ssd *ssd);
|
void ssd_update_geometry(struct ssd *ssd);
|
||||||
void ssd_destroy(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);
|
void ssd_enable_keybind_inhibit_indicator(struct ssd *ssd, bool enable);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -89,6 +89,7 @@ struct view {
|
||||||
bool mapped;
|
bool mapped;
|
||||||
bool been_mapped;
|
bool been_mapped;
|
||||||
bool ssd_enabled;
|
bool ssd_enabled;
|
||||||
|
bool ssd_titlebar_hidden;
|
||||||
enum ssd_preference ssd_preference;
|
enum ssd_preference ssd_preference;
|
||||||
bool minimized;
|
bool minimized;
|
||||||
bool maximized;
|
bool maximized;
|
||||||
|
|
|
||||||
|
|
@ -575,6 +575,8 @@ entry(xmlNode *node, char *nodename, char *content)
|
||||||
rc.theme_name = xstrdup(content);
|
rc.theme_name = xstrdup(content);
|
||||||
} else if (!strcmp(nodename, "cornerradius.theme")) {
|
} else if (!strcmp(nodename, "cornerradius.theme")) {
|
||||||
rc.corner_radius = atoi(content);
|
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")) {
|
} else if (!strcmp(nodename, "name.font.theme")) {
|
||||||
fill_font(nodename, content, font_place);
|
fill_font(nodename, content, font_place);
|
||||||
} else if (!strcmp(nodename, "size.font.theme")) {
|
} else if (!strcmp(nodename, "size.font.theme")) {
|
||||||
|
|
@ -780,6 +782,7 @@ rcxml_init(void)
|
||||||
has_run = true;
|
has_run = true;
|
||||||
|
|
||||||
rc.xdg_shell_server_side_deco = true;
|
rc.xdg_shell_server_side_deco = true;
|
||||||
|
rc.ssd_keep_border = true;
|
||||||
rc.corner_radius = 8;
|
rc.corner_radius = 8;
|
||||||
|
|
||||||
init_font_defaults(&rc.font_activewindow);
|
init_font_defaults(&rc.font_activewindow);
|
||||||
|
|
|
||||||
|
|
@ -25,13 +25,19 @@ ssd_thickness(struct view *view)
|
||||||
if (!view->ssd_enabled || view->fullscreen) {
|
if (!view->ssd_enabled || view->fullscreen) {
|
||||||
return (struct border){ 0 };
|
return (struct border){ 0 };
|
||||||
}
|
}
|
||||||
|
|
||||||
struct theme *theme = view->server->theme;
|
struct theme *theme = view->server->theme;
|
||||||
return (struct border){
|
struct border thickness = {
|
||||||
.top = theme->title_height + theme->border_width,
|
.top = theme->title_height + theme->border_width,
|
||||||
.bottom = theme->border_width,
|
.bottom = theme->border_width,
|
||||||
.left = theme->border_width,
|
.left = theme->border_width,
|
||||||
.right = theme->border_width,
|
.right = theme->border_width,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (ssd_titlebar_is_hidden(view->ssd)) {
|
||||||
|
thickness.top -= theme->title_height;
|
||||||
|
}
|
||||||
|
return thickness;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct wlr_box
|
struct wlr_box
|
||||||
|
|
@ -158,9 +164,14 @@ ssd_create(struct view *view, bool active)
|
||||||
ssd->view = view;
|
ssd->view = view;
|
||||||
ssd->tree = wlr_scene_tree_create(view->scene_tree);
|
ssd->tree = wlr_scene_tree_create(view->scene_tree);
|
||||||
wlr_scene_node_lower_to_bottom(&ssd->tree->node);
|
wlr_scene_node_lower_to_bottom(&ssd->tree->node);
|
||||||
|
ssd->titlebar.height = view->server->theme->title_height;
|
||||||
ssd_extents_create(ssd);
|
ssd_extents_create(ssd);
|
||||||
ssd_border_create(ssd);
|
ssd_border_create(ssd);
|
||||||
ssd_titlebar_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->margin = ssd_thickness(view);
|
||||||
ssd_set_active(ssd, active);
|
ssd_set_active(ssd, active);
|
||||||
ssd_enable_keybind_inhibit_indicator(ssd, view->inhibits_keybinds);
|
ssd_enable_keybind_inhibit_indicator(ssd, view->inhibits_keybinds);
|
||||||
|
|
@ -198,6 +209,25 @@ ssd_update_geometry(struct ssd *ssd)
|
||||||
ssd->state.geometry = current;
|
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
|
void
|
||||||
ssd_destroy(struct ssd *ssd)
|
ssd_destroy(struct ssd *ssd)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ ssd_border_create(struct ssd *ssd)
|
||||||
add_scene_rect(&subtree->parts, LAB_SSD_PART_TOP, parent,
|
add_scene_rect(&subtree->parts, LAB_SSD_PART_TOP, parent,
|
||||||
width - 2 * SSD_BUTTON_WIDTH, theme->border_width,
|
width - 2 * SSD_BUTTON_WIDTH, theme->border_width,
|
||||||
theme->border_width + SSD_BUTTON_WIDTH,
|
theme->border_width + SSD_BUTTON_WIDTH,
|
||||||
-(theme->title_height + theme->border_width), color);
|
-(ssd->titlebar.height + theme->border_width), color);
|
||||||
} FOR_EACH_END
|
} FOR_EACH_END
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -82,9 +82,19 @@ ssd_border_update(struct ssd *ssd)
|
||||||
0, height);
|
0, height);
|
||||||
continue;
|
continue;
|
||||||
case LAB_SSD_PART_TOP:
|
case LAB_SSD_PART_TOP:
|
||||||
wlr_scene_rect_set_size(rect,
|
if (ssd->titlebar.height > 0) {
|
||||||
width - 2 * SSD_BUTTON_WIDTH,
|
wlr_scene_rect_set_size(rect,
|
||||||
theme->border_width);
|
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;
|
continue;
|
||||||
default:
|
default:
|
||||||
continue;
|
continue;
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ ssd_extents_create(struct ssd *ssd)
|
||||||
wl_list_init(&ssd->extents.parts);
|
wl_list_init(&ssd->extents.parts);
|
||||||
wlr_scene_node_set_position(&parent->node,
|
wlr_scene_node_set_position(&parent->node,
|
||||||
-(theme->border_width + extended_area),
|
-(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 */
|
/* Initialize parts and set constant values for targeted geometry */
|
||||||
struct ssd_part *p;
|
struct ssd_part *p;
|
||||||
|
|
@ -110,7 +110,7 @@ ssd_extents_update(struct ssd *ssd)
|
||||||
|
|
||||||
int width = view->current.width;
|
int width = view->current.width;
|
||||||
int height = view->current.height;
|
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 full_width = width + 2 * theme->border_width;
|
||||||
int extended_area = SSD_EXTENDED_AREA;
|
int extended_area = SSD_EXTENDED_AREA;
|
||||||
int corner_size = extended_area + theme->border_width + SSD_BUTTON_WIDTH / 2;
|
int corner_size = extended_area + theme->border_width + SSD_BUTTON_WIDTH / 2;
|
||||||
|
|
@ -122,6 +122,11 @@ ssd_extents_update(struct ssd *ssd)
|
||||||
struct ssd_part *part;
|
struct ssd_part *part;
|
||||||
struct wlr_scene_rect *rect;
|
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 */
|
/* Convert usable area into layout coordinates */
|
||||||
struct wlr_box usable_area = view->output->usable_area;
|
struct wlr_box usable_area = view->output->usable_area;
|
||||||
usable_area.x += l_output->x;
|
usable_area.x += l_output->x;
|
||||||
|
|
|
||||||
|
|
@ -34,9 +34,11 @@ ssd_titlebar_create(struct ssd *ssd)
|
||||||
struct wlr_buffer *maximize_button_unpressed;
|
struct wlr_buffer *maximize_button_unpressed;
|
||||||
struct wlr_buffer *close_button_unpressed;
|
struct wlr_buffer *close_button_unpressed;
|
||||||
|
|
||||||
|
ssd->titlebar.tree = wlr_scene_tree_create(ssd->tree);
|
||||||
|
|
||||||
struct ssd_sub_tree *subtree;
|
struct ssd_sub_tree *subtree;
|
||||||
FOR_EACH_STATE(ssd, 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;
|
parent = subtree->tree;
|
||||||
wlr_scene_node_set_position(&parent->node, 0, -theme->title_height);
|
wlr_scene_node_set_position(&parent->node, 0, -theme->title_height);
|
||||||
if (subtree == &ssd->titlebar.active) {
|
if (subtree == &ssd->titlebar.active) {
|
||||||
|
|
@ -138,7 +140,7 @@ ssd_titlebar_update(struct ssd *ssd)
|
||||||
void
|
void
|
||||||
ssd_titlebar_destroy(struct ssd *ssd)
|
ssd_titlebar_destroy(struct ssd *ssd)
|
||||||
{
|
{
|
||||||
if (!ssd->titlebar.active.tree) {
|
if (!ssd->titlebar.tree) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -153,6 +155,9 @@ ssd_titlebar_destroy(struct ssd *ssd)
|
||||||
free(ssd->state.title.text);
|
free(ssd->state.title.text);
|
||||||
ssd->state.title.text = NULL;
|
ssd->state.title.text = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wlr_scene_node_destroy(&ssd->titlebar.tree->node);
|
||||||
|
ssd->titlebar.tree = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
10
src/view.c
10
src/view.c
|
|
@ -658,6 +658,15 @@ void
|
||||||
view_toggle_decorations(struct view *view)
|
view_toggle_decorations(struct view *view)
|
||||||
{
|
{
|
||||||
assert(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);
|
view_set_decorations(view, !view->ssd_enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -748,6 +757,7 @@ view_set_decorations(struct view *view, bool decorations)
|
||||||
decorate(view);
|
decorate(view);
|
||||||
} else {
|
} else {
|
||||||
undecorate(view);
|
undecorate(view);
|
||||||
|
view->ssd_titlebar_hidden = false;
|
||||||
}
|
}
|
||||||
if (!view_is_floating(view)) {
|
if (!view_is_floating(view)) {
|
||||||
view_apply_special_geometry(view);
|
view_apply_special_geometry(view);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue