@@ -320,6 +320,17 @@ impl WindowManager { |
| 320 | 320 | return Ok(()); |
| 321 | 321 | } |
| 322 | 322 | |
| 323 | + // Check if we intentionally unmapped this window (workspace switch, move, etc.) |
| 324 | + // If so, decrement the counter and ignore this UnmapNotify |
| 325 | + if let Some(win) = self.windows.get_mut(&window) { |
| 326 | + if win.ignore_unmap_count > 0 { |
| 327 | + win.ignore_unmap_count -= 1; |
| 328 | + tracing::debug!("Ignoring UnmapNotify for window {} (intentional unmap, count now {})", |
| 329 | + window, win.ignore_unmap_count); |
| 330 | + return Ok(()); |
| 331 | + } |
| 332 | + } |
| 333 | + |
| 323 | 334 | // Check if this window is on a visible workspace (any monitor's active workspace) |
| 324 | 335 | let is_visible = self.windows.get(&window) |
| 325 | 336 | .map(|w| self.is_workspace_visible(w.workspace)) |
@@ -1069,6 +1080,10 @@ impl WindowManager { |
| 1069 | 1080 | |
| 1070 | 1081 | // Hide windows on old workspace |
| 1071 | 1082 | for window in self.workspaces[old_ws].all_windows() { |
| 1083 | + // Mark as intentional unmap so UnmapNotify handler ignores it |
| 1084 | + if let Some(win) = self.windows.get_mut(&window) { |
| 1085 | + win.ignore_unmap_count += 1; |
| 1086 | + } |
| 1072 | 1087 | self.conn.unmap_window(window)?; |
| 1073 | 1088 | // Also unmap frames if present |
| 1074 | 1089 | if let Some(frame) = self.frames.frame_for_client(window) { |
@@ -1194,6 +1209,10 @@ impl WindowManager { |
| 1194 | 1209 | self.conn.map_window(window)?; |
| 1195 | 1210 | } else { |
| 1196 | 1211 | // Target is not visible - hide the window |
| 1212 | + // Mark as intentional unmap so UnmapNotify handler ignores it |
| 1213 | + if let Some(win) = self.windows.get_mut(&window) { |
| 1214 | + win.ignore_unmap_count += 1; |
| 1215 | + } |
| 1197 | 1216 | self.conn.unmap_window(window)?; |
| 1198 | 1217 | if let Some(frame) = self.frames.frame_for_client(window) { |
| 1199 | 1218 | self.conn.unmap_window(frame)?; |