/* button background */
struct wlr_cursor *cur = view->server->seat.cursor;
enum ssd_part_type type = ssd_at(view, cur->x, cur->y);
- struct wlr_box box = ssd_box(view, type);
+ struct wlr_box box = ssd_visible_box(view, type);
if (isbutton(type) &&
wlr_box_contains_point(&box, cur->x, cur->y)) {
float *color = (float[4]){ 0.5, 0.5, 0.5, 0.5 };
/* buttons */
struct theme *theme = view->server->theme;
if (view->surface == seat->keyboard_state.focused_surface) {
- box = ssd_box(view, LAB_SSD_BUTTON_CLOSE);
+ box = ssd_visible_box(view, LAB_SSD_BUTTON_CLOSE);
render_icon(output, output_damage, &box,
theme->xbm_close_active_unpressed);
- box = ssd_box(view, LAB_SSD_BUTTON_MAXIMIZE);
+ box = ssd_visible_box(view, LAB_SSD_BUTTON_MAXIMIZE);
render_icon(output, output_damage, &box,
theme->xbm_maximize_active_unpressed);
- box = ssd_box(view, LAB_SSD_BUTTON_ICONIFY);
+ box = ssd_visible_box(view, LAB_SSD_BUTTON_ICONIFY);
render_icon(output, output_damage, &box,
theme->xbm_iconify_active_unpressed);
} else {
- box = ssd_box(view, LAB_SSD_BUTTON_CLOSE);
+ box = ssd_visible_box(view, LAB_SSD_BUTTON_CLOSE);
render_icon(output, output_damage, &box,
theme->xbm_close_inactive_unpressed);
- box = ssd_box(view, LAB_SSD_BUTTON_MAXIMIZE);
+ box = ssd_visible_box(view, LAB_SSD_BUTTON_MAXIMIZE);
render_icon(output, output_damage, &box,
theme->xbm_maximize_inactive_unpressed);
- box = ssd_box(view, LAB_SSD_BUTTON_ICONIFY);
+ box = ssd_visible_box(view, LAB_SSD_BUTTON_ICONIFY);
render_icon(output, output_damage, &box,
theme->xbm_iconify_inactive_unpressed);
}
return box;
}
+#define NR_BUTTONS (3)
+
+/**
+ * ssd_box - the 'full' decoration geometry which includes both visible
+ * and invisible parts. It typically includes an invisible margin outside
+ * the decoration.
+ */
static struct wlr_box
-ssd_interactive_box(struct view *view, enum ssd_part_type type)
+ssd_box(struct view *view, enum ssd_part_type type)
{
struct theme *theme = view->server->theme;
struct wlr_box box = { 0 };
box.width = view->w;
box.height = theme->title_height;
break;
+ case LAB_SSD_PART_TITLE:
+ box.x = view->x + corner_square / 2;
+ box.y = view->y - theme->title_height;
+ box.width = view->w - NR_BUTTONS * corner_square;
+ box.height = theme->title_height;
+ break;
case LAB_SSD_PART_CORNER_TOP_LEFT:
box.x = view->x - theme->border_width - INVISIBLE_MARGIN;
box.y = view->y - corner_square - INVISIBLE_MARGIN;
}
struct wlr_box
-ssd_box(struct view *view, enum ssd_part_type type)
+ssd_visible_box(struct view *view, enum ssd_part_type type)
{
struct theme *theme = view->server->theme;
struct wlr_box box = { 0 };
switch (type) {
case LAB_SSD_BUTTON_CLOSE:
- box = ssd_interactive_box(view, type);
+ box = ssd_box(view, type);
break;
case LAB_SSD_BUTTON_MAXIMIZE:
- box = ssd_interactive_box(view, type);
+ box = ssd_box(view, type);
break;
case LAB_SSD_BUTTON_ICONIFY:
- box = ssd_interactive_box(view, type);
+ box = ssd_box(view, type);
break;
case LAB_SSD_PART_TITLEBAR:
- box = ssd_interactive_box(view, type);
+ box = ssd_box(view, type);
box.x += theme->title_height;
box.width -= 2 * theme->title_height;
break;
case LAB_SSD_PART_TITLE:
- box = ssd_box(view, LAB_SSD_PART_TITLEBAR);
+ box = ssd_box(view, type);
if (view->title) {
- /* center align title vertically within allocated box */
+ /* center align title vertically */
box.y += (box.height - view->title->height) / 2;
box.width = view->title->width;
box.height = view->title->height;
}
break;
case LAB_SSD_PART_CORNER_TOP_LEFT:
- box = ssd_interactive_box(view, type);
+ box = ssd_box(view, type);
box.x += INVISIBLE_MARGIN;
box.y += INVISIBLE_MARGIN;
box.width -= INVISIBLE_MARGIN;
box.height -= INVISIBLE_MARGIN;
break;
case LAB_SSD_PART_CORNER_TOP_RIGHT:
- box = ssd_interactive_box(view, type);
+ box = ssd_box(view, type);
box.y += INVISIBLE_MARGIN;
box.width -= INVISIBLE_MARGIN;
box.height -= INVISIBLE_MARGIN;
break;
case LAB_SSD_PART_TOP:
- box = ssd_interactive_box(view, type);
+ box = ssd_box(view, type);
box.y += INVISIBLE_MARGIN;
box.height -= INVISIBLE_MARGIN;
break;
case LAB_SSD_PART_RIGHT:
- box = ssd_interactive_box(view, type);
+ box = ssd_box(view, type);
box.width -= INVISIBLE_MARGIN;
break;
case LAB_SSD_PART_BOTTOM:
- box = ssd_interactive_box(view, type);
+ box = ssd_box(view, type);
box.height -= INVISIBLE_MARGIN;
break;
case LAB_SSD_PART_LEFT:
- box = ssd_interactive_box(view, type);
+ box = ssd_box(view, type);
box.x += INVISIBLE_MARGIN;
box.width -= INVISIBLE_MARGIN;
break;
{
enum ssd_part_type type;
for (type = 0; type < LAB_SSD_END_MARKER; ++type) {
- struct wlr_box box = ssd_interactive_box(view, type);
+ struct wlr_box box = ssd_box(view, type);
if (wlr_box_contains_point(&box, lx, ly)) {
return type;
}
struct ssd_part *part;
wl_list_for_each(part, &view->ssd.parts, link) {
if (part->type == LAB_SSD_PART_TITLE) {
- part->box = ssd_box(view, LAB_SSD_PART_TITLEBAR);
+ part->box = ssd_box(view, part->type);
break;
}
}
+ if (part->type != LAB_SSD_PART_TITLE) {
+ return;
+ }
int max_width = part->box.width > 0 ? part->box.width : 1000;
view->impl->get_string_prop(view, "title"),
&font, theme->menu_items_active_text_color);
- part->box = ssd_box(view, LAB_SSD_PART_TITLE);
+ part->box = ssd_visible_box(view, part->type);
}
void
};
for (int i = 0; i < 4; i++) {
part = add_part(view, border[i]);
- part->box = ssd_box(view, border[i]);
+ part->box = ssd_visible_box(view, border[i]);
part->color.active = theme->window_active_border_color;
part->color.inactive = theme->window_inactive_border_color;
}
/* titlebar */
part = add_part(view, LAB_SSD_PART_TITLEBAR);
- part->box = ssd_box(view, LAB_SSD_PART_TITLEBAR);
+ part->box = ssd_visible_box(view, LAB_SSD_PART_TITLEBAR);
part->color.active = theme->window_active_title_bg_color;
part->color.inactive = theme->window_inactive_title_bg_color;
- /* title text */
- part = add_part(view, LAB_SSD_PART_TITLE);
- ssd_update_title(view);
- part->texture.active = &view->title;
- part->texture.inactive = &view->title;
-
/* titlebar top-left corner */
part = add_part(view, LAB_SSD_PART_CORNER_TOP_LEFT);
- part->box = ssd_box(view, part->type);
+ part->box = ssd_visible_box(view, part->type);
part->texture.active = &theme->corner_top_left_active_normal;
part->texture.inactive = &theme->corner_top_left_inactive_normal;
/* titlebar top-right corner */
part = add_part(view, LAB_SSD_PART_CORNER_TOP_RIGHT);
- part->box = ssd_box(view, part->type);
+ part->box = ssd_visible_box(view, part->type);
part->texture.active = &theme->corner_top_right_active_normal;
part->texture.inactive = &theme->corner_top_right_inactive_normal;
+
+ /* title text */
+ part = add_part(view, LAB_SSD_PART_TITLE);
+ ssd_update_title(view);
+ part->texture.active = &view->title;
+ part->texture.inactive = &view->title;
}
void
}
struct ssd_part *part;
wl_list_for_each(part, &view->ssd.parts, link) {
- part->box = ssd_box(view, part->type);
+ part->box = ssd_visible_box(view, part->type);
}
view->ssd.box.x = view->x;
view->ssd.box.y = view->y;