Skip to content

Commit

Permalink
Fix clickthrough for reparented windows, closes #80
Browse files Browse the repository at this point in the history
  • Loading branch information
jarcode-foss committed Mar 10, 2019
1 parent f7170af commit d07b93d
Showing 1 changed file with 30 additions and 5 deletions.
35 changes: 30 additions & 5 deletions glx_wcb.c
Original file line number Diff line number Diff line change
Expand Up @@ -254,15 +254,37 @@ static void apply_decorations(Window w) {
}
}

static bool find_parent(Window w, Window* parent) {
Window root, *children = NULL;
unsigned int num_children;

if(!XQueryTree(display, w, &root, parent, &children, &num_children))
return false;

if (children)
XFree(children);

return *parent != None;
}

static void apply_clickthrough(struct glxwin* w) {
if (w->clickthrough) {
int ignored;
if (XShapeQueryExtension(display, &ignored, &ignored)) {
Region region;
if ((region = XCreateRegion())) {
XShapeCombineRegion(display, w->w, ShapeInput, 0, 0, region, ShapeSet);
XDestroyRegion(region);
Window root = DefaultRootWindow(display);
Window win = w->w;
while (win != None) {
Region region;
if ((region = XCreateRegion())) {
XShapeCombineRegion(display, w->w, ShapeInput, 0, 0, region, ShapeSet);
XDestroyRegion(region);
}
Window parent;
find_parent(win, &parent);
win = (parent == root ? None : parent);
}
} else {
fprintf(stderr, "Warning: XShape extension not available\n");
}
}
}
Expand All @@ -278,6 +300,10 @@ static void process_events(struct glxwin* w) {
w->should_close = true;
}
break;
case MapNotify:
apply_clickthrough(w);
XFlush(display);
break;
case VisibilityNotify:
switch (ev.xvisibility.state) {
case VisibilityFullyObscured:
Expand Down Expand Up @@ -514,7 +540,6 @@ static void set_geometry(struct glxwin* w, int x, int y, int d, int h) {
static void set_visible(struct glxwin* w, bool visible) {
if (visible) {
XMapWindow(display, w->w);
apply_clickthrough(w);
switch (w->override_state) {
case '+': XRaiseWindow(display, w->w); break;
case '-': XLowerWindow(display, w->w); break;
Expand Down

0 comments on commit d07b93d

Please sign in to comment.