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 * corner_width, theme->border_width,
+ MAX(width - 2 * corner_width, 0), theme->border_width,
theme->border_width + corner_width,
-(ssd->titlebar.height + theme->border_width), color);
} FOR_EACH_END
: 0;
int top_width = ssd->titlebar.height <= 0 || ssd->state.was_squared
? full_width
- : width - 2 * corner_width;
+ : MAX(width - 2 * corner_width, 0);
int top_x = ssd->titlebar.height <= 0 || ssd->state.was_squared
? 0
: theme->border_width + corner_width;
struct wlr_scene_tree *parent, int width, int height,
int x, int y, float color[4])
{
- /*
- * When initialized without surface being mapped,
- * size may be negative. Just set to 0, next call
- * to ssd_*_update() will update the rect to use
- * its correct size.
- */
- width = width >= 0 ? width : 0;
- height = height >= 0 ? height : 0;
-
+ assert(width >= 0 && height >= 0);
struct ssd_part *part = add_scene_part(list, type);
part->node = &wlr_scene_rect_create(
parent, width, height, color)->node;
corner_scale_crop(struct wlr_scene_buffer *buffer, int horizontal_overlap,
int vertical_overlap, int corner_size)
{
- int width = corner_size - horizontal_overlap;
- int height = corner_size - vertical_overlap;
+ int width = MAX(corner_size - horizontal_overlap, 0);
+ int height = MAX(corner_size - vertical_overlap, 0);
struct wlr_fbox src_box = {
.x = horizontal_overlap,
.y = vertical_overlap,
y = -titlebar_height + inset;
wlr_scene_node_set_position(part->node, x, y);
wlr_scene_buffer_set_dest_size(
- scene_buf, visible_shadow_width, height - 2 * inset);
+ scene_buf, visible_shadow_width, MAX(height - 2 * inset, 0));
wlr_scene_node_set_enabled(part->node, show_sides);
break;
case LAB_SSD_PART_BOTTOM:
y = -titlebar_height + height;
wlr_scene_node_set_position(part->node, x, y);
wlr_scene_buffer_set_dest_size(
- scene_buf, width - 2 * inset, visible_shadow_width);
+ scene_buf, MAX(width - 2 * inset, 0), visible_shadow_width);
wlr_scene_node_set_enabled(part->node, show_topbottom);
break;
case LAB_SSD_PART_LEFT:
y = -titlebar_height + inset;
wlr_scene_node_set_position(part->node, x, y);
wlr_scene_buffer_set_dest_size(
- scene_buf, visible_shadow_width, height - 2 * inset);
+ scene_buf, visible_shadow_width, MAX(height - 2 * inset, 0));
wlr_scene_node_set_enabled(part->node, show_sides);
break;
case LAB_SSD_PART_TOP:
y = -titlebar_height - visible_shadow_width;
wlr_scene_node_set_position(part->node, x, y);
wlr_scene_buffer_set_dest_size(
- scene_buf, width - 2 * inset, visible_shadow_width);
+ scene_buf, MAX(width - 2 * inset, 0), visible_shadow_width);
wlr_scene_node_set_enabled(part->node, show_topbottom);
break;
default:
/* Background */
add_scene_rect(&subtree->parts, LAB_SSD_PART_TITLEBAR, parent,
- width - corner_width * 2, theme->titlebar_height,
+ MAX(width - corner_width * 2, 0), theme->titlebar_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);
part = ssd_get_part(&subtree->parts, LAB_SSD_PART_TITLEBAR);
wlr_scene_node_set_position(part->node, x, 0);
wlr_scene_rect_set_size(wlr_scene_rect_from_node(part->node),
- width - 2 * x, theme->titlebar_height);
+ MAX(width - 2 * x, 0), theme->titlebar_height);
part = ssd_get_part(&subtree->parts, LAB_SSD_PART_TITLEBAR_CORNER_LEFT);
wlr_scene_node_set_enabled(part->node, !enable);
update_visible_buttons(struct ssd *ssd)
{
struct view *view = ssd->view;
- 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;
+ struct theme *theme = view->server->theme;
+ int width = MAX(view->current.width - 2 * theme->window_titlebar_padding_width, 0);
+ int button_width = theme->window_button_width;
+ int button_spacing = 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);
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->titlebar_height);
+ MAX(width - bg_offset * 2, 0), theme->titlebar_height);
x = theme->window_titlebar_padding_width;
wl_list_for_each(b, &rc.title_buttons_left, link) {