diff options
-rw-r--r-- | src/Makefile_Ecore_Wl2.am | 2 | ||||
-rw-r--r-- | src/lib/ecore_wl2/ecore_wl2.c | 5 | ||||
-rw-r--r-- | src/lib/ecore_wl2/ecore_wl2_display.c | 8 | ||||
-rw-r--r-- | src/lib/ecore_wl2/ecore_wl2_private.h | 34 | ||||
-rw-r--r-- | src/lib/ecore_wl2/ecore_wl2_window.c | 71 | ||||
-rw-r--r-- | src/lib/ecore_wl2/www-protocol.c | 41 | ||||
-rw-r--r-- | src/lib/ecore_wl2/www-protocol.h | 134 |
7 files changed, 294 insertions, 1 deletions
diff --git a/src/Makefile_Ecore_Wl2.am b/src/Makefile_Ecore_Wl2.am index d08414bb6b..1263ea2ed8 100644 --- a/src/Makefile_Ecore_Wl2.am +++ b/src/Makefile_Ecore_Wl2.am | |||
@@ -12,6 +12,8 @@ lib/ecore_wl2/subsurface-client-protocol.h \ | |||
12 | lib/ecore_wl2/subsurface-protocol.c \ | 12 | lib/ecore_wl2/subsurface-protocol.c \ |
13 | lib/ecore_wl2/xdg-shell-client-protocol.h \ | 13 | lib/ecore_wl2/xdg-shell-client-protocol.h \ |
14 | lib/ecore_wl2/xdg-shell-protocol.c \ | 14 | lib/ecore_wl2/xdg-shell-protocol.c \ |
15 | lib/ecore_wl2/www-protocol.h \ | ||
16 | lib/ecore_wl2/www-protocol.c \ | ||
15 | lib/ecore_wl2/ecore_wl2_seat.c \ | 17 | lib/ecore_wl2/ecore_wl2_seat.c \ |
16 | lib/ecore_wl2/ecore_wl2_subsurf.c \ | 18 | lib/ecore_wl2/ecore_wl2_subsurf.c \ |
17 | lib/ecore_wl2/ecore_wl2_dnd.c \ | 19 | lib/ecore_wl2/ecore_wl2_dnd.c \ |
diff --git a/src/lib/ecore_wl2/ecore_wl2.c b/src/lib/ecore_wl2/ecore_wl2.c index a8d328b7d0..b31b2de2e5 100644 --- a/src/lib/ecore_wl2/ecore_wl2.c +++ b/src/lib/ecore_wl2/ecore_wl2.c | |||
@@ -27,6 +27,9 @@ EAPI int ECORE_WL2_EVENT_SELECTION_DATA_READY = 0; | |||
27 | EAPI int ECORE_WL2_EVENT_WINDOW_CONFIGURE = 0; | 27 | EAPI int ECORE_WL2_EVENT_WINDOW_CONFIGURE = 0; |
28 | EAPI int ECORE_WL2_EVENT_SYNC_DONE = 0; | 28 | EAPI int ECORE_WL2_EVENT_SYNC_DONE = 0; |
29 | 29 | ||
30 | EAPI int _ecore_wl2_event_window_www = -1; | ||
31 | EAPI int _ecore_wl2_event_window_www_drag = -1; | ||
32 | |||
30 | /* public API functions */ | 33 | /* public API functions */ |
31 | EAPI int | 34 | EAPI int |
32 | ecore_wl2_init(void) | 35 | ecore_wl2_init(void) |
@@ -77,6 +80,8 @@ ecore_wl2_init(void) | |||
77 | ECORE_WL2_EVENT_SELECTION_DATA_READY = ecore_event_type_new(); | 80 | ECORE_WL2_EVENT_SELECTION_DATA_READY = ecore_event_type_new(); |
78 | ECORE_WL2_EVENT_WINDOW_CONFIGURE = ecore_event_type_new(); | 81 | ECORE_WL2_EVENT_WINDOW_CONFIGURE = ecore_event_type_new(); |
79 | ECORE_WL2_EVENT_SYNC_DONE = ecore_event_type_new(); | 82 | ECORE_WL2_EVENT_SYNC_DONE = ecore_event_type_new(); |
83 | _ecore_wl2_event_window_www = ecore_event_type_new(); | ||
84 | _ecore_wl2_event_window_www_drag = ecore_event_type_new(); | ||
80 | } | 85 | } |
81 | 86 | ||
82 | return _ecore_wl2_init_count; | 87 | return _ecore_wl2_init_count; |
diff --git a/src/lib/ecore_wl2/ecore_wl2_display.c b/src/lib/ecore_wl2/ecore_wl2_display.c index 6569a43d25..d141250543 100644 --- a/src/lib/ecore_wl2/ecore_wl2_display.c +++ b/src/lib/ecore_wl2/ecore_wl2_display.c | |||
@@ -119,6 +119,13 @@ _cb_global_add(void *data, struct wl_registry *registry, unsigned int id, const | |||
119 | EINA_INLIST_FOREACH(ewd->windows, window) | 119 | EINA_INLIST_FOREACH(ewd->windows, window) |
120 | _ecore_wl2_window_shell_surface_init(window); | 120 | _ecore_wl2_window_shell_surface_init(window); |
121 | } | 121 | } |
122 | else if (eina_streq(interface, "www")) | ||
123 | { | ||
124 | Ecore_Wl2_Window *window; | ||
125 | ewd->wl.www = wl_registry_bind(registry, id, &www_interface, 1); | ||
126 | EINA_INLIST_FOREACH(ewd->windows, window) | ||
127 | _ecore_wl2_window_www_surface_init(window); | ||
128 | } | ||
122 | else if (!strcmp(interface, "wl_output")) | 129 | else if (!strcmp(interface, "wl_output")) |
123 | _ecore_wl2_output_add(ewd, id); | 130 | _ecore_wl2_output_add(ewd, id); |
124 | else if (!strcmp(interface, "wl_seat")) | 131 | else if (!strcmp(interface, "wl_seat")) |
@@ -364,6 +371,7 @@ _ecore_wl2_display_cleanup(Ecore_Wl2_Display *ewd) | |||
364 | 371 | ||
365 | eina_hash_free(ewd->globals); | 372 | eina_hash_free(ewd->globals); |
366 | 373 | ||
374 | if (ewd->wl.www) www_destroy(ewd->wl.www); | ||
367 | if (ewd->wl.xdg_shell) xdg_shell_destroy(ewd->wl.xdg_shell); | 375 | if (ewd->wl.xdg_shell) xdg_shell_destroy(ewd->wl.xdg_shell); |
368 | if (ewd->wl.wl_shell) wl_shell_destroy(ewd->wl.wl_shell); | 376 | if (ewd->wl.wl_shell) wl_shell_destroy(ewd->wl.wl_shell); |
369 | if (ewd->wl.shm) wl_shm_destroy(ewd->wl.shm); | 377 | if (ewd->wl.shm) wl_shm_destroy(ewd->wl.shm); |
diff --git a/src/lib/ecore_wl2/ecore_wl2_private.h b/src/lib/ecore_wl2/ecore_wl2_private.h index a31e65098f..58e8744038 100644 --- a/src/lib/ecore_wl2/ecore_wl2_private.h +++ b/src/lib/ecore_wl2/ecore_wl2_private.h | |||
@@ -4,6 +4,7 @@ | |||
4 | # include <unistd.h> | 4 | # include <unistd.h> |
5 | # include "Ecore_Wl2.h" | 5 | # include "Ecore_Wl2.h" |
6 | # include "Ecore_Input.h" | 6 | # include "Ecore_Input.h" |
7 | # include "www-protocol.h" | ||
7 | 8 | ||
8 | /* NB: Test if subsurface protocol is part of wayland code, if not then | 9 | /* NB: Test if subsurface protocol is part of wayland code, if not then |
9 | * include our own copy */ | 10 | * include our own copy */ |
@@ -16,6 +17,20 @@ | |||
16 | 17 | ||
17 | extern int _ecore_wl2_log_dom; | 18 | extern int _ecore_wl2_log_dom; |
18 | 19 | ||
20 | # ifdef EAPI | ||
21 | # undef EAPI | ||
22 | # endif | ||
23 | |||
24 | # ifdef __GNUC__ | ||
25 | # if __GNUC__ >= 4 | ||
26 | # define EAPI __attribute__ ((visibility("default"))) | ||
27 | # else | ||
28 | # define EAPI | ||
29 | # endif | ||
30 | # else | ||
31 | # define EAPI | ||
32 | # endif | ||
33 | |||
19 | # ifdef ECORE_WL2_DEFAULT_LOG_COLOR | 34 | # ifdef ECORE_WL2_DEFAULT_LOG_COLOR |
20 | # undef ECORE_WL2_DEFAULT_LOG_COLOR | 35 | # undef ECORE_WL2_DEFAULT_LOG_COLOR |
21 | # endif | 36 | # endif |
@@ -62,6 +77,7 @@ struct _Ecore_Wl2_Display | |||
62 | struct wl_shm *shm; | 77 | struct wl_shm *shm; |
63 | struct wl_shell *wl_shell; | 78 | struct wl_shell *wl_shell; |
64 | struct xdg_shell *xdg_shell; | 79 | struct xdg_shell *xdg_shell; |
80 | struct www *www; | ||
65 | int compositor_version; | 81 | int compositor_version; |
66 | } wl; | 82 | } wl; |
67 | 83 | ||
@@ -117,6 +133,7 @@ struct _Ecore_Wl2_Window | |||
117 | struct wl_shell_surface *wl_shell_surface; | 133 | struct wl_shell_surface *wl_shell_surface; |
118 | struct xdg_surface *xdg_surface; | 134 | struct xdg_surface *xdg_surface; |
119 | struct xdg_popup *xdg_popup; | 135 | struct xdg_popup *xdg_popup; |
136 | struct www_surface *www_surface; | ||
120 | 137 | ||
121 | uint32_t configure_serial; | 138 | uint32_t configure_serial; |
122 | void (*configure_ack)(struct xdg_surface *surface, uint32_t serial); | 139 | void (*configure_ack)(struct xdg_surface *surface, uint32_t serial); |
@@ -405,4 +422,21 @@ void _ecore_wl2_dnd_del(Ecore_Wl2_Dnd_Source *source); | |||
405 | void _ecore_wl2_subsurf_free(Ecore_Wl2_Subsurface *subsurf); | 422 | void _ecore_wl2_subsurf_free(Ecore_Wl2_Subsurface *subsurf); |
406 | 423 | ||
407 | void _ecore_wl2_window_shell_surface_init(Ecore_Wl2_Window *window); | 424 | void _ecore_wl2_window_shell_surface_init(Ecore_Wl2_Window *window); |
425 | void _ecore_wl2_window_www_surface_init(Ecore_Wl2_Window *window); | ||
426 | |||
427 | typedef struct Ecore_Wl2_Event_Window_WWW | ||
428 | { | ||
429 | unsigned int window; | ||
430 | int x_rel; | ||
431 | int y_rel; | ||
432 | uint32_t timestamp; | ||
433 | } Ecore_Wl2_Event_Window_WWW; | ||
434 | |||
435 | typedef struct Ecore_Wl2_Event_Window_WWW_Drag | ||
436 | { | ||
437 | unsigned int window; | ||
438 | Eina_Bool dragging; | ||
439 | } Ecore_Wl2_Event_Window_WWW_Drag; | ||
440 | EAPI extern int _ecore_wl2_event_window_www; | ||
441 | EAPI extern int _ecore_wl2_event_window_www_drag; | ||
408 | #endif | 442 | #endif |
diff --git a/src/lib/ecore_wl2/ecore_wl2_window.c b/src/lib/ecore_wl2/ecore_wl2_window.c index 28359c20f3..1de96d3968 100644 --- a/src/lib/ecore_wl2/ecore_wl2_window.c +++ b/src/lib/ecore_wl2/ecore_wl2_window.c | |||
@@ -215,6 +215,68 @@ _ecore_wl2_window_type_set(Ecore_Wl2_Window *win) | |||
215 | } | 215 | } |
216 | } | 216 | } |
217 | 217 | ||
218 | static void | ||
219 | _www_surface_end_drag(void *data, struct www_surface *www_surface EINA_UNUSED) | ||
220 | { | ||
221 | Ecore_Wl2_Window *window = data; | ||
222 | Ecore_Wl2_Event_Window_WWW_Drag *ev; | ||
223 | |||
224 | ev = malloc(sizeof(Ecore_Wl2_Event_Window_WWW_Drag)); | ||
225 | EINA_SAFETY_ON_NULL_RETURN(ev); | ||
226 | ev->window = window->id; | ||
227 | ev->dragging = 0; | ||
228 | |||
229 | ecore_event_add(_ecore_wl2_event_window_www_drag, ev, NULL, NULL); | ||
230 | } | ||
231 | |||
232 | static void | ||
233 | _www_surface_start_drag(void *data, struct www_surface *www_surface EINA_UNUSED) | ||
234 | { | ||
235 | Ecore_Wl2_Window *window = data; | ||
236 | Ecore_Wl2_Event_Window_WWW_Drag *ev; | ||
237 | |||
238 | ev = malloc(sizeof(Ecore_Wl2_Event_Window_WWW_Drag)); | ||
239 | EINA_SAFETY_ON_NULL_RETURN(ev); | ||
240 | ev->window = window->id; | ||
241 | ev->dragging = 1; | ||
242 | |||
243 | ecore_event_add(_ecore_wl2_event_window_www_drag, ev, NULL, NULL); | ||
244 | } | ||
245 | |||
246 | static void | ||
247 | _www_surface_status(void *data, struct www_surface *www_surface EINA_UNUSED, int32_t x_rel, int32_t y_rel, uint32_t timestamp) | ||
248 | { | ||
249 | Ecore_Wl2_Window *window = data; | ||
250 | Ecore_Wl2_Event_Window_WWW *ev; | ||
251 | |||
252 | ev = malloc(sizeof(Ecore_Wl2_Event_Window_WWW)); | ||
253 | EINA_SAFETY_ON_NULL_RETURN(ev); | ||
254 | ev->window = window->id; | ||
255 | ev->x_rel = x_rel; | ||
256 | ev->y_rel = y_rel; | ||
257 | ev->timestamp = timestamp; | ||
258 | |||
259 | ecore_event_add(_ecore_wl2_event_window_www, ev, NULL, NULL); | ||
260 | } | ||
261 | |||
262 | static struct www_surface_listener _www_surface_listener = | ||
263 | { | ||
264 | .status = _www_surface_status, | ||
265 | .start_drag = _www_surface_start_drag, | ||
266 | .end_drag = _www_surface_end_drag, | ||
267 | }; | ||
268 | |||
269 | void | ||
270 | _ecore_wl2_window_www_surface_init(Ecore_Wl2_Window *window) | ||
271 | { | ||
272 | if (!window->surface) return; | ||
273 | if (!window->display->wl.www) return; | ||
274 | if (window->www_surface) return; | ||
275 | window->www_surface = www_create(window->display->wl.www, window->surface); | ||
276 | www_surface_set_user_data(window->www_surface, window); | ||
277 | www_surface_add_listener(window->www_surface, &_www_surface_listener, window); | ||
278 | } | ||
279 | |||
218 | void | 280 | void |
219 | _ecore_wl2_window_shell_surface_init(Ecore_Wl2_Window *window) | 281 | _ecore_wl2_window_shell_surface_init(Ecore_Wl2_Window *window) |
220 | { | 282 | { |
@@ -346,7 +408,10 @@ ecore_wl2_window_show(Ecore_Wl2_Window *window) | |||
346 | 408 | ||
347 | if ((window->type != ECORE_WL2_WINDOW_TYPE_DND) && | 409 | if ((window->type != ECORE_WL2_WINDOW_TYPE_DND) && |
348 | (window->type != ECORE_WL2_WINDOW_TYPE_NONE)) | 410 | (window->type != ECORE_WL2_WINDOW_TYPE_NONE)) |
349 | _ecore_wl2_window_shell_surface_init(window); | 411 | { |
412 | _ecore_wl2_window_shell_surface_init(window); | ||
413 | _ecore_wl2_window_www_surface_init(window); | ||
414 | } | ||
350 | } | 415 | } |
351 | 416 | ||
352 | EAPI void | 417 | EAPI void |
@@ -364,6 +429,10 @@ ecore_wl2_window_hide(Ecore_Wl2_Window *window) | |||
364 | wl_shell_surface_destroy(window->wl_shell_surface); | 429 | wl_shell_surface_destroy(window->wl_shell_surface); |
365 | window->wl_shell_surface = NULL; | 430 | window->wl_shell_surface = NULL; |
366 | 431 | ||
432 | if (window->www_surface) | ||
433 | www_surface_destroy(window->www_surface); | ||
434 | window->www_surface = NULL; | ||
435 | |||
367 | if (window->surface) wl_surface_destroy(window->surface); | 436 | if (window->surface) wl_surface_destroy(window->surface); |
368 | window->surface = NULL; | 437 | window->surface = NULL; |
369 | } | 438 | } |
diff --git a/src/lib/ecore_wl2/www-protocol.c b/src/lib/ecore_wl2/www-protocol.c new file mode 100644 index 0000000000..952b333b58 --- /dev/null +++ b/src/lib/ecore_wl2/www-protocol.c | |||
@@ -0,0 +1,41 @@ | |||
1 | #include <stdlib.h> | ||
2 | #include <stdint.h> | ||
3 | #include "wayland-util.h" | ||
4 | |||
5 | extern const struct wl_interface wl_surface_interface; | ||
6 | extern const struct wl_interface www_surface_interface; | ||
7 | |||
8 | static const struct wl_interface *types[] = { | ||
9 | NULL, | ||
10 | NULL, | ||
11 | NULL, | ||
12 | &www_surface_interface, | ||
13 | &wl_surface_interface, | ||
14 | }; | ||
15 | |||
16 | static const struct wl_message www_requests[] = { | ||
17 | { "create", "no", types + 3 }, | ||
18 | }; | ||
19 | |||
20 | WL_EXPORT const struct wl_interface www_interface = { | ||
21 | "www", 1, | ||
22 | 1, www_requests, | ||
23 | 0, NULL, | ||
24 | }; | ||
25 | |||
26 | static const struct wl_message www_surface_requests[] = { | ||
27 | { "destroy", "", types + 0 }, | ||
28 | }; | ||
29 | |||
30 | static const struct wl_message www_surface_events[] = { | ||
31 | { "status", "iiu", types + 0 }, | ||
32 | { "start_drag", "", types + 0 }, | ||
33 | { "end_drag", "", types + 0 }, | ||
34 | }; | ||
35 | |||
36 | WL_EXPORT const struct wl_interface www_surface_interface = { | ||
37 | "www_surface", 1, | ||
38 | 1, www_surface_requests, | ||
39 | 3, www_surface_events, | ||
40 | }; | ||
41 | |||
diff --git a/src/lib/ecore_wl2/www-protocol.h b/src/lib/ecore_wl2/www-protocol.h new file mode 100644 index 0000000000..b7d553d795 --- /dev/null +++ b/src/lib/ecore_wl2/www-protocol.h | |||
@@ -0,0 +1,134 @@ | |||
1 | #ifndef ZWP_WWW_CLIENT_PROTOCOL_H | ||
2 | #define ZWP_WWW_CLIENT_PROTOCOL_H | ||
3 | |||
4 | #ifdef __cplusplus | ||
5 | extern "C" { | ||
6 | #endif | ||
7 | |||
8 | #include <stdint.h> | ||
9 | #include <stddef.h> | ||
10 | #include "wayland-client.h" | ||
11 | |||
12 | struct wl_client; | ||
13 | struct wl_resource; | ||
14 | |||
15 | struct wl_surface; | ||
16 | struct www; | ||
17 | struct www_surface; | ||
18 | |||
19 | extern const struct wl_interface www_interface; | ||
20 | extern const struct wl_interface www_surface_interface; | ||
21 | |||
22 | #define WWW_CREATE 0 | ||
23 | |||
24 | #define WWW_CREATE_SINCE_VERSION 1 | ||
25 | |||
26 | static inline void | ||
27 | www_set_user_data(struct www *www, void *user_data) | ||
28 | { | ||
29 | wl_proxy_set_user_data((struct wl_proxy *) www, user_data); | ||
30 | } | ||
31 | |||
32 | static inline void * | ||
33 | www_get_user_data(struct www *www) | ||
34 | { | ||
35 | return wl_proxy_get_user_data((struct wl_proxy *) www); | ||
36 | } | ||
37 | |||
38 | static inline uint32_t | ||
39 | www_get_version(struct www *www) | ||
40 | { | ||
41 | return wl_proxy_get_version((struct wl_proxy *) www); | ||
42 | } | ||
43 | |||
44 | static inline void | ||
45 | www_destroy(struct www *www) | ||
46 | { | ||
47 | wl_proxy_destroy((struct wl_proxy *) www); | ||
48 | } | ||
49 | |||
50 | static inline struct www_surface * | ||
51 | www_create(struct www *www, struct wl_surface *surface) | ||
52 | { | ||
53 | struct wl_proxy *id; | ||
54 | |||
55 | id = wl_proxy_marshal_constructor((struct wl_proxy *) www, | ||
56 | WWW_CREATE, &www_surface_interface, NULL, surface); | ||
57 | |||
58 | return (struct www_surface *) id; | ||
59 | } | ||
60 | |||
61 | struct www_surface_listener { | ||
62 | /** | ||
63 | * status - Status update on a www_surface | ||
64 | * @x_rel: (none) | ||
65 | * @y_rel: (none) | ||
66 | * @timestamp: (none) | ||
67 | * | ||
68 | * | ||
69 | */ | ||
70 | void (*status)(void *data, | ||
71 | struct www_surface *www_surface, | ||
72 | int32_t x_rel, | ||
73 | int32_t y_rel, | ||
74 | uint32_t timestamp); | ||
75 | /** | ||
76 | * start_drag - Drag has started | ||
77 | * | ||
78 | * | ||
79 | */ | ||
80 | void (*start_drag)(void *data, | ||
81 | struct www_surface *www_surface); | ||
82 | /** | ||
83 | * end_drag - Drag has ended | ||
84 | * | ||
85 | * | ||
86 | */ | ||
87 | void (*end_drag)(void *data, | ||
88 | struct www_surface *www_surface); | ||
89 | }; | ||
90 | |||
91 | static inline int | ||
92 | www_surface_add_listener(struct www_surface *www_surface, | ||
93 | const struct www_surface_listener *listener, void *data) | ||
94 | { | ||
95 | return wl_proxy_add_listener((struct wl_proxy *) www_surface, | ||
96 | (void (**)(void)) listener, data); | ||
97 | } | ||
98 | |||
99 | #define WWW_SURFACE_DESTROY 0 | ||
100 | |||
101 | #define WWW_SURFACE_DESTROY_SINCE_VERSION 1 | ||
102 | |||
103 | static inline void | ||
104 | www_surface_set_user_data(struct www_surface *www_surface, void *user_data) | ||
105 | { | ||
106 | wl_proxy_set_user_data((struct wl_proxy *) www_surface, user_data); | ||
107 | } | ||
108 | |||
109 | static inline void * | ||
110 | www_surface_get_user_data(struct www_surface *www_surface) | ||
111 | { | ||
112 | return wl_proxy_get_user_data((struct wl_proxy *) www_surface); | ||
113 | } | ||
114 | |||
115 | static inline uint32_t | ||
116 | www_surface_get_version(struct www_surface *www_surface) | ||
117 | { | ||
118 | return wl_proxy_get_version((struct wl_proxy *) www_surface); | ||
119 | } | ||
120 | |||
121 | static inline void | ||
122 | www_surface_destroy(struct www_surface *www_surface) | ||
123 | { | ||
124 | wl_proxy_marshal((struct wl_proxy *) www_surface, | ||
125 | WWW_SURFACE_DESTROY); | ||
126 | |||
127 | wl_proxy_destroy((struct wl_proxy *) www_surface); | ||
128 | } | ||
129 | |||
130 | #ifdef __cplusplus | ||
131 | } | ||
132 | #endif | ||
133 | |||
134 | #endif | ||