@@ -254,15 +254,37 @@ static void apply_decorations(Window w) {
254
254
}
255
255
}
256
256
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
+
257
270
static void apply_clickthrough (struct glxwin * w ) {
258
271
if (w -> clickthrough ) {
259
272
int ignored ;
260
273
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 );
265
285
}
286
+ } else {
287
+ fprintf (stderr , "Warning: XShape extension not available\n" );
266
288
}
267
289
}
268
290
}
@@ -278,6 +300,10 @@ static void process_events(struct glxwin* w) {
278
300
w -> should_close = true;
279
301
}
280
302
break ;
303
+ case MapNotify :
304
+ apply_clickthrough (w );
305
+ XFlush (display );
306
+ break ;
281
307
case VisibilityNotify :
282
308
switch (ev .xvisibility .state ) {
283
309
case VisibilityFullyObscured :
@@ -514,7 +540,6 @@ static void set_geometry(struct glxwin* w, int x, int y, int d, int h) {
514
540
static void set_visible (struct glxwin * w , bool visible ) {
515
541
if (visible ) {
516
542
XMapWindow (display , w -> w );
517
- apply_clickthrough (w );
518
543
switch (w -> override_state ) {
519
544
case '+' : XRaiseWindow (display , w -> w ); break ;
520
545
case '-' : XLowerWindow (display , w -> w ); break ;
0 commit comments