#include "egl_dri2_fallbacks.h"
#include "loader.h"
#include "util/u_vector.h"
+#include "eglglobals.h"
#include <wayland-client.h>
#include "wayland-drm-client-protocol.h"
dri2_surf->wl_win = NULL;
}
+static struct wl_surface *
+get_wl_surface_proxy(struct wl_egl_window *window)
+{
+ /* Version 3 of wl_egl_window introduced a version field at the same
+ * location where a pointer to wl_surface was stored. Thus, if
+ * window->version is dereferencable, we've been given an older version of
+ * wl_egl_window, and window->version points to wl_surface */
+ if (_eglPointerIsDereferencable((void *)(window->version))) {
+ return wl_proxy_create_wrapper((void *)(window->version));
+ }
+ return wl_proxy_create_wrapper(window->surface);
+}
+
/**
* Called via eglCreateWindowSurface(), drv->API.CreateWindowSurface().
*/
wl_proxy_set_queue((struct wl_proxy *)dri2_surf->wl_dpy_wrapper,
dri2_surf->wl_queue);
- dri2_surf->wl_surface_wrapper = wl_proxy_create_wrapper(window->surface);
+ dri2_surf->wl_surface_wrapper = get_wl_surface_proxy(window);
if (!dri2_surf->wl_surface_wrapper) {
_eglError(EGL_BAD_ALLOC, "dri2_create_surface");
goto cleanup_drm;
extern "C" {
#endif
+#define WL_EGL_WINDOW_VERSION 3
+
struct wl_egl_window {
- struct wl_surface *surface;
+ const intptr_t version;
int width;
int height;
void *private;
void (*resize_callback)(struct wl_egl_window *, void *);
void (*destroy_window_callback)(void *);
+
+ struct wl_surface *surface;
};
#ifdef __cplusplus
*/
#include <stdlib.h>
+#include <string.h>
#include <wayland-client.h>
#include "wayland-egl.h"
wl_egl_window_create(struct wl_surface *surface,
int width, int height)
{
+ struct wl_egl_window _INIT_ = { .version = WL_EGL_WINDOW_VERSION };
struct wl_egl_window *egl_window;
if (width <= 0 || height <= 0)
if (!egl_window)
return NULL;
+ memcpy(egl_window, &_INIT_, sizeof *egl_window);
+
egl_window->surface = surface;
egl_window->private = NULL;
egl_window->resize_callback = NULL;