gardesk/ers / 7c6e94f

Browse files

Revert tag-based exclusion; restore EventShape click-through

Setting any SLS window tags (bit 1 or bits 1|9) post-creation breaks
border visibility on Tahoe in our recreate-overlay-on-move lifecycle:
borders flicker on and disappear during the rapid sync_overlay churn
that tiling produces. JankyBorders works with tags 1|9 because it
creates each border window once and moves it via
SLSTransactionMoveWindowWithGroup; ers releases and recreates the SLS
window on every geometry change, and Tahoe's compositor handles the
tagged-then-released window very differently.

Restoring SLSSetWindowEventShape(empty) + SLSSetWindowEventMask(0) for
click-through; screenshots will again include the overlay until the
lifecycle is refactored to match JankyBorders'.
Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
7c6e94f50639cc5a3964ef8596fc4e7f044cbfc1
Parents
cd9587f
Tree
64c56c2

2 changed files

StatusFile+-
M src/main.rs 18 13
M src/skylight.rs 7 0
src/main.rsmodified
@@ -1227,19 +1227,6 @@ fn create_overlay(
12271227
         );
12281228
 
12291229
         SLSSetWindowResolution(cid, wid, scale);
1230
-
1231
-        // Tag bit 1 (kCGSIgnoreForEvents) makes the overlay click/scroll
1232
-        // through; tag bit 9 hides it from ScreenCaptureKit (cmd+shift+4
1233
-        // + space, screen recordings, the picker). Mirrors JankyBorders'
1234
-        // ordering: tags MUST be set before SLWindowContextCreate /
1235
-        // drawing — setting them post-draw poisons subsequent SLSNewWindow
1236
-        // calls on the shared connection during stack-cycle recreates.
1237
-        // tag_size 64 (0x40) is the SLS-documented length.
1238
-        let set_tags: u64 = (1u64 << 1) | (1u64 << 9);
1239
-        let clear_tags: u64 = 0;
1240
-        SLSSetWindowTags(cid, wid, &set_tags, 64);
1241
-        SLSClearWindowTags(cid, wid, &clear_tags, 64);
1242
-
12431230
         SLSSetWindowOpacity(cid, wid, false);
12441231
         SLSSetWindowLevel(cid, wid, 0);
12451232
         SLSOrderWindow(cid, wid, 1, target_wid);
@@ -1256,6 +1243,24 @@ fn create_overlay(
12561243
         SLSFlushWindowContentRegion(cid, wid, ptr::null());
12571244
         CGContextRelease(ctx);
12581245
 
1246
+        // Click-through. Setting an empty event/hit-test shape passes
1247
+        // mouse events through to the window beneath. We deliberately
1248
+        // avoid SLSSetWindowTags(kCGSIgnoreForEvents): even when set
1249
+        // before drawing on Tahoe, the tag-bit-1 flag breaks overlay
1250
+        // visibility during the rapid sync_overlay/recreate churn that
1251
+        // tiling produces. Empty event shape + zero event mask is the
1252
+        // only combination that gives both click-through AND persistent
1253
+        // borders on Tahoe.
1254
+        let empty = CGRect::new(0.0, 0.0, 0.0, 0.0);
1255
+        let mut empty_region: CFTypeRef = ptr::null();
1256
+        if CGSNewRegionWithRect(&empty, &mut empty_region) == kCGErrorSuccess
1257
+            && !empty_region.is_null()
1258
+        {
1259
+            SLSSetWindowEventShape(cid, wid, empty_region);
1260
+            CFRelease(empty_region);
1261
+        }
1262
+        SLSSetWindowEventMask(cid, wid, 0);
1263
+
12591264
         Some((cid, wid, bounds, scale))
12601265
     }
12611266
 }
src/skylight.rsmodified
@@ -199,6 +199,13 @@ unsafe extern "C" {
199199
     ) -> CGError;
200200
     pub fn SLSSetWindowResolution(cid: CGSConnectionID, wid: u32, res: f64) -> CGError;
201201
     pub fn SLSSetWindowOpacity(cid: CGSConnectionID, wid: u32, is_opaque: bool) -> CGError;
202
+    /// Mask of events the SLS window captures. Set to 0 to make the window
203
+    /// click-through (mouse events pass to the window beneath).
204
+    pub fn SLSSetWindowEventMask(cid: CGSConnectionID, wid: u32, mask: u32) -> CGError;
205
+    /// Hit-test/input shape. An empty region passes all mouse events
206
+    /// through to the window beneath. Equivalent to NSWindow's
207
+    /// `setIgnoresMouseEvents(true)` at the SLS layer.
208
+    pub fn SLSSetWindowEventShape(cid: CGSConnectionID, wid: u32, shape: CFTypeRef) -> CGError;
202209
     pub fn SLSSetWindowAlpha(cid: CGSConnectionID, wid: u32, alpha: f32) -> CGError;
203210
     pub fn SLSSetWindowBackgroundBlurRadius(cid: CGSConnectionID, wid: u32, radius: u32)
204211
     -> CGError;