ecore_wl2 : Organize window creation/deletion events.

Summary:
Add create / destroy events.
Call hide event when the window terminated if the window was visible.

Reviewers: devilhorns, Hermet, raster

Reviewed By: devilhorns

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D11878
This commit is contained in:
Woochanlee 2020-05-26 11:49:16 -04:00 committed by Christopher Michael
parent d584696f12
commit 9ca13ef5c1
4 changed files with 43 additions and 1 deletions

View File

@ -320,6 +320,13 @@ typedef struct _Ecore_Wl2_Event_Window_Deactivate
Ecore_Wl2_Window *event_win;
} Ecore_Wl2_Event_Window_Deactivate;
typedef struct _Ecore_Wl2_Event_Window_Common
{
Ecore_Wl2_Window *win;
Ecore_Wl2_Window *parent_win;
Ecore_Wl2_Window *event_win;
} Ecore_Wl2_Event_Window_Common;
typedef struct _Ecore_Wl2_Event_Window_Iconify_State_Change
{
Ecore_Wl2_Window *win;
@ -422,6 +429,8 @@ EAPI extern int ECORE_WL2_EVENT_WINDOW_ACTIVATE; /** @since 1.20 */
EAPI extern int ECORE_WL2_EVENT_WINDOW_DEACTIVATE; /** @since 1.20 */
EAPI extern int ECORE_WL2_EVENT_WINDOW_ICONIFY_STATE_CHANGE; /** @since 1.21 */
EAPI extern int ECORE_WL2_EVENT_WINDOW_OFFSCREEN; /** @since 1.21 */
EAPI extern int ECORE_WL2_EVENT_WINDOW_CREATE; /** @since 1.25 */
EAPI extern int ECORE_WL2_EVENT_WINDOW_DESTROY; /** @since 1.25 */
typedef struct _Ecore_Wl2_Surface_Interface
{

View File

@ -58,6 +58,8 @@ EAPI int ECORE_WL2_EVENT_WINDOW_ACTIVATE = 0;
EAPI int ECORE_WL2_EVENT_WINDOW_DEACTIVATE = 0;
EAPI int ECORE_WL2_EVENT_WINDOW_ICONIFY_STATE_CHANGE = 0;
EAPI int ECORE_WL2_EVENT_WINDOW_OFFSCREEN = 0;
EAPI int ECORE_WL2_EVENT_WINDOW_CREATE = 0;
EAPI int ECORE_WL2_EVENT_WINDOW_DESTROY = 0;
EAPI int _ecore_wl2_event_window_www = -1;
EAPI int _ecore_wl2_event_window_www_drag = -1;
@ -203,6 +205,8 @@ ecore_wl2_init(void)
ECORE_WL2_EVENT_WINDOW_DEACTIVATE = ecore_event_type_new();
ECORE_WL2_EVENT_WINDOW_ICONIFY_STATE_CHANGE = ecore_event_type_new();
ECORE_WL2_EVENT_WINDOW_OFFSCREEN = ecore_event_type_new();
ECORE_WL2_EVENT_WINDOW_CREATE = ecore_event_type_new();
ECORE_WL2_EVENT_WINDOW_DESTROY = ecore_event_type_new();
if (!no_session_recovery)
no_session_recovery = !!getenv("EFL_NO_WAYLAND_SESSION_RECOVERY");
@ -277,7 +281,9 @@ ecore_wl2_shutdown(void)
ECORE_WL2_EVENT_WINDOW_ACTIVATE,
ECORE_WL2_EVENT_WINDOW_DEACTIVATE,
ECORE_WL2_EVENT_WINDOW_ICONIFY_STATE_CHANGE,
ECORE_WL2_EVENT_WINDOW_OFFSCREEN);
ECORE_WL2_EVENT_WINDOW_OFFSCREEN
ECORE_WL2_EVENT_WINDOW_CREATE,
ECORE_WL2_EVENT_WINDOW_DESTROY);
/* shutdown Ecore_Event */
ecore_event_shutdown();

View File

@ -266,6 +266,8 @@ struct _Ecore_Wl2_Window
Eina_Bool has_buffer : 1;
Eina_Bool updating : 1;
Eina_Bool deferred_minimize : 1;
Eina_Bool visible : 1;
};
struct _Ecore_Wl2_Output

View File

@ -519,6 +519,7 @@ _ecore_wl2_window_show_send(Ecore_Wl2_Window *window)
if (window->parent)
ev->parent_win = window->parent;
ev->event_win = window;
window->visible = EINA_TRUE;
ecore_event_add(ECORE_WL2_EVENT_WINDOW_SHOW, ev, NULL, NULL);
}
@ -534,9 +535,27 @@ _ecore_wl2_window_hide_send(Ecore_Wl2_Window *window)
if (window->parent)
ev->parent_win = window->parent;
ev->event_win = window;
window->visible = EINA_FALSE;
ecore_event_add(ECORE_WL2_EVENT_WINDOW_HIDE, ev, NULL, NULL);
}
static void
_ecore_wl2_window_create_destroy_send(Ecore_Wl2_Window *window, Eina_Bool create)
{
Ecore_Wl2_Event_Window_Hide *ev;
ev = calloc(1, sizeof(Ecore_Wl2_Event_Window_Common));
if (!ev) return;
ev->win = window;
if (window->parent)
ev->parent_win = window->parent;
ev->event_win = window;
if (create) ecore_event_add(ECORE_WL2_EVENT_WINDOW_CREATE, ev, NULL, NULL);
else ecore_event_add(ECORE_WL2_EVENT_WINDOW_DESTROY, ev, NULL, NULL);
}
EAPI Ecore_Wl2_Window *
ecore_wl2_window_new(Ecore_Wl2_Display *display, Ecore_Wl2_Window *parent, int x, int y, int w, int h)
{
@ -569,6 +588,8 @@ ecore_wl2_window_new(Ecore_Wl2_Display *display, Ecore_Wl2_Window *parent, int x
_ecore_wl2_window_surface_create(win);
_ecore_wl2_window_create_destroy_send(win, EINA_TRUE);
return win;
}
@ -692,6 +713,10 @@ ecore_wl2_window_free(Ecore_Wl2_Window *window)
EINA_SAFETY_ON_NULL_RETURN(window);
if (window->visible) _ecore_wl2_window_hide_send(window);
_ecore_wl2_window_create_destroy_send(window, EINA_FALSE);
display = window->display;
EINA_INLIST_FOREACH(display->inputs, input)