From 1a1cbc9cc837be982ae945c5907bf98b2e46f647 Mon Sep 17 00:00:00 2001 From: Jarcode Date: Mon, 8 Oct 2018 11:53:58 -0700 Subject: [PATCH] Fixed changes to _XROOTPMAP_ID not updating background with "xroot" transparency --- glfw_wcb.c | 1 + glx_wcb.c | 16 +++++++++++++--- render.c | 2 +- render.h | 2 ++ xwin.c | 2 +- 5 files changed, 18 insertions(+), 5 deletions(-) diff --git a/glfw_wcb.c b/glfw_wcb.c index 56ca2fd..65f76da 100644 --- a/glfw_wcb.c +++ b/glfw_wcb.c @@ -129,6 +129,7 @@ static Display* get_x11_display(void) { return glfwGetX static Window get_x11_window (GLFWwindow* w) { return glfwGetX11Window(w); } static bool should_close (GLFWwindow* w) { return glfwWindowShouldClose(w); } static bool should_render (GLFWwindow* w) { return true; } +static bool bg_changed (GLFWwindow* w) { return false; } static void get_fbsize (GLFWwindow* w, int* d, int* h) { glfwGetFramebufferSize(w, d, h); } static void get_pos (GLFWwindow* w, int* x, int* y) { glfwGetWindowPos(w, x, y); } static double get_time (GLFWwindow* w) { return glfwGetTime(); } diff --git a/glx_wcb.c b/glx_wcb.c index 29ed469..0016732 100644 --- a/glx_wcb.c +++ b/glx_wcb.c @@ -175,11 +175,11 @@ struct glxwin { Window w; GLXContext context; double time; - bool should_close, should_render, clickthrough; + bool should_close, should_render, bg_changed, clickthrough; char override_state; }; -static Atom ATOM__MOTIF_WM_HINTS, ATOM_WM_DELETE_WINDOW, ATOM_WM_PROTOCOLS, ATOM__NET_ACTIVE_WINDOW; +static Atom ATOM__MOTIF_WM_HINTS, ATOM_WM_DELETE_WINDOW, ATOM_WM_PROTOCOLS, ATOM__NET_ACTIVE_WINDOW, ATOM__XROOTPMAP_ID; static void init(void) { display = XOpenDisplay(NULL); @@ -232,6 +232,7 @@ static void init(void) { intern(WM_DELETE_WINDOW, true); intern(WM_PROTOCOLS, true); intern(_NET_ACTIVE_WINDOW, false); + intern(_XROOTPMAP_ID, false); #undef intern #undef resolve @@ -279,6 +280,7 @@ static void* create_and_bind(const char* name, const char* class, .time = 0.0D, .should_close = false, .should_render = true, + .bg_changed = false, .clickthrough = false }; @@ -432,7 +434,8 @@ static void* create_and_bind(const char* name, const char* class, if (glXSwapIntervalEXT) glXSwapIntervalEXT(display, drawable, swap); - // XSelectInput(display, DefaultRootWindow(display), VisibilityChangeMask | PropertyChangeMask); + if (!transparent) + XSelectInput(display, DefaultRootWindow(display), PropertyChangeMask); return w; } @@ -488,6 +491,7 @@ static void set_visible(struct glxwin* w, bool visible) { } static bool should_close (struct glxwin* w) { return w->should_close; } +static bool bg_changed (struct glxwin* w) { return w->bg_changed; } static bool should_render(struct glxwin* w) { /* For nearly all window managers, windows are 'minimized' by unmapping parent windows. VisibilityNotify events are not sent in these instances, so we have to read window @@ -523,6 +527,12 @@ static void swap_buffers(struct glxwin* w) { fprintf(stderr, "Invalid VisibilityNotify event state (%d)\n", ev.xvisibility.state); break; } + break; + case PropertyNotify: + if (ev.xproperty.atom == ATOM__XROOTPMAP_ID) { + w->bg_changed = true; + } + break; default: break; } } diff --git a/render.c b/render.c index f970607..f5c4951 100644 --- a/render.c +++ b/render.c @@ -1422,7 +1422,7 @@ bool rd_update(struct renderer* r, float* lb, float* rb, size_t bsz, bool modifi } /* Resize and grab new background data if needed */ - if (gl->copy_desktop && (ww != gl->lww || wh != gl->lwh || wx != gl->lwx || wy != gl->lwy)) { + if (gl->copy_desktop && (gl->wcb->bg_changed(gl->w) || ww != gl->lww || wh != gl->lwh || wx != gl->lwx || wy != gl->lwy)) { gl->bg_tex = xwin_copyglbg(r, gl->bg_tex); } diff --git a/render.h b/render.h index 32064bb..4591222 100644 --- a/render.h +++ b/render.h @@ -34,6 +34,7 @@ struct gl_wcb { bool clickthrough); bool (*should_close) (void* ptr); bool (*should_render) (void* ptr); + bool (*bg_changed) (void* ptr); void (*swap_buffers) (void* ptr); void (*raise) (void* ptr); void (*destroy) (void* ptr); @@ -70,6 +71,7 @@ struct gl_wcb { WCB_FUNC(create_and_bind), \ WCB_FUNC(should_close), \ WCB_FUNC(should_render), \ + WCB_FUNC(bg_changed), \ WCB_FUNC(swap_buffers), \ WCB_FUNC(raise), \ WCB_FUNC(destroy), \ diff --git a/xwin.c b/xwin.c index 3c223b0..8c900ca 100644 --- a/xwin.c +++ b/xwin.c @@ -280,7 +280,7 @@ unsigned int xwin_copyglbg(struct renderer* rd, unsigned int tex) { Display* d = rd_get_wcb(rd)->get_x11_display(); Drawable src = get_drawable(d, DefaultRootWindow(d)); bool use_shm = XShmQueryExtension(d); - + /* Obtain section of root pixmap */ XShmSegmentInfo shminfo;