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