From 91828be79db2071061e9f290a8ef5915535cbf3b Mon Sep 17 00:00:00 2001 From: Maxim Solovyov Date: Fri, 30 Dec 2022 06:16:46 +0300 Subject: [PATCH 1/5] picom: free root image properly fixes #982 --- src/picom.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/picom.c b/src/picom.c index b5ac3a3..8705de4 100644 --- a/src/picom.c +++ b/src/picom.c @@ -990,6 +990,7 @@ void root_damaged(session_t *ps) { if (ps->backend_data) { if (ps->root_image) { ps->backend_data->ops->release_image(ps->backend_data, ps->root_image); + ps->root_image = NULL; } auto pixmap = x_get_root_back_pixmap(ps->c, ps->root, ps->atoms); if (pixmap != XCB_NONE) { From 29342e7cead35775d6e4f68027c9338087acc7c1 Mon Sep 17 00:00:00 2001 From: Maxim Solovyov Date: Mon, 9 Jan 2023 04:20:53 +0300 Subject: [PATCH 2/5] backend: egl: simplify getting a framebuffer configuration we're using the first available framebuffer configuration that meets our needs so there is no need to ask for more than one --- src/backend/gl/egl.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/src/backend/gl/egl.c b/src/backend/gl/egl.c index e6d4d90..d619456 100644 --- a/src/backend/gl/egl.c +++ b/src/backend/gl/egl.c @@ -166,14 +166,9 @@ static backend_t *egl_init(session_t *ps) { goto end; } - int ncfgs = 0; - if (eglGetConfigs(gd->display, NULL, 0, &ncfgs) != EGL_TRUE) { - log_error("Failed to get EGL configs."); - goto end; - } - auto visual_info = x_get_visual_info(ps->c, ps->vis); - EGLConfig *cfgs = ccalloc(ncfgs, EGLConfig); + EGLConfig config = NULL; + int nconfigs = 1; // clang-format off if (eglChooseConfig(gd->display, (EGLint[]){ @@ -186,17 +181,14 @@ static backend_t *egl_init(session_t *ps) { EGL_STENCIL_SIZE, 1, EGL_CONFIG_CAVEAT, EGL_NONE, EGL_NONE, - }, cfgs, ncfgs, &ncfgs) != EGL_TRUE) { + }, &config, nconfigs, &nconfigs) != EGL_TRUE) { log_error("Failed to choose EGL config for the root window."); goto end; } // clang-format on - EGLConfig target_cfg = cfgs[0]; - free(cfgs); - gd->target_win = eglCreatePlatformWindowSurfaceProc( - gd->display, target_cfg, (xcb_window_t[]){session_get_target_window(ps)}, NULL); + gd->display, config, (xcb_window_t[]){session_get_target_window(ps)}, NULL); if (gd->target_win == EGL_NO_SURFACE) { log_error("Failed to create EGL surface."); goto end; @@ -207,7 +199,7 @@ static backend_t *egl_init(session_t *ps) { goto end; } - gd->ctx = eglCreateContext(gd->display, target_cfg, NULL, NULL); + gd->ctx = eglCreateContext(gd->display, config, NULL, NULL); if (gd->ctx == EGL_NO_CONTEXT) { log_error("Failed to get GLX context."); goto end; From 81f2bf4c0721809cf452ded50cec65a1c5e37a46 Mon Sep 17 00:00:00 2001 From: Maxim Solovyov Date: Tue, 10 Jan 2023 01:13:08 +0300 Subject: [PATCH 3/5] picom: fix xcb_request_check memory leaks --- src/picom.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/picom.c b/src/picom.c index b5ac3a3..8fb0a73 100644 --- a/src/picom.c +++ b/src/picom.c @@ -1463,6 +1463,7 @@ static void handle_pending_updates(EV_P_ struct session *ps) { auto e = xcb_request_check(ps->c, xcb_grab_server_checked(ps->c)); if (e) { log_fatal_x_error(e, "failed to grab x server"); + free(e); return quit(ps); } @@ -1498,6 +1499,7 @@ static void handle_pending_updates(EV_P_ struct session *ps) { e = xcb_request_check(ps->c, xcb_ungrab_server_checked(ps->c)); if (e) { log_fatal_x_error(e, "failed to ungrab x server"); + free(e); return quit(ps); } @@ -1822,6 +1824,7 @@ static session_t *session_init(int argc, char **argv, Display *dpy, XCB_EVENT_MASK_PROPERTY_CHANGE})); if (e) { log_error_x_error(e, "Failed to setup root window event mask"); + free(e); } xcb_prefetch_extension_data(ps->c, &xcb_render_id); From 0ecfd9fd32d92cf520c05b61378f296989b71c55 Mon Sep 17 00:00:00 2001 From: Maxim Solovyov Date: Fri, 30 Dec 2022 07:38:28 +0300 Subject: [PATCH 4/5] backend: egl: fix creating eglpixmap according to the specification of the EGL_KHR_image_pixmap extension, if target is EGL_NATIVE_PIXMAP_KHR then ctx must be EGL_NO_CONTEXT, otherwise, the EGL_BAD_PARAMETER error is generated. source: https://registry.khronos.org/EGL/extensions/KHR/EGL_KHR_image_pixmap.txt fixes #981 --- src/backend/gl/egl.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/backend/gl/egl.c b/src/backend/gl/egl.c index e6d4d90..c83ff3c 100644 --- a/src/backend/gl/egl.c +++ b/src/backend/gl/egl.c @@ -285,8 +285,9 @@ egl_bind_pixmap(backend_t *base, xcb_pixmap_t pixmap, struct xvisual_info fmt, b eglpixmap = cmalloc(struct egl_pixmap); eglpixmap->pixmap = pixmap; - eglpixmap->image = eglCreateImageProc(gd->display, gd->ctx, EGL_NATIVE_PIXMAP_KHR, - (EGLClientBuffer)(uintptr_t)pixmap, NULL); + eglpixmap->image = + eglCreateImageProc(gd->display, EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, + (EGLClientBuffer)(uintptr_t)pixmap, NULL); eglpixmap->owned = owned; if (eglpixmap->image == EGL_NO_IMAGE) { From 74ab307626d5d5d351df64495bc43a1ec13edfac Mon Sep 17 00:00:00 2001 From: Maxim Solovyov Date: Wed, 11 Jan 2023 05:23:02 +0300 Subject: [PATCH 5/5] opengl: fix segfault in ensure_glx_context --- src/opengl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/opengl.h b/src/opengl.h index dcd8697..d0d37dd 100644 --- a/src/opengl.h +++ b/src/opengl.h @@ -159,7 +159,7 @@ static inline bool ensure_glx_context(session_t *ps) { if (!glx_has_context(ps)) glx_init(ps, false); - return ps->psglx->context; + return glx_has_context(ps); } /**