From 792d53522578a1410160e40cbb01c206b2bdf840 Mon Sep 17 00:00:00 2001 From: nyorain Date: Mon, 19 Jun 2017 22:36:40 +0200 Subject: Rework wayland backend output implementation --- backend/egl.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'backend/egl.c') diff --git a/backend/egl.c b/backend/egl.c index 2aac25b7..3462113c 100644 --- a/backend/egl.c +++ b/backend/egl.c @@ -73,6 +73,7 @@ static bool egl_get_config(EGLDisplay disp, EGLConfig *out) { ret = eglGetConfigs(disp, NULL, 0, &count); if (ret == EGL_FALSE || count == 0) { + wlr_log(L_ERROR, "eglGetConfigs returned no configs"); return false; } @@ -80,12 +81,19 @@ static bool egl_get_config(EGLDisplay disp, EGLConfig *out) { ret = eglChooseConfig(disp, NULL, configs, count, &matched); if (ret == EGL_FALSE) { + wlr_log(L_ERROR, "eglChooseConfig failed"); return false; } for (int i = 0; i < matched; ++i) { EGLint gbm_format; + // TODO, see below + // best would probably be to propagate parameter or config + // choose callback + *out = configs[i]; + return true; + if (!eglGetConfigAttrib(disp, configs[i], EGL_NATIVE_VISUAL_ID, @@ -101,6 +109,7 @@ static bool egl_get_config(EGLDisplay disp, EGLConfig *out) { } } + wlr_log(L_ERROR, "no valid egl config found"); return false; } @@ -109,7 +118,7 @@ bool wlr_egl_init(struct wlr_egl *egl, EGLenum platform, void *display) { if (!egl_exts()) { return false; } - + if (eglBindAPI(EGL_OPENGL_ES_API) == EGL_FALSE) { wlr_log(L_ERROR, "Failed to bind to the OpenGL ES API: %s", egl_error()); goto error; @@ -163,7 +172,7 @@ void wlr_egl_free(struct wlr_egl *egl) { eglDestroyContext(egl->display, egl->context); eglTerminate(egl->display); eglReleaseThread(); - eglMakeCurrent(EGL_NO_DISPLAY, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); + eglMakeCurrent(EGL_NO_DISPLAY, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); } EGLSurface wlr_egl_create_surface(struct wlr_egl *egl, void *window) { -- cgit v1.2.3 From 62b1421635581fbffc50eac680bb5a5d7a0b8535 Mon Sep 17 00:00:00 2001 From: nyorain Date: Tue, 20 Jun 2017 18:26:29 +0200 Subject: Make egl_error function part of the egl interface The function may be useful for backends using egl. --- backend/egl.c | 2 +- include/backend/egl.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'backend/egl.c') diff --git a/backend/egl.c b/backend/egl.c index 3462113c..cfee59ce 100644 --- a/backend/egl.c +++ b/backend/egl.c @@ -6,7 +6,7 @@ #include "backend/egl.h" #include "common/log.h" -static const char *egl_error(void) { +const char *egl_error(void) { switch (eglGetError()) { case EGL_SUCCESS: return "Success"; diff --git a/include/backend/egl.h b/include/backend/egl.h index 8cef36b7..0422a52b 100644 --- a/include/backend/egl.h +++ b/include/backend/egl.h @@ -10,6 +10,7 @@ struct wlr_egl { EGLContext context; }; +const char *egl_error(void); bool wlr_egl_init(struct wlr_egl *egl, EGLenum platform, void *display); void wlr_egl_free(struct wlr_egl *egl); EGLSurface wlr_egl_create_surface(struct wlr_egl *egl, void *window); -- cgit v1.2.3 From 500e9184f1081753f85df7f0a6d13b6b62a53ee3 Mon Sep 17 00:00:00 2001 From: nyorain Date: Tue, 20 Jun 2017 18:44:11 +0200 Subject: Fix egl workaround; Test with weston --- backend/egl.c | 13 ++++++------- backend/wayland/output.c | 1 + 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'backend/egl.c') diff --git a/backend/egl.c b/backend/egl.c index cfee59ce..1ce2d8a7 100644 --- a/backend/egl.c +++ b/backend/egl.c @@ -68,7 +68,7 @@ static bool egl_exts() { return true; } -static bool egl_get_config(EGLDisplay disp, EGLConfig *out) { +static bool egl_get_config(EGLDisplay disp, EGLConfig *out, EGLenum platform) { EGLint count = 0, matched = 0, ret; ret = eglGetConfigs(disp, NULL, 0, &count); @@ -88,11 +88,10 @@ static bool egl_get_config(EGLDisplay disp, EGLConfig *out) { for (int i = 0; i < matched; ++i) { EGLint gbm_format; - // TODO, see below - // best would probably be to propagate parameter or config - // choose callback - *out = configs[i]; - return true; + if(platform == EGL_PLATFORM_WAYLAND_EXT) { + *out = configs[i]; + return true; + } if (!eglGetConfigAttrib(disp, configs[i], @@ -136,7 +135,7 @@ bool wlr_egl_init(struct wlr_egl *egl, EGLenum platform, void *display) { goto error; } - if (!egl_get_config(egl->display, &egl->config)) { + if (!egl_get_config(egl->display, &egl->config, platform)) { wlr_log(L_ERROR, "Failed to get EGL config"); goto error; } diff --git a/backend/wayland/output.c b/backend/wayland/output.c index f8751c3c..3ec167bc 100644 --- a/backend/wayland/output.c +++ b/backend/wayland/output.c @@ -166,6 +166,7 @@ struct wlr_output *wlr_wl_output_create(struct wlr_backend_state* backend, wl_shell_surface_set_class(ostate->shell_surface, "sway"); wl_shell_surface_set_title(ostate->shell_surface, "sway-wl"); wl_shell_surface_add_listener(ostate->shell_surface, &shell_surface_listener, ostate); + wl_shell_surface_set_toplevel(ostate->shell_surface); ostate->egl_window = wl_egl_window_create(ostate->surface, width, height); ostate->egl_surface = wlr_egl_create_surface(&backend->egl, ostate->egl_window); -- cgit v1.2.3