summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafael Antognolli <rafael.antognolli@intel.com>2013-09-05 18:10:50 -0300
committerRafael Antognolli <rafael.antognolli@intel.com>2013-10-10 13:24:22 -0300
commitf2d1a211472e2779969ead8d6331fd3d13230946 (patch)
tree2621c4071b2f5b556a09e564947a20aafa89f3e6
parent1cef77bfd784772539a395363b3aecbd3c2655d5 (diff)
ecore/wayland: Add subsurface handling APIs.
-rw-r--r--src/Makefile_Ecore_Wayland.am1
-rw-r--r--src/lib/ecore_wayland/Ecore_Wayland.h92
-rw-r--r--src/lib/ecore_wayland/ecore_wl.c3
-rw-r--r--src/lib/ecore_wayland/ecore_wl_private.h2
-rw-r--r--src/lib/ecore_wayland/ecore_wl_subsurf.c191
-rw-r--r--src/lib/ecore_wayland/ecore_wl_window.c2
6 files changed, 289 insertions, 2 deletions
diff --git a/src/Makefile_Ecore_Wayland.am b/src/Makefile_Ecore_Wayland.am
index 607d26e032..b2c66a19cb 100644
--- a/src/Makefile_Ecore_Wayland.am
+++ b/src/Makefile_Ecore_Wayland.am
@@ -14,6 +14,7 @@ lib/ecore_wayland/ecore_wl_dnd.c \
14lib/ecore_wayland/ecore_wl_input.c \ 14lib/ecore_wayland/ecore_wl_input.c \
15lib/ecore_wayland/ecore_wl_output.c \ 15lib/ecore_wayland/ecore_wl_output.c \
16lib/ecore_wayland/ecore_wl_window.c \ 16lib/ecore_wayland/ecore_wl_window.c \
17lib/ecore_wayland/ecore_wl_subsurf.c \
17lib/ecore_wayland/ecore_wl_private.h 18lib/ecore_wayland/ecore_wl_private.h
18 19
19lib_ecore_wayland_libecore_wayland_la_BUILT_SOURCES = \ 20lib_ecore_wayland_libecore_wayland_la_BUILT_SOURCES = \
diff --git a/src/lib/ecore_wayland/Ecore_Wayland.h b/src/lib/ecore_wayland/Ecore_Wayland.h
index c9b3e1f6ca..30545b7343 100644
--- a/src/lib/ecore_wayland/Ecore_Wayland.h
+++ b/src/lib/ecore_wayland/Ecore_Wayland.h
@@ -12,7 +12,6 @@
12# include <wayland-client.h> 12# include <wayland-client.h>
13# include <wayland-cursor.h> 13# include <wayland-cursor.h>
14# include <xkbcommon/xkbcommon.h> 14# include <xkbcommon/xkbcommon.h>
15# include <subsurface-client-protocol.h>
16 15
17# ifdef EAPI 16# ifdef EAPI
18# undef EAPI 17# undef EAPI
@@ -36,6 +35,7 @@ typedef struct _Ecore_Wl_Display Ecore_Wl_Display;
36typedef struct _Ecore_Wl_Output Ecore_Wl_Output; 35typedef struct _Ecore_Wl_Output Ecore_Wl_Output;
37typedef struct _Ecore_Wl_Input Ecore_Wl_Input; 36typedef struct _Ecore_Wl_Input Ecore_Wl_Input;
38typedef struct _Ecore_Wl_Global Ecore_Wl_Global; /** @since 1.7.6 */ 37typedef struct _Ecore_Wl_Global Ecore_Wl_Global; /** @since 1.7.6 */
38typedef struct _Ecore_Wl_Subsurf Ecore_Wl_Subsurf; /** @since 1.8 */
39 39
40# ifndef _ECORE_WAYLAND_WINDOW_PREDEF 40# ifndef _ECORE_WAYLAND_WINDOW_PREDEF
41typedef struct _Ecore_Wl_Window Ecore_Wl_Window; 41typedef struct _Ecore_Wl_Window Ecore_Wl_Window;
@@ -253,6 +253,8 @@ struct _Ecore_Wl_Window
253 /* FIXME: Ideally we should record the cursor name for this window 253 /* FIXME: Ideally we should record the cursor name for this window
254 * so we can compare and avoid unnecessary cursor set calls to wayland */ 254 * so we can compare and avoid unnecessary cursor set calls to wayland */
255 255
256 Ecore_Wl_Subsurf *subsurfs;
257
256 void *data; 258 void *data;
257}; 259};
258 260
@@ -383,6 +385,7 @@ struct _Ecore_Wl_Event_Interfaces_Bound
383 * @li @ref Ecore_Wl_Window_Group 385 * @li @ref Ecore_Wl_Window_Group
384 * @li @ref Ecore_Wl_Input_Group 386 * @li @ref Ecore_Wl_Input_Group
385 * @li @ref Ecore_Wl_Dnd_Group 387 * @li @ref Ecore_Wl_Dnd_Group
388 * @li @ref Ecore_Wl_Subsurf
386 */ 389 */
387 390
388EAPI extern int ECORE_WL_EVENT_MOUSE_IN; 391EAPI extern int ECORE_WL_EVENT_MOUSE_IN;
@@ -866,6 +869,93 @@ EAPI struct wl_array *ecore_wl_dnd_drag_types_get(Ecore_Wl_Input *input);
866 869
867EAPI void ecore_wl_server_mode_set(Eina_Bool on); 870EAPI void ecore_wl_server_mode_set(Eina_Bool on);
868 871
872/**
873 * @defgroup Ecore_Wl_Subsurf Functions to manipulate subsurfaces.
874 * @ingroup Ecore_Wl_Group
875 *
876 * Functions to manipulate wayland subsurfaces, using Ecore_Wl_Subsurf.
877 *
878 * This API is intended to expose Wayland subsurface functionality, although it
879 * should not be necessary for most applications to use it, as soon as we have
880 * means to make Evas automatically switch Evas images to use subsurfaces.
881 *
882 * It can/should be used, for instance, when subsurfaces are needed to be not
883 * in sync with the main window surface.
884 */
885
886/**
887 * Create and return a new subsurface.
888 *
889 * Create a new surface (and subsurface interface), with the parent surface
890 * being the one associated with the given @param win.
891 *
892 * The @param win must be visible, otherwise there will be no surface created
893 * for it yet.
894 *
895 * @ingroup Ecore_Wl_Subsurf
896 * @since 1.8
897 */
898EAPI Ecore_Wl_Subsurf *ecore_wl_subsurf_create(Ecore_Wl_Window *win);
899
900/**
901 * Destroy the given subsurface, as well as the surface associated with it.
902 *
903 * @ingroup Ecore_Wl_Subsurf
904 * @since 1.8
905 */
906EAPI void ecore_wl_subsurf_del(Ecore_Wl_Subsurf *ess);
907
908/**
909 * Return the wl_surface associated with this subsurface.
910 *
911 * @ingroup Ecore_Wl_Subsurf
912 * @since 1.8
913 */
914EAPI struct wl_surface *ecore_wl_subsurf_surface_get(Ecore_Wl_Subsurf *ess);
915
916/**
917 * Set the position of this subsurface, relative to its parent surface.
918 *
919 * @ingroup Ecore_Wl_Subsurf
920 * @since 1.8
921 */
922EAPI void ecore_wl_subsurf_position_set(Ecore_Wl_Subsurf *ess, int x, int y);
923
924/**
925 * Get the position of this subsurface, relative to its parent surface.
926 *
927 * @ingroup Ecore_Wl_Subsurf
928 * @since 1.8
929 */
930EAPI void ecore_wl_subsurf_position_get(Ecore_Wl_Subsurf *ess, int *x, int *y);
931
932/**
933 * @ingroup Ecore_Wl_Subsurf
934 * @since 1.8
935 */
936EAPI void ecore_wl_subsurf_place_above(Ecore_Wl_Subsurf *ess, struct wl_surface *surface);
937
938/**
939 * @ingroup Ecore_Wl_Subsurf
940 * @since 1.8
941 */
942EAPI void ecore_wl_subsurf_place_below(Ecore_Wl_Subsurf *ess, struct wl_surface *surface);
943
944/**
945 * @ingroup Ecore_Wl_Subsurf
946 * @since 1.8
947 */
948EAPI void ecore_wl_subsurf_sync_set(Ecore_Wl_Subsurf *ess, Eina_Bool val);
949
950/**
951 * Set an opaque region for the given subsurface.
952 *
953 * Use a 0x0 region size to unset the opaque region.
954 *
955 * @ingroup Ecore_Wl_Subsurf
956 * @since 1.8
957 */
958EAPI void ecore_wl_subsurf_opaque_region_set(Ecore_Wl_Subsurf *ess, int x, int y, int w, int h);
869#ifdef __cplusplus 959#ifdef __cplusplus
870} 960}
871#endif 961#endif
diff --git a/src/lib/ecore_wayland/ecore_wl.c b/src/lib/ecore_wayland/ecore_wl.c
index acc5988af9..ee614e0e4b 100644
--- a/src/lib/ecore_wayland/ecore_wl.c
+++ b/src/lib/ecore_wayland/ecore_wl.c
@@ -4,6 +4,7 @@
4 4
5#include <fcntl.h> 5#include <fcntl.h>
6#include "ecore_wl_private.h" 6#include "ecore_wl_private.h"
7#include <subsurface-client-protocol.h>
7 8
8/* local function prototypes */ 9/* local function prototypes */
9static Eina_Bool _ecore_wl_shutdown(Eina_Bool close); 10static Eina_Bool _ecore_wl_shutdown(Eina_Bool close);
@@ -398,7 +399,7 @@ _ecore_wl_shutdown(Eina_Bool close)
398 if (_ecore_wl_disp->wl.compositor) 399 if (_ecore_wl_disp->wl.compositor)
399 wl_compositor_destroy(_ecore_wl_disp->wl.compositor); 400 wl_compositor_destroy(_ecore_wl_disp->wl.compositor);
400 if (_ecore_wl_disp->wl.subcompositor) 401 if (_ecore_wl_disp->wl.subcompositor)
401 wl_compositor_destroy(_ecore_wl_disp->wl.subcompositor); 402 wl_subcompositor_destroy(_ecore_wl_disp->wl.subcompositor);
402 if (_ecore_wl_disp->wl.display) 403 if (_ecore_wl_disp->wl.display)
403 { 404 {
404 wl_registry_destroy(_ecore_wl_disp->wl.registry); 405 wl_registry_destroy(_ecore_wl_disp->wl.registry);
diff --git a/src/lib/ecore_wayland/ecore_wl_private.h b/src/lib/ecore_wayland/ecore_wl_private.h
index dc034af8d8..b83aae38eb 100644
--- a/src/lib/ecore_wayland/ecore_wl_private.h
+++ b/src/lib/ecore_wayland/ecore_wl_private.h
@@ -95,4 +95,6 @@ void _ecore_wl_dnd_del(Ecore_Wl_Dnd_Source *source);
95void _ecore_wl_events_init(void); 95void _ecore_wl_events_init(void);
96void _ecore_wl_events_shutdown(void); 96void _ecore_wl_events_shutdown(void);
97 97
98void _ecore_wl_subsurfs_del_all(Ecore_Wl_Window *win);
99
98#endif 100#endif
diff --git a/src/lib/ecore_wayland/ecore_wl_subsurf.c b/src/lib/ecore_wayland/ecore_wl_subsurf.c
new file mode 100644
index 0000000000..4e144fa084
--- /dev/null
+++ b/src/lib/ecore_wayland/ecore_wl_subsurf.c
@@ -0,0 +1,191 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include "ecore_wl_private.h"
6#include <subsurface-client-protocol.h>
7
8struct _Ecore_Wl_Subsurf
9{
10 EINA_INLIST;
11 Ecore_Wl_Window *parent_win;
12 struct wl_surface *surface;
13 struct wl_subsurface *subsurface;
14
15 int x, y;
16
17 Eina_Bool sync : 1;
18};
19
20EAPI Ecore_Wl_Subsurf *
21ecore_wl_subsurf_create(Ecore_Wl_Window *win)
22{
23 struct wl_subsurface *subsurface;
24 struct wl_surface *surface;
25 Ecore_Wl_Subsurf *ess;
26
27 LOGFN(__FILE__, __LINE__, __FUNCTION__);
28
29 if (!win) return NULL;
30 if (!win->surface) return NULL;
31 if (!_ecore_wl_disp->wl.subcompositor) return NULL;
32
33 surface = wl_compositor_create_surface(_ecore_wl_disp->wl.compositor);
34 if (!surface)
35 return NULL;
36
37 subsurface = wl_subcompositor_get_subsurface
38 (_ecore_wl_disp->wl.subcompositor, surface, win->surface);
39 if (!subsurface)
40 {
41 wl_surface_destroy(surface);
42 return NULL;
43 }
44
45 ess = calloc(1, sizeof(*ess));
46 ess->surface = surface;
47 ess->subsurface = subsurface;
48 ess->parent_win = win;
49
50 win->subsurfs = (Ecore_Wl_Subsurf *)eina_inlist_append
51 (EINA_INLIST_GET(win->subsurfs), EINA_INLIST_GET(ess));
52
53 return ess;
54}
55
56static void
57_ecore_wl_subsurf_destroy(Ecore_Wl_Subsurf *ess)
58{
59 Ecore_Wl_Window *parent;
60
61 wl_subsurface_destroy(ess->subsurface);
62 wl_surface_destroy(ess->surface);
63
64 parent = ess->parent_win;
65 parent->subsurfs = (Ecore_Wl_Subsurf *)eina_inlist_remove
66 (EINA_INLIST_GET(parent->subsurfs), EINA_INLIST_GET(ess));
67
68 free(ess);
69}
70
71EAPI void
72ecore_wl_subsurf_del(Ecore_Wl_Subsurf *ess)
73{
74 LOGFN(__FILE__, __LINE__, __FUNCTION__);
75
76 if (!ess) return;
77
78 _ecore_wl_subsurf_destroy(ess);
79}
80
81void
82_ecore_wl_subsurfs_del_all(Ecore_Wl_Window *win)
83{
84 Ecore_Wl_Subsurf *ess;
85
86 if (!win) return;
87
88 EINA_INLIST_FREE(win->subsurfs, ess)
89 {
90 _ecore_wl_subsurf_destroy(ess);
91 }
92}
93
94EAPI struct wl_surface *
95ecore_wl_subsurf_surface_get(Ecore_Wl_Subsurf *ess)
96{
97 LOGFN(__FILE__, __LINE__, __FUNCTION__);
98
99 if (!ess) return NULL;
100
101 return ess->surface;
102}
103
104EAPI void
105ecore_wl_subsurf_position_set(Ecore_Wl_Subsurf *ess, int x, int y)
106{
107 LOGFN(__FILE__, __LINE__, __FUNCTION__);
108
109 if (!ess) return;
110
111 if ((x == ess->x) && (y == ess->y))
112 return;
113
114 ess->x = x;
115 ess->y = y;
116
117 wl_subsurface_set_position(ess->subsurface, x, y);
118}
119
120EAPI void
121ecore_wl_subsurf_position_get(Ecore_Wl_Subsurf *ess, int *x, int *y)
122{
123 LOGFN(__FILE__, __LINE__, __FUNCTION__);
124
125 if (!ess) return;
126
127 if (x) *x = ess->x;
128 if (y) *y = ess->y;
129}
130
131EAPI void
132ecore_wl_subsurf_place_above(Ecore_Wl_Subsurf *ess, struct wl_surface *surface)
133{
134 LOGFN(__FILE__, __LINE__, __FUNCTION__);
135
136 if (!ess) return;
137 if (!surface) return;
138
139 wl_subsurface_place_above(ess->subsurface, surface);
140}
141
142EAPI void
143ecore_wl_subsurf_place_below(Ecore_Wl_Subsurf *ess, struct wl_surface *surface)
144{
145 LOGFN(__FILE__, __LINE__, __FUNCTION__);
146
147 if (!ess) return;
148 if (!surface) return;
149
150 wl_subsurface_place_below(ess->subsurface, surface);
151}
152
153EAPI void
154ecore_wl_subsurf_sync_set(Ecore_Wl_Subsurf *ess, Eina_Bool val)
155{
156 LOGFN(__FILE__, __LINE__, __FUNCTION__);
157
158 if (!ess) return;
159
160 val = !!val;
161 if (val == ess->sync) return;
162
163 ess->sync = val;
164
165 if (ess->sync)
166 wl_subsurface_set_sync(ess->subsurface);
167 else
168 wl_subsurface_set_desync(ess->subsurface);
169}
170
171EAPI void
172ecore_wl_subsurf_opaque_region_set(Ecore_Wl_Subsurf *ess, int x, int y, int w, int h)
173{
174 Ecore_Wl_Window *parent;
175 struct wl_region *region = NULL;
176
177 LOGFN(__FILE__, __LINE__, __FUNCTION__);
178
179 if (!ess) return;
180
181 if ((w > 0) && (h > 0))
182 {
183 parent = ess->parent_win;
184 region = wl_compositor_create_region(parent->display->wl.compositor);
185 wl_region_add(region, x, y, w, h);
186 wl_surface_set_opaque_region(ess->surface, region);
187 wl_region_destroy(region);
188 }
189 else
190 wl_surface_set_opaque_region(ess->surface, NULL);
191}
diff --git a/src/lib/ecore_wayland/ecore_wl_window.c b/src/lib/ecore_wayland/ecore_wl_window.c
index cd5aabe7ad..4ec78c8460 100644
--- a/src/lib/ecore_wayland/ecore_wl_window.c
+++ b/src/lib/ecore_wayland/ecore_wl_window.c
@@ -114,6 +114,8 @@ ecore_wl_window_free(Ecore_Wl_Window *win)
114 if (win->anim_callback) wl_callback_destroy(win->anim_callback); 114 if (win->anim_callback) wl_callback_destroy(win->anim_callback);
115 win->anim_callback = NULL; 115 win->anim_callback = NULL;
116 116
117 if (win->subsurfs) _ecore_wl_subsurfs_del_all(win);
118
117 if (win->shell_surface) wl_shell_surface_destroy(win->shell_surface); 119 if (win->shell_surface) wl_shell_surface_destroy(win->shell_surface);
118 win->shell_surface = NULL; 120 win->shell_surface = NULL;
119 if (win->surface) wl_surface_destroy(win->surface); 121 if (win->surface) wl_surface_destroy(win->surface);