Merge pull request #14 from yshui/next

Merge yshui/next
This commit is contained in:
Arda Atci
2023-01-13 23:02:18 +03:00
committed by GitHub
3 changed files with 13 additions and 16 deletions

View File

@@ -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;
@@ -285,8 +277,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) {

View File

@@ -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);
}
/**

View File

@@ -1162,6 +1162,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) {
@@ -1640,6 +1641,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);
}
@@ -1675,6 +1677,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);
}
@@ -2009,6 +2012,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);