Skip to content

Commit

Permalink
Fix XShape/click through handling.
Browse files Browse the repository at this point in the history
This should (hopefully) resolve #654 and #709.
  • Loading branch information
brndnmtthws committed Nov 6, 2022
1 parent 8142c69 commit 9490fc4
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 7 deletions.
34 changes: 34 additions & 0 deletions src/display-x11.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
#ifdef BUILD_IMLIB2
#include "imlib2.h"
#endif /* BUILD_IMLIB2 */
#ifdef BUILD_XSHAPE
#include <X11/extensions/shape.h>
#endif /* BUILD_XSHAPE */
#endif /* BUILD_X11 */

#include <iostream>
Expand Down Expand Up @@ -219,6 +222,15 @@ bool display_output_x11::initialize() {

bool display_output_x11::shutdown() { return false; }

void find_parent(Window window, Window *parent) {
Window root, *children = nullptr;
unsigned int num_children;

if (XQueryTree(display, window, &root, parent, &children, &num_children)) {
if (children) { XFree((char *)children); }
}
}

bool display_output_x11::main_loop_wait(double t) {
/* wait for X event or timeout */

Expand Down Expand Up @@ -480,6 +492,28 @@ bool display_output_x11::main_loop_wait(double t) {
XSendEvent(display, ev.xbutton.window, False, ButtonReleaseMask, &ev);
}
break;
#ifdef BUILD_XSHAPE
case MapNotify: {
if (window.has_xshape) {
Window root = DefaultRootWindow(display);
Window win = window.window;
while (win != None) {
Region region;
if ((region = XCreateRegion())) {
XSetRegion(display, window.gc, region);
XShapeCombineRegion(display, win, ShapeInput, 0, 0, region,
ShapeSet);
XDestroyRegion(region);
}
Window parent;
find_parent(win, &parent);
win = (parent == root ? None : parent);
}
XFlush(display);
}
break;
}
#endif /* BUILD_XSHAPE */

#endif

Expand Down
8 changes: 1 addition & 7 deletions src/x11.cc
Original file line number Diff line number Diff line change
Expand Up @@ -781,13 +781,7 @@ static void init_window(lua::state &l __attribute__((unused)), bool own) {
if (XShapeQueryVersion(display, &major_version, &minor_version) == 0) {
NORM_ERR("Input shapes are not supported");
} else {
if (own_window.get(*state) &&
(own_window_type.get(*state) != TYPE_NORMAL ||
((TEST_HINT(own_window_hints.get(*state), HINT_UNDECORATED)) !=
0))) {
XShapeCombineRectangles(display, window.window, ShapeInput, 0, 0,
nullptr, 0, ShapeSet, Unsorted);
}
window.has_xshape = true;
}
}
#endif /* BUILD_XSHAPE */
Expand Down
3 changes: 3 additions & 0 deletions src/x11.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ struct conky_window {
#ifdef BUILD_XFT
XftDraw *xftdraw;
#endif
#ifdef BUILD_XSHAPE
bool has_xshape;
#endif /* BUILD_XSHAPE */

int width;
int height;
Expand Down

0 comments on commit 9490fc4

Please sign in to comment.