gardesk/gar / d93df2d

Browse files

fix: skip pointer warp for unmanaged window destroy events

Popup windows (menus, tooltips) from apps like JetBrains IDEs trigger
DestroyNotify without being managed. Previously this caused pointer
warp to focused window center on every popup close, making edge
buttons nearly unusable.
Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
d93df2d5cc6a770a3d9b9785d64aa70e72b959fa
Parents
faa0eff
Tree
347a68e

1 changed file

StatusFile+-
M gar/src/x11/events.rs 20 12
gar/src/x11/events.rsmodified
@@ -676,25 +676,33 @@ impl WindowManager {
676676
             tracing::info!("Dock window {} destroyed, removing strut", event.window);
677677
         }
678678
 
679
+        // Check if this window was actually managed before doing layout/focus work
680
+        let was_managed = self.windows.contains_key(&event.window);
681
+
679682
         // Remove from management
680683
         self.unmanage_window(event.window);
681684
 
682
-        // Clear the entire root window to remove any leftover pixels
683
-        // This is needed because X11 without a compositor doesn't automatically repaint
684
-        self.conn.clear_root_area(0, 0, self.conn.screen_width, self.conn.screen_height)?;
685
+        // Only do layout/focus work if the window was actually managed
686
+        // Unmanaged windows (like popup menus, tooltips) shouldn't trigger pointer warps
687
+        if was_managed {
688
+            // Clear the entire root window to remove any leftover pixels
689
+            // This is needed because X11 without a compositor doesn't automatically repaint
690
+            self.conn.clear_root_area(0, 0, self.conn.screen_width, self.conn.screen_height)?;
685691
 
686
-        // Re-apply layout
687
-        self.apply_layout()?;
692
+            // Re-apply layout
693
+            self.apply_layout()?;
688694
 
689
-        // Focus next window or warp to monitor if none left
690
-        if let Some(window) = self.focused_window {
691
-            self.set_focus(window, true)?;
692
-        } else {
693
-            // No windows left, warp to current monitor center
694
-            self.warp_to_monitor(self.focused_monitor)?;
695
+            // Focus next window or warp to monitor if none left
696
+            if let Some(window) = self.focused_window {
697
+                self.set_focus(window, true)?;
698
+            } else {
699
+                // No windows left, warp to current monitor center
700
+                self.warp_to_monitor(self.focused_monitor)?;
701
+            }
702
+
703
+            self.conn.flush()?;
695704
         }
696705
 
697
-        self.conn.flush()?;
698706
         Ok(())
699707
     }
700708