summaryrefslogtreecommitdiff
path: root/src/lib/ecore_wl2/ecore_wl2_subsurf.c
diff options
context:
space:
mode:
authorChris Michael <cp.michael@samsung.com>2015-10-01 12:22:32 -0400
committerChris Michael <cp.michael@samsung.com>2015-12-03 12:02:40 -0500
commit434fbd6fb94acf728056009f316b261f950a83fb (patch)
treedd9d9ac3b352a8a32a4d814f0433bfe3e1ef4ba0 /src/lib/ecore_wl2/ecore_wl2_subsurf.c
parentd4c312eccec2bfc7736f9db59c95d9587057577f (diff)
ecore-wl2: Start on preliminary subsurface support
Signed-off-by: Chris Michael <cp.michael@samsung.com>
Diffstat (limited to 'src/lib/ecore_wl2/ecore_wl2_subsurf.c')
-rw-r--r--src/lib/ecore_wl2/ecore_wl2_subsurf.c71
1 files changed, 71 insertions, 0 deletions
diff --git a/src/lib/ecore_wl2/ecore_wl2_subsurf.c b/src/lib/ecore_wl2/ecore_wl2_subsurf.c
new file mode 100644
index 0000000000..90a934364a
--- /dev/null
+++ b/src/lib/ecore_wl2/ecore_wl2_subsurf.c
@@ -0,0 +1,71 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include "ecore_wl2_private.h"
6
7void
8_ecore_wl2_subsurf_free(Ecore_Wl2_Subsurface *subsurf)
9{
10 Ecore_Wl2_Window *parent;
11
12 if (subsurf->wl.subsurface) wl_subsurface_destroy(subsurf->wl.subsurface);
13 if (subsurf->wl.surface) wl_surface_destroy(subsurf->wl.surface);
14
15 parent = subsurf->parent;
16 if (parent)
17 {
18 parent->subsurfs =
19 eina_inlist_remove(parent->subsurfs, EINA_INLIST_GET(subsurf));
20 }
21
22 free(subsurf);
23}
24
25EAPI Ecore_Wl2_Subsurface *
26ecore_wl2_subsurface_new(Ecore_Wl2_Window *window)
27{
28 Ecore_Wl2_Display *display;
29 Ecore_Wl2_Subsurface *subsurf;
30
31 EINA_SAFETY_ON_NULL_RETURN_VAL(window, NULL);
32 EINA_SAFETY_ON_NULL_RETURN_VAL(window->surface, NULL);
33
34 display = window->display;
35
36 EINA_SAFETY_ON_NULL_RETURN_VAL(display->wl.compositor, NULL);
37 EINA_SAFETY_ON_NULL_RETURN_VAL(display->wl.subcompositor, NULL);
38
39 subsurf = calloc(1, sizeof(Ecore_Wl2_Subsurface));
40 if (!subsurf) return NULL;
41
42 subsurf->parent = window;
43
44 subsurf->wl.surface = wl_compositor_create_surface(display->wl.compositor);
45 if (!subsurf->wl.surface)
46 {
47 ERR("Failed to create surface: %m");
48 goto surf_err;
49 }
50
51 subsurf->wl.subsurface =
52 wl_subcompositor_get_subsurface(display->wl.subcompositor,
53 subsurf->wl.surface, window->surface);
54 if (!subsurf->wl.subsurface)
55 {
56 ERR("Could not create subsurface: %m");
57 goto sub_surf_err;
58 }
59
60 window->subsurfs =
61 eina_inlist_append(window->subsurfs, EINA_INLIST_GET(subsurf));
62
63 return subsurf;
64
65sub_surf_err:
66 wl_surface_destroy(subsurf->wl.surface);
67
68surf_err:
69 free(subsurf);
70 return NULL;
71}