- new->floating_rect.x = new->rect.x;
- new->floating_rect.y = new->rect.y;
- LOG("copying size from tiling (%d, %d) size (%d, %d)\n",
+ /* Add the client to the list of floating clients for its workspace */
+ TAILQ_INSERT_TAIL(&(new->workspace->floating_clients), new, floating_clients);
+
+ new->container = NULL;
+
+ new->rect.width = new->floating_rect.width + 2 + 2;
+ new->rect.height = new->floating_rect.height + (font->height + 2 + 2) + 2;
+
+ /* Some clients (like GIMP’s color picker window) get mapped
+ * to (0, 0), so we push them to a reasonable position
+ * (centered over their leader) */
+ if (new->leader != 0 && x == 0 && y == 0) {
+ DLOG("Floating client wants to (0x0), moving it over its leader instead\n");
+ Client *leader = table_get(&by_child, new->leader);
+ if (leader == NULL) {
+ DLOG("leader is NULL, centering it over current workspace\n");
+
+ x = c_ws->rect.x + (c_ws->rect.width / 2) - (new->rect.width / 2);
+ y = c_ws->rect.y + (c_ws->rect.height / 2) - (new->rect.height / 2);
+ } else {
+ x = leader->rect.x + (leader->rect.width / 2) - (new->rect.width / 2);
+ y = leader->rect.y + (leader->rect.height / 2) - (new->rect.height / 2);
+ }
+ }
+ new->floating_rect.x = new->rect.x = x;
+ new->floating_rect.y = new->rect.y = y;
+ DLOG("copying floating_rect from tiling (%d, %d) size (%d, %d)\n",