$OpenBSD: patch-src_floating_c,v 1.17 2013/07/01 13:42:25 dcoppa Exp $

commit b4f7142509e3af51504a1e72163d544d305f0fa8
Author: Michael Stapelberg <michael@stapelberg.de>
Date:   Sat Jun 29 20:27:33 2013 +0200

Bugfix: fix focus handling in 'floating disable' on non-visible windows

fixes #1027

--- src/floating.c.orig	Mon Mar 18 22:43:36 2013
+++ src/floating.c	Mon Jul  1 15:26:35 2013
@@ -315,6 +315,8 @@ void floating_disable(Con *con, bool automatic) {
         return;
     }
 
+    const bool set_focus = (con == focused);
+
     Con *ws = con_get_workspace(con);
 
     /* 1: detach from parent container */
@@ -344,8 +346,9 @@ void floating_disable(Con *con, bool automatic) {
     con_attach(con, con->parent, false);
 
     con_fix_percent(con->parent);
-    // TODO: don’t influence focus handling when Con was not focused before.
-    con_focus(con);
+
+    if (set_focus)
+        con_focus(con);
 }
 
 /*
