summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvivek <vivek.ellur@samsung.com>2014-08-13 08:51:02 -0400
committerChris Michael <cp.michael@samsung.com>2014-08-13 09:41:26 -0400
commit2f4db577b524e0813ee0777642a2690d252977fd (patch)
tree29af64127dc1bdff4a679b22d163f852611737b6
parent4ad176e4813aaff9f7fd66fdc8785023cc146600 (diff)
Added support for xdg-shell protocol in ecore-wayland
Summary: Signed-off-by: vivek <vivek.ellur@samsung.com> Reviewers: devilhorns Subscribers: cedric Differential Revision: https://phab.enlightenment.org/D1326
-rw-r--r--src/Makefile_Ecore_Wayland.am4
-rw-r--r--src/lib/ecore_wayland/Ecore_Wayland.h1
-rw-r--r--src/lib/ecore_wayland/ecore_wl.c24
-rw-r--r--src/lib/ecore_wayland/ecore_wl_private.h9
-rw-r--r--src/lib/ecore_wayland/ecore_wl_window.c71
-rw-r--r--src/lib/ecore_wayland/xdg-shell-client-protocol.h496
-rw-r--r--src/lib/ecore_wayland/xdg-shell-protocol.c125
7 files changed, 729 insertions, 1 deletions
diff --git a/src/Makefile_Ecore_Wayland.am b/src/Makefile_Ecore_Wayland.am
index f11c3a5f74..c93162a10b 100644
--- a/src/Makefile_Ecore_Wayland.am
+++ b/src/Makefile_Ecore_Wayland.am
@@ -17,7 +17,9 @@ lib/ecore_wayland/ecore_wl_window.c \
17lib/ecore_wayland/ecore_wl_subsurf.c \ 17lib/ecore_wayland/ecore_wl_subsurf.c \
18lib/ecore_wayland/ecore_wl_private.h \ 18lib/ecore_wayland/ecore_wl_private.h \
19lib/ecore_wayland/subsurface-protocol.c \ 19lib/ecore_wayland/subsurface-protocol.c \
20lib/ecore_wayland/subsurface-client-protocol.h 20lib/ecore_wayland/subsurface-client-protocol.h \
21lib/ecore_wayland/xdg-shell-client-protocol.h \
22lib/ecore_wayland/xdg-shell-protocol.c
21 23
22lib_ecore_wayland_libecore_wayland_la_CPPFLAGS = -I$(top_builddir)/src/lib/efl @ECORE_WAYLAND_CFLAGS@ 24lib_ecore_wayland_libecore_wayland_la_CPPFLAGS = -I$(top_builddir)/src/lib/efl @ECORE_WAYLAND_CFLAGS@
23lib_ecore_wayland_libecore_wayland_la_LIBADD = @ECORE_WAYLAND_LIBS@ 25lib_ecore_wayland_libecore_wayland_la_LIBADD = @ECORE_WAYLAND_LIBS@
diff --git a/src/lib/ecore_wayland/Ecore_Wayland.h b/src/lib/ecore_wayland/Ecore_Wayland.h
index f0bdf880db..289df31f78 100644
--- a/src/lib/ecore_wayland/Ecore_Wayland.h
+++ b/src/lib/ecore_wayland/Ecore_Wayland.h
@@ -548,6 +548,7 @@ EAPI void ecore_wl_window_update_size(Ecore_Wl_Window *win, int w, int h);
548EAPI void ecore_wl_window_update_location(Ecore_Wl_Window *win, int x, int y); 548EAPI void ecore_wl_window_update_location(Ecore_Wl_Window *win, int x, int y);
549EAPI struct wl_surface *ecore_wl_window_surface_get(Ecore_Wl_Window *win); 549EAPI struct wl_surface *ecore_wl_window_surface_get(Ecore_Wl_Window *win);
550EAPI struct wl_shell_surface *ecore_wl_window_shell_surface_get(Ecore_Wl_Window *win); 550EAPI struct wl_shell_surface *ecore_wl_window_shell_surface_get(Ecore_Wl_Window *win);
551EAPI struct xdg_surface *ecore_wl_window_xdg_surface_get(Ecore_Wl_Window *win);
551EAPI Ecore_Wl_Window *ecore_wl_window_find(unsigned int id); 552EAPI Ecore_Wl_Window *ecore_wl_window_find(unsigned int id);
552EAPI void ecore_wl_window_type_set(Ecore_Wl_Window *win, Ecore_Wl_Window_Type type); 553EAPI void ecore_wl_window_type_set(Ecore_Wl_Window *win, Ecore_Wl_Window_Type type);
553EAPI void ecore_wl_window_pointer_set(Ecore_Wl_Window *win, struct wl_surface *surface, int hot_x, int hot_y); 554EAPI void ecore_wl_window_pointer_set(Ecore_Wl_Window *win, struct wl_surface *surface, int hot_x, int hot_y);
diff --git a/src/lib/ecore_wayland/ecore_wl.c b/src/lib/ecore_wayland/ecore_wl.c
index 49d10b74e5..c4f87b0697 100644
--- a/src/lib/ecore_wayland/ecore_wl.c
+++ b/src/lib/ecore_wayland/ecore_wl.c
@@ -16,6 +16,9 @@
16# include <subsurface-client-protocol.h> 16# include <subsurface-client-protocol.h>
17#endif 17#endif
18 18
19#include "xdg-shell-client-protocol.h"
20#define XDG_VERSION 3
21
19/* local function prototypes */ 22/* local function prototypes */
20static Eina_Bool _ecore_wl_shutdown(Eina_Bool close); 23static Eina_Bool _ecore_wl_shutdown(Eina_Bool close);
21static Eina_Bool _ecore_wl_cb_idle_enterer(void *data); 24static Eina_Bool _ecore_wl_cb_idle_enterer(void *data);
@@ -61,6 +64,17 @@ static const struct wl_callback_listener _ecore_wl_anim_listener =
61 _ecore_wl_animator_callback 64 _ecore_wl_animator_callback
62}; 65};
63 66
67static void xdg_shell_ping(void *data, struct xdg_shell *shell, uint32_t serial)
68{
69 xdg_shell_pong(shell, serial);
70}
71
72static const struct xdg_shell_listener xdg_shell_listener =
73{
74 xdg_shell_ping,
75};
76
77
64/* external variables */ 78/* external variables */
65int _ecore_wl_log_dom = -1; 79int _ecore_wl_log_dom = -1;
66Ecore_Wl_Display *_ecore_wl_disp = NULL; 80Ecore_Wl_Display *_ecore_wl_disp = NULL;
@@ -458,6 +472,8 @@ _ecore_wl_shutdown(Eina_Bool close)
458 472
459 _ecore_wl_xkb_shutdown(_ecore_wl_disp); 473 _ecore_wl_xkb_shutdown(_ecore_wl_disp);
460 474
475 if (_ecore_wl_disp->wl.xdg_shell)
476 xdg_shell_destroy(_ecore_wl_disp->wl.xdg_shell);
461 if (_ecore_wl_disp->wl.shell) 477 if (_ecore_wl_disp->wl.shell)
462 wl_shell_destroy(_ecore_wl_disp->wl.shell); 478 wl_shell_destroy(_ecore_wl_disp->wl.shell);
463 if (_ecore_wl_disp->wl.shm) wl_shm_destroy(_ecore_wl_disp->wl.shm); 479 if (_ecore_wl_disp->wl.shm) wl_shm_destroy(_ecore_wl_disp->wl.shm);
@@ -599,6 +615,14 @@ _ecore_wl_cb_handle_global(void *data, struct wl_registry *registry, unsigned in
599 _ecore_wl_output_add(ewd, id); 615 _ecore_wl_output_add(ewd, id);
600 else if (!strcmp(interface, "wl_seat")) 616 else if (!strcmp(interface, "wl_seat"))
601 _ecore_wl_input_add(ewd, id); 617 _ecore_wl_input_add(ewd, id);
618 else if (!strcmp(interface, "xdg_shell"))
619 {
620 ewd->wl.xdg_shell = wl_registry_bind(registry, id,
621 &xdg_shell_interface, 1);
622 xdg_shell_use_unstable_version(ewd->wl.xdg_shell, XDG_VERSION);
623 xdg_shell_add_listener(ewd->wl.xdg_shell, &xdg_shell_listener,
624 ewd->wl.display);
625 }
602 else if (!strcmp(interface, "wl_shell")) 626 else if (!strcmp(interface, "wl_shell"))
603 { 627 {
604 ewd->wl.shell = 628 ewd->wl.shell =
diff --git a/src/lib/ecore_wayland/ecore_wl_private.h b/src/lib/ecore_wayland/ecore_wl_private.h
index c7791a9910..afead8332a 100644
--- a/src/lib/ecore_wayland/ecore_wl_private.h
+++ b/src/lib/ecore_wayland/ecore_wl_private.h
@@ -60,6 +60,7 @@ struct _Ecore_Wl_Display
60 struct wl_compositor *compositor; 60 struct wl_compositor *compositor;
61 struct wl_subcompositor *subcompositor; 61 struct wl_subcompositor *subcompositor;
62 struct wl_shell *shell; 62 struct wl_shell *shell;
63 struct xdg_shell *xdg_shell;
63 struct wl_shell *desktop_shell; 64 struct wl_shell *desktop_shell;
64 struct wl_shm *shm; 65 struct wl_shm *shm;
65 struct wl_data_device_manager *data_device_manager; 66 struct wl_data_device_manager *data_device_manager;
@@ -100,6 +101,14 @@ struct _Ecore_Wl_Window
100 struct wl_surface *surface; 101 struct wl_surface *surface;
101 struct wl_shell_surface *shell_surface; 102 struct wl_shell_surface *shell_surface;
102 103
104 struct xdg_surface *xdg_surface;
105 struct xdg_popup *xdg_popup;
106 Eina_Bool focused : 1;
107 Eina_Bool resizing : 1;
108
109 Eina_Bool fullscreen : 1;
110 Eina_Bool maximized : 1;
111
103 struct 112 struct
104 { 113 {
105 struct wl_surface *surface; 114 struct wl_surface *surface;
diff --git a/src/lib/ecore_wayland/ecore_wl_window.c b/src/lib/ecore_wayland/ecore_wl_window.c
index 5dfb35c7bc..3fb5f87830 100644
--- a/src/lib/ecore_wayland/ecore_wl_window.c
+++ b/src/lib/ecore_wayland/ecore_wl_window.c
@@ -3,6 +3,7 @@
3#endif 3#endif
4 4
5#include "ecore_wl_private.h" 5#include "ecore_wl_private.h"
6#include "xdg-shell-client-protocol.h"
6 7
7/* local function prototypes */ 8/* local function prototypes */
8static void _ecore_wl_window_cb_ping(void *data EINA_UNUSED, struct wl_shell_surface *shell_surface, unsigned int serial); 9static void _ecore_wl_window_cb_ping(void *data EINA_UNUSED, struct wl_shell_surface *shell_surface, unsigned int serial);
@@ -12,6 +13,9 @@ static void _ecore_wl_window_cb_surface_enter(void *data, struct wl_surface *sur
12static void _ecore_wl_window_cb_surface_leave(void *data, struct wl_surface *surface, struct wl_output *output EINA_UNUSED); 13static void _ecore_wl_window_cb_surface_leave(void *data, struct wl_surface *surface, struct wl_output *output EINA_UNUSED);
13static void _ecore_wl_window_configure_send(Ecore_Wl_Window *win, int w, int h, int edges); 14static void _ecore_wl_window_configure_send(Ecore_Wl_Window *win, int w, int h, int edges);
14static char *_ecore_wl_window_id_str_get(unsigned int win_id); 15static char *_ecore_wl_window_id_str_get(unsigned int win_id);
16static void _ecore_xdg_handle_surface_configure(void *data, struct xdg_surface *xdg_surface, int32_t width, int32_t height,struct wl_array *states, uint32_t serial);
17static void _ecore_xdg_handle_popup_done(void *data, struct xdg_popup *xdg_popup, unsigned int serial);
18
15 19
16/* local variables */ 20/* local variables */
17static Eina_Hash *_windows = NULL; 21static Eina_Hash *_windows = NULL;
@@ -30,6 +34,14 @@ static const struct wl_shell_surface_listener _ecore_wl_shell_surface_listener =
30 _ecore_wl_window_cb_popup_done 34 _ecore_wl_window_cb_popup_done
31}; 35};
32 36
37static const struct xdg_surface_listener _ecore_xdg_surface_listener = {
38 _ecore_xdg_handle_surface_configure,
39};
40
41static const struct xdg_popup_listener _ecore_xdg_popup_listener = {
42 _ecore_xdg_handle_popup_done,
43};
44
33/* internal functions */ 45/* internal functions */
34void 46void
35_ecore_wl_window_init(void) 47_ecore_wl_window_init(void)
@@ -787,6 +799,53 @@ _ecore_wl_window_cb_configure(void *data, struct wl_shell_surface *shell_surface
787 } 799 }
788} 800}
789 801
802static void
803_ecore_xdg_handle_surface_configure(void *data, struct xdg_surface *xdg_surface, int32_t width, int32_t height, struct wl_array *states, uint32_t serial)
804{
805 Ecore_Wl_Window *win = data;
806 uint32_t *p;
807
808 LOGFN(__FILE__, __LINE__, __FUNCTION__);
809
810 win->maximized = EINA_FALSE;
811 win->fullscreen = EINA_FALSE;
812 win->resizing = EINA_FALSE;
813 win->focused = EINA_FALSE;
814
815 wl_array_for_each(p, states)
816 {
817 uint32_t state = *p;
818 switch (state)
819 {
820 case XDG_SURFACE_STATE_MAXIMIZED:
821 win->maximized = EINA_TRUE;
822 break;
823 case XDG_SURFACE_STATE_FULLSCREEN:
824 win->fullscreen = EINA_TRUE;
825 break;
826 case XDG_SURFACE_STATE_RESIZING:
827 win->resizing = EINA_TRUE;
828 break;
829 case XDG_SURFACE_STATE_ACTIVATED:
830 win->focused = EINA_TRUE;
831 break;
832 default:
833 break;
834 }
835 }
836 if ((width > 0) && (height > 0))
837 {
838 _ecore_wl_window_configure_send(win, width, height, 0);
839 }
840 else
841 {
842 if ((win->saved.w != 1) || (win->saved.h != 1))
843 _ecore_wl_window_configure_send(win, win->saved.w, win->saved.h, 0);
844 }
845
846 xdg_surface_ack_configure(win->xdg_surface, serial);
847}
848
790static void 849static void
791_ecore_wl_window_cb_popup_done(void *data, struct wl_shell_surface *shell_surface EINA_UNUSED) 850_ecore_wl_window_cb_popup_done(void *data, struct wl_shell_surface *shell_surface EINA_UNUSED)
792{ 851{
@@ -799,6 +858,18 @@ _ecore_wl_window_cb_popup_done(void *data, struct wl_shell_surface *shell_surfac
799 ecore_wl_input_ungrab(win->pointer_device); 858 ecore_wl_input_ungrab(win->pointer_device);
800} 859}
801 860
861static void
862_ecore_xdg_handle_popup_done(void *data, struct xdg_popup *xdg_popup, unsigned int serial)
863{
864 Ecore_Wl_Window *win;
865
866 LOGFN(__FILE__, __LINE__, __FUNCTION__);
867
868 if (!xdg_popup) return;
869 if (!(win = data)) return;
870 ecore_wl_input_ungrab(win->pointer_device);
871}
872
802static void 873static void
803_ecore_wl_window_cb_surface_enter(void *data, struct wl_surface *surface, struct wl_output *output EINA_UNUSED) 874_ecore_wl_window_cb_surface_enter(void *data, struct wl_surface *surface, struct wl_output *output EINA_UNUSED)
804{ 875{
diff --git a/src/lib/ecore_wayland/xdg-shell-client-protocol.h b/src/lib/ecore_wayland/xdg-shell-client-protocol.h
new file mode 100644
index 0000000000..11eb5cfa5d
--- /dev/null
+++ b/src/lib/ecore_wayland/xdg-shell-client-protocol.h
@@ -0,0 +1,496 @@
1/*
2 * Copyright © 2008-2013 Kristian Høgsberg
3 * Copyright © 2013 Rafael Antognolli
4 * Copyright © 2013 Jasper St. Pierre
5 * Copyright © 2010-2013 Intel Corporation
6 *
7 * Permission to use, copy, modify, distribute, and sell this
8 * software and its documentation for any purpose is hereby granted
9 * without fee, provided that the above copyright notice appear in
10 * all copies and that both that copyright notice and this permission
11 * notice appear in supporting documentation, and that the name of
12 * the copyright holders not be used in advertising or publicity
13 * pertaining to distribution of the software without specific,
14 * written prior permission. The copyright holders make no
15 * representations about the suitability of this software for any
16 * purpose. It is provided "as is" without express or implied
17 * warranty.
18 *
19 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
20 * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
21 * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
22 * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
23 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
24 * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
25 * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
26 * THIS SOFTWARE.
27 */
28
29#ifndef XDG_SHELL_CLIENT_PROTOCOL_H
30#define XDG_SHELL_CLIENT_PROTOCOL_H
31
32#ifdef __cplusplus
33extern "C" {
34#endif
35
36#include <stdint.h>
37#include <stddef.h>
38#include "wayland-client.h"
39
40struct wl_client;
41struct wl_resource;
42
43struct xdg_shell;
44struct xdg_surface;
45struct xdg_popup;
46
47extern const struct wl_interface xdg_shell_interface;
48extern const struct wl_interface xdg_surface_interface;
49extern const struct wl_interface xdg_popup_interface;
50
51#ifndef XDG_SHELL_VERSION_ENUM
52#define XDG_SHELL_VERSION_ENUM
53/**
54 * xdg_shell_version - latest protocol version
55 * @XDG_SHELL_VERSION_CURRENT: Always the latest version
56 *
57 * The 'current' member of this enum gives the version of the protocol.
58 * Implementations can compare this to the version they implement using
59 * static_assert to ensure the protocol and implementation versions match.
60 */
61enum xdg_shell_version {
62 XDG_SHELL_VERSION_CURRENT = 3,
63};
64#endif /* XDG_SHELL_VERSION_ENUM */
65
66/**
67 * xdg_shell - create desktop-style surfaces
68 * @ping: check if the client is alive
69 *
70 * This interface is implemented by servers that provide desktop-style
71 * user interfaces.
72 *
73 * It allows clients to associate a xdg_surface with a basic surface.
74 */
75struct xdg_shell_listener {
76 /**
77 * ping - check if the client is alive
78 * @serial: pass this to the callback
79 *
80 * The ping event asks the client if it's still alive. Pass the
81 * serial specified in the event back to the compositor by sending
82 * a "pong" request back with the specified serial.
83 *
84 * Compositors can use this to determine if the client is still
85 * alive. It's unspecified what will happen if the client doesn't
86 * respond to the ping request, or in what timeframe. Clients
87 * should try to respond in a reasonable amount of time.
88 */
89 void (*ping)(void *data,
90 struct xdg_shell *xdg_shell,
91 uint32_t serial);
92};
93
94static inline int
95xdg_shell_add_listener(struct xdg_shell *xdg_shell,
96 const struct xdg_shell_listener *listener, void *data)
97{
98 return wl_proxy_add_listener((struct wl_proxy *) xdg_shell,
99 (void (**)(void)) listener, data);
100}
101
102#define XDG_SHELL_USE_UNSTABLE_VERSION 0
103#define XDG_SHELL_GET_XDG_SURFACE 1
104#define XDG_SHELL_GET_XDG_POPUP 2
105#define XDG_SHELL_PONG 3
106
107static inline void
108xdg_shell_set_user_data(struct xdg_shell *xdg_shell, void *user_data)
109{
110 wl_proxy_set_user_data((struct wl_proxy *) xdg_shell, user_data);
111}
112
113static inline void *
114xdg_shell_get_user_data(struct xdg_shell *xdg_shell)
115{
116 return wl_proxy_get_user_data((struct wl_proxy *) xdg_shell);
117}
118
119static inline void
120xdg_shell_destroy(struct xdg_shell *xdg_shell)
121{
122 wl_proxy_destroy((struct wl_proxy *) xdg_shell);
123}
124
125static inline void
126xdg_shell_use_unstable_version(struct xdg_shell *xdg_shell, int32_t version)
127{
128 wl_proxy_marshal((struct wl_proxy *) xdg_shell,
129 XDG_SHELL_USE_UNSTABLE_VERSION, version);
130}
131
132static inline struct xdg_surface *
133xdg_shell_get_xdg_surface(struct xdg_shell *xdg_shell, struct wl_surface *surface)
134{
135 struct wl_proxy *id;
136
137 id = wl_proxy_marshal_constructor((struct wl_proxy *) xdg_shell,
138 XDG_SHELL_GET_XDG_SURFACE, &xdg_surface_interface, NULL, surface);
139
140 return (struct xdg_surface *) id;
141}
142
143static inline struct xdg_popup *
144xdg_shell_get_xdg_popup(struct xdg_shell *xdg_shell, struct wl_surface *surface, struct wl_surface *parent, struct wl_seat *seat, uint32_t serial, int32_t x, int32_t y, uint32_t flags)
145{
146 struct wl_proxy *id;
147
148 id = wl_proxy_marshal_constructor((struct wl_proxy *) xdg_shell,
149 XDG_SHELL_GET_XDG_POPUP, &xdg_popup_interface, NULL, surface, parent, seat, serial, x, y, flags);
150
151 return (struct xdg_popup *) id;
152}
153
154static inline void
155xdg_shell_pong(struct xdg_shell *xdg_shell, uint32_t serial)
156{
157 wl_proxy_marshal((struct wl_proxy *) xdg_shell,
158 XDG_SHELL_PONG, serial);
159}
160
161#ifndef XDG_SURFACE_RESIZE_EDGE_ENUM
162#define XDG_SURFACE_RESIZE_EDGE_ENUM
163/**
164 * xdg_surface_resize_edge - edge values for resizing
165 * @XDG_SURFACE_RESIZE_EDGE_NONE: (none)
166 * @XDG_SURFACE_RESIZE_EDGE_TOP: (none)
167 * @XDG_SURFACE_RESIZE_EDGE_BOTTOM: (none)
168 * @XDG_SURFACE_RESIZE_EDGE_LEFT: (none)
169 * @XDG_SURFACE_RESIZE_EDGE_TOP_LEFT: (none)
170 * @XDG_SURFACE_RESIZE_EDGE_BOTTOM_LEFT: (none)
171 * @XDG_SURFACE_RESIZE_EDGE_RIGHT: (none)
172 * @XDG_SURFACE_RESIZE_EDGE_TOP_RIGHT: (none)
173 * @XDG_SURFACE_RESIZE_EDGE_BOTTOM_RIGHT: (none)
174 *
175 * These values are used to indicate which edge of a surface is being
176 * dragged in a resize operation. The server may use this information to
177 * adapt its behavior, e.g. choose an appropriate cursor image.
178 */
179enum xdg_surface_resize_edge {
180 XDG_SURFACE_RESIZE_EDGE_NONE = 0,
181 XDG_SURFACE_RESIZE_EDGE_TOP = 1,
182 XDG_SURFACE_RESIZE_EDGE_BOTTOM = 2,
183 XDG_SURFACE_RESIZE_EDGE_LEFT = 4,
184 XDG_SURFACE_RESIZE_EDGE_TOP_LEFT = 5,
185 XDG_SURFACE_RESIZE_EDGE_BOTTOM_LEFT = 6,
186 XDG_SURFACE_RESIZE_EDGE_RIGHT = 8,
187 XDG_SURFACE_RESIZE_EDGE_TOP_RIGHT = 9,
188 XDG_SURFACE_RESIZE_EDGE_BOTTOM_RIGHT = 10,
189};
190#endif /* XDG_SURFACE_RESIZE_EDGE_ENUM */
191
192#ifndef XDG_SURFACE_STATE_ENUM
193#define XDG_SURFACE_STATE_ENUM
194/**
195 * xdg_surface_state - types of state on the surface
196 * @XDG_SURFACE_STATE_MAXIMIZED: the surface is maximized
197 * @XDG_SURFACE_STATE_FULLSCREEN: the surface is fullscreen
198 * @XDG_SURFACE_STATE_RESIZING: (none)
199 * @XDG_SURFACE_STATE_ACTIVATED: (none)
200 *
201 * The different state values used on the surface. This is designed for
202 * state values like maximized, fullscreen. It is paired with the configure
203 * event to ensure that both the client and the compositor setting the
204 * state can be synchronized.
205 *
206 * States set in this way are double-buffered. They will get applied on the
207 * next commit.
208 *
209 * Desktop environments may extend this enum by taking up a range of values
210 * and documenting the range they chose in this description. They are not
211 * required to document the values for the range that they chose. Ideally,
212 * any good extensions from a desktop environment should make its way into
213 * standardization into this enum.
214 *
215 * The current reserved ranges are:
216 *
217 * 0x0000 - 0x0FFF: xdg-shell core values, documented below. 0x1000 -
218 * 0x1FFF: GNOME
219 */
220enum xdg_surface_state {
221 XDG_SURFACE_STATE_MAXIMIZED = 1,
222 XDG_SURFACE_STATE_FULLSCREEN = 2,
223 XDG_SURFACE_STATE_RESIZING = 3,
224 XDG_SURFACE_STATE_ACTIVATED = 4,
225};
226#endif /* XDG_SURFACE_STATE_ENUM */
227
228/**
229 * xdg_surface - desktop-style metadata interface
230 * @configure: suggest a surface change
231 * @close: surface wants to be closed
232 *
233 * An interface that may be implemented by a wl_surface, for
234 * implementations that provide a desktop-style user interface.
235 *
236 * It provides requests to treat surfaces like windows, allowing to set
237 * properties like maximized, fullscreen, minimized, and to move and resize
238 * them, and associate metadata like title and app id.
239 *
240 * On the server side the object is automatically destroyed when the
241 * related wl_surface is destroyed. On client side, xdg_surface.destroy()
242 * must be called before destroying the wl_surface object.
243 */
244struct xdg_surface_listener {
245 /**
246 * configure - suggest a surface change
247 * @width: (none)
248 * @height: (none)
249 * @states: (none)
250 * @serial: (none)
251 *
252 * The configure event asks the client to resize its surface.
253 *
254 * The width and height arguments specify a hint to the window
255 * about how its surface should be resized in window geometry
256 * coordinates. The states listed in the event specify how the
257 * width/height arguments should be interpreted.
258 *
259 * A client should arrange a new surface, and then send a
260 * ack_configure request with the serial sent in this configure
261 * event before attaching a new surface.
262 *
263 * If the client receives multiple configure events before it can
264 * respond to one, it is free to discard all but the last event it
265 * received.
266 */
267 void (*configure)(void *data,
268 struct xdg_surface *xdg_surface,
269 int32_t width,
270 int32_t height,
271 struct wl_array *states,
272 uint32_t serial);
273 /**
274 * close - surface wants to be closed
275 *
276 * The close event is sent by the compositor when the user wants
277 * the surface to be closed. This should be equivalent to the user
278 * clicking the close button in client-side decorations, if your
279 * application has any...
280 *
281 * This is only a request that the user intends to close your
282 * window. The client may choose to ignore this request, or show a
283 * dialog to ask the user to save their data...
284 */
285 void (*close)(void *data,
286 struct xdg_surface *xdg_surface);
287};
288
289static inline int
290xdg_surface_add_listener(struct xdg_surface *xdg_surface,
291 const struct xdg_surface_listener *listener, void *data)
292{
293 return wl_proxy_add_listener((struct wl_proxy *) xdg_surface,
294 (void (**)(void)) listener, data);
295}
296
297#define XDG_SURFACE_DESTROY 0
298#define XDG_SURFACE_SET_PARENT 1
299#define XDG_SURFACE_SET_TITLE 2
300#define XDG_SURFACE_SET_APP_ID 3
301#define XDG_SURFACE_SHOW_WINDOW_MENU 4
302#define XDG_SURFACE_MOVE 5
303#define XDG_SURFACE_RESIZE 6
304#define XDG_SURFACE_ACK_CONFIGURE 7
305#define XDG_SURFACE_SET_WINDOW_GEOMETRY 8
306#define XDG_SURFACE_SET_MAXIMIZED 9
307#define XDG_SURFACE_UNSET_MAXIMIZED 10
308#define XDG_SURFACE_SET_FULLSCREEN 11
309#define XDG_SURFACE_UNSET_FULLSCREEN 12
310#define XDG_SURFACE_SET_MINIMIZED 13
311
312static inline void
313xdg_surface_set_user_data(struct xdg_surface *xdg_surface, void *user_data)
314{
315 wl_proxy_set_user_data((struct wl_proxy *) xdg_surface, user_data);
316}
317
318static inline void *
319xdg_surface_get_user_data(struct xdg_surface *xdg_surface)
320{
321 return wl_proxy_get_user_data((struct wl_proxy *) xdg_surface);
322}
323
324static inline void
325xdg_surface_destroy(struct xdg_surface *xdg_surface)
326{
327 wl_proxy_marshal((struct wl_proxy *) xdg_surface,
328 XDG_SURFACE_DESTROY);
329
330 wl_proxy_destroy((struct wl_proxy *) xdg_surface);
331}
332
333static inline void
334xdg_surface_set_parent(struct xdg_surface *xdg_surface, struct wl_surface *parent)
335{
336 wl_proxy_marshal((struct wl_proxy *) xdg_surface,
337 XDG_SURFACE_SET_PARENT, parent);
338}
339
340static inline void
341xdg_surface_set_title(struct xdg_surface *xdg_surface, const char *title)
342{
343 wl_proxy_marshal((struct wl_proxy *) xdg_surface,
344 XDG_SURFACE_SET_TITLE, title);
345}
346
347static inline void
348xdg_surface_set_app_id(struct xdg_surface *xdg_surface, const char *app_id)
349{
350 wl_proxy_marshal((struct wl_proxy *) xdg_surface,
351 XDG_SURFACE_SET_APP_ID, app_id);
352}
353
354static inline void
355xdg_surface_show_window_menu(struct xdg_surface *xdg_surface, struct wl_seat *seat, uint32_t serial, int32_t x, int32_t y)
356{
357 wl_proxy_marshal((struct wl_proxy *) xdg_surface,
358 XDG_SURFACE_SHOW_WINDOW_MENU, seat, serial, x, y);
359}
360
361static inline void
362xdg_surface_move(struct xdg_surface *xdg_surface, struct wl_seat *seat, uint32_t serial)
363{
364 wl_proxy_marshal((struct wl_proxy *) xdg_surface,
365 XDG_SURFACE_MOVE, seat, serial);
366}
367
368static inline void
369xdg_surface_resize(struct xdg_surface *xdg_surface, struct wl_seat *seat, uint32_t serial, uint32_t edges)
370{
371 wl_proxy_marshal((struct wl_proxy *) xdg_surface,
372 XDG_SURFACE_RESIZE, seat, serial, edges);
373}
374
375static inline void
376xdg_surface_ack_configure(struct xdg_surface *xdg_surface, uint32_t serial)
377{
378 wl_proxy_marshal((struct wl_proxy *) xdg_surface,
379 XDG_SURFACE_ACK_CONFIGURE, serial);
380}
381
382static inline void
383xdg_surface_set_window_geometry(struct xdg_surface *xdg_surface, int32_t x, int32_t y, int32_t width, int32_t height)
384{
385 wl_proxy_marshal((struct wl_proxy *) xdg_surface,
386 XDG_SURFACE_SET_WINDOW_GEOMETRY, x, y, width, height);
387}
388
389static inline void
390xdg_surface_set_maximized(struct xdg_surface *xdg_surface)
391{
392 wl_proxy_marshal((struct wl_proxy *) xdg_surface,
393 XDG_SURFACE_SET_MAXIMIZED);
394}
395
396static inline void
397xdg_surface_unset_maximized(struct xdg_surface *xdg_surface)
398{
399 wl_proxy_marshal((struct wl_proxy *) xdg_surface,
400 XDG_SURFACE_UNSET_MAXIMIZED);
401}
402
403static inline void
404xdg_surface_set_fullscreen(struct xdg_surface *xdg_surface, struct wl_output *output)
405{
406 wl_proxy_marshal((struct wl_proxy *) xdg_surface,
407 XDG_SURFACE_SET_FULLSCREEN, output);
408}
409
410static inline void
411xdg_surface_unset_fullscreen(struct xdg_surface *xdg_surface)
412{
413 wl_proxy_marshal((struct wl_proxy *) xdg_surface,
414 XDG_SURFACE_UNSET_FULLSCREEN);
415}
416
417static inline void
418xdg_surface_set_minimized(struct xdg_surface *xdg_surface)
419{
420 wl_proxy_marshal((struct wl_proxy *) xdg_surface,
421 XDG_SURFACE_SET_MINIMIZED);
422}
423
424/**
425 * xdg_popup - desktop-style metadata interface
426 * @popup_done: popup interaction is done
427 *
428 * An interface that may be implemented by a wl_surface, for
429 * implementations that provide a desktop-style popups/menus. A popup
430 * surface is a transient surface with an added pointer grab.
431 *
432 * An existing implicit grab will be changed to owner-events mode, and the
433 * popup grab will continue after the implicit grab ends (i.e. releasing
434 * the mouse button does not cause the popup to be unmapped).
435 *
436 * The popup grab continues until the window is destroyed or a mouse button
437 * is pressed in any other clients window. A click in any of the clients
438 * surfaces is reported as normal, however, clicks in other clients
439 * surfaces will be discarded and trigger the callback.
440 *
441 * The x and y arguments specify the locations of the upper left corner of
442 * the surface relative to the upper left corner of the parent surface, in
443 * surface local coordinates.
444 *
445 * xdg_popup surfaces are always transient for another surface.
446 */
447struct xdg_popup_listener {
448 /**
449 * popup_done - popup interaction is done
450 * @serial: serial of the implicit grab on the pointer
451 *
452 * The popup_done event is sent out when a popup grab is broken,
453 * that is, when the users clicks a surface that doesn't belong to
454 * the client owning the popup surface.
455 */
456 void (*popup_done)(void *data,
457 struct xdg_popup *xdg_popup,
458 uint32_t serial);
459};
460
461static inline int
462xdg_popup_add_listener(struct xdg_popup *xdg_popup,
463 const struct xdg_popup_listener *listener, void *data)
464{
465 return wl_proxy_add_listener((struct wl_proxy *) xdg_popup,
466 (void (**)(void)) listener, data);
467}
468
469#define XDG_POPUP_DESTROY 0
470
471static inline void
472xdg_popup_set_user_data(struct xdg_popup *xdg_popup, void *user_data)
473{
474 wl_proxy_set_user_data((struct wl_proxy *) xdg_popup, user_data);
475}
476
477static inline void *
478xdg_popup_get_user_data(struct xdg_popup *xdg_popup)
479{
480 return wl_proxy_get_user_data((struct wl_proxy *) xdg_popup);
481}
482
483static inline void
484xdg_popup_destroy(struct xdg_popup *xdg_popup)
485{
486 wl_proxy_marshal((struct wl_proxy *) xdg_popup,
487 XDG_POPUP_DESTROY);
488
489 wl_proxy_destroy((struct wl_proxy *) xdg_popup);
490}
491
492#ifdef __cplusplus
493}
494#endif
495
496#endif
diff --git a/src/lib/ecore_wayland/xdg-shell-protocol.c b/src/lib/ecore_wayland/xdg-shell-protocol.c
new file mode 100644
index 0000000000..863f74eec8
--- /dev/null
+++ b/src/lib/ecore_wayland/xdg-shell-protocol.c
@@ -0,0 +1,125 @@
1/*
2 * Copyright © 2008-2013 Kristian Høgsberg
3 * Copyright © 2013 Rafael Antognolli
4 * Copyright © 2013 Jasper St. Pierre
5 * Copyright © 2010-2013 Intel Corporation
6 *
7 * Permission to use, copy, modify, distribute, and sell this
8 * software and its documentation for any purpose is hereby granted
9 * without fee, provided that the above copyright notice appear in
10 * all copies and that both that copyright notice and this permission
11 * notice appear in supporting documentation, and that the name of
12 * the copyright holders not be used in advertising or publicity
13 * pertaining to distribution of the software without specific,
14 * written prior permission. The copyright holders make no
15 * representations about the suitability of this software for any
16 * purpose. It is provided "as is" without express or implied
17 * warranty.
18 *
19 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
20 * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
21 * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
22 * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
23 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
24 * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
25 * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
26 * THIS SOFTWARE.
27 */
28
29#include <stdlib.h>
30#include <stdint.h>
31#include "wayland-util.h"
32
33extern const struct wl_interface wl_output_interface;
34extern const struct wl_interface wl_seat_interface;
35extern const struct wl_interface wl_surface_interface;
36extern const struct wl_interface xdg_popup_interface;
37extern const struct wl_interface xdg_surface_interface;
38
39static const struct wl_interface *types[] = {
40 NULL,
41 NULL,
42 NULL,
43 NULL,
44 &xdg_surface_interface,
45 &wl_surface_interface,
46 &xdg_popup_interface,
47 &wl_surface_interface,
48 &wl_surface_interface,
49 &wl_seat_interface,
50 NULL,
51 NULL,
52 NULL,
53 NULL,
54 &wl_surface_interface,
55 &wl_seat_interface,
56 NULL,
57 NULL,
58 NULL,
59 &wl_seat_interface,
60 NULL,
61 &wl_seat_interface,
62 NULL,
63 NULL,
64 &wl_output_interface,
65};
66
67static const struct wl_message xdg_shell_requests[] = {
68 { "use_unstable_version", "i", types + 0 },
69 { "get_xdg_surface", "no", types + 4 },
70 { "get_xdg_popup", "nooouiiu", types + 6 },
71 { "pong", "u", types + 0 },
72};
73
74static const struct wl_message xdg_shell_events[] = {
75 { "ping", "u", types + 0 },
76};
77
78WL_EXPORT const struct wl_interface xdg_shell_interface = {
79 "xdg_shell", 1,
80 4, xdg_shell_requests,
81 1, xdg_shell_events,
82};
83
84static const struct wl_message xdg_surface_requests[] = {
85 { "destroy", "", types + 0 },
86 { "set_parent", "?o", types + 14 },
87 { "set_title", "s", types + 0 },
88 { "set_app_id", "s", types + 0 },
89 { "show_window_menu", "ouii", types + 15 },
90 { "move", "ou", types + 19 },
91 { "resize", "ouu", types + 21 },
92 { "ack_configure", "u", types + 0 },
93 { "set_window_geometry", "iiii", types + 0 },
94 { "set_maximized", "", types + 0 },
95 { "unset_maximized", "", types + 0 },
96 { "set_fullscreen", "?o", types + 24 },
97 { "unset_fullscreen", "", types + 0 },
98 { "set_minimized", "", types + 0 },
99};
100
101static const struct wl_message xdg_surface_events[] = {
102 { "configure", "iiau", types + 0 },
103 { "close", "", types + 0 },
104};
105
106WL_EXPORT const struct wl_interface xdg_surface_interface = {
107 "xdg_surface", 1,
108 14, xdg_surface_requests,
109 2, xdg_surface_events,
110};
111
112static const struct wl_message xdg_popup_requests[] = {
113 { "destroy", "", types + 0 },
114};
115
116static const struct wl_message xdg_popup_events[] = {
117 { "popup_done", "u", types + 0 },
118};
119
120WL_EXPORT const struct wl_interface xdg_popup_interface = {
121 "xdg_popup", 1,
122 1, xdg_popup_requests,
123 1, xdg_popup_events,
124};
125