gardesk/gar / 44630cf

Browse files

broadcast workspace event on all monitor focus changes

focus_monitor, focus_adjacent_monitor, and move_to_monitor now
set _NET_CURRENT_DESKTOP and broadcast i3 workspace events so
garbar updates the active workspace underline on monitor switches.
Authored by espadonne
SHA
44630cf8bf19be7e5c12bac9a9c7209dfa5506c3
Parents
c315c11
Tree
88cd5b3

1 changed file

StatusFile+-
M gar/src/x11/events.rs 9 0
gar/src/x11/events.rsmodified
@@ -2186,12 +2186,16 @@ impl WindowManager {
21862186
         };
21872187
 
21882188
         tracing::info!("Moving focus from monitor {} to {}", self.focused_monitor, target_idx);
2189
+        let old_workspace_idx = self.focused_workspace;
21892190
         self.focused_monitor = target_idx;
21902191
 
21912192
         // Focus the active workspace on that monitor
21922193
         let workspace_idx = self.monitors[target_idx].active_workspace;
21932194
         self.focused_workspace = workspace_idx;
21942195
 
2196
+        // Update EWMH
2197
+        self.conn.set_current_desktop(workspace_idx as u32)?;
2198
+
21952199
         // Focus a window on that workspace if any, or just warp to monitor center
21962200
         if let Some(window) = self.workspaces[workspace_idx].focused
21972201
             .or_else(|| self.workspaces[workspace_idx].floating.last().copied())
@@ -2206,6 +2210,11 @@ impl WindowManager {
22062210
             tracing::debug!("No windows on monitor {}, warped to center", target_idx);
22072211
         }
22082212
 
2213
+        // Broadcast i3 workspace event so garbar updates
2214
+        if workspace_idx != old_workspace_idx {
2215
+            self.broadcast_i3_workspace_event("focus", workspace_idx, Some(old_workspace_idx));
2216
+        }
2217
+
22092218
         self.conn.flush()?;
22102219
         Ok(())
22112220
     }