gardesk/gar / c315c11

Browse files

broadcast workspace event on monitor focus/move

focus_monitor and move_to_monitor now set _NET_CURRENT_DESKTOP
and broadcast i3 workspace events so garbar updates the active
workspace underline when focus moves between monitors.
Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
c315c113bd5a3e3be56c7b68acaade97ec9648ba
Parents
e50c72e
Tree
747826e

1 changed file

StatusFile+-
M gar/src/x11/events.rs 18 0
gar/src/x11/events.rsmodified
@@ -3076,12 +3076,16 @@ impl WindowManager {
30763076
         }
30773077
 
30783078
         tracing::info!("Focusing monitor {}: '{}'", target_idx, self.monitors[target_idx].name);
3079
+        let old_workspace_idx = self.focused_workspace;
30793080
         self.focused_monitor = target_idx;
30803081
 
30813082
         // Focus the active workspace on that monitor
30823083
         let workspace_idx = self.monitors[target_idx].active_workspace;
30833084
         self.focused_workspace = workspace_idx;
30843085
 
3086
+        // Update EWMH
3087
+        self.conn.set_current_desktop(workspace_idx as u32)?;
3088
+
30853089
         // Focus a window on that workspace if any, or warp to monitor center
30863090
         if let Some(window) = self.workspaces[workspace_idx].focused
30873091
             .or_else(|| self.workspaces[workspace_idx].floating.last().copied())
@@ -3095,6 +3099,11 @@ impl WindowManager {
30953099
             self.warp_to_monitor(target_idx)?;
30963100
         }
30973101
 
3102
+        // Broadcast i3 workspace event so garbar updates
3103
+        if workspace_idx != old_workspace_idx {
3104
+            self.broadcast_i3_workspace_event("focus", workspace_idx, Some(old_workspace_idx));
3105
+        }
3106
+
30983107
         self.conn.flush()?;
30993108
         Ok(())
31003109
     }
@@ -3171,16 +3180,25 @@ impl WindowManager {
31713180
         self.conn.set_window_desktop(window, target_workspace as u32)?;
31723181
 
31733182
         // Focus follows window to new monitor
3183
+        let old_workspace_idx = self.focused_workspace;
31743184
         self.focused_monitor = target_idx;
31753185
         self.focused_workspace = target_workspace;
31763186
         self.workspaces[target_workspace].focused = Some(window);
31773187
 
3188
+        // Update EWMH
3189
+        self.conn.set_current_desktop(target_workspace as u32)?;
3190
+
31783191
         // Apply layouts on both monitors
31793192
         self.apply_layout()?;
31803193
 
31813194
         // Set X11 focus on the moved window (updates focused_window, button grabs, EWMH)
31823195
         self.set_focus(window, true)?;
31833196
 
3197
+        // Broadcast i3 workspace event so garbar updates
3198
+        if target_workspace != old_workspace_idx {
3199
+            self.broadcast_i3_workspace_event("focus", target_workspace, Some(old_workspace_idx));
3200
+        }
3201
+
31843202
         self.conn.flush()?;
31853203
         Ok(())
31863204
     }