From 1f8ec20b5539f731b309bdd4f24c645a46c1d573 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Tue, 19 Dec 2017 21:32:31 +0100 Subject: [PATCH] Correctly destroy subsurfaces on window destroy --- src/wl_window.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/wl_window.c b/src/wl_window.c index d39267dd..71dfad4c 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -254,6 +254,24 @@ static void createDecorations(_GLFWwindow* window) window->wl.width + 2 * _GLFW_DECORATION_WIDTH, _GLFW_DECORATION_WIDTH); } +static void destroyDecoration(_GLFWdecorationWayland* decoration) +{ + if (decoration->surface) + wl_surface_destroy(decoration->surface); + if (decoration->subsurface) + wl_subsurface_destroy(decoration->subsurface); + if (decoration->viewport) + wp_viewport_destroy(decoration->viewport); +} + +static void destroyDecorations(_GLFWwindow* window) +{ + destroyDecoration(&window->wl.decorations.top); + destroyDecoration(&window->wl.decorations.left); + destroyDecoration(&window->wl.decorations.right); + destroyDecoration(&window->wl.decorations.bottom); +} + static void resizeWindow(_GLFWwindow* window, int width, int height) { wl_egl_window_resize(window->wl.native, width, height, 0, 0); @@ -783,6 +801,8 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window) if (window->context.destroy) window->context.destroy(window); + destroyDecorations(window); + if (window->wl.native) wl_egl_window_destroy(window->wl.native);