diff --git a/WINGs/WINGs/WINGsP.h.in b/WINGs/WINGs/WINGsP.h.in index 7ec546a..9d26bf2 100644 --- a/WINGs/WINGs/WINGsP.h.in +++ b/WINGs/WINGs/WINGsP.h.in @@ -484,6 +484,7 @@ Bool W_IsValidView(struct W_View *view); void W_WL_EnqueueEvent(struct W_Screen *scr, const WMEvent *ev, struct W_View *target); void W_WL_InvalidateView(struct W_Screen *scr, struct W_View *target); +extern void (*W_ViewDestroyBackingFn)(unsigned long id); void W_WL_SetLoopDispatch(struct W_Screen *scr, int loop_fd, void (*dispatch_fn)(int timeout_ms, void *ud), diff --git a/WINGs/wview_wl.c b/WINGs/wview_wl.c index 5c08eea..8380dcf 100644 --- a/WINGs/wview_wl.c +++ b/WINGs/wview_wl.c @@ -14,6 +14,9 @@ static unsigned int wl_view_next_id = WL_VIEW_ID_BASE; /* Callback set by WM backend to commit frame_buf after paint */ void (*W_ViewCommitBackingFn)(unsigned long id) = NULL; +void (*W_ViewDestroyBackingFn)(unsigned long id) = NULL; + +extern void wl_view_destroy_backing_impl(unsigned long id); /* Simple view lookup table (ID → W_View*) */ #define VIEW_TABLE_SIZE 256 @@ -246,7 +249,8 @@ static void wl_destroy(void *vctx, W_View *view) { (void)vctx; W_WL_InvalidateView(view->screen, view); - /* Nothing to free — synthetic ID only */ + if (view->flags.topLevel && W_ViewDestroyBackingFn) + W_ViewDestroyBackingFn((unsigned long)view->window); } static void wl_set_background_color(void *vctx, W_View *view, WMColor *color) diff --git a/src/backend/wayland/wl_backend.c b/src/backend/wayland/wl_backend.c index df6bd75..68c3c49 100644 --- a/src/backend/wayland/wl_backend.c +++ b/src/backend/wayland/wl_backend.c @@ -2302,7 +2302,10 @@ wl_display_open(const char *name) { extern void (*W_ViewCommitBackingFn)(unsigned long id); extern void wl_view_commit_backing_impl(unsigned long id); + extern void wl_view_destroy_backing_impl(unsigned long id); W_ViewCommitBackingFn = wl_view_commit_backing_impl; + extern void (*W_ViewDestroyBackingFn)(unsigned long id); + W_ViewDestroyBackingFn = wl_view_destroy_backing_impl; } if (wl_state.scene) { wwarning("wl_backend: scene graph created"); @@ -6711,6 +6714,15 @@ void wl_view_commit_backing_impl(unsigned long id) } } +void wl_view_destroy_backing_impl(unsigned long id) +{ + struct wl_frame_buf *fb = frame_buf_find((WNativeWindow)id); + if (!fb) return; + wl_list_remove(&fb->link); + wlr_scene_node_destroy(&fb->scene_buf->node); + wlr_buffer_drop(&fb->base); +} + static void wl_client_synth_configure(WNativeWindow client_win, int x, int y, int width, int height,