gardesk/gar / 124c7fe

Browse files

fix focus stuck after move_to_monitor: clear stale focused pointer on source workspace

Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
124c7fec1884905525918eec8759131035fcafc5
Parents
267851c
Tree
2d11762

1 changed file

StatusFile+-
M gar/src/x11/events.rs 6 0
gar/src/x11/events.rsmodified
@@ -3141,12 +3141,18 @@ impl WindowManager {
31413141
             window, target_idx, self.monitors[target_idx].name, target_workspace + 1);
31423142
 
31433143
         // Remove from current workspace
3144
+        let source_ws = self.focused_workspace;
31443145
         if is_floating {
31453146
             self.current_workspace_mut().remove_floating(window);
31463147
         } else {
31473148
             self.current_workspace_mut().tree.remove(window);
31483149
         }
31493150
 
3151
+        // Update focus on source workspace so it doesn't point to the moved window
3152
+        let new_focus_on_source = self.workspaces[source_ws].tree.first_window()
3153
+            .or_else(|| self.workspaces[source_ws].floating.last().copied());
3154
+        self.workspaces[source_ws].focused = new_focus_on_source;
3155
+
31503156
         // Update window's workspace
31513157
         if let Some(win) = self.windows.get_mut(&window) {
31523158
             win.workspace = target_workspace;