ecore_wl2: add Ecore_Wl2_Surface to Ecore_Wl2_Window
authorDerek Foreman <derekf@osg.samsung.com>
Thu, 30 Nov 2017 21:10:22 +0000 (15:10 -0600)
committerDerek Foreman <derekf@osg.samsung.com>
Fri, 1 Dec 2017 16:58:44 +0000 (10:58 -0600)
Track the surface of a window and only allow one.

Eventually this might be worthwhile to apply to subsurfaces, but for today
lazy is the way.

src/lib/ecore_wl2/ecore_wl2_private.h
src/lib/ecore_wl2/ecore_wl2_surface.c

index 8e1c2fb..c8865bc 100644 (file)
@@ -170,6 +170,8 @@ struct _Ecore_Wl2_Window
    Ecore_Wl2_Window *parent;
    Ecore_Wl2_Input *grab;
 
+   Ecore_Wl2_Surface *wl2_surface;
+
    int id, rotation, surface_id;
    const char *title;
    const char *class;
index 9a1c8ea..8fcf9c1 100644 (file)
@@ -146,8 +146,6 @@ _evas_dmabuf_surface_destroy(Ecore_Wl2_Surface *s)
 
    EINA_LIST_FREE(s->buffers, b)
      ecore_wl2_buffer_destroy(b);
-
-   free(s);
 }
 
 EAPI void
@@ -156,6 +154,9 @@ ecore_wl2_surface_destroy(Ecore_Wl2_Surface *surface)
    EINA_SAFETY_ON_NULL_RETURN(surface);
 
    surface->funcs.destroy(surface);
+   surface->wl2_win = NULL;
+
+   free(surface);
 }
 
 EAPI void
@@ -197,6 +198,10 @@ ecore_wl2_surface_create(Ecore_Wl2_Window *win, Eina_Bool alpha)
    Ecore_Wl2_Display *ewd;
    Ecore_Wl2_Buffer_Type types = 0;
 
+   EINA_SAFETY_ON_NULL_RETURN_VAL(win, NULL);
+
+   if (win->wl2_surface) return win->wl2_surface;
+
    out = calloc(1, sizeof(*out));
    if (!out) return NULL;
    out->wl2_win = win;
@@ -219,7 +224,7 @@ ecore_wl2_surface_create(Ecore_Wl2_Window *win, Eina_Bool alpha)
    out->funcs.data_get = _evas_dmabuf_surface_data_get;
    out->funcs.assign = _evas_dmabuf_surface_assign;
    out->funcs.post = _evas_dmabuf_surface_post;
-
+   win->wl2_surface = out;
    return out;
 
 err: