This commit is contained in:
2026-01-06 01:41:46 +07:00
parent 8995db6e1c
commit e4657bb3db
7 changed files with 95 additions and 19 deletions
+41
View File
@@ -22,3 +22,44 @@ struct absinthe_toplevel *absinthe_toplevel_at(struct absinthe_server *server, d
}
return tree->node.data;
}
void absinthe_toplevel_set_position(struct absinthe_toplevel *toplevel, int32_t x, int32_t y)
{
wlr_scene_node_set_position(&toplevel->scene_tree->node, x, y);
}
void absinthe_toplevel_set_size(struct absinthe_toplevel *toplevel, int32_t width, int32_t height)
{
if (width == toplevel->xdg_toplevel->current.width && height == toplevel->xdg_toplevel->current.height) {
return;
}
toplevel->geometry.width = width;
toplevel->geometry.height = height;
wlr_xdg_toplevel_set_size(toplevel->xdg_toplevel, width, height);
}
void absinthe_toplevel_update_border_geometry(struct absinthe_toplevel *toplevel)
{
int bw = ABSINTHE_BORDER_WIDTH;
wlr_scene_rect_set_size(toplevel->border[0], toplevel->geometry.width - 2 * bw, bw);
wlr_scene_rect_set_size(toplevel->border[1], toplevel->geometry.width - 2 * bw, bw);
wlr_scene_rect_set_size(toplevel->border[2], bw, toplevel->geometry.height);
wlr_scene_rect_set_size(toplevel->border[3], bw, toplevel->geometry.height);
wlr_scene_node_set_position(&toplevel->border[0]->node, 0, -bw);
wlr_scene_node_set_position(&toplevel->border[1]->node, 0, toplevel->geometry.height - 2 * bw);
wlr_scene_node_set_position(&toplevel->border[2]->node, -bw, -bw);
wlr_scene_node_set_position(&toplevel->border[3]->node, toplevel->geometry.width - 2 * bw, -bw);
absinthe_toplevel_set_size(toplevel, toplevel->geometry.width - 2 * bw, toplevel->geometry.height - 2 * bw);
}
void absinthe_toplevel_set_border_color(struct absinthe_toplevel *toplevel, const float color[4])
{
for (int i = 0; i < 4; ++i) {
wlr_scene_rect_set_color(toplevel->border[i], color);
}
}