Skip to content

Commit d07b93d

Browse files
committed
Fix clickthrough for reparented windows, closes #80
1 parent f7170af commit d07b93d

File tree

1 file changed

+30
-5
lines changed

1 file changed

+30
-5
lines changed

Diff for: glx_wcb.c

+30-5
Original file line numberDiff line numberDiff line change
@@ -254,15 +254,37 @@ static void apply_decorations(Window w) {
254254
}
255255
}
256256

257+
static bool find_parent(Window w, Window* parent) {
258+
Window root, *children = NULL;
259+
unsigned int num_children;
260+
261+
if(!XQueryTree(display, w, &root, parent, &children, &num_children))
262+
return false;
263+
264+
if (children)
265+
XFree(children);
266+
267+
return *parent != None;
268+
}
269+
257270
static void apply_clickthrough(struct glxwin* w) {
258271
if (w->clickthrough) {
259272
int ignored;
260273
if (XShapeQueryExtension(display, &ignored, &ignored)) {
261-
Region region;
262-
if ((region = XCreateRegion())) {
263-
XShapeCombineRegion(display, w->w, ShapeInput, 0, 0, region, ShapeSet);
264-
XDestroyRegion(region);
274+
Window root = DefaultRootWindow(display);
275+
Window win = w->w;
276+
while (win != None) {
277+
Region region;
278+
if ((region = XCreateRegion())) {
279+
XShapeCombineRegion(display, w->w, ShapeInput, 0, 0, region, ShapeSet);
280+
XDestroyRegion(region);
281+
}
282+
Window parent;
283+
find_parent(win, &parent);
284+
win = (parent == root ? None : parent);
265285
}
286+
} else {
287+
fprintf(stderr, "Warning: XShape extension not available\n");
266288
}
267289
}
268290
}
@@ -278,6 +300,10 @@ static void process_events(struct glxwin* w) {
278300
w->should_close = true;
279301
}
280302
break;
303+
case MapNotify:
304+
apply_clickthrough(w);
305+
XFlush(display);
306+
break;
281307
case VisibilityNotify:
282308
switch (ev.xvisibility.state) {
283309
case VisibilityFullyObscured:
@@ -514,7 +540,6 @@ static void set_geometry(struct glxwin* w, int x, int y, int d, int h) {
514540
static void set_visible(struct glxwin* w, bool visible) {
515541
if (visible) {
516542
XMapWindow(display, w->w);
517-
apply_clickthrough(w);
518543
switch (w->override_state) {
519544
case '+': XRaiseWindow(display, w->w); break;
520545
case '-': XLowerWindow(display, w->w); break;

0 commit comments

Comments
 (0)