From d4e4cbfd2504fee3a2570bac5b1c1104cb5f2e2b Mon Sep 17 00:00:00 2001
From: Orestis Floros <orestisf1993@gmail.com>
Date: Fri, 22 Mar 2019 00:55:30 +0200
Subject: [PATCH] workspace_move_to_output: Avoid operations when workspace
 already at destination

Closes #3635.
Probably the bug can still happen when a tree_close_internal happens
inside a workspace_show but modifying the code to avoid them seems to
not be worth it.
---
 src/workspace.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/workspace.c b/src/workspace.c
index 0aeecb45..3cf74754 100644
--- a/src/workspace.c
+++ b/src/workspace.c
@@ -969,6 +969,11 @@ void workspace_move_to_output(Con *ws, Output *output) {
     Con *content = output_get_content(output->con);
     DLOG("got output %p with content %p\n", output, content);
 
+    if (ws->parent == content) {
+        DLOG("Nothing to do, workspace already there\n");
+        return;
+    }
+
     Con *previously_visible_ws = TAILQ_FIRST(&(content->focus_head));
     if (previously_visible_ws) {
         DLOG("Previously visible workspace = %p / %s\n", previously_visible_ws, previously_visible_ws->name);