]> git.sur5r.net Git - i3/i3/commitdiff
Bugfix: Center floating windows with invalid coordinates on current ws
authorMichael Stapelberg <michael@stapelberg.de>
Mon, 18 Apr 2011 17:36:10 +0000 (19:36 +0200)
committerMichael Stapelberg <michael@stapelberg.de>
Mon, 18 Apr 2011 17:36:10 +0000 (19:36 +0200)
src/floating.c

index 78804c8e11a1b6e91b368ae0a26f2260ac771d65..1d08ec9e4102fc2e36680ee55c1d43d1d9f83a27 100644 (file)
@@ -157,7 +157,19 @@ void floating_enable(Con *con, bool automatic) {
     if (set_focus)
         con_focus(con);
 
-    floating_maybe_reassign_ws(nc);
+    /* Check if we need to re-assign it to a different workspace because of its
+     * coordinates and exit if that was done successfully. */
+    if (floating_maybe_reassign_ws(nc))
+        return;
+
+    /* Sanitize coordinates: Check if they are on any output */
+    if (get_output_containing(nc->rect.x, nc->rect.y) != NULL)
+        return;
+
+    ELOG("No output found at destination coordinates, centering floating window on current ws\n");
+    Con *ws = nc->parent;
+    nc->rect.x = ws->rect.x + (ws->rect.width / 2) - (nc->rect.width / 2);
+    nc->rect.y = ws->rect.y + (ws->rect.height / 2) - (nc->rect.height / 2);
 }
 
 void floating_disable(Con *con, bool automatic) {