]> git.sur5r.net Git - i3/i3/commitdiff
Correctly re-assign floating clients to the destination workspace when moving
authorMichael Stapelberg <michael@stapelberg.de>
Wed, 24 Jun 2009 15:12:12 +0000 (17:12 +0200)
committerMichael Stapelberg <michael@stapelberg.de>
Wed, 24 Jun 2009 15:12:12 +0000 (17:12 +0200)
include/floating.h
src/commands.c
src/floating.c
src/layout.c

index edc11a95b77bb04e2170e07a6c6136635646598b..a4f8619ac4e1b38abd52bb4424fdf76aae9491cc 100644 (file)
@@ -3,7 +3,7 @@
  *
  * i3 - an improved dynamic tiling window manager
  *
- * (c) 2009 Michael Stapelberg and contributors
+ * © 2009 Michael Stapelberg and contributors
  *
  * See file LICENSE for license information.
  *
  */
 void toggle_floating_mode(xcb_connection_t *conn, Client *client, bool automatic);
 
+/**
+ * Removes the floating client from its workspace and attaches it to the new workspace.
+ * This is centralized here because it may happen if you move it via keyboard and
+ * if you move it using your mouse.
+ *
+ */
+void floating_assign_to_workspace(Client *client, Workspace *new_workspace);
+
 /**
  * Called whenever the user clicks on a border (not the titlebar!) of a floating window.
  * Determines on which border the user clicked and launches the drag_pointer function
index ff682bd5ed35b20dec55c0bfa3ee64bd92f213b4..2b4b163e8a5961428e9d1f4d5bb35ccadc99ba31 100644 (file)
@@ -453,19 +453,7 @@ static void move_floating_window_to_workspace(xcb_connection_t *conn, Client *cl
                 }
         }
 
-        /* Remove from focus stack and list of floating clients */
-        SLIST_REMOVE(&(client->workspace->focus_stack), client, Client, focus_clients);
-        TAILQ_REMOVE(&(client->workspace->floating_clients), client, floating_clients);
-
-        if (client->workspace->fullscreen_client == client)
-                client->workspace->fullscreen_client = NULL;
-
-        /* Insert into destination focus stack and list of floating clients */
-        client->workspace = t_ws;
-        SLIST_INSERT_HEAD(&(t_ws->focus_stack), client, focus_clients);
-        TAILQ_INSERT_TAIL(&(t_ws->floating_clients), client, floating_clients);
-        if (client->fullscreen)
-                t_ws->fullscreen_client = client;
+        floating_assign_to_workspace(client, t_ws);
 
         /* If we’re moving it to an invisible screen, we need to unmap it */
         if (t_ws->screen->current_workspace != t_ws->num) {
index fb280dc963e0dbd746f4eea411e1b56195389a5e..6e5bec52b65dbe3cb8fc0bc79809e6dd71db779b 100644 (file)
@@ -140,6 +140,28 @@ void toggle_floating_mode(xcb_connection_t *conn, Client *client, bool automatic
         xcb_flush(conn);
 }
 
+/*
+ * Removes the floating client from its workspace and attaches it to the new workspace.
+ * This is centralized here because it may happen if you move it via keyboard and
+ * if you move it using your mouse.
+ *
+ */
+void floating_assign_to_workspace(Client *client, Workspace *new_workspace) {
+        /* Remove from focus stack and list of floating clients */
+        SLIST_REMOVE(&(client->workspace->focus_stack), client, Client, focus_clients);
+        TAILQ_REMOVE(&(client->workspace->floating_clients), client, floating_clients);
+
+        if (client->workspace->fullscreen_client == client)
+                client->workspace->fullscreen_client = NULL;
+
+        /* Insert into destination focus stack and list of floating clients */
+        client->workspace = new_workspace;
+        SLIST_INSERT_HEAD(&(client->workspace->focus_stack), client, focus_clients);
+        TAILQ_INSERT_TAIL(&(client->workspace->floating_clients), client, floating_clients);
+        if (client->fullscreen)
+                client->workspace->fullscreen_client = client;
+
+}
 
 /*
  * Called whenever the user clicks on a border (not the titlebar!) of a floating window.
index 2b01f90c55a72f309438f3c6d3dcfa5705a1a395..e70d0f49682217376d50d1512d87217eda3030d4 100644 (file)
@@ -25,6 +25,7 @@
 #include "xinerama.h"
 #include "layout.h"
 #include "client.h"
+#include "floating.h"
 
 /*
  * Updates *destination with new_value and returns true if it was changed or false
@@ -173,10 +174,24 @@ void decorate_window(xcb_connection_t *conn, Client *client, xcb_drawable_t draw
  *
  */
 void reposition_client(xcb_connection_t *conn, Client *client) {
+        i3Screen *screen;
+
         LOG("frame 0x%08x needs to be pushed to %dx%d\n", client->frame, client->rect.x, client->rect.y);
         /* Note: We can use a pointer to client->x like an array of uint32_ts
            because it is followed by client->y by definition */
         xcb_configure_window(conn, client->frame, XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y, &(client->rect.x));
+
+        if (!client_is_floating(client))
+                return;
+
+        /* If the client is floating, we need to check if we moved it to a different workspace */
+        if (client->workspace->screen == (screen = get_screen_containing(client->rect.x, client->rect.y)))
+                return;
+
+        LOG("Client is on workspace %p with screen %p\n", client->workspace, client->workspace->screen);
+        LOG("but screen at %d, %d is %p\n", client->rect.x, client->rect.y, screen);
+        floating_assign_to_workspace(client, &workspaces[screen->current_workspace]);
+        LOG("fixed that\n");
 }
 
 /*