ecore_wl2 : Organize window creation/deletion events.
authorWoochanlee <wc0917.lee@samsung.com>
Tue, 26 May 2020 15:49:16 +0000 (11:49 -0400)
committerJongmin Lee <jm105.lee@samsung.com>
Tue, 26 May 2020 22:28:14 +0000 (07:28 +0900)
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

src/lib/ecore_wl2/Ecore_Wl2.h
src/lib/ecore_wl2/ecore_wl2.c
src/lib/ecore_wl2/ecore_wl2_private.h
src/lib/ecore_wl2/ecore_wl2_window.c

index 4545955..c5e299b 100644 (file)
@@ -222,6 +222,13 @@ typedef struct _Ecore_Wl2_Event_Window_Deactivate
    unsigned int event_win;
 } Ecore_Wl2_Event_Window_Deactivate;
 
+typedef struct _Ecore_Wl2_Event_Window_Common
+{
+   unsigned int win;
+   unsigned int parent_win;
+   unsigned int event_win;
+} Ecore_Wl2_Event_Window_Common;
+
 /*
  * @ingroup Ecore_Wl2_Group
  *
@@ -834,6 +841,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 */
 // TIZEN_ONLY(20171107): added wl events from ecore_wayland to ecore_wl2
 EAPI extern int ECORE_WL2_EVENT_WINDOW_VISIBILITY_CHANGE;
 EAPI extern int ECORE_WL2_EVENT_WINDOW_PRE_VISIBILITY_CHANGE;
index 835f44f..8c08dee 100644 (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;
 // TIZEN_ONLY(20171107): added wl events from ecore_wayland to ecore_wl2
 EAPI int ECORE_WL2_EVENT_WINDOW_VISIBILITY_CHANGE = 0;
 EAPI int ECORE_WL2_EVENT_WINDOW_PRE_VISIBILITY_CHANGE = 0;
@@ -218,6 +220,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();
 // TIZEN_ONLY(20171107): added wl events from ecore_wayland to ecore_wl2
    ECORE_WL2_EVENT_WINDOW_VISIBILITY_CHANGE = ecore_event_type_new();
    ECORE_WL2_EVENT_WINDOW_PRE_VISIBILITY_CHANGE = ecore_event_type_new();
@@ -324,7 +328,9 @@ ecore_wl2_shutdown(void)
                           ECORE_WL2_EVENT_INDICATOR_FLICK,
                           ECORE_WL2_EVENT_CLIPBOARD_DATA_SELECTED,
                           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);
 
    //TIZEN_ONLY(20171216): add ecore_wl2_window_find
    _ecore_wl2_window_shutdown();
index bb0e643..bdb2c66 100644 (file)
@@ -349,6 +349,7 @@ struct _Ecore_Wl2_Window
      } wm_rot;
    Eina_Bool has_buffer : 1;
    Eina_Bool updating : 1;
+   Eina_Bool visible : 1;
 
    // TIZEN_ONLY(20171108) : indicator information
    struct
index cd5d075..ef37d86 100644 (file)
@@ -1024,6 +1024,7 @@ _ecore_wl2_window_show_send(Ecore_Wl2_Window *window)
    if (window->parent)
      ev->parent_win = window->parent->id;
    ev->event_win = window->id;
+   window->visible = EINA_TRUE;
    ecore_event_add(ECORE_WL2_EVENT_WINDOW_SHOW, ev, NULL, NULL);
 }
 
@@ -1039,9 +1040,27 @@ _ecore_wl2_window_hide_send(Ecore_Wl2_Window *window)
    if (window->parent)
      ev->parent_win = window->parent->id;
    ev->event_win = window->id;
+   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->id;
+   if (window->parent)
+     ev->parent_win = window->parent->id;
+   ev->event_win = window->id;
+
+   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)
 {
@@ -1090,6 +1109,8 @@ ecore_wl2_window_new(Ecore_Wl2_Display *display, Ecore_Wl2_Window *parent, int x
 
    _ecore_wl2_input_devices_send(ecore_wl2_input_default_input_get(display), win);
 
+   _ecore_wl2_window_create_destroy_send(win, EINA_TRUE);
+
    return win;
 }
 
@@ -1276,6 +1297,10 @@ ecore_wl2_window_free(Ecore_Wl2_Window *window)
    eina_hash_del(_windows, _ecore_wl2_window_id_str_get(window->id), 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)