mirror of
https://github.com/gwm17/glfw.git
synced 2024-12-03 07:28:51 -05:00
Wayland: Make libwayland-client dynamically loaded
The insight to use wayland.xml to resolve the difficult-to-redirect interface symbols was gleaned from SDL. Instead of compiling the code output of wayland-scanner separately it is made part of the wl_init compilation unit. This lets us do things like transparently rename our copies of Wayland globals. The OS version of wayland-client-protocol.h is no longer used by GLFW, but it is presumably ABI compatible with the output of wayland-scanner. Closes #1174. Closes #1338. Related to #1655.
This commit is contained in:
parent
56092814f3
commit
a7ea3a0ef9
|
@ -204,7 +204,6 @@ if (_GLFW_WAYLAND)
|
||||||
list(APPEND glfw_PKG_DEPS "wayland-client")
|
list(APPEND glfw_PKG_DEPS "wayland-client")
|
||||||
|
|
||||||
list(APPEND glfw_INCLUDE_DIRS "${Wayland_INCLUDE_DIRS}")
|
list(APPEND glfw_INCLUDE_DIRS "${Wayland_INCLUDE_DIRS}")
|
||||||
list(APPEND glfw_LIBRARIES "${Wayland_LINK_LIBRARIES}")
|
|
||||||
|
|
||||||
include(CheckIncludeFiles)
|
include(CheckIncludeFiles)
|
||||||
include(CheckFunctionExists)
|
include(CheckFunctionExists)
|
||||||
|
|
|
@ -225,6 +225,7 @@ information on what to include when reporting a bug.
|
||||||
reported (#1112,#1415,#1472,#1616)
|
reported (#1112,#1415,#1472,#1616)
|
||||||
- [X11] Bugfix: Some window attributes were not applied on leaving fullscreen
|
- [X11] Bugfix: Some window attributes were not applied on leaving fullscreen
|
||||||
(#1863)
|
(#1863)
|
||||||
|
- [Wayland] Added dynamic loading of all Wayland libraries
|
||||||
- [Wayland] Removed support for `wl_shell` (#1443)
|
- [Wayland] Removed support for `wl_shell` (#1443)
|
||||||
- [Wayland] Bugfix: The `GLFW_HAND_CURSOR` shape used the wrong image (#1432)
|
- [Wayland] Bugfix: The `GLFW_HAND_CURSOR` shape used the wrong image (#1432)
|
||||||
- [Wayland] Bugfix: `CLOCK_MONOTONIC` was not correctly enabled
|
- [Wayland] Bugfix: `CLOCK_MONOTONIC` was not correctly enabled
|
||||||
|
|
|
@ -48,6 +48,7 @@ if (_GLFW_WAYLAND)
|
||||||
find_program(WAYLAND_SCANNER_EXECUTABLE NAMES wayland-scanner)
|
find_program(WAYLAND_SCANNER_EXECUTABLE NAMES wayland-scanner)
|
||||||
pkg_check_modules(WAYLAND_PROTOCOLS REQUIRED wayland-protocols>=1.15)
|
pkg_check_modules(WAYLAND_PROTOCOLS REQUIRED wayland-protocols>=1.15)
|
||||||
pkg_get_variable(WAYLAND_PROTOCOLS_BASE wayland-protocols pkgdatadir)
|
pkg_get_variable(WAYLAND_PROTOCOLS_BASE wayland-protocols pkgdatadir)
|
||||||
|
pkg_get_variable(WAYLAND_CLIENT_PKGDATADIR wayland-client pkgdatadir)
|
||||||
|
|
||||||
macro(wayland_generate protocol_file output_file)
|
macro(wayland_generate protocol_file output_file)
|
||||||
add_custom_command(OUTPUT "${output_file}.h"
|
add_custom_command(OUTPUT "${output_file}.h"
|
||||||
|
@ -55,14 +56,17 @@ if (_GLFW_WAYLAND)
|
||||||
DEPENDS "${protocol_file}"
|
DEPENDS "${protocol_file}"
|
||||||
VERBATIM)
|
VERBATIM)
|
||||||
|
|
||||||
add_custom_command(OUTPUT "${output_file}.c"
|
add_custom_command(OUTPUT "${output_file}-code.h"
|
||||||
COMMAND "${WAYLAND_SCANNER_EXECUTABLE}" private-code "${protocol_file}" "${output_file}.c"
|
COMMAND "${WAYLAND_SCANNER_EXECUTABLE}" private-code "${protocol_file}" "${output_file}-code.h"
|
||||||
DEPENDS "${protocol_file}"
|
DEPENDS "${protocol_file}"
|
||||||
VERBATIM)
|
VERBATIM)
|
||||||
|
|
||||||
target_sources(glfw PRIVATE "${output_file}.h" "${output_file}.c")
|
target_sources(glfw PRIVATE "${output_file}.h" "${output_file}-code.h")
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
|
wayland_generate(
|
||||||
|
"${WAYLAND_CLIENT_PKGDATADIR}/wayland.xml"
|
||||||
|
"${GLFW_BINARY_DIR}/src/wayland-client-protocol")
|
||||||
wayland_generate(
|
wayland_generate(
|
||||||
"${WAYLAND_PROTOCOLS_BASE}/stable/xdg-shell/xdg-shell.xml"
|
"${WAYLAND_PROTOCOLS_BASE}/stable/xdg-shell/xdg-shell.xml"
|
||||||
"${GLFW_BINARY_DIR}/src/wayland-xdg-shell-client-protocol")
|
"${GLFW_BINARY_DIR}/src/wayland-xdg-shell-client-protocol")
|
||||||
|
|
|
@ -41,7 +41,22 @@
|
||||||
#include <sys/timerfd.h>
|
#include <sys/timerfd.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <wayland-client.h>
|
|
||||||
|
#include "wayland-client-protocol.h"
|
||||||
|
#include "wayland-xdg-shell-client-protocol.h"
|
||||||
|
#include "wayland-xdg-decoration-client-protocol.h"
|
||||||
|
#include "wayland-viewporter-client-protocol.h"
|
||||||
|
#include "wayland-relative-pointer-unstable-v1-client-protocol.h"
|
||||||
|
#include "wayland-pointer-constraints-unstable-v1-client-protocol.h"
|
||||||
|
#include "wayland-idle-inhibit-unstable-v1-client-protocol.h"
|
||||||
|
|
||||||
|
#include "wayland-client-protocol-code.h"
|
||||||
|
#include "wayland-xdg-shell-client-protocol-code.h"
|
||||||
|
#include "wayland-xdg-decoration-client-protocol-code.h"
|
||||||
|
#include "wayland-viewporter-client-protocol-code.h"
|
||||||
|
#include "wayland-relative-pointer-unstable-v1-client-protocol-code.h"
|
||||||
|
#include "wayland-pointer-constraints-unstable-v1-client-protocol-code.h"
|
||||||
|
#include "wayland-idle-inhibit-unstable-v1-client-protocol-code.h"
|
||||||
|
|
||||||
|
|
||||||
static inline int min(int n1, int n2)
|
static inline int min(int n1, int n2)
|
||||||
|
@ -1039,6 +1054,69 @@ int _glfwPlatformInit(void)
|
||||||
long cursorSizeLong;
|
long cursorSizeLong;
|
||||||
int cursorSize;
|
int cursorSize;
|
||||||
|
|
||||||
|
_glfw.wl.client.handle = _glfw_dlopen("libwayland-client.so.0");
|
||||||
|
if (!_glfw.wl.client.handle)
|
||||||
|
{
|
||||||
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||||
|
"Wayland: Failed to open libwayland-client");
|
||||||
|
return GLFW_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
_glfw.wl.client.display_flush = (PFN_wl_display_flush)
|
||||||
|
_glfw_dlsym(_glfw.wl.client.handle, "wl_display_flush");
|
||||||
|
_glfw.wl.client.display_cancel_read = (PFN_wl_display_cancel_read)
|
||||||
|
_glfw_dlsym(_glfw.wl.client.handle, "wl_display_cancel_read");
|
||||||
|
_glfw.wl.client.display_dispatch_pending = (PFN_wl_display_dispatch_pending)
|
||||||
|
_glfw_dlsym(_glfw.wl.client.handle, "wl_display_dispatch_pending");
|
||||||
|
_glfw.wl.client.display_read_events = (PFN_wl_display_read_events)
|
||||||
|
_glfw_dlsym(_glfw.wl.client.handle, "wl_display_read_events");
|
||||||
|
_glfw.wl.client.display_connect = (PFN_wl_display_connect)
|
||||||
|
_glfw_dlsym(_glfw.wl.client.handle, "wl_display_connect");
|
||||||
|
_glfw.wl.client.display_disconnect = (PFN_wl_display_disconnect)
|
||||||
|
_glfw_dlsym(_glfw.wl.client.handle, "wl_display_disconnect");
|
||||||
|
_glfw.wl.client.display_roundtrip = (PFN_wl_display_roundtrip)
|
||||||
|
_glfw_dlsym(_glfw.wl.client.handle, "wl_display_roundtrip");
|
||||||
|
_glfw.wl.client.display_get_fd = (PFN_wl_display_get_fd)
|
||||||
|
_glfw_dlsym(_glfw.wl.client.handle, "wl_display_get_fd");
|
||||||
|
_glfw.wl.client.display_prepare_read = (PFN_wl_display_prepare_read)
|
||||||
|
_glfw_dlsym(_glfw.wl.client.handle, "wl_display_prepare_read");
|
||||||
|
_glfw.wl.client.proxy_marshal = (PFN_wl_proxy_marshal)
|
||||||
|
_glfw_dlsym(_glfw.wl.client.handle, "wl_proxy_marshal");
|
||||||
|
_glfw.wl.client.proxy_add_listener = (PFN_wl_proxy_add_listener)
|
||||||
|
_glfw_dlsym(_glfw.wl.client.handle, "wl_proxy_add_listener");
|
||||||
|
_glfw.wl.client.proxy_destroy = (PFN_wl_proxy_destroy)
|
||||||
|
_glfw_dlsym(_glfw.wl.client.handle, "wl_proxy_destroy");
|
||||||
|
_glfw.wl.client.proxy_marshal_constructor = (PFN_wl_proxy_marshal_constructor)
|
||||||
|
_glfw_dlsym(_glfw.wl.client.handle, "wl_proxy_marshal_constructor");
|
||||||
|
_glfw.wl.client.proxy_marshal_constructor_versioned = (PFN_wl_proxy_marshal_constructor_versioned)
|
||||||
|
_glfw_dlsym(_glfw.wl.client.handle, "wl_proxy_marshal_constructor_versioned");
|
||||||
|
_glfw.wl.client.proxy_get_user_data = (PFN_wl_proxy_get_user_data)
|
||||||
|
_glfw_dlsym(_glfw.wl.client.handle, "wl_proxy_get_user_data");
|
||||||
|
_glfw.wl.client.proxy_set_user_data = (PFN_wl_proxy_set_user_data)
|
||||||
|
_glfw_dlsym(_glfw.wl.client.handle, "wl_proxy_set_user_data");
|
||||||
|
|
||||||
|
if (!_glfw.wl.client.display_flush ||
|
||||||
|
!_glfw.wl.client.display_cancel_read ||
|
||||||
|
!_glfw.wl.client.display_dispatch_pending ||
|
||||||
|
!_glfw.wl.client.display_read_events ||
|
||||||
|
!_glfw.wl.client.display_connect ||
|
||||||
|
!_glfw.wl.client.display_disconnect ||
|
||||||
|
!_glfw.wl.client.display_roundtrip ||
|
||||||
|
!_glfw.wl.client.display_get_fd ||
|
||||||
|
!_glfw.wl.client.display_prepare_read ||
|
||||||
|
!_glfw.wl.client.proxy_marshal ||
|
||||||
|
!_glfw.wl.client.proxy_add_listener ||
|
||||||
|
!_glfw.wl.client.proxy_destroy ||
|
||||||
|
!_glfw.wl.client.proxy_marshal_constructor ||
|
||||||
|
!_glfw.wl.client.proxy_marshal_constructor_versioned ||
|
||||||
|
!_glfw.wl.client.proxy_get_user_data ||
|
||||||
|
!_glfw.wl.client.proxy_set_user_data)
|
||||||
|
{
|
||||||
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||||
|
"Wayland: Failed to load libwayland-client entry point");
|
||||||
|
return GLFW_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
_glfw.wl.cursor.handle = _glfw_dlopen("libwayland-cursor.so.0");
|
_glfw.wl.cursor.handle = _glfw_dlopen("libwayland-cursor.so.0");
|
||||||
if (!_glfw.wl.cursor.handle)
|
if (!_glfw.wl.cursor.handle)
|
||||||
{
|
{
|
||||||
|
|
|
@ -34,6 +34,8 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
|
#include "wayland-client-protocol.h"
|
||||||
|
|
||||||
|
|
||||||
static void outputHandleGeometry(void* data,
|
static void outputHandleGeometry(void* data,
|
||||||
struct wl_output* output,
|
struct wl_output* output,
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
//
|
//
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
#include <wayland-client.h>
|
#include <wayland-client-core.h>
|
||||||
#include <xkbcommon/xkbcommon.h>
|
#include <xkbcommon/xkbcommon.h>
|
||||||
#ifdef HAVE_XKBCOMMON_COMPOSE_H
|
#ifdef HAVE_XKBCOMMON_COMPOSE_H
|
||||||
#include <xkbcommon/xkbcommon-compose.h>
|
#include <xkbcommon/xkbcommon-compose.h>
|
||||||
|
@ -54,12 +54,40 @@ typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR
|
||||||
#endif
|
#endif
|
||||||
#include "xkb_unicode.h"
|
#include "xkb_unicode.h"
|
||||||
|
|
||||||
#include "wayland-xdg-shell-client-protocol.h"
|
typedef int (* PFN_wl_display_flush)(struct wl_display *display);
|
||||||
#include "wayland-xdg-decoration-client-protocol.h"
|
typedef void (* PFN_wl_display_cancel_read)(struct wl_display *display);
|
||||||
#include "wayland-viewporter-client-protocol.h"
|
typedef int (* PFN_wl_display_dispatch_pending)(struct wl_display *display);
|
||||||
#include "wayland-relative-pointer-unstable-v1-client-protocol.h"
|
typedef int (* PFN_wl_display_read_events)(struct wl_display *display);
|
||||||
#include "wayland-pointer-constraints-unstable-v1-client-protocol.h"
|
typedef struct wl_display* (* PFN_wl_display_connect)(const char*);
|
||||||
#include "wayland-idle-inhibit-unstable-v1-client-protocol.h"
|
typedef void (* PFN_wl_display_disconnect)(struct wl_display*);
|
||||||
|
typedef int (* PFN_wl_display_roundtrip)(struct wl_display*);
|
||||||
|
typedef int (* PFN_wl_display_get_fd)(struct wl_display*);
|
||||||
|
typedef int (* PFN_wl_display_prepare_read)(struct wl_display*);
|
||||||
|
typedef void (* PFN_wl_proxy_marshal)(struct wl_proxy*,uint32_t,...);
|
||||||
|
typedef int (* PFN_wl_proxy_add_listener)(struct wl_proxy*,void(**)(void),void*);
|
||||||
|
typedef void (* PFN_wl_proxy_destroy)(struct wl_proxy*);
|
||||||
|
typedef struct wl_proxy* (* PFN_wl_proxy_marshal_constructor)(struct wl_proxy*,uint32_t,const struct wl_interface*,...);
|
||||||
|
typedef struct wl_proxy* (* PFN_wl_proxy_marshal_constructor_versioned)(struct wl_proxy*,uint32_t,const struct wl_interface*,uint32_t,...);
|
||||||
|
typedef void* (* PFN_wl_proxy_get_user_data)(struct wl_proxy*);
|
||||||
|
typedef void (* PFN_wl_proxy_set_user_data)(struct wl_proxy*,void*);
|
||||||
|
#define wl_display_flush _glfw.wl.client.display_flush
|
||||||
|
#define wl_display_cancel_read _glfw.wl.client.display_cancel_read
|
||||||
|
#define wl_display_dispatch_pending _glfw.wl.client.display_dispatch_pending
|
||||||
|
#define wl_display_read_events _glfw.wl.client.display_read_events
|
||||||
|
#define wl_display_connect _glfw.wl.client.display_connect
|
||||||
|
#define wl_display_disconnect _glfw.wl.client.display_disconnect
|
||||||
|
#define wl_display_roundtrip _glfw.wl.client.display_roundtrip
|
||||||
|
#define wl_display_get_fd _glfw.wl.client.display_get_fd
|
||||||
|
#define wl_display_prepare_read _glfw.wl.client.display_prepare_read
|
||||||
|
#define wl_proxy_marshal _glfw.wl.client.proxy_marshal
|
||||||
|
#define wl_proxy_add_listener _glfw.wl.client.proxy_add_listener
|
||||||
|
#define wl_proxy_destroy _glfw.wl.client.proxy_destroy
|
||||||
|
#define wl_proxy_marshal_constructor _glfw.wl.client.proxy_marshal_constructor
|
||||||
|
#define wl_proxy_marshal_constructor_versioned _glfw.wl.client.proxy_marshal_constructor_versioned
|
||||||
|
#define wl_proxy_get_user_data _glfw.wl.client.proxy_get_user_data
|
||||||
|
#define wl_proxy_set_user_data _glfw.wl.client.proxy_set_user_data
|
||||||
|
|
||||||
|
struct wl_shm;
|
||||||
|
|
||||||
#define _glfw_dlopen(name) dlopen(name, RTLD_LAZY | RTLD_LOCAL)
|
#define _glfw_dlopen(name) dlopen(name, RTLD_LAZY | RTLD_LOCAL)
|
||||||
#define _glfw_dlclose(handle) dlclose(handle)
|
#define _glfw_dlclose(handle) dlclose(handle)
|
||||||
|
@ -302,6 +330,26 @@ typedef struct _GLFWlibraryWayland
|
||||||
_GLFWwindow* pointerFocus;
|
_GLFWwindow* pointerFocus;
|
||||||
_GLFWwindow* keyboardFocus;
|
_GLFWwindow* keyboardFocus;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
void* handle;
|
||||||
|
PFN_wl_display_flush display_flush;
|
||||||
|
PFN_wl_display_cancel_read display_cancel_read;
|
||||||
|
PFN_wl_display_dispatch_pending display_dispatch_pending;
|
||||||
|
PFN_wl_display_read_events display_read_events;
|
||||||
|
PFN_wl_display_connect display_connect;
|
||||||
|
PFN_wl_display_disconnect display_disconnect;
|
||||||
|
PFN_wl_display_roundtrip display_roundtrip;
|
||||||
|
PFN_wl_display_get_fd display_get_fd;
|
||||||
|
PFN_wl_display_prepare_read display_prepare_read;
|
||||||
|
PFN_wl_proxy_marshal proxy_marshal;
|
||||||
|
PFN_wl_proxy_add_listener proxy_add_listener;
|
||||||
|
PFN_wl_proxy_destroy proxy_destroy;
|
||||||
|
PFN_wl_proxy_marshal_constructor proxy_marshal_constructor;
|
||||||
|
PFN_wl_proxy_marshal_constructor_versioned proxy_marshal_constructor_versioned;
|
||||||
|
PFN_wl_proxy_get_user_data proxy_get_user_data;
|
||||||
|
PFN_wl_proxy_set_user_data proxy_set_user_data;
|
||||||
|
} client;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
void* handle;
|
void* handle;
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,14 @@
|
||||||
#include <sys/timerfd.h>
|
#include <sys/timerfd.h>
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
|
|
||||||
|
#include "wayland-client-protocol.h"
|
||||||
|
#include "wayland-xdg-shell-client-protocol.h"
|
||||||
|
#include "wayland-xdg-decoration-client-protocol.h"
|
||||||
|
#include "wayland-viewporter-client-protocol.h"
|
||||||
|
#include "wayland-relative-pointer-unstable-v1-client-protocol.h"
|
||||||
|
#include "wayland-pointer-constraints-unstable-v1-client-protocol.h"
|
||||||
|
#include "wayland-idle-inhibit-unstable-v1-client-protocol.h"
|
||||||
|
|
||||||
|
|
||||||
static int createTmpfileCloexec(char* tmpname)
|
static int createTmpfileCloexec(char* tmpname)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user