ecore/wayland: Add some getters.
authorRafael Antognolli <rafael.antognolli@intel.com>
Tue, 29 Oct 2013 20:40:33 +0000 (18:40 -0200)
committerRafael Antognolli <rafael.antognolli@intel.com>
Tue, 29 Oct 2013 21:14:22 +0000 (19:14 -0200)
This centralizes the place where we have to wait for the init to have
finished before first using the compositor. It's also part of the later
step of hiding Ecore_Wl_* private structs.

src/lib/ecore_wayland/Ecore_Wayland.h
src/lib/ecore_wayland/ecore_wl.c
src/lib/ecore_wayland/ecore_wl_private.h
src/lib/ecore_wayland/ecore_wl_subsurf.c
src/lib/ecore_wayland/ecore_wl_window.c

index 9ba7636..7828281 100644 (file)
@@ -496,6 +496,16 @@ EAPI struct wl_shm *ecore_wl_shm_get(void);
 EAPI struct wl_display *ecore_wl_display_get(void);
 
 /**
+ * Retrieves the Compositor interface.
+ *
+ * This interface is used by clients to request the creation of surfaces and
+ * regions.
+ *
+ * @return The current wayland compositor interface
+ * @since 1.8
+ */
+
+/**
  * Retrieves the size of the current screen.
  *
  * @param w where to return the width. May be NULL. Returns 0 on error.
index 451aa79..f763675 100644 (file)
@@ -272,6 +272,28 @@ ecore_wl_registry_get(void)
    return _ecore_wl_disp->wl.registry;
 }
 
+struct wl_compositor *
+ecore_wl_compositor_get(void)
+{
+   if ((!_ecore_wl_disp) || (!_ecore_wl_disp->wl.display))
+     return NULL;
+
+   _ecore_wl_init_wait();
+
+   return _ecore_wl_disp->wl.compositor;
+}
+
+struct wl_subcompositor *
+ecore_wl_subcompositor_get(void)
+{
+   if ((!_ecore_wl_disp) || (!_ecore_wl_disp->wl.display))
+     return NULL;
+
+   _ecore_wl_init_wait();
+
+   return _ecore_wl_disp->wl.subcompositor;
+}
+
 EAPI void
 ecore_wl_screen_size_get(int *w, int *h)
 {
index b83aae3..d615f0f 100644 (file)
@@ -97,4 +97,7 @@ void _ecore_wl_events_shutdown(void);
 
 void _ecore_wl_subsurfs_del_all(Ecore_Wl_Window *win);
 
+struct wl_compositor *ecore_wl_compositor_get(void);
+struct wl_subcompositor *ecore_wl_subcompositor_get(void);
+
 #endif
index 4e144fa..d59810d 100644 (file)
@@ -23,19 +23,22 @@ ecore_wl_subsurf_create(Ecore_Wl_Window *win)
    struct wl_subsurface *subsurface;
    struct wl_surface *surface;
    Ecore_Wl_Subsurf *ess;
+   struct wl_subcompositor *subcomp;
 
    LOGFN(__FILE__, __LINE__, __FUNCTION__);
 
    if (!win) return NULL;
    if (!win->surface) return NULL;
-   if (!_ecore_wl_disp->wl.subcompositor) return NULL;
 
-   surface = wl_compositor_create_surface(_ecore_wl_disp->wl.compositor);
+   subcomp = ecore_wl_subcompositor_get();
+   if (!subcomp) return NULL;
+
+   surface = wl_compositor_create_surface(ecore_wl_compositor_get());
    if (!surface)
      return NULL;
 
    subsurface = wl_subcompositor_get_subsurface
-      (_ecore_wl_disp->wl.subcompositor, surface, win->surface);
+      (subcomp, surface, win->surface);
    if (!subsurface)
      {
         wl_surface_destroy(surface);
@@ -171,7 +174,6 @@ ecore_wl_subsurf_sync_set(Ecore_Wl_Subsurf *ess, Eina_Bool val)
 EAPI void
 ecore_wl_subsurf_opaque_region_set(Ecore_Wl_Subsurf *ess, int x, int y, int w, int h)
 {
-   Ecore_Wl_Window *parent;
    struct wl_region *region = NULL;
 
    LOGFN(__FILE__, __LINE__, __FUNCTION__);
@@ -180,8 +182,7 @@ ecore_wl_subsurf_opaque_region_set(Ecore_Wl_Subsurf *ess, int x, int y, int w, i
 
    if ((w > 0) && (h > 0))
      {
-        parent = ess->parent_win;
-        region = wl_compositor_create_region(parent->display->wl.compositor);
+        region = wl_compositor_create_region(ecore_wl_compositor_get());
         wl_region_add(region, x, y, w, h);
         wl_surface_set_opaque_region(ess->surface, region);
         wl_region_destroy(region);
index 4ec78c8..b924691 100644 (file)
@@ -252,7 +252,7 @@ ecore_wl_window_surface_create(Ecore_Wl_Window *win)
 {
    if (!win) return NULL;
    if (win->surface) return win->surface;
-   win->surface = wl_compositor_create_surface(_ecore_wl_disp->wl.compositor);
+   win->surface = wl_compositor_create_surface(ecore_wl_compositor_get());
    win->surface_id = wl_proxy_get_id((struct wl_proxy *)win->surface);
    return win->surface;
 }
@@ -610,7 +610,7 @@ ecore_wl_window_input_region_set(Ecore_Wl_Window *win, int x, int y, int w, int
              struct wl_region *region = NULL;
 
              region = 
-               wl_compositor_create_region(_ecore_wl_disp->wl.compositor);
+               wl_compositor_create_region(ecore_wl_compositor_get());
              wl_region_add(region, x, y, w, h);
              wl_surface_set_input_region(win->surface, region);
              wl_region_destroy(region);
@@ -640,7 +640,7 @@ ecore_wl_window_opaque_region_set(Ecore_Wl_Window *win, int x, int y, int w, int
         struct wl_region *region = NULL;
 
         region = 
-          wl_compositor_create_region(_ecore_wl_disp->wl.compositor);
+          wl_compositor_create_region(ecore_wl_compositor_get());
 
         switch (win->rotation)
           {