gardesk/gar / d920c3b

Browse files

Fix mouse click behavior: pass-through and no spurious warp

- Move button grab/ungrab into set_focus() to ensure clicks reach apps
- Don't warp pointer on _NET_ACTIVE_WINDOW (user is already interacting)
Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
d920c3baffc16bdb2a2796e1a062519f259e221e
Parents
90232b7
Tree
1e2cc7b

2 changed files

StatusFile+-
M gar/src/core/mod.rs 10 0
M gar/src/x11/events.rs 2 6
gar/src/core/mod.rsmodified
@@ -484,9 +484,19 @@ impl WindowManager {
484484
     /// If `warp_pointer` is true, the mouse pointer will be moved to the window center.
485485
     /// Use true for keyboard navigation, false for mouse-initiated focus changes.
486486
     pub fn set_focus(&mut self, window: XWindow, warp_pointer: bool) -> Result<()> {
487
+        // Re-grab buttons on old focused window (for click-to-focus)
488
+        if let Some(old) = self.focused_window {
489
+            if old != window {
490
+                let _ = self.conn.grab_button(old);
491
+            }
492
+        }
493
+
487494
         self.focused_window = Some(window);
488495
         self.current_workspace_mut().focused = Some(window);
489496
 
497
+        // Ungrab buttons on new focused window (allow clicks through)
498
+        let _ = self.conn.ungrab_button(window);
499
+
490500
         // Update focus history - move window to front
491501
         self.focus_history.retain(|&w| w != window);
492502
         self.focus_history.insert(0, window);
gar/src/x11/events.rsmodified
@@ -579,12 +579,8 @@ impl WindowManager {
579579
                         self.switch_workspace(ws_idx)?;
580580
                     }
581581
                 }
582
-                // Focus the window (external activation, warp pointer)
583
-                if let Some(old) = self.focused_window {
584
-                    self.conn.grab_button(old)?;
585
-                }
586
-                self.set_focus(window, true)?;
587
-                self.conn.ungrab_button(window)?;
582
+                // Focus the window (external activation, no warp - user is already interacting)
583
+                self.set_focus(window, false)?;
588584
                 if self.is_floating(window) {
589585
                     self.raise_window(window)?;
590586
                 }