Skip to content

Commit

Permalink
fixed position / size
Browse files Browse the repository at this point in the history
  • Loading branch information
WillPower3309 committed Oct 19, 2024
1 parent cf3c771 commit 3eabbee
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions examples/scene-graph.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* New surfaces are stacked on top of the existing ones as they appear. */

static const int border_width = 3;
static const int corner_radius = 5;
static const int corner_radius = 0; // TODO

struct server {
struct wl_display *display;
Expand Down Expand Up @@ -101,10 +101,9 @@ static void surface_handle_commit(struct wl_listener *listener, void *data) {
wlr_scene_rect_set_size(surface->border,
surface->wlr->current.width + 2 * border_width,
surface->wlr->current.height + 2 * border_width);

wlr_scene_shadow_set_size(surface->shadow,
surface->wlr->current.width + (2 * border_width + surface->shadow->blur_sigma),
surface->wlr->current.height + (2 * border_width + surface->shadow->blur_sigma));
surface->wlr->current.width + 2 * (surface->shadow->blur_sigma + border_width),
surface->wlr->current.height + 2 * (surface->shadow->blur_sigma + border_width));
}

static void surface_handle_destroy(struct wl_listener *listener, void *data) {
Expand Down Expand Up @@ -135,13 +134,15 @@ static void server_handle_new_surface(struct wl_listener *listener,
/* Border dimensions will be set in surface.commit handler */
surface->border = wlr_scene_rect_create(&server->scene->tree,
0, 0, (float[4]){ 0.5f, 0.5f, 0.5f, 1 });
wlr_scene_node_set_position(&surface->border->node, pos, pos);
wlr_scene_node_set_position(&surface->border->node, pos - border_width,
pos - border_width);

/* Shadow dimensions will be set in surface.commit handler */
float blur_sigma = 20.0f;
surface->shadow = wlr_scene_shadow_create(&server->scene->tree,
0, 0, corner_radius, 20.0, (float[4]){ 1.0f, 0.f, 0.f, 1.0f });
0, 0, corner_radius, blur_sigma, (float[4]){ 1.0f, 0.f, 0.f, 1.0f });
wlr_scene_node_set_position(&surface->shadow->node,
pos - border_width, pos - border_width);

pos - blur_sigma - border_width, pos - blur_sigma - border_width);
surface->scene_surface =
wlr_scene_surface_create(&server->scene->tree, wlr_surface);
wlr_scene_buffer_set_corner_radius(surface->scene_surface->buffer, corner_radius);
Expand Down

0 comments on commit 3eabbee

Please sign in to comment.