From 98f0a245ce9478a57a8a5892042d4458514036be Mon Sep 17 00:00:00 2001 From: Chris Michael Date: Thu, 1 Oct 2015 11:28:54 -0400 Subject: [PATCH] ecore-wl2: Add subsurface protocol files to support subsurfaces Signed-off-by: Chris Michael --- src/Makefile_Ecore_Wl2.am | 2 + src/lib/ecore_wl2/ecore_wl2_private.h | 6 + .../ecore_wl2/subsurface-client-protocol.h | 167 ++++++++++++++++++ src/lib/ecore_wl2/subsurface-protocol.c | 70 ++++++++ 4 files changed, 245 insertions(+) create mode 100644 src/lib/ecore_wl2/subsurface-client-protocol.h create mode 100644 src/lib/ecore_wl2/subsurface-protocol.c diff --git a/src/Makefile_Ecore_Wl2.am b/src/Makefile_Ecore_Wl2.am index e194c3dddc..462e8aac06 100644 --- a/src/Makefile_Ecore_Wl2.am +++ b/src/Makefile_Ecore_Wl2.am @@ -8,6 +8,8 @@ installed_ecorewl2mainheadersdir = $(includedir)/ecore-wl2-@VMAJ@ dist_installed_ecorewl2mainheaders_DATA = lib/ecore_wl2/Ecore_Wl2.h lib_ecore_wl2_libecore_wl2_la_SOURCES = \ +lib/ecore_wl2/subsurface-client-protocol.h \ +lib/ecore_wl2/subsurface-protocol.c \ lib/ecore_wl2/xdg-shell-client-protocol.h \ lib/ecore_wl2/xdg-shell-protocol.c \ lib/ecore_wl2/ecore_wl2_dnd.c \ diff --git a/src/lib/ecore_wl2/ecore_wl2_private.h b/src/lib/ecore_wl2/ecore_wl2_private.h index 20a7fa4a4b..4014930a4c 100644 --- a/src/lib/ecore_wl2/ecore_wl2_private.h +++ b/src/lib/ecore_wl2/ecore_wl2_private.h @@ -4,6 +4,12 @@ # include "Ecore_Wl2.h" # include "Ecore_Input.h" +/* NB: Test if subsurface protocol is part of wayland code, if not then + * include our own copy */ +# ifndef WL_SUBSURFACE_ERROR_ENUM +# include "subsurface-client-protocol.h" +# endif + # include "xdg-shell-client-protocol.h" # define XDG_VERSION 5 diff --git a/src/lib/ecore_wl2/subsurface-client-protocol.h b/src/lib/ecore_wl2/subsurface-client-protocol.h new file mode 100644 index 0000000000..4396ea44ce --- /dev/null +++ b/src/lib/ecore_wl2/subsurface-client-protocol.h @@ -0,0 +1,167 @@ +/* + * Copyright © 2012-2013 Collabora, Ltd. + * + * Permission to use, copy, modify, distribute, and sell this + * software and its documentation for any purpose is hereby granted + * without fee, provided that the above copyright notice appear in + * all copies and that both that copyright notice and this permission + * notice appear in supporting documentation, and that the name of + * the copyright holders not be used in advertising or publicity + * pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied + * warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS + * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY + * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN + * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF + * THIS SOFTWARE. + */ + +#ifndef SUBSURFACE_CLIENT_PROTOCOL_H +#define SUBSURFACE_CLIENT_PROTOCOL_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include "wayland-client.h" + +struct wl_client; +struct wl_resource; + +struct wl_subcompositor; +struct wl_subsurface; + +extern const struct wl_interface wl_subcompositor_interface; +extern const struct wl_interface wl_subsurface_interface; + +#ifndef WL_SUBCOMPOSITOR_ERROR_ENUM +#define WL_SUBCOMPOSITOR_ERROR_ENUM +enum wl_subcompositor_error { + WL_SUBCOMPOSITOR_ERROR_BAD_SURFACE = 0, +}; +#endif /* WL_SUBCOMPOSITOR_ERROR_ENUM */ + +#define WL_SUBCOMPOSITOR_DESTROY 0 +#define WL_SUBCOMPOSITOR_GET_SUBSURFACE 1 + +static inline void +wl_subcompositor_set_user_data(struct wl_subcompositor *wl_subcompositor, void *user_data) +{ + wl_proxy_set_user_data((struct wl_proxy *) wl_subcompositor, user_data); +} + +static inline void * +wl_subcompositor_get_user_data(struct wl_subcompositor *wl_subcompositor) +{ + return wl_proxy_get_user_data((struct wl_proxy *) wl_subcompositor); +} + +static inline void +wl_subcompositor_destroy(struct wl_subcompositor *wl_subcompositor) +{ + wl_proxy_marshal((struct wl_proxy *) wl_subcompositor, + WL_SUBCOMPOSITOR_DESTROY); + + wl_proxy_destroy((struct wl_proxy *) wl_subcompositor); +} + +static inline struct wl_subsurface * +wl_subcompositor_get_subsurface(struct wl_subcompositor *wl_subcompositor, struct wl_surface *surface, struct wl_surface *parent) +{ + struct wl_proxy *id; + + id = wl_proxy_create((struct wl_proxy *) wl_subcompositor, + &wl_subsurface_interface); + if (!id) + return NULL; + + wl_proxy_marshal((struct wl_proxy *) wl_subcompositor, + WL_SUBCOMPOSITOR_GET_SUBSURFACE, id, surface, parent); + + return (struct wl_subsurface *) id; +} + +#ifndef WL_SUBSURFACE_ERROR_ENUM +#define WL_SUBSURFACE_ERROR_ENUM +enum wl_subsurface_error { + WL_SUBSURFACE_ERROR_BAD_SURFACE = 0, +}; +#endif /* WL_SUBSURFACE_ERROR_ENUM */ + +#define WL_SUBSURFACE_DESTROY 0 +#define WL_SUBSURFACE_SET_POSITION 1 +#define WL_SUBSURFACE_PLACE_ABOVE 2 +#define WL_SUBSURFACE_PLACE_BELOW 3 +#define WL_SUBSURFACE_SET_SYNC 4 +#define WL_SUBSURFACE_SET_DESYNC 5 + +static inline void +wl_subsurface_set_user_data(struct wl_subsurface *wl_subsurface, void *user_data) +{ + wl_proxy_set_user_data((struct wl_proxy *) wl_subsurface, user_data); +} + +static inline void * +wl_subsurface_get_user_data(struct wl_subsurface *wl_subsurface) +{ + return wl_proxy_get_user_data((struct wl_proxy *) wl_subsurface); +} + +static inline void +wl_subsurface_destroy(struct wl_subsurface *wl_subsurface) +{ + wl_proxy_marshal((struct wl_proxy *) wl_subsurface, + WL_SUBSURFACE_DESTROY); + + wl_proxy_destroy((struct wl_proxy *) wl_subsurface); +} + +static inline void +wl_subsurface_set_position(struct wl_subsurface *wl_subsurface, int32_t x, int32_t y) +{ + wl_proxy_marshal((struct wl_proxy *) wl_subsurface, + WL_SUBSURFACE_SET_POSITION, x, y); +} + +static inline void +wl_subsurface_place_above(struct wl_subsurface *wl_subsurface, struct wl_surface *sibling) +{ + wl_proxy_marshal((struct wl_proxy *) wl_subsurface, + WL_SUBSURFACE_PLACE_ABOVE, sibling); +} + +static inline void +wl_subsurface_place_below(struct wl_subsurface *wl_subsurface, struct wl_surface *sibling) +{ + wl_proxy_marshal((struct wl_proxy *) wl_subsurface, + WL_SUBSURFACE_PLACE_BELOW, sibling); +} + +static inline void +wl_subsurface_set_sync(struct wl_subsurface *wl_subsurface) +{ + wl_proxy_marshal((struct wl_proxy *) wl_subsurface, + WL_SUBSURFACE_SET_SYNC); +} + +static inline void +wl_subsurface_set_desync(struct wl_subsurface *wl_subsurface) +{ + wl_proxy_marshal((struct wl_proxy *) wl_subsurface, + WL_SUBSURFACE_SET_DESYNC); +} + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/lib/ecore_wl2/subsurface-protocol.c b/src/lib/ecore_wl2/subsurface-protocol.c new file mode 100644 index 0000000000..3e67801c35 --- /dev/null +++ b/src/lib/ecore_wl2/subsurface-protocol.c @@ -0,0 +1,70 @@ +/* + * Copyright © 2012-2013 Collabora, Ltd. + * + * Permission to use, copy, modify, distribute, and sell this + * software and its documentation for any purpose is hereby granted + * without fee, provided that the above copyright notice appear in + * all copies and that both that copyright notice and this permission + * notice appear in supporting documentation, and that the name of + * the copyright holders not be used in advertising or publicity + * pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied + * warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS + * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY + * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN + * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF + * THIS SOFTWARE. + */ + +#include +#include +#include "wayland-util.h" + +extern const struct wl_interface wl_subsurface_interface; +extern const struct wl_interface wl_surface_interface; +extern const struct wl_interface wl_surface_interface; +extern const struct wl_interface wl_surface_interface; +extern const struct wl_interface wl_surface_interface; + +static const struct wl_interface *types[] = { + NULL, + NULL, + &wl_subsurface_interface, + &wl_surface_interface, + &wl_surface_interface, + &wl_surface_interface, + &wl_surface_interface, +}; + +static const struct wl_message wl_subcompositor_requests[] = { + { "destroy", "", types + 0 }, + { "get_subsurface", "noo", types + 2 }, +}; + +WL_EXPORT const struct wl_interface wl_subcompositor_interface = { + "wl_subcompositor", 1, + 2, wl_subcompositor_requests, + 0, NULL, +}; + +static const struct wl_message wl_subsurface_requests[] = { + { "destroy", "", types + 0 }, + { "set_position", "ii", types + 0 }, + { "place_above", "o", types + 5 }, + { "place_below", "o", types + 6 }, + { "set_sync", "", types + 0 }, + { "set_desync", "", types + 0 }, +}; + +WL_EXPORT const struct wl_interface wl_subsurface_interface = { + "wl_subsurface", 1, + 6, wl_subsurface_requests, + 0, NULL, +};