summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authoramy <[email protected]>2024-10-27 19:14:24 -0500
committerGitHub <[email protected]>2024-10-27 19:14:24 -0500
commit5eaf99e89af029623297f08d684cd98449c81eb3 (patch)
tree6d139a90abffb3a706fdc40126c0701abfb8cd79 /examples
parent042ed3a4c2667d04613fe6800700e9b1943fdb70 (diff)
parentd998099612f0397234910ce753859ee127ec5b45 (diff)
Merge branch 'wlrfx:main' into mainHEADmain
Diffstat (limited to 'examples')
-rw-r--r--examples/meson.build2
-rw-r--r--examples/scene-graph.c15
2 files changed, 15 insertions, 2 deletions
diff --git a/examples/meson.build b/examples/meson.build
index da32934..dc6f171 100644
--- a/examples/meson.build
+++ b/examples/meson.build
@@ -17,7 +17,7 @@ foreach name, info : compositors
executable(
name,
[info.get('src'), extra_src],
- dependencies: [wlroots, scenefx, libdrm_header, info.get('dep', [])],
+ dependencies: [scenefx, libdrm_header, info.get('dep', [])],
build_by_default: get_option('examples'),
)
endforeach
diff --git a/examples/scene-graph.c b/examples/scene-graph.c
index 562f72e..e2e7d19 100644
--- a/examples/scene-graph.c
+++ b/examples/scene-graph.c
@@ -2,6 +2,7 @@
#include <assert.h>
#include <getopt.h>
#include <scenefx/render/fx_renderer/fx_renderer.h>
+#include <scenefx/types/wlr_scene.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
@@ -13,7 +14,6 @@
#include <wlr/render/wlr_renderer.h>
#include <wlr/types/wlr_compositor.h>
#include <wlr/types/wlr_output.h>
-#include <wlr/types/wlr_scene.h>
#include <wlr/types/wlr_xdg_shell.h>
#include <wlr/util/log.h>
@@ -22,6 +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 = 0; // TODO
struct server {
struct wl_display *display;
@@ -40,6 +41,7 @@ struct surface {
struct wlr_surface *wlr;
struct wlr_scene_surface *scene_surface;
struct wlr_scene_rect *border;
+ struct wlr_scene_shadow *shadow;
struct wl_list link;
struct wl_listener commit;
@@ -99,12 +101,16 @@ 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 * (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) {
struct surface *surface = wl_container_of(listener, surface, destroy);
wlr_scene_node_destroy(&surface->scene_surface->buffer->node);
wlr_scene_node_destroy(&surface->border->node);
+ wlr_scene_node_destroy(&surface->shadow->node);
wl_list_remove(&surface->destroy.link);
wl_list_remove(&surface->link);
free(surface);
@@ -130,8 +136,15 @@ static void server_handle_new_surface(struct wl_listener *listener,
0, 0, (float[4]){ 0.5f, 0.5f, 0.5f, 1 });
wlr_scene_node_set_position(&surface->border->node, pos, pos);
+ /* 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, blur_sigma, (float[4]){ 1.0f, 0.f, 0.f, 1.0f });
+ wlr_scene_node_set_position(&surface->shadow->node,
+ pos - blur_sigma, pos - blur_sigma);
surface->scene_surface =
wlr_scene_surface_create(&server->scene->tree, wlr_surface);
+ wlr_scene_buffer_set_corner_radius(surface->scene_surface->buffer, corner_radius);
wlr_scene_node_set_position(&surface->scene_surface->buffer->node,
pos + border_width, pos + border_width);