ecore-wl2: Add function to find a window based on surface
authorChris Michael <cp.michael@samsung.com>
Thu, 10 Sep 2015 17:21:02 +0000 (13:21 -0400)
committerChris Michael <cp.michael@samsung.com>
Thu, 3 Dec 2015 17:02:40 +0000 (12:02 -0500)
Signed-off-by: Chris Michael <cp.michael@samsung.com>
src/lib/ecore_wl2/ecore_wl2_display.c
src/lib/ecore_wl2/ecore_wl2_private.h
src/lib/ecore_wl2/ecore_wl2_window.c

index 8fea4fc..97867a8 100644 (file)
@@ -234,6 +234,23 @@ _ecore_wl2_display_cleanup(Ecore_Wl2_Display *ewd)
    eina_hash_free(ewd->globals);
 }
 
+Ecore_Wl2_Window *
+_ecore_wl2_display_window_surface_find(Ecore_Wl2_Display *display, struct wl_surface *wl_surface)
+{
+   Ecore_Wl2_Window *window;
+
+   if ((!display) || (!wl_surface)) return NULL;
+
+   EINA_INLIST_FOREACH(display->windows, window)
+     {
+        if ((window->surface) &&
+            (window->surface == wl_surface))
+          return window;
+     }
+
+   return NULL;
+}
+
 EAPI Ecore_Wl2_Display *
 ecore_wl2_display_create(const char *name)
 {
index 6555cdf..3c87cae 100644 (file)
@@ -60,6 +60,7 @@ struct _Ecore_Wl2_Display
 
    Eina_Hash *globals;
 
+   Eina_Inlist *windows;
    Eina_Inlist *outputs;
    Eina_Inlist *inputs;
 
@@ -68,6 +69,8 @@ struct _Ecore_Wl2_Display
 
 struct _Ecore_Wl2_Window
 {
+   EINA_INLIST;
+
    Ecore_Wl2_Display *display;
 
    Ecore_Wl2_Window *parent;
@@ -183,6 +186,8 @@ struct _Ecore_Wl2_Input
      } repeat;
 };
 
+Ecore_Wl2_Window *_ecore_wl2_display_window_surface_find(Ecore_Wl2_Display *display, struct wl_surface *wl_surface);
+
 void _ecore_wl2_output_add(Ecore_Wl2_Display *display, unsigned int id);
 void _ecore_wl2_output_del(Ecore_Wl2_Output *output);
 
index 03991c2..12c63f3 100644 (file)
@@ -187,6 +187,9 @@ ecore_wl2_window_new(Ecore_Wl2_Display *display, Ecore_Wl2_Window *parent, int x
 
    win->type = ECORE_WL2_WINDOW_TYPE_TOPLEVEL;
 
+   display->windows =
+     eina_inlist_append(display->windows, EINA_INLIST_GET(win));
+
    return win;
 }
 
@@ -286,8 +289,12 @@ ecore_wl2_window_hide(Ecore_Wl2_Window *window)
 EAPI void
 ecore_wl2_window_free(Ecore_Wl2_Window *window)
 {
+   Ecore_Wl2_Display *display;
+
    EINA_SAFETY_ON_NULL_RETURN(window);
 
+   display = window->display;
+
    /* TODO: reset input pointer and keyboard focus */
    /* TODO: delete window anim callback */
    /* TODO: destroy subsurfaces */
@@ -297,6 +304,9 @@ ecore_wl2_window_free(Ecore_Wl2_Window *window)
    if (window->title) eina_stringshare_del(window->title);
    if (window->class) eina_stringshare_del(window->class);
 
+   display->windows =
+     eina_inlist_remove(display->windows, EINA_INLIST_GET(window));
+
    free(window);
 }