# THEME ELEMENTS
*border.width*
- Line width (integer) of border border drawn around window frames.
+ Line width (integer) of border drawn around window frames.
Default is 1.
+*padding.width*
+ Horizontal padding size, in pixels, between border and first
+ button on the left/right.
+ Default is 0.
+
*padding.height*
- Vertical padding size, used for spacing out elements in the window
- decorations. Default is 3.
+ Vertical padding size, in pixels, used for spacing out elements
+ in the window decorations.
+ Default is 3.
*titlebar.height*
Window title bar height.
Width of a titlebar button, in pixels.
Default is 26.
+*window.button.spacing*
+ Space between titlebar buttons, in pixels.
+ Default is 0.
+
*window.active.button.unpressed.image.color*
Color of the images in titlebar buttons in their default, unpressed,
state. This element is for the focused window.
# general
border.width: 1
+padding.width: 0
padding.height: 3
# The following options has no default, but fallbacks back to
window.inactive.label.text.color: #000000
window.label.text.justify: center
-# window button width
+# window button width and spacing
window.button.width: 26
+window.button.spacing: 0
# window buttons
window.active.button.unpressed.image.color: #000000
*/
struct ssd *ssd_create(struct view *view, bool active);
struct border ssd_get_margin(const struct ssd *ssd);
+int ssd_get_corner_width(void);
void ssd_update_margin(struct ssd *ssd);
void ssd_set_active(struct ssd *ssd, bool active);
void ssd_update_title(struct ssd *ssd);
struct theme {
int border_width;
+
+ /*
+ * the space between title bar border and
+ * buttons on the left/right/top
+ */
+ int padding_width;
int padding_height;
+
int title_height;
int menu_overlap_x;
int menu_overlap_y;
/* button width */
int window_button_width;
+ /* the space between buttons */
+ int window_button_spacing;
/* button colors */
float window_active_button_menu_unpressed_image_color[4];
void view_update_title(struct view *view);
void view_update_app_id(struct view *view);
void view_reload_ssd(struct view *view);
+int view_get_min_width(void);
void view_set_shade(struct view *view, bool shaded);
*geo = view->pending;
uint32_t resize_edges;
- int min_view_width = rc.theme->window_button_width * (
- wl_list_length(&rc.title_buttons_left) + wl_list_length(&rc.title_buttons_right));
+ int min_width = view_get_min_width();
/*
* First shrink the view along the relevant edge. The maximum shrink
*/
switch (direction) {
case VIEW_EDGE_RIGHT:
- geo->width = MAX(geo->width / 2, min_view_width);
+ geo->width = MAX(geo->width / 2, min_width);
geo->x = view->pending.x + view->pending.width - geo->width;
resize_edges = WLR_EDGE_LEFT;
break;
case VIEW_EDGE_LEFT:
- geo->width = MAX(geo->width / 2, min_view_width);
+ geo->width = MAX(geo->width / 2, min_width);
resize_edges = WLR_EDGE_RIGHT;
break;
case VIEW_EDGE_DOWN:
int width = view->current.width;
int height = view_effective_height(view, /* use_pending */ false);
int full_width = width + 2 * theme->border_width;
+ int corner_width = ssd_get_corner_width();
float *color;
struct wlr_scene_tree *parent;
add_scene_rect(&subtree->parts, LAB_SSD_PART_BOTTOM, parent,
full_width, theme->border_width, 0, height, color);
add_scene_rect(&subtree->parts, LAB_SSD_PART_TOP, parent,
- width - 2 * theme->window_button_width, theme->border_width,
- theme->border_width + theme->window_button_width,
+ width - 2 * corner_width, theme->border_width,
+ theme->border_width + corner_width,
-(ssd->titlebar.height + theme->border_width), color);
} FOR_EACH_END
int width = view->current.width;
int height = view_effective_height(view, /* use_pending */ false);
int full_width = width + 2 * theme->border_width;
+ int corner_width = ssd_get_corner_width();
/*
* From here on we have to cover the following border scenarios:
: 0;
int top_width = ssd->titlebar.height <= 0 || ssd->state.was_squared
? full_width
- : width - 2 * theme->window_button_width;
+ : width - 2 * corner_width;
int top_x = ssd->titlebar.height <= 0 || ssd->state.was_squared
? 0
- : theme->border_width + theme->window_button_width;
+ : theme->border_width + corner_width;
struct ssd_part *part;
struct wlr_scene_rect *rect;
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_width = ssd_get_corner_width();
int corner_size = extended_area + theme->border_width +
- MIN(theme->window_button_width, width) / 2;
+ MIN(corner_width, width) / 2;
int side_width = full_width + extended_area * 2 - corner_size * 2;
int side_height = full_height + extended_area * 2 - corner_size * 2;
struct view *view = ssd->view;
struct theme *theme = view->server->theme;
int width = view->current.width;
+ int corner_width = ssd_get_corner_width();
float *color;
struct wlr_scene_tree *parent;
/* Background */
add_scene_rect(&subtree->parts, LAB_SSD_PART_TITLEBAR, parent,
- width - theme->window_button_width * 2, theme->title_height,
- theme->window_button_width, 0, color);
+ width - corner_width * 2, theme->title_height,
+ corner_width, 0, color);
add_scene_buffer(&subtree->parts, LAB_SSD_PART_TITLEBAR_CORNER_LEFT, parent,
corner_top_left, -rc.theme->border_width, -rc.theme->border_width);
add_scene_buffer(&subtree->parts, LAB_SSD_PART_TITLEBAR_CORNER_RIGHT, parent,
- corner_top_right, width - theme->window_button_width,
+ corner_top_right, width - corner_width,
-rc.theme->border_width);
/* Buttons */
struct title_button *b;
- int x = 0;
+ int x = theme->padding_width;
wl_list_for_each(b, &rc.title_buttons_left, link) {
add_button(ssd, subtree, b->type, x);
- x += theme->window_button_width;
+ x += theme->window_button_width + theme->window_button_spacing;
}
- x = width;
+ x = width - theme->padding_width + theme->window_button_spacing;
wl_list_for_each_reverse(b, &rc.title_buttons_right, link) {
- x -= theme->window_button_width;
+ x -= theme->window_button_width + theme->window_button_spacing;
add_button(ssd, subtree, b->type, x);
}
} FOR_EACH_END
{
struct view *view = ssd->view;
int width = view->current.width;
+ int corner_width = ssd_get_corner_width();
struct theme *theme = view->server->theme;
struct ssd_part *part;
struct ssd_sub_tree *subtree;
- int x = enable ? 0 : theme->window_button_width;
+ int x = enable ? 0 : corner_width;
FOR_EACH_STATE(ssd, subtree) {
part = ssd_get_part(&subtree->parts, LAB_SSD_PART_TITLEBAR);
update_visible_buttons(struct ssd *ssd)
{
struct view *view = ssd->view;
- int width = view->current.width;
+ int width = view->current.width - (2 * view->server->theme->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);
int button_count_right = wl_list_length(&rc.title_buttons_right);
/* Make sure infinite loop never occurs */
assert(button_width > 0);
+
/*
* The corner-left button is lastly removed as it's usually a window
* menu button (or an app icon button in the future).
*/
- while (width < button_width * (button_count_left + button_count_right)) {
+ while (width <
+ ((button_width * (button_count_left + button_count_right)) +
+ (MAX((button_count_right - 1), 0) * button_spacing) +
+ (MAX((button_count_left - 1), 0) * button_spacing))) {
if (button_count_left > button_count_right) {
button_count_left--;
} else {
{
struct view *view = ssd->view;
int width = view->current.width;
+ int corner_width = ssd_get_corner_width();
struct theme *theme = view->server->theme;
bool maximized = view->maximized == VIEW_AXIS_BOTH;
struct ssd_part *part;
struct ssd_sub_tree *subtree;
struct title_button *b;
- int bg_offset = maximized || squared ? 0 : theme->window_button_width;
+ int bg_offset = maximized || squared ? 0 : corner_width;
FOR_EACH_STATE(ssd, subtree) {
part = ssd_get_part(&subtree->parts, LAB_SSD_PART_TITLEBAR);
wlr_scene_rect_set_size(
wlr_scene_rect_from_node(part->node),
width - bg_offset * 2, theme->title_height);
- x = 0;
+ x = theme->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, 0);
- x += theme->window_button_width;
+ x += theme->window_button_width + theme->window_button_spacing;
}
- x = width - theme->window_button_width;
+ x = width - corner_width;
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;
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;
wlr_scene_node_set_position(part->node, x, 0);
- x -= theme->window_button_width;
}
} FOR_EACH_END
ssd_update_title(ssd);
{
struct ssd_sub_tree *subtree = &ssd->titlebar.active;
int button_width = ssd->view->server->theme->window_button_width;
- *offset_left = 0;
- *offset_right = 0;
+ int button_spacing = ssd->view->server->theme->window_button_spacing;
+ int padding_width = ssd->view->server->theme->padding_width;
+ *offset_left = padding_width;
+ *offset_right = padding_width;
struct title_button *b;
wl_list_for_each(b, &rc.title_buttons_left, link) {
struct ssd_part *part = ssd_get_part(&subtree->parts, b->type);
if (part->node->enabled) {
+ *offset_left += *offset_left > padding_width ? button_spacing : 0;
*offset_left += button_width;
}
}
wl_list_for_each_reverse(b, &rc.title_buttons_right, link) {
struct ssd_part *part = ssd_get_part(&subtree->parts, b->type);
if (part->node->enabled) {
+ *offset_right += *offset_right > padding_width ? button_spacing : 0;
*offset_right += button_width;
}
}
ssd_should_be_squared(struct ssd *ssd)
{
struct view *view = ssd->view;
- int button_width = view->server->theme->window_button_width;
+ int corner_width = ssd_get_corner_width();
return (view_is_tiled_and_notify_tiled(view)
- || view->current.width < button_width * 2)
+ || view->current.width < corner_width * 2)
&& view->maximized != VIEW_AXIS_BOTH;
}
return ssd ? ssd->margin : (struct border){ 0 };
}
+int
+ssd_get_corner_width(void)
+{
+ /* ensure a minimum corner width */
+ return MAX(rc.corner_radius, 5);
+}
+
void
ssd_update_margin(struct ssd *ssd)
{
theme->window_label_text_justify = parse_justification("Center");
theme->menu_title_text_justify = parse_justification("Center");
+ theme->padding_width = 0;
theme->window_button_width = 26;
+ theme->window_button_spacing = 0;
parse_hexstr("#000000",
theme->window_active_button_menu_unpressed_image_color);
if (match_glob(key, "border.width")) {
theme->border_width = atoi(value);
}
+ if (match_glob(key, "padding.width")) {
+ theme->padding_width = atoi(value);
+ }
if (match_glob(key, "padding.height")) {
theme->padding_height = atoi(value);
}
theme->window_button_width = 1;
}
}
+ if (match_glob(key, "window.button.spacing")) {
+ theme->window_button_spacing = atoi(value);
+ }
/* universal button */
if (match_glob(key, "window.active.button.unpressed.image.color")) {
static void
create_corners(struct theme *theme)
{
+ int corner_width = ssd_get_corner_width();
+
struct wlr_box box = {
.x = 0,
.y = 0,
- .width = theme->window_button_width + theme->border_width,
+ .width = corner_width + theme->border_width,
.height = theme->title_height + theme->border_width,
};
{
assert(view);
struct view_size_hints hints = view_get_size_hints(view);
- int min_view_width = rc.theme->window_button_width * (
- wl_list_length(&rc.title_buttons_left) + wl_list_length(&rc.title_buttons_right));
+ int min_width = view_get_min_width();
/*
* "If a base size is not provided, the minimum size is to be
* This is currently always the case for xdg-shell views.
*/
if (hints.min_width < 1) {
- hints.min_width = min_view_width;
+ hints.min_width = min_width;
}
if (hints.min_height < 1) {
hints.min_height = LAB_MIN_VIEW_HEIGHT;
}
}
+int
+view_get_min_width(void)
+{
+ int button_count_left = wl_list_length(&rc.title_buttons_left);
+ int button_count_right = wl_list_length(&rc.title_buttons_right);
+ return (rc.theme->window_button_width * (button_count_left + button_count_right)) +
+ (rc.theme->window_button_spacing * MAX((button_count_right - 1), 0)) +
+ (rc.theme->window_button_spacing * MAX((button_count_left - 1), 0)) +
+ (2 * rc.theme->padding_width);
+}
+
void
view_toggle_keybinds(struct view *view)
{
static void
check_natural_geometry(struct view *view)
{
+ int min_width = view_get_min_width();
+
/*
* Some applications (example: Thonny) don't set a reasonable
* un-maximized size when started maximized. Try to detect this
* and set a fallback size.
*/
- int min_view_width = rc.theme->window_button_width * (
- wl_list_length(&rc.title_buttons_left) + wl_list_length(&rc.title_buttons_right));
if (!view_is_floating(view)
- && (view->natural_geometry.width < min_view_width
+ && (view->natural_geometry.width < min_width
|| view->natural_geometry.height < LAB_MIN_VIEW_HEIGHT)) {
view_set_fallback_natural_geometry(view);
}