EAPI int ecore_wl2_window_id_get(Ecore_Wl2_Window *window);
/**
+ * 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
*
* @param window The Ecore_Wl2_Window to get the surface of
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);
}
return window->id;
}
+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)
{
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)
_ecore_evas_wl_common_evas_engine_rsc_free,
};
+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)
{
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_wl2_window_id_get(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");