diff --git a/CMakeLists.txt b/CMakeLists.txt index c0ff1b4..ebfca95 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,6 +27,7 @@ find_package(EGL REQUIRED) find_package(GLIB REQUIRED COMPONENTS gio) find_package(Wayland REQUIRED) find_package(WaylandEGL REQUIRED) +find_package(WaylandScanner REQUIRED) find_package(WPE REQUIRED) if (EGL_DEFINITIONS) @@ -41,6 +42,7 @@ endif () set(WPEBACKEND_FDO_INCLUDE_DIRECTORIES "include" + ${CMAKE_BINARY_DIR} ${EGL_INCLUDE_DIRS} ${GLIB_INCLUDE_DIRS} ${WAYLAND_INCLUDE_DIRS} @@ -64,7 +66,13 @@ set(WPEBACKEND_FDO_PUBLIC_HEADERS include/wpe-fdo/fdo.h ) +set(WPEBACKEND_FDO_GENERATED_SOURCES + ${CMAKE_BINARY_DIR}/bridge/wpe-bridge-protocol.c +) + set(WPEBACKEND_FDO_SOURCES + ${WPEBACKEND_FDO_GENERATED_SOURCES} + src/fdo.cpp src/initialize-egl.cpp src/renderer-backend-egl.cpp @@ -73,12 +81,22 @@ set(WPEBACKEND_FDO_SOURCES src/view-backend-exportable-private.cpp src/ws.cpp - src/bridge/wpe-bridge-protocol.c - src/linux-dmabuf/linux-dmabuf.c src/linux-dmabuf/linux-dmabuf-protocol.c ) +file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/bridge) +add_custom_command( + OUTPUT ${CMAKE_BINARY_DIR}/bridge/wpe-bridge-protocol.c + ${CMAKE_BINARY_DIR}/bridge/wpe-bridge-client-protocol.h + ${CMAKE_BINARY_DIR}/bridge/wpe-bridge-server-protocol.h + DEPENDS ${CMAKE_SOURCE_DIR}/src/bridge/wpe-bridge.xml + COMMAND ${WAYLAND_SCANNER} ${WAYLAND_SCANNER_CODE_ARG} < ${CMAKE_SOURCE_DIR}/src/bridge/wpe-bridge.xml > ${CMAKE_BINARY_DIR}/bridge/wpe-bridge-protocol.c + COMMAND ${WAYLAND_SCANNER} client-header < ${CMAKE_SOURCE_DIR}/src/bridge/wpe-bridge.xml > ${CMAKE_BINARY_DIR}/bridge/wpe-bridge-client-protocol.h + COMMAND ${WAYLAND_SCANNER} server-header < ${CMAKE_SOURCE_DIR}/src/bridge/wpe-bridge.xml > ${CMAKE_BINARY_DIR}/bridge/wpe-bridge-server-protocol.h + VERBATIM +) + option(EXPORTABLE_EGL "Enable the exportable EGL interface" ON) if (EXPORTABLE_EGL) diff --git a/cmake/FindWaylandScanner.cmake b/cmake/FindWaylandScanner.cmake new file mode 100644 index 0000000..09a92b2 --- /dev/null +++ b/cmake/FindWaylandScanner.cmake @@ -0,0 +1,42 @@ +# - Try to find wayland-scanner. +# Once done, this will define +# +# WAYLAND_SCANNER_FOUND - system has Wayland. +# WAYLAND_SCANNER - the path to the wayland-scanner binary +# WAYLAND_SCANNER_CODE_ARG - the code argument to pass +# +# Copyright (C) 2019 Igalia S.L. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND ITS CONTRIBUTORS ``AS +# IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR ITS +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +find_package(PkgConfig) +pkg_check_modules(WAYLAND_SCANNER wayland-scanner) + +pkg_get_variable(WAYLAND_SCANNER wayland-scanner wayland_scanner) +if (WAYLAND_SCANNER_VERSION VERSION_LESS "1.15") + set(WAYLAND_SCANNER_CODE_ARG "code") +else () + set(WAYLAND_SCANNER_CODE_ARG "private-code") +endif () + +include(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(WAYLAND_SCANNER DEFAULT_MSG WAYLAND_SCANNER) diff --git a/src/bridge/wpe-bridge-client-protocol.h b/src/bridge/wpe-bridge-client-protocol.h deleted file mode 100644 index 2372060..0000000 --- a/src/bridge/wpe-bridge-client-protocol.h +++ /dev/null @@ -1,107 +0,0 @@ -/* Generated by wayland-scanner 1.16.0 */ - -#ifndef WPE_BRIDGE_CLIENT_PROTOCOL_H -#define WPE_BRIDGE_CLIENT_PROTOCOL_H - -#include -#include -#include "wayland-client.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @page page_wpe_bridge The wpe_bridge protocol - * @section page_ifaces_wpe_bridge Interfaces - * - @subpage page_iface_wpe_bridge - - * @section page_copyright_wpe_bridge Copyright - *
- *
- * Copyright © 2019 Igalia S.L.
- *
- * 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.
- * 
- */ -struct wl_surface; -struct wpe_bridge; - -/** - * @page page_iface_wpe_bridge wpe_bridge - * @section page_iface_wpe_bridge_api API - * See @ref iface_wpe_bridge. - */ -/** - * @defgroup iface_wpe_bridge The wpe_bridge interface - */ -extern const struct wl_interface wpe_bridge_interface; - -#define WPE_BRIDGE_CONNECT 0 - - -/** - * @ingroup iface_wpe_bridge - */ -#define WPE_BRIDGE_CONNECT_SINCE_VERSION 1 - -/** @ingroup iface_wpe_bridge */ -static inline void -wpe_bridge_set_user_data(struct wpe_bridge *wpe_bridge, void *user_data) -{ - wl_proxy_set_user_data((struct wl_proxy *) wpe_bridge, user_data); -} - -/** @ingroup iface_wpe_bridge */ -static inline void * -wpe_bridge_get_user_data(struct wpe_bridge *wpe_bridge) -{ - return wl_proxy_get_user_data((struct wl_proxy *) wpe_bridge); -} - -static inline uint32_t -wpe_bridge_get_version(struct wpe_bridge *wpe_bridge) -{ - return wl_proxy_get_version((struct wl_proxy *) wpe_bridge); -} - -/** @ingroup iface_wpe_bridge */ -static inline void -wpe_bridge_destroy(struct wpe_bridge *wpe_bridge) -{ - wl_proxy_destroy((struct wl_proxy *) wpe_bridge); -} - -/** - * @ingroup iface_wpe_bridge - */ -static inline void -wpe_bridge_connect(struct wpe_bridge *wpe_bridge, struct wl_surface *surface, uint32_t id) -{ - wl_proxy_marshal((struct wl_proxy *) wpe_bridge, - WPE_BRIDGE_CONNECT, surface, id); -} - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/bridge/wpe-bridge-protocol.c b/src/bridge/wpe-bridge-protocol.c deleted file mode 100644 index 270d77d..0000000 --- a/src/bridge/wpe-bridge-protocol.c +++ /dev/null @@ -1,48 +0,0 @@ -/* Generated by wayland-scanner 1.16.0 */ - -/* - * Copyright © 2019 Igalia S.L. - * - * 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_surface_interface; - -static const struct wl_interface *types[] = { - &wl_surface_interface, - NULL, -}; - -static const struct wl_message wpe_bridge_requests[] = { - { "connect", "ou", types + 0 }, -}; - -WL_EXPORT const struct wl_interface wpe_bridge_interface = { - "wpe_bridge", 1, - 1, wpe_bridge_requests, - 0, NULL, -}; - diff --git a/src/bridge/wpe-bridge-server-protocol.h b/src/bridge/wpe-bridge-server-protocol.h deleted file mode 100644 index 53974fb..0000000 --- a/src/bridge/wpe-bridge-server-protocol.h +++ /dev/null @@ -1,84 +0,0 @@ -/* Generated by wayland-scanner 1.16.0 */ - -#ifndef WPE_BRIDGE_SERVER_PROTOCOL_H -#define WPE_BRIDGE_SERVER_PROTOCOL_H - -#include -#include -#include "wayland-server.h" - -#ifdef __cplusplus -extern "C" { -#endif - -struct wl_client; -struct wl_resource; - -/** - * @page page_wpe_bridge The wpe_bridge protocol - * @section page_ifaces_wpe_bridge Interfaces - * - @subpage page_iface_wpe_bridge - - * @section page_copyright_wpe_bridge Copyright - *
- *
- * Copyright © 2019 Igalia S.L.
- *
- * 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.
- * 
- */ -struct wl_surface; -struct wpe_bridge; - -/** - * @page page_iface_wpe_bridge wpe_bridge - * @section page_iface_wpe_bridge_api API - * See @ref iface_wpe_bridge. - */ -/** - * @defgroup iface_wpe_bridge The wpe_bridge interface - */ -extern const struct wl_interface wpe_bridge_interface; - -/** - * @ingroup iface_wpe_bridge - * @struct wpe_bridge_interface - */ -struct wpe_bridge_interface { - /** - */ - void (*connect)(struct wl_client *client, - struct wl_resource *resource, - struct wl_resource *surface, - uint32_t id); -}; - - -/** - * @ingroup iface_wpe_bridge - */ -#define WPE_BRIDGE_CONNECT_SINCE_VERSION 1 - -#ifdef __cplusplus -} -#endif - -#endif