Centralize buffer preparation and standardize placement

This commit is contained in:
Jack Zeal 2026-03-28 09:01:21 -07:00
parent 90e652a8a1
commit d80dd2470b
16 changed files with 251 additions and 431 deletions

View file

@ -61,44 +61,8 @@ resize_indicator_init(struct view *view)
int bw = rc.theme->osd_border_width;
uint32_t colour32 = (uint32_t)(a*255) << 24 | (uint32_t)(r*255) << 16 | (uint32_t)(g*255) << 8 | (uint32_t)(b*255);
struct borderset * renderedborders = getBorders(colour32, bw, 1, 0);
struct lab_data_buffer *ttexture_buffer =
buffer_create_from_data(renderedborders->top, 1, 1, 4);
indicator->top = wlr_scene_buffer_create(indicator->tree, &ttexture_buffer->base);
struct lab_data_buffer *ltexture_buffer =
buffer_create_from_data(renderedborders->left, 1, 1, 4);
indicator->left = wlr_scene_buffer_create(indicator->tree, &ltexture_buffer->base);
struct lab_data_buffer *rtexture_buffer =
buffer_create_from_data(renderedborders->right, 1, 1, 4);
indicator->right = wlr_scene_buffer_create(indicator->tree, &rtexture_buffer->base);
struct lab_data_buffer *btexture_buffer =
buffer_create_from_data(renderedborders->bottom, 1, 1, 4);
indicator->bottom = wlr_scene_buffer_create(indicator->tree, &btexture_buffer->base);
struct lab_data_buffer *tltexture_buffer =
buffer_create_from_data(renderedborders->tl, bw, bw, 4*bw);
indicator->tl = wlr_scene_buffer_create(indicator->tree, &tltexture_buffer->base);
struct lab_data_buffer *trtexture_buffer =
buffer_create_from_data(renderedborders->tr, bw, bw, 4*bw);
indicator->tr = wlr_scene_buffer_create(indicator->tree, &trtexture_buffer->base);
struct lab_data_buffer *bltexture_buffer =
buffer_create_from_data(renderedborders->bl, bw, bw, 4*bw);
indicator->bl = wlr_scene_buffer_create(indicator->tree, &bltexture_buffer->base);
struct lab_data_buffer *brtexture_buffer =
buffer_create_from_data(renderedborders->br, bw, bw, 4*bw);
indicator->br = wlr_scene_buffer_create(indicator->tree, &brtexture_buffer->base);
struct borderset * renderedborders = getBorders(colour32, bw, BORDER_SINGLE, 0);
indicator->texturedBorders = generateBufferset(indicator->tree, renderedborders, bw);
}
@ -171,58 +135,8 @@ resize_indicator_set_size(struct resize_indicator *indicator, int width)
indicator->width - 2 * rc.theme->osd_border_width,
indicator->height - 2 * rc.theme->osd_border_width);
if (rc.theme->beveled_border) {
int height = indicator->height;
int border_width = rc.theme->osd_border_width;
wlr_scene_buffer_set_dest_size(indicator->top,
indicator->width, border_width);
wlr_scene_node_set_position(&indicator->top->node,
0,0);
wlr_scene_buffer_set_dest_size(indicator->bottom,
indicator->width, border_width);
wlr_scene_node_set_position(&indicator->bottom->node,
0, height - border_width);
wlr_scene_buffer_set_dest_size(indicator->left,
border_width, height - border_width * 2);
wlr_scene_node_set_position(&indicator->left->node,
0, border_width);
wlr_scene_buffer_set_dest_size(indicator->right,
border_width, height - border_width * 2);
wlr_scene_node_set_position(&indicator->right->node,
indicator->width - border_width, border_width);
wlr_scene_buffer_set_dest_size(indicator->tl,
border_width, border_width);
wlr_scene_node_set_position(&indicator->tl->node,
0,0);
wlr_scene_buffer_set_dest_size(indicator->tr,
border_width, border_width);
wlr_scene_node_set_position(&indicator->tr->node,
indicator->width-border_width, 0);
wlr_scene_buffer_set_dest_size(indicator->br,
border_width, border_width);
wlr_scene_node_set_position(&indicator->br->node,
indicator->width-border_width , height-border_width);
wlr_scene_buffer_set_dest_size(indicator->bl,
border_width, border_width);
wlr_scene_node_set_position(&indicator->bl->node,
0, height-border_width);
if (rc.theme->beveled_border) {
renderBufferset(indicator->texturedBorders, indicator->width, indicator->height, 0);
}
}

View file

@ -63,56 +63,9 @@ ssd_border_create(struct ssd *ssd)
float a = color[3];
uint32_t colour32 = (uint32_t)(a*255) << 24 | (uint32_t)(r*255) << 16 | (uint32_t)(g*255) << 8 | (uint32_t)(b*255);
struct borderset * renderedborders = getBorders(colour32, bw, 2, bevelSize);
struct lab_data_buffer *ttexture_buffer =
buffer_create_from_data(renderedborders->top, 1,theme->border_width,
4);
subtree->ttexture = wlr_scene_buffer_create(parent, &ttexture_buffer->base);
struct lab_data_buffer *btexture_buffer =
buffer_create_from_data(renderedborders->bottom, 1,theme->border_width,
4);
subtree->btexture = wlr_scene_buffer_create(parent, &btexture_buffer->base);
struct lab_data_buffer *ltexture_buffer =
buffer_create_from_data(renderedborders->left, theme->border_width, 1,
4*theme->border_width);
subtree->ltexture = wlr_scene_buffer_create(parent, &ltexture_buffer->base);
struct lab_data_buffer *rtexture_buffer =
buffer_create_from_data(renderedborders->right, theme->border_width, 1,
4*theme->border_width);
subtree->rtexture = wlr_scene_buffer_create(parent, &rtexture_buffer->base);
struct lab_data_buffer *tltexture_buffer =
buffer_create_from_data(renderedborders->tl, theme->border_width, theme->border_width,
4*theme->border_width);
subtree->tlcorner = wlr_scene_buffer_create(parent, &tltexture_buffer->base);
struct lab_data_buffer *trtexture_buffer =
buffer_create_from_data(renderedborders->tr, theme->border_width, theme->border_width,
4*theme->border_width);
subtree->trcorner = wlr_scene_buffer_create(parent, &trtexture_buffer->base);
struct lab_data_buffer *bltexture_buffer =
buffer_create_from_data(renderedborders->bl, theme->border_width, theme->border_width,
4*theme->border_width);
subtree->blcorner = wlr_scene_buffer_create(parent, &bltexture_buffer->base);
struct lab_data_buffer *brtexture_buffer =
buffer_create_from_data(renderedborders->br, theme->border_width, theme->border_width,
4*theme->border_width);
subtree->brcorner = wlr_scene_buffer_create(parent, &brtexture_buffer->base);
} else {
struct borderset * renderedborders = getBorders(colour32, bw, BORDER_DOUBLE, bevelSize);
subtree->texturedBorders = generateBufferset(subtree->tree, renderedborders, bw);
} else {
subtree->left = lab_wlr_scene_rect_create(parent,
theme->border_width, height, color);
@ -220,47 +173,7 @@ ssd_border_update(struct ssd *ssd)
if (theme->beveled_border) {
wlr_scene_buffer_set_dest_size(subtree->ttexture,
full_width, theme->border_width);
wlr_scene_node_set_position(&subtree->ttexture->node,
0, -(ssd->titlebar.height + theme->border_width));
wlr_scene_buffer_set_dest_size(subtree->rtexture,
theme->border_width, side_height+(ssd->titlebar.height + theme->border_width));
wlr_scene_node_set_position(&subtree->rtexture->node,
theme->border_width + width, -(ssd->titlebar.height + theme->border_width));
wlr_scene_buffer_set_dest_size(subtree->btexture,
full_width, theme->border_width);
wlr_scene_node_set_position(&subtree->btexture->node,
0, height);
wlr_scene_buffer_set_dest_size(subtree->ltexture,
theme->border_width, side_height+(ssd->titlebar.height + theme->border_width));
wlr_scene_node_set_position(&subtree->ltexture->node,
0, -(ssd->titlebar.height + theme->border_width));
wlr_scene_buffer_set_dest_size(subtree->tlcorner,
theme->border_width, theme->border_width);
wlr_scene_node_set_position(&subtree->tlcorner->node,
0, -(ssd->titlebar.height + theme->border_width));
wlr_scene_buffer_set_dest_size(subtree->trcorner,
theme->border_width, theme->border_width);
wlr_scene_node_set_position(&subtree->trcorner->node,
theme->border_width + width, -(ssd->titlebar.height + theme->border_width));
wlr_scene_buffer_set_dest_size(subtree->brcorner,
theme->border_width, theme->border_width);
wlr_scene_node_set_position(&subtree->brcorner->node,
theme->border_width + width, height);
wlr_scene_buffer_set_dest_size(subtree->blcorner,
theme->border_width, theme->border_width);
wlr_scene_node_set_position(&subtree->blcorner->node,
0, height);
renderBufferset(subtree->texturedBorders, full_width, side_height+(ssd->titlebar.height + 2*theme->border_width), -ssd->titlebar.height-theme->border_width);
} else {
wlr_scene_rect_set_size(subtree->left,
theme->border_width, side_height);