+ /* To make static analyzers happy: */
+ default:
+ return;
+ }
+
+ render_layout(conn);
+}
+
+static void move_floating_window_to_workspace(xcb_connection_t *conn, Client *client, int workspace) {
+ /* t_ws (to workspace) is just a container pointer to the workspace we’re switching to */
+ Workspace *t_ws = workspace_get(workspace-1),
+ *old_ws = client->workspace;
+
+ LOG("moving floating\n");
+
+ workspace_initialize(t_ws, c_ws->output, false);
+
+ /* Check if there is already a fullscreen client on the destination workspace and
+ * stop moving if so. */
+ if (client->fullscreen && (t_ws->fullscreen_client != NULL)) {
+ ELOG("Not moving: Fullscreen client already existing on destination workspace.\n");
+ return;
+ }
+
+ floating_assign_to_workspace(client, t_ws);
+
+ /* If we’re moving it to an invisible screen, we need to unmap it */
+ if (!workspace_is_visible(t_ws)) {
+ DLOG("This workspace is not visible, unmapping\n");
+ client_unmap(conn, client);
+ } else {
+ /* If this is not the case, we move the window to a workspace
+ * which is on another screen, so we also need to adjust its
+ * coordinates. */
+ DLOG("before x = %d, y = %d\n", client->rect.x, client->rect.y);
+ uint32_t relative_x = client->rect.x - old_ws->rect.x,
+ relative_y = client->rect.y - old_ws->rect.y;
+ DLOG("rel_x = %d, rel_y = %d\n", relative_x, relative_y);
+ client->rect.x = t_ws->rect.x + relative_x;
+ client->rect.y = t_ws->rect.y + relative_y;
+ DLOG("after x = %d, y = %d\n", client->rect.x, client->rect.y);
+ reposition_client(conn, client);
+ xcb_flush(conn);
+ }
+
+ /* Configure the window above all tiling windows (or below a fullscreen
+ * window, if any) */
+ if (t_ws->fullscreen_client != NULL) {
+ uint32_t values[] = { t_ws->fullscreen_client->frame, XCB_STACK_MODE_BELOW };
+ xcb_configure_window(conn, client->frame, XCB_CONFIG_WINDOW_SIBLING | XCB_CONFIG_WINDOW_STACK_MODE, values);
+ } else {
+ Client *last_tiling;
+ SLIST_FOREACH(last_tiling, &(t_ws->focus_stack), focus_clients)
+ if (!client_is_floating(last_tiling))
+ break;
+ if (last_tiling != SLIST_END(&(t_ws->focus_stack))) {
+ uint32_t values[] = { last_tiling->frame, XCB_STACK_MODE_ABOVE };
+ xcb_configure_window(conn, client->frame, XCB_CONFIG_WINDOW_SIBLING | XCB_CONFIG_WINDOW_STACK_MODE, values);
+ }