Detect input shapes wip/mikabox
authorMikael Magnusson <mikachu@gmail.com>
Mon, 2 Jan 2023 18:29:32 +0000 (19:29 +0100)
committerMikael Magnusson <mikachu@gmail.com>
Mon, 2 Jan 2023 19:19:21 +0000 (20:19 +0100)
openbox/client.c

index dbe93ae..bdf1258 100644 (file)
@@ -1384,6 +1384,7 @@ static void client_get_state(ObClient *self)
 static void client_get_shaped(ObClient *self)
 {
     self->shaped = FALSE;
+    self->shaped_input = FALSE;
 #ifdef SHAPE
     if (obt_display_extension_shape) {
         gint foo;
@@ -1396,6 +1397,23 @@ static void client_get_shaped(ObClient *self)
                            &foo, &ufoo, &ufoo, &foo, &foo, &foo, &ufoo,
                            &ufoo);
         self->shaped = !!s;
+#ifdef ShapeInput
+        { /* when some smart people added ShapeInput they forgot to update XShapeQueryExtents or
+             add a new one for input shapes, so we get to do this instead, yay! */
+            int nrects, ordering;
+            XRectangle *input_rect = XShapeGetRectangles(obt_display, self->window,
+                                                         ShapeInput, &nrects, &ordering);
+            if (nrects == 1 && input_rect->width == self->area.width &&
+                               input_rect->height == self->area.height &&
+                               /* openbox sets the border width of client windows to 0 */
+                               input_rect->x == 0 && input_rect->y == 0) {
+                self->shaped_input = FALSE;
+            } else {
+                self->shaped_input = TRUE;
+            }
+            XFree(input_rect);
+        }
+#endif
     }
 #endif
 }