if (fs == NULL) {
DLOG("Not in fullscreen mode, focusing\n");
if (!cwindow->dock) {
- /* Check that the workspace is visible. If the window was assigned
- * to an invisible workspace, we should not steal focus. */
- if (workspace_is_visible(ws)) {
+ /* Check that the workspace is visible and on the same output as
+ * the current focused container. If the window was assigned to an
+ * invisible workspace, we should not steal focus. */
+ Con *current_output = con_get_output(focused);
+ Con *target_output = con_get_output(ws);
+
+ if (workspace_is_visible(ws) && current_output == target_output) {
con_focus(nc);
} else DLOG("workspace not visible, not focusing\n");
} else DLOG("dock, not focusing\n");