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 {
3076
         }
3076
         }
3077
 
3077
 
3078
         tracing::info!("Focusing monitor {}: '{}'", target_idx, self.monitors[target_idx].name);
3078
         tracing::info!("Focusing monitor {}: '{}'", target_idx, self.monitors[target_idx].name);
3079
+        let old_workspace_idx = self.focused_workspace;
3079
         self.focused_monitor = target_idx;
3080
         self.focused_monitor = target_idx;
3080
 
3081
 
3081
         // Focus the active workspace on that monitor
3082
         // Focus the active workspace on that monitor
3082
         let workspace_idx = self.monitors[target_idx].active_workspace;
3083
         let workspace_idx = self.monitors[target_idx].active_workspace;
3083
         self.focused_workspace = workspace_idx;
3084
         self.focused_workspace = workspace_idx;
3084
 
3085
 
3086
+        // Update EWMH
3087
+        self.conn.set_current_desktop(workspace_idx as u32)?;
3088
+
3085
         // Focus a window on that workspace if any, or warp to monitor center
3089
         // Focus a window on that workspace if any, or warp to monitor center
3086
         if let Some(window) = self.workspaces[workspace_idx].focused
3090
         if let Some(window) = self.workspaces[workspace_idx].focused
3087
             .or_else(|| self.workspaces[workspace_idx].floating.last().copied())
3091
             .or_else(|| self.workspaces[workspace_idx].floating.last().copied())
@@ -3095,6 +3099,11 @@ impl WindowManager {
3095
             self.warp_to_monitor(target_idx)?;
3099
             self.warp_to_monitor(target_idx)?;
3096
         }
3100
         }
3097
 
3101
 
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
+
3098
         self.conn.flush()?;
3107
         self.conn.flush()?;
3099
         Ok(())
3108
         Ok(())
3100
     }
3109
     }
@@ -3171,16 +3180,25 @@ impl WindowManager {
3171
         self.conn.set_window_desktop(window, target_workspace as u32)?;
3180
         self.conn.set_window_desktop(window, target_workspace as u32)?;
3172
 
3181
 
3173
         // Focus follows window to new monitor
3182
         // Focus follows window to new monitor
3183
+        let old_workspace_idx = self.focused_workspace;
3174
         self.focused_monitor = target_idx;
3184
         self.focused_monitor = target_idx;
3175
         self.focused_workspace = target_workspace;
3185
         self.focused_workspace = target_workspace;
3176
         self.workspaces[target_workspace].focused = Some(window);
3186
         self.workspaces[target_workspace].focused = Some(window);
3177
 
3187
 
3188
+        // Update EWMH
3189
+        self.conn.set_current_desktop(target_workspace as u32)?;
3190
+
3178
         // Apply layouts on both monitors
3191
         // Apply layouts on both monitors
3179
         self.apply_layout()?;
3192
         self.apply_layout()?;
3180
 
3193
 
3181
         // Set X11 focus on the moved window (updates focused_window, button grabs, EWMH)
3194
         // Set X11 focus on the moved window (updates focused_window, button grabs, EWMH)
3182
         self.set_focus(window, true)?;
3195
         self.set_focus(window, true)?;
3183
 
3196
 
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
+
3184
         self.conn.flush()?;
3202
         self.conn.flush()?;
3185
         Ok(())
3203
         Ok(())
3186
     }
3204
     }