From accac3a015bd64c62ccfde61d212916c5489d73b Mon Sep 17 00:00:00 2001 From: jackun Date: Wed, 1 Apr 2020 11:20:55 +0300 Subject: [PATCH] [OpenGL] Import XGetGeometry --- src/gl/inject_glx.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/gl/inject_glx.cpp b/src/gl/inject_glx.cpp index 1b3f7e7..b18233c 100644 --- a/src/gl/inject_glx.cpp +++ b/src/gl/inject_glx.cpp @@ -1,3 +1,4 @@ +#include #include #include #include @@ -270,6 +271,30 @@ void* get_glx_proc_address(const char* name) { return func; } +Status XGetGeometry( + Display *display, + Drawable d, + Window *root, + int *x, + int *y, + unsigned int *width, + unsigned int *height, + unsigned int *border_width, + unsigned int *depth +) +{ + static decltype(&::XGetGeometry) pfnXGetGeometry = nullptr; + if (!pfnXGetGeometry) { + void *handle = real_dlopen("libX11.so.6", RTLD_LAZY); + if (!handle) + std::cerr << "MANGOHUD: couldn't find libX11.so.6" << std::endl; + pfnXGetGeometry = reinterpret_cast( + real_dlsym(handle, "XGetGeometry")); + } + + return pfnXGetGeometry(display, d, root, x, y, width, height, border_width, depth); +} + EXPORT_C_(void *) glXCreateContext(void *dpy, void *vis, void *shareList, int direct) { gl.Load();