diff options
author | Guido Günther <agx@sigxcpu.org> | 2018-04-23 09:53:46 +0200 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2018-04-23 12:52:05 +0200 |
commit | 32e043f996d00428731e9d97f8e45180574681b1 (patch) | |
tree | 101646e1bb387610b1e29f24427ea4bd01fd546f | |
parent | 5209c797026cc5c97d2abc796b70d43ceaaac519 (diff) |
examples: Allow to close the popup
So we can the xdg_popup_destroy path.
-rw-r--r-- | examples/layer-shell.c | 18 |
1 files 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++; } |