diff options
author | dec05eba <dec05eba@protonmail.com> | 2020-07-05 07:49:13 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-07-05 07:49:13 +0200 |
commit | bf9df281d2cf5ecdb4de42b1aff9b1db89b37e6d (patch) | |
tree | b58f7c3171d1fe18b1b232bb77011e02bd49321c /src | |
parent | 6343c5a76bb0456c7c192c3815c02431bd7cba0f (diff) |
Fix screen recording for certain windows (such as termite)
Diffstat (limited to 'src')
-rw-r--r-- | src/main.cpp | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/src/main.cpp b/src/main.cpp index 4594def..7de6cf0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -151,6 +151,12 @@ static bool recreate_window_pixmap(Display *dpy, Window window_id, WindowPixmap &pixmap) { cleanup_window_pixmap(dpy, pixmap); + XWindowAttributes attr; + if (!XGetWindowAttributes(dpy, window_id, &attr)) { + fprintf(stderr, "Failed to get window attributes\n"); + return false; + } + const int pixmap_config[] = { GLX_BIND_TO_TEXTURE_RGBA_EXT, True, GLX_DRAWABLE_TYPE, GLX_PIXMAP_BIT | GLX_WINDOW_BIT, @@ -181,6 +187,28 @@ static bool recreate_window_pixmap(Display *dpy, Window window_id, ScopedGLXFBConfig scoped_configs; scoped_configs.configs = configs; + bool found = false; + GLXFBConfig config; + for (int i = 0; i < c; i++) { + config = configs[i]; + XVisualInfo *visual = glXGetVisualFromFBConfig(dpy, config); + if (!visual) + continue; + + if (attr.depth != visual->depth) { + XFree(visual); + continue; + } + XFree(visual); + found = true; + break; + } + + if(!found) { + fprintf(stderr, "No matching fb config found\n"); + return false; + } + Pixmap new_window_pixmap = XCompositeNameWindowPixmap(dpy, window_id); if (!new_window_pixmap) { fprintf(stderr, "Failed to get pixmap for window %ld\n", window_id); @@ -188,7 +216,7 @@ static bool recreate_window_pixmap(Display *dpy, Window window_id, } GLXPixmap glx_pixmap = - glXCreatePixmap(dpy, *configs, new_window_pixmap, pixmap_attribs); + glXCreatePixmap(dpy, config, new_window_pixmap, pixmap_attribs); if (!glx_pixmap) { fprintf(stderr, "Failed to create glx pixmap\n"); XFreePixmap(dpy, new_window_pixmap); |