gardesk/gar / 46030f0

Browse files

Disable mouse warp on enter/click, add mouse_follows_focus config

Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
46030f0ef739e4b32d7edf6b9c60e49cc7e2b647
Parents
10ca6a2
Tree
17c4a93

3 changed files

StatusFile+-
M gar/src/config/lua.rs 5 0
M gar/src/config/mod.rs 3 0
M gar/src/x11/events.rs 19 19
gar/src/config/lua.rsmodified
@@ -282,6 +282,11 @@ impl LuaConfig {
282282
                         state.config.follow_window_on_move = v;
283283
                     }
284284
                 }
285
+                "mouse_follows_focus" => {
286
+                    if let Value::Boolean(v) = value {
287
+                        state.config.mouse_follows_focus = v;
288
+                    }
289
+                }
285290
                 _ => {
286291
                     tracing::warn!("Unknown config key: {}", key);
287292
                 }
gar/src/config/mod.rsmodified
@@ -18,6 +18,7 @@ pub struct Config {
1818
     pub titlebar_text_color: u32,
1919
     // Behavior settings
2020
     pub follow_window_on_move: bool,
21
+    pub mouse_follows_focus: bool,
2122
 }
2223
 
2324
 impl Default for Config {
@@ -37,6 +38,8 @@ impl Default for Config {
3738
             titlebar_text_color: 0xffffff,
3839
             // Behavior: follow window when moving to another workspace
3940
             follow_window_on_move: false,
41
+            // Behavior: warp mouse pointer to center of focused window
42
+            mouse_follows_focus: false,
4043
         }
4144
     }
4245
 }
gar/src/x11/events.rsmodified
@@ -153,7 +153,7 @@ impl WindowManager {
153153
             self.apply_layout()?;
154154
             // Focus the first window
155155
             if let Some(window) = self.focused_window {
156
-                self.set_focus(window)?;
156
+                self.set_focus(window, true)?;
157157
                 self.conn.ungrab_button(window)?;
158158
             }
159159
             tracing::info!("Adopted {} existing windows", adopted);
@@ -276,7 +276,7 @@ impl WindowManager {
276276
 
277277
         // Focus the new window (only if on current workspace)
278278
         if target_idx == self.focused_workspace {
279
-            self.set_focus(window)?;
279
+            self.set_focus(window, true)?;
280280
         }
281281
 
282282
         Ok(())
@@ -317,7 +317,7 @@ impl WindowManager {
317317
 
318318
             // Focus next window or warp to monitor if none left
319319
             if let Some(win) = self.focused_window {
320
-                self.set_focus(win)?;
320
+                self.set_focus(win, true)?;
321321
             } else {
322322
                 // No windows left, warp to current monitor center
323323
                 self.warp_to_monitor(self.focused_monitor)?;
@@ -344,7 +344,7 @@ impl WindowManager {
344344
 
345345
         // Focus next window or warp to monitor if none left
346346
         if let Some(window) = self.focused_window {
347
-            self.set_focus(window)?;
347
+            self.set_focus(window, true)?;
348348
         } else {
349349
             // No windows left, warp to current monitor center
350350
             self.warp_to_monitor(self.focused_monitor)?;
@@ -412,8 +412,8 @@ impl WindowManager {
412412
                 self.conn.grab_button(old)?;
413413
             }
414414
 
415
-            // Set focus and ungrab button on new focused window
416
-            self.set_focus(window)?;
415
+            // Set focus and ungrab button on new focused window (no warp - mouse click)
416
+            self.set_focus(window, false)?;
417417
             self.conn.ungrab_button(window)?;
418418
 
419419
             // Raise floating windows on focus
@@ -524,8 +524,8 @@ impl WindowManager {
524524
             self.conn.grab_button(old)?;
525525
         }
526526
 
527
-        // Focus the new window (this will warp pointer back, but we'll suppress the resulting EnterNotify)
528
-        self.set_focus(window)?;
527
+        // Focus the new window (no warp - mouse enter)
528
+        self.set_focus(window, false)?;
529529
         self.conn.ungrab_button(window)?;
530530
 
531531
         // Raise floating windows on focus
@@ -554,11 +554,11 @@ impl WindowManager {
554554
                         self.switch_workspace(ws_idx)?;
555555
                     }
556556
                 }
557
-                // Focus the window
557
+                // Focus the window (external activation, warp pointer)
558558
                 if let Some(old) = self.focused_window {
559559
                     self.conn.grab_button(old)?;
560560
                 }
561
-                self.set_focus(window)?;
561
+                self.set_focus(window, true)?;
562562
                 self.conn.ungrab_button(window)?;
563563
                 if self.is_floating(window) {
564564
                     self.raise_window(window)?;
@@ -854,8 +854,8 @@ impl WindowManager {
854854
             // Regrab button on old window
855855
             self.conn.grab_button(focused)?;
856856
 
857
-            // Focus new window
858
-            self.set_focus(target)?;
857
+            // Focus new window (keyboard navigation, warp pointer)
858
+            self.set_focus(target, true)?;
859859
             self.conn.ungrab_button(target)?;
860860
             self.conn.flush()?;
861861
 
@@ -909,7 +909,7 @@ impl WindowManager {
909909
             if let Some(old) = self.focused_window {
910910
                 self.conn.grab_button(old)?;
911911
             }
912
-            self.set_focus(window)?;
912
+            self.set_focus(window, true)?;
913913
             self.conn.ungrab_button(window)?;
914914
         } else {
915915
             // No windows on target monitor - clear focus and warp to monitor center
@@ -1014,7 +1014,7 @@ impl WindowManager {
10141014
                 .or_else(|| self.workspaces[idx].floating.last().copied())
10151015
                 .or_else(|| self.workspaces[idx].tree.first_window())
10161016
             {
1017
-                self.set_focus(window)?;
1017
+                self.set_focus(window, true)?;
10181018
             } else {
10191019
                 self.focused_window = None;
10201020
                 self.conn.set_active_window(None)?;
@@ -1061,7 +1061,7 @@ impl WindowManager {
10611061
                 .or_else(|| self.workspaces[idx].floating.last().copied())
10621062
                 .or_else(|| self.workspaces[idx].tree.first_window())
10631063
             {
1064
-                self.set_focus(window)?;
1064
+                self.set_focus(window, true)?;
10651065
             } else {
10661066
                 // No windows - warp to center of monitor
10671067
                 self.focused_window = None;
@@ -1171,7 +1171,7 @@ impl WindowManager {
11711171
             if current_ws == self.focused_workspace {
11721172
                 self.focused_window = new_focus_on_current;
11731173
                 if let Some(new_focus) = self.focused_window {
1174
-                    self.set_focus(new_focus)?;
1174
+                    self.set_focus(new_focus, true)?;
11751175
                 } else {
11761176
                     self.conn.set_active_window(None)?;
11771177
                 }
@@ -1559,7 +1559,7 @@ impl WindowManager {
15591559
             if let Some(old) = self.focused_window {
15601560
                 self.conn.grab_button(old)?;
15611561
             }
1562
-            self.set_focus(window)?;
1562
+            self.set_focus(window, true)?;
15631563
             self.conn.ungrab_button(window)?;
15641564
         } else {
15651565
             // No windows - warp to monitor center
@@ -1673,8 +1673,8 @@ impl WindowManager {
16731673
             self.conn.grab_button(old)?;
16741674
         }
16751675
 
1676
-        // Focus and raise the next floating window
1677
-        self.set_focus(next_window)?;
1676
+        // Focus and raise the next floating window (keyboard action, warp pointer)
1677
+        self.set_focus(next_window, true)?;
16781678
         self.conn.ungrab_button(next_window)?;
16791679
         self.raise_window(next_window)?;
16801680