gardesk/ers / 645d1f5

Browse files

filter new windows by level, size, and visibility

Authored by espadonne
SHA
645d1f575714e29358739b431e3ee3230f8ce698
Parents
52420a9
Tree
bb14475

1 changed file

StatusFile+-
M src/main.rs 10 1
src/main.rsmodified
@@ -45,17 +45,26 @@ impl BorderMap {
4545
     fn add_fresh(&mut self, target_wid: u32) {
4646
         if self.overlays.contains_key(&target_wid) { return; }
4747
 
48
-        // Filter: must be ordered in and owned by another process
48
+        // Filter: must be visible, layer 0, owned by another process
4949
         unsafe {
5050
             let mut shown = false;
5151
             SLSWindowIsOrderedIn(self.main_cid, target_wid, &mut shown);
5252
             if !shown { return; }
5353
 
54
+            let mut level: i64 = -1;
55
+            SLSGetWindowLevel(self.main_cid, target_wid, &mut level);
56
+            if level != 0 { return; }
57
+
5458
             let mut wid_cid: CGSConnectionID = 0;
5559
             SLSGetWindowOwner(self.main_cid, target_wid, &mut wid_cid);
5660
             let mut pid: i32 = 0;
5761
             SLSConnectionGetPID(wid_cid, &mut pid);
5862
             if pid == self.own_pid { return; }
63
+
64
+            // Skip tiny windows
65
+            let mut bounds = CGRect::default();
66
+            SLSGetWindowBounds(self.main_cid, target_wid, &mut bounds);
67
+            if bounds.size.width < 50.0 || bounds.size.height < 50.0 { return; }
5968
         }
6069
 
6170
         let fresh = unsafe {