ecore_evas/wl2 0 fux xdg close cb for window when it's closed remotely

this should fix this:

https://matrix.org/_matrix/media/r0/download/matrix.org/lhFneENlWAjuXDaJfSYuJjjJ

unfortunately this means adding an api and then using it in ecore_evas.

@fix
This commit is contained in:
Carsten Haitzler 2019-10-14 19:12:25 +01:00
parent 90f40e43ff
commit eafb1109a5
4 changed files with 46 additions and 2 deletions

View File

@ -736,6 +736,18 @@ EAPI const char *ecore_wl2_display_name_get(const Ecore_Wl2_Display *display);
*/
EAPI Ecore_Wl2_Window *ecore_wl2_window_new(Ecore_Wl2_Display *display, Ecore_Wl2_Window *parent, int x, int y, int w, int h);
/**
* Set a callback to be caleld just before the window is closed and freed
*
* @param window The window to listen to for a xdg toplevel close callback
* @param cb The callback function to call being passed data and window
* @param data The Data pointer to pass as data to the callback
*
* @ingroup Ecore_Wl2_Window_Group
* @since 1.24
*/
EAPI void ecore_wl2_window_close_callback_set(Ecore_Wl2_Window *window, void (*cb) (void *data, Ecore_Wl2_Window *win), void *data);
/**
* Get the wl_surface which belongs to this window
*

View File

@ -191,6 +191,9 @@ struct _Ecore_Wl2_Window
struct zxdg_toplevel_v6 *zxdg_toplevel;
struct zxdg_popup_v6 *zxdg_popup;
void (*cb_close) (void *data, Ecore_Wl2_Window *win);
void *cb_close_data;
Eina_Stringshare *uuid;
void (*xdg_configure_ack)(struct xdg_surface *surface, uint32_t serial);

View File

@ -264,7 +264,11 @@ _xdg_toplevel_cb_close(void *data, struct xdg_toplevel *xdg_toplevel EINA_UNUSED
win = data;
if (!win) return;
if (win->cb_close)
{
win->cb_close(win->cb_close_data, win);
win->cb_close = NULL;
}
ecore_wl2_window_free(win);
}
@ -568,6 +572,14 @@ ecore_wl2_window_new(Ecore_Wl2_Display *display, Ecore_Wl2_Window *parent, int x
return win;
}
EAPI void
ecore_wl2_window_close_callback_set(Ecore_Wl2_Window *window, void (*cb) (void *data, Ecore_Wl2_Window *win), void *data)
{
EINA_SAFETY_ON_NULL_RETURN(window);
window->cb_close = cb;
window->cb_close_data = data;
}
EAPI struct wl_surface *
ecore_wl2_window_surface_get(Ecore_Wl2_Window *window)
{

View File

@ -1438,7 +1438,12 @@ _ecore_evas_wl_common_free(Ecore_Evas *ee)
if (wdata->frame) ecore_wl2_window_frame_callback_del(wdata->frame);
wdata->frame = NULL;
ecore_event_handler_del(wdata->sync_handler);
if (wdata->win) ecore_wl2_window_free(wdata->win);
if (wdata->win)
{
ecore_wl2_window_close_callback_set(wdata->win, NULL, NULL);
ecore_wl2_window_free(wdata->win);
wdata->win = NULL;
}
ecore_wl2_display_disconnect(wdata->display);
EINA_LIST_FREE(wdata->devices_list, device)
@ -2466,6 +2471,17 @@ static Ecore_Evas_Engine_Func _ecore_wl_engine_func =
NULL, //fn_last_tick_get
};
static void
_ecore_evas_wl_common_win_close(void *data, Ecore_Wl2_Window *win EINA_UNUSED)
{
Ecore_Evas *ee = data;
Ecore_Evas_Engine_Wl_Data *wdata = ee->engine.data;
if (ee->func.fn_delete_request) ee->func.fn_delete_request(ee);
wdata->win = NULL;
}
Ecore_Evas *
_ecore_evas_wl_common_new_internal(const char *disp_name, Ecore_Window parent, int x, int y, int w, int h, Eina_Bool frame, const int *opt, const char *engine_name)
{
@ -2553,6 +2569,7 @@ _ecore_evas_wl_common_new_internal(const char *disp_name, Ecore_Window parent, i
wdata->display = ewd;
wdata->win = ecore_wl2_window_new(ewd, p, x, y, w, h);
ecore_wl2_window_close_callback_set(wdata->win, _ecore_evas_wl_common_win_close, ee);
ee->prop.window = (Ecore_Window)wdata->win;
ee->prop.aux_hint.supported_list = ecore_wl2_window_aux_hints_supported_get(wdata->win);
ecore_evas_aux_hint_add(ee, "wm.policy.win.msg.use", "1");