[client] egl: added untested support for wayland

This commit is contained in:
Geoffrey McRae 2019-01-02 00:04:40 +11:00
parent 1d3a23e051
commit 667aed635d
2 changed files with 32 additions and 10 deletions

View File

@ -16,6 +16,7 @@ pkg_check_modules(PKGCONFIG REQUIRED
spice-protocol spice-protocol
fontconfig fontconfig
x11 x11
wayland-egl
libconfig libconfig
nettle nettle
hogweed hogweed

View File

@ -25,6 +25,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA
#include <SDL2/SDL_syswm.h> #include <SDL2/SDL_syswm.h>
#include <SDL2/SDL_egl.h> #include <SDL2/SDL_egl.h>
#include <wayland-egl.h>
#include "egl/model.h" #include "egl/model.h"
#include "egl/shader.h" #include "egl/shader.h"
@ -52,8 +53,8 @@ struct Inst
LG_RendererParams params; LG_RendererParams params;
struct Options opt; struct Options opt;
Display * xDisplay; EGLNativeDisplayType nativeDisp;
Window xWindow; EGLNativeWindowType nativeWind;
EGLDisplay display; EGLDisplay display;
EGLConfig configs; EGLConfig configs;
EGLSurface surface; EGLSurface surface;
@ -294,10 +295,30 @@ bool egl_render_startup(void * opaque, SDL_Window * window)
return false; return false;
} }
this->xDisplay = wminfo.info.x11.display; switch(wminfo.subsystem)
this->xWindow = wminfo.info.x11.window; {
case SDL_SYSWM_X11:
{
this->nativeDisp = (EGLNativeDisplayType)wminfo.info.x11.display;
this->nativeWind = (EGLNativeWindowType)wminfo.info.x11.window;
break;
}
this->display = eglGetDisplay((EGLNativeDisplayType)this->xDisplay); case SDL_SYSWM_WAYLAND:
{
int width, height;
SDL_GetWindowSize(window, &width, &height);
this->nativeDisp = (EGLNativeDisplayType)wminfo.info.wl.display;
this->nativeWind = (EGLNativeWindowType)wl_egl_window_create(wminfo.info.wl.surface, width, height);
break;
}
default:
DEBUG_ERROR("Unsupported subsystem");
return false;
}
this->display = eglGetDisplay(this->nativeDisp);
if (this->display == EGL_NO_DISPLAY) if (this->display == EGL_NO_DISPLAY)
{ {
DEBUG_ERROR("eglGetDisplay failed"); DEBUG_ERROR("eglGetDisplay failed");
@ -326,7 +347,7 @@ bool egl_render_startup(void * opaque, SDL_Window * window)
return false; return false;
} }
this->surface = eglCreateWindowSurface(this->display, this->configs, this->xWindow, NULL); this->surface = eglCreateWindowSurface(this->display, this->configs, this->nativeWind, NULL);
if (this->surface == EGL_NO_SURFACE) if (this->surface == EGL_NO_SURFACE)
{ {
DEBUG_ERROR("Failed to create EGL surface (eglError: 0x%x)", eglGetError()); DEBUG_ERROR("Failed to create EGL surface (eglError: 0x%x)", eglGetError());