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-09-23 11:03:23 -0300
commit0258a7c4660e9e987f3934045f5bd52fa13eb9aa (patch)
tree8ff35051282a4d432dcb94fa8718ed7ba2122209
parent0046e5b40f4b6366e89338f4ecdc8a9d74a511ce (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.c192
-rw-r--r--src/lib/ecore_wayland/ecore_wl_window.c2
6 files changed, 290 insertions, 2 deletions
diff --git a/src/Makefile_Ecore_Wayland.am b/src/Makefile_Ecore_Wayland.am
index 0709d6b545..2e71df1a0b 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 f6ee5e419a..145dc3bc81 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;
@@ -252,6 +252,8 @@ struct _Ecore_Wl_Window
252 /* FIXME: Ideally we should record the cursor name for this window 252 /* FIXME: Ideally we should record the cursor name for this window
253 * so we can compare and avoid unnecessary cursor set calls to wayland */ 253 * so we can compare and avoid unnecessary cursor set calls to wayland */
254 254
255 Ecore_Wl_Subsurf *subsurfs;
256
255 void *data; 257 void *data;
256}; 258};
257 259
@@ -382,6 +384,7 @@ struct _Ecore_Wl_Event_Interfaces_Bound
382 * @li @ref Ecore_Wl_Window_Group 384 * @li @ref Ecore_Wl_Window_Group
383 * @li @ref Ecore_Wl_Input_Group 385 * @li @ref Ecore_Wl_Input_Group
384 * @li @ref Ecore_Wl_Dnd_Group 386 * @li @ref Ecore_Wl_Dnd_Group
387 * @li @ref Ecore_Wl_Subsurf
385 */ 388 */
386 389
387EAPI extern int ECORE_WL_EVENT_MOUSE_IN; 390EAPI extern int ECORE_WL_EVENT_MOUSE_IN;
@@ -865,6 +868,93 @@ EAPI struct wl_array *ecore_wl_dnd_drag_types_get(Ecore_Wl_Input *input);
865 868
866EAPI void ecore_wl_server_mode_set(Eina_Bool on); 869EAPI void ecore_wl_server_mode_set(Eina_Bool on);
867 870
871/**
872 * @defgroup Ecore_Wl_Subsurf Functions to manipulate subsurfaces.
873 * @ingroup Ecore_Wl_Group
874 *
875 * Functions to manipulate wayland subsurfaces, using Ecore_Wl_Subsurf.
876 *
877 * This API is intended to expose Wayland subsurface functionality, although it
878 * should not be necessary for most applications to use it, as soon as we have
879 * means to make Evas automatically switch Evas images to use subsurfaces.
880 *
881 * It can/should be used, for instance, when subsurfaces are needed to be not
882 * in sync with the main window surface.
883 */
884
885/**
886 * Create and return a new subsurface.
887 *
888 * Create a new surface (and subsurface interface), with the parent surface
889 * being the one associated with the given @param win.
890 *
891 * The @param win must be visible, otherwise there will be no surface created
892 * for it yet.
893 *
894 * @ingroup Ecore_Wl_Subsurf
895 * @since 1.8
896 */
897EAPI Ecore_Wl_Subsurf *ecore_wl_subsurf_create(Ecore_Wl_Window *win);
898
899/**
900 * Destroy the given subsurface, as well as the surface associated with it.
901 *
902 * @ingroup Ecore_Wl_Subsurf
903 * @since 1.8
904 */
905EAPI void ecore_wl_subsurf_del(Ecore_Wl_Subsurf *ess);
906
907/**
908 * Return the wl_surface associated with this subsurface.
909 *
910 * @ingroup Ecore_Wl_Subsurf
911 * @since 1.8
912 */
913EAPI struct wl_surface *ecore_wl_subsurf_surface_get(Ecore_Wl_Subsurf *ess);
914
915/**
916 * Set the position of this subsurface, relative to its parent surface.
917 *
918 * @ingroup Ecore_Wl_Subsurf
919 * @since 1.8
920 */
921EAPI void ecore_wl_subsurf_position_set(Ecore_Wl_Subsurf *ess, int x, int y);
922
923/**
924 * Get the position of this subsurface, relative to its parent surface.
925 *
926 * @ingroup Ecore_Wl_Subsurf
927 * @since 1.8
928 */
929EAPI void ecore_wl_subsurf_position_get(Ecore_Wl_Subsurf *ess, int *x, int *y);
930
931/**
932 * @ingroup Ecore_Wl_Subsurf
933 * @since 1.8
934 */
935EAPI void ecore_wl_subsurf_place_above(Ecore_Wl_Subsurf *ess, struct wl_surface *surface);
936
937/**
938 * @ingroup Ecore_Wl_Subsurf
939 * @since 1.8
940 */
941EAPI void ecore_wl_subsurf_place_below(Ecore_Wl_Subsurf *ess, struct wl_surface *surface);
942
943/**
944 * @ingroup Ecore_Wl_Subsurf
945 * @since 1.8
946 */
947EAPI void ecore_wl_subsurf_sync_set(Ecore_Wl_Subsurf *ess, Eina_Bool val);
948
949/**
950 * Set an opaque region for the given subsurface.
951 *
952 * Use a 0x0 region size to unset the opaque region.
953 *
954 * @ingroup Ecore_Wl_Subsurf
955 * @since 1.8
956 */
957EAPI void ecore_wl_subsurf_opaque_region_set(Ecore_Wl_Subsurf *ess, int x, int y, int w, int h);
868#ifdef __cplusplus 958#ifdef __cplusplus
869} 959}
870#endif 960#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..96f729ed8b
--- /dev/null
+++ b/src/lib/ecore_wayland/ecore_wl_subsurf.c
@@ -0,0 +1,192 @@
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 wl_subsurface_destroy(ess->subsurface);
60 wl_surface_destroy(ess->surface);
61
62 free(ess);
63}
64
65EAPI void
66ecore_wl_subsurf_del(Ecore_Wl_Subsurf *ess)
67{
68 Ecore_Wl_Window *parent;
69
70 LOGFN(__FILE__, __LINE__, __FUNCTION__);
71
72 if (!ess) return;
73
74 parent = ess->parent_win;
75
76 parent->subsurfs = (Ecore_Wl_Subsurf *)eina_inlist_remove
77 (EINA_INLIST_GET(parent->subsurfs), EINA_INLIST_GET(ess));
78
79 _ecore_wl_subsurf_destroy(ess);
80}
81
82void
83_ecore_wl_subsurfs_del_all(Ecore_Wl_Window *win)
84{
85 Ecore_Wl_Subsurf *ess;
86
87 if (!win) return;
88
89 EINA_INLIST_FREE(win->subsurfs, ess)
90 {
91 _ecore_wl_subsurf_destroy(ess);
92 }
93}
94
95EAPI struct wl_surface *
96ecore_wl_subsurf_surface_get(Ecore_Wl_Subsurf *ess)
97{
98 LOGFN(__FILE__, __LINE__, __FUNCTION__);
99
100 if (!ess) return NULL;
101
102 return ess->surface;
103}
104
105EAPI void
106ecore_wl_subsurf_position_set(Ecore_Wl_Subsurf *ess, int x, int y)
107{
108 LOGFN(__FILE__, __LINE__, __FUNCTION__);
109
110 if (!ess) return;
111
112 if ((x == ess->x) && (y == ess->y))
113 return;
114
115 ess->x = x;
116 ess->y = y;
117
118 wl_subsurface_set_position(ess->subsurface, x, y);
119}
120
121EAPI void
122ecore_wl_subsurf_position_get(Ecore_Wl_Subsurf *ess, int *x, int *y)
123{
124 LOGFN(__FILE__, __LINE__, __FUNCTION__);
125
126 if (!ess) return;
127
128 if (x) *x = ess->x;
129 if (y) *y = ess->y;
130}
131
132EAPI void
133ecore_wl_subsurf_place_above(Ecore_Wl_Subsurf *ess, struct wl_surface *surface)
134{
135 LOGFN(__FILE__, __LINE__, __FUNCTION__);
136
137 if (!ess) return;
138 if (!surface) return;
139
140 wl_subsurface_place_above(ess->subsurface, surface);
141}
142
143EAPI void
144ecore_wl_subsurf_place_below(Ecore_Wl_Subsurf *ess, struct wl_surface *surface)
145{
146 LOGFN(__FILE__, __LINE__, __FUNCTION__);
147
148 if (!ess) return;
149 if (!surface) return;
150
151 wl_subsurface_place_below(ess->subsurface, surface);
152}
153
154EAPI void
155ecore_wl_subsurf_sync_set(Ecore_Wl_Subsurf *ess, Eina_Bool val)
156{
157 LOGFN(__FILE__, __LINE__, __FUNCTION__);
158
159 if (!ess) return;
160
161 val = !!val;
162 if (val == ess->sync) return;
163
164 ess->sync = val;
165
166 if (ess->sync)
167 wl_subsurface_set_sync(ess->subsurface);
168 else
169 wl_subsurface_set_desync(ess->subsurface);
170}
171
172EAPI void
173ecore_wl_subsurf_opaque_region_set(Ecore_Wl_Subsurf *ess, int x, int y, int w, int h)
174{
175 Ecore_Wl_Window *parent;
176 struct wl_region *region = NULL;
177
178 LOGFN(__FILE__, __LINE__, __FUNCTION__);
179
180 if (!ess) return;
181
182 if ((w > 0) && (h > 0))
183 {
184 parent = ess->parent_win;
185 region = wl_compositor_create_region(parent->display->wl.compositor);
186 wl_region_add(region, x, y, w, h);
187 wl_surface_set_opaque_region(ess->surface, region);
188 wl_region_destroy(region);
189 }
190 else
191 wl_surface_set_opaque_region(ess->surface, NULL);
192}
diff --git a/src/lib/ecore_wayland/ecore_wl_window.c b/src/lib/ecore_wayland/ecore_wl_window.c
index 748aa76a20..1a40144962 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);