theme: add window.titlebar.padding.{width,height}

...to replace padding.{width,height} to minimize breaking changes with the
visual appearance of the titlebar.

With the diverging labwc specification for the titlebar (listed below)
we have to choose between (a) not supporting the padding.{width,height}
option which exist in many extant Openbox themes to keep titlebar height
(almost) the same; or (b) making the allocated button areas much smaller
and not keeping the default hover going all the way to the edges. All in
all it just seems a lot simpler and cleaner to break this link to the
openbox spec.

Examples of previous change driving the requirement for this change:

- SVG and PNG support which often results in large icons with hover
  effects.
- Theme option window.button.{height,width}
- Larger default areas for icons (26x26)

In way of an example, Numix theme sets a padding.height of 6 which would
have resulted in a titlebar 12px taller without this change.
This commit is contained in:
Johan Malm 2024-10-08 17:52:57 +01:00
parent 383fb20bf4
commit e16e78e7a4
6 changed files with 36 additions and 29 deletions

View file

@ -74,7 +74,7 @@ ssd_titlebar_create(struct ssd *ssd)
/* Buttons */
struct title_button *b;
int x = theme->padding_width;
int x = theme->window_titlebar_padding_width;
/* Center vertically within titlebar */
int y = (theme->title_height - theme->window_button_height) / 2;
@ -87,7 +87,7 @@ ssd_titlebar_create(struct ssd *ssd)
x += theme->window_button_width + theme->window_button_spacing;
}
x = width - theme->padding_width + theme->window_button_spacing;
x = width - theme->window_titlebar_padding_width + theme->window_button_spacing;
wl_list_for_each_reverse(b, &rc.title_buttons_right, link) {
x -= theme->window_button_width + theme->window_button_spacing;
struct lab_data_buffer **buffers =
@ -211,7 +211,7 @@ static void
update_visible_buttons(struct ssd *ssd)
{
struct view *view = ssd->view;
int width = view->current.width - (2 * view->server->theme->padding_width);
int width = view->current.width - (2 * view->server->theme->window_titlebar_padding_width);
int button_width = view->server->theme->window_button_width;
int button_spacing = view->server->theme->window_button_spacing;
int button_count_left = wl_list_length(&rc.title_buttons_left);
@ -310,7 +310,7 @@ ssd_titlebar_update(struct ssd *ssd)
wlr_scene_rect_from_node(part->node),
width - bg_offset * 2, theme->title_height);
x = theme->padding_width;
x = theme->window_titlebar_padding_width;
wl_list_for_each(b, &rc.title_buttons_left, link) {
part = ssd_get_part(&subtree->parts, b->type);
wlr_scene_node_set_position(part->node, x, y);
@ -321,7 +321,7 @@ ssd_titlebar_update(struct ssd *ssd)
part = ssd_get_part(&subtree->parts, LAB_SSD_PART_TITLEBAR_CORNER_RIGHT);
wlr_scene_node_set_position(part->node, x, -rc.theme->border_width);
x = width - theme->padding_width + theme->window_button_spacing;
x = width - theme->window_titlebar_padding_width + theme->window_button_spacing;
wl_list_for_each_reverse(b, &rc.title_buttons_right, link) {
part = ssd_get_part(&subtree->parts, b->type);
x -= theme->window_button_width + theme->window_button_spacing;
@ -432,7 +432,7 @@ get_title_offsets(struct ssd *ssd, int *offset_left, int *offset_right)
struct ssd_sub_tree *subtree = &ssd->titlebar.active;
int button_width = ssd->view->server->theme->window_button_width;
int button_spacing = ssd->view->server->theme->window_button_spacing;
int padding_width = ssd->view->server->theme->padding_width;
int padding_width = ssd->view->server->theme->window_titlebar_padding_width;
*offset_left = padding_width;
*offset_right = padding_width;
@ -609,7 +609,7 @@ ssd_update_window_icon(struct ssd *ssd)
*/
int hpad = theme->window_button_width / 10;
int icon_size = MIN(theme->window_button_width - 2 * hpad,
theme->title_height - 2 * theme->padding_height);
theme->title_height - 2 * theme->window_titlebar_padding_height);
/*
* Load/render icons at the max scale of any usable output (at