@@ -519,27 +519,27 @@ impl WindowManager { |
| 519 | 519 | self.conn.grab_button(window)?; |
| 520 | 520 | |
| 521 | 521 | // Manage window on target workspace |
| 522 | | - if target_idx != self.focused_workspace { |
| 523 | | - // Window goes to a different workspace |
| 524 | | - if should_float { |
| 525 | | - self.manage_window_floating_on_workspace(window, target_idx); |
| 522 | + let target_visible = self.is_workspace_visible(target_idx); |
| 523 | + |
| 524 | + if should_float { |
| 525 | + if target_idx == self.focused_workspace { |
| 526 | + self.manage_window_floating(window); |
| 526 | 527 | } else { |
| 527 | | - self.manage_window_on_workspace(window, target_idx); |
| 528 | + self.manage_window_floating_on_workspace(window, target_idx); |
| 528 | 529 | } |
| 529 | | - // Create frame if title bars enabled |
| 530 | | - self.create_frame_for_window(window); |
| 531 | | - // Don't map - it's on another workspace |
| 532 | 530 | } else { |
| 533 | | - // Window goes to current workspace |
| 534 | | - if should_float { |
| 535 | | - self.manage_window_floating(window); |
| 536 | | - } else { |
| 531 | + if target_idx == self.focused_workspace { |
| 537 | 532 | self.manage_window(window); |
| 533 | + } else { |
| 534 | + self.manage_window_on_workspace(window, target_idx); |
| 538 | 535 | } |
| 539 | | - // Create frame if title bars enabled |
| 540 | | - let frame = self.create_frame_for_window(window); |
| 536 | + } |
| 537 | + |
| 538 | + // Create frame if title bars enabled |
| 539 | + let frame = self.create_frame_for_window(window); |
| 541 | 540 | |
| 542 | | - // Map the window (and frame if present) |
| 541 | + // Map window if it's on a visible workspace (any monitor) |
| 542 | + if target_visible { |
| 543 | 543 | if frame.is_some() { |
| 544 | 544 | self.frames.map_frame(&self.conn.conn, window)?; |
| 545 | 545 | } |
@@ -549,8 +549,8 @@ impl WindowManager { |
| 549 | 549 | // Apply layout to all windows |
| 550 | 550 | self.apply_layout()?; |
| 551 | 551 | |
| 552 | | - // Focus the new window (only if on current workspace) |
| 553 | | - if target_idx == self.focused_workspace { |
| 552 | + // Focus the new window if on a visible workspace |
| 553 | + if target_visible { |
| 554 | 554 | self.set_focus(window, true)?; |
| 555 | 555 | } |
| 556 | 556 | |