]> git.sur5r.net Git - i3/i3/commitdiff
Use the size when mapping the window as size for floating (correct size for tool...
authorMichael Stapelberg <michael@stapelberg.de>
Tue, 2 Jun 2009 12:24:37 +0000 (14:24 +0200)
committerMichael Stapelberg <michael@stapelberg.de>
Tue, 2 Jun 2009 12:24:37 +0000 (14:24 +0200)
src/floating.c
src/handlers.c
src/manage.c

index 9c71cf36fb174b8b1de7be36fd6eb1175accbb01..181fbe34ab389686884a92867ad9c0597083dbb0 100644 (file)
@@ -96,13 +96,22 @@ void toggle_floating_mode(xcb_connection_t *conn, Client *client, bool automatic
         else client->floating = FLOATING_USER_ON;
 
         /* Initialize the floating position from the position in tiling mode, if this
-         * client never was floating (width == 0) */
-        if (client->floating_rect.width == 0) {
-                memcpy(&(client->floating_rect), &(client->rect), sizeof(Rect));
-                LOG("(%d, %d) size (%d, %d)\n", client->floating_rect.x, client->floating_rect.y,
+         * client never was floating (x == -1) */
+        if (client->floating_rect.x == -1) {
+                /* Copy over the position */
+                client->floating_rect.x = client->rect.x;
+                client->floating_rect.y = client->rect.y;
+
+                /* Copy the size the other direction */
+                client->rect.width = client->floating_rect.width;
+                client->rect.height = client->floating_rect.height;
+
+                LOG("copying size from tiling (%d, %d) size (%d, %d)\n", client->floating_rect.x, client->floating_rect.y,
                                 client->floating_rect.width, client->floating_rect.height);
         } else {
                 /* If the client was already in floating before we restore the old position / size */
+                LOG("using: (%d, %d) size (%d, %d)\n", client->floating_rect.x, client->floating_rect.y,
+                        client->floating_rect.width, client->floating_rect.height);
                 memcpy(&(client->rect), &(client->floating_rect), sizeof(Rect));
         }
 
index cdc735e48682adb88ddb8e96db604a6e9a080956..92ad73cb5b4c6dee008ca800d5de7af287efe36e 100644 (file)
@@ -874,6 +874,7 @@ int handle_normal_hints(void *data, xcb_connection_t *conn, uint8_t state, xcb_w
                 return 1;
         }
         xcb_size_hints_t size_hints;
+        LOG("client is %08x / child %08x\n", client->frame, client->child);
 
         /* If the hints were already in this event, use them, if not, request them */
         if (reply != NULL)
index c87de57557abfe45cb51c469a4bbe1bec37085cb..9a26f21424695c4817e1a2d725997fa69875cfde 100644 (file)
@@ -159,6 +159,7 @@ void reparent_window(xcb_connection_t *conn, xcb_window_t child,
         assert(new == NULL);
 
         LOG("reparenting new client\n");
+        LOG("x = %d, y = %d, width = %d, height = %d\n", x, y, width, height);
         new = calloc(sizeof(Client), 1);
         new->force_reconfigure = true;
 
@@ -172,6 +173,10 @@ void reparent_window(xcb_connection_t *conn, xcb_window_t child,
         new->child = child;
         new->rect.width = width;
         new->rect.height = height;
+        /* Pre-initialize the values for floating */
+        new->floating_rect.x = -1;
+        new->floating_rect.width = width;
+        new->floating_rect.height = height;
 
         mask = 0;