From 32e043f996d00428731e9d97f8e45180574681b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Mon, 23 Apr 2018 09:53:46 +0200 Subject: [PATCH] examples: Allow to close the popup So we can the xdg_popup_destroy path. --- examples/layer-shell.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/examples/layer-shell.c b/examples/layer-shell.c index 721fd69e..0e1d61ca 100644 --- a/examples/layer-shell.c +++ b/examples/layer-shell.c @@ -188,12 +188,20 @@ static void xdg_popup_configure(void *data, struct xdg_popup *xdg_popup, } } -static void xdg_popup_done(void *data, struct xdg_popup *xdg_popup) { +static void popup_destroy() +{ eglDestroySurface(egl.display, popup_egl_surface); wl_egl_window_destroy(popup_egl_window); - wl_surface_destroy(popup_wl_surface); xdg_popup_destroy(popup); + wl_surface_destroy(popup_wl_surface); + popup_wl_surface = NULL; popup = NULL; + popup_egl_window = NULL; +} + +static void xdg_popup_done(void *data, struct xdg_popup *xdg_popup) { + wlr_log(L_DEBUG, "Popup done"); + popup_destroy(); } static const struct xdg_popup_listener xdg_popup_listener = { @@ -300,7 +308,11 @@ static void wl_pointer_button(void *data, struct wl_pointer *wl_pointer, if (input_surface == wl_surface) { if (state == WL_POINTER_BUTTON_STATE_PRESSED) { if (button == BTN_RIGHT) { - create_popup(); + if (popup_wl_surface) { + popup_destroy(); + } else { + create_popup(); + } } else { buttons++; }