]> git.sur5r.net Git - i3/i3/commitdiff
Bugfix: Re-assign dock windows to different workspaces when a workspace is deleted
authorMichael Stapelberg <michael@stapelberg.de>
Sat, 16 May 2009 16:12:35 +0000 (18:12 +0200)
committerMichael Stapelberg <michael@stapelberg.de>
Sat, 16 May 2009 16:12:35 +0000 (18:12 +0200)
Killing a dock client and having destroyed workspace 1 before (or the workspace
on which the dock client was started when it was not auto-started) crashed i3 before
this bugfix.

src/commands.c
src/handlers.c
src/util.c

index b84cb858d00f111e50486b21a4a87e90dd743e01..e289e018f163e71e5e7432cbb00fc8dd69ffa6fd 100644 (file)
@@ -547,11 +547,12 @@ void show_workspace(xcb_connection_t *conn, int workspace) {
         }
 
         t_ws->screen->current_workspace = workspace-1;
+        Workspace *old_workspace = c_ws;
+        c_ws = &workspaces[workspace-1];
 
-        /* Unmap all clients of the current workspace */
-        unmap_workspace(conn, c_ws);
+        /* Unmap all clients of the old workspace */
+        unmap_workspace(conn, old_workspace);
 
-        c_ws = &workspaces[workspace-1];
         current_row = c_ws->current_row;
         current_col = c_ws->current_col;
         LOG("new current row = %d, current col = %d\n", current_row, current_col);
index c7c11246833bf9881707174f7351abb8c48dd2ef..7dae114912049684f10cf9985c71ed8fdc7d72aa 100644 (file)
@@ -145,7 +145,7 @@ int handle_enter_notify(void *ignored, xcb_connection_t *conn, xcb_enter_notify_
                 return 1;
         }
         /* Some events are not interesting, because they were not generated actively by the
-           user, but be reconfiguration of windows */
+           user, but by reconfiguration of windows */
         if (event_is_ignored(event->sequence))
                 return 1;
 
@@ -192,6 +192,14 @@ int handle_enter_notify(void *ignored, xcb_connection_t *conn, xcb_enter_notify_
                 return 1;
         }
 
+        if (client->container->workspace != c_ws) {
+                /* This can happen when a client gets assigned to a different workspace than
+                 * the current one (see src/mainx.c:reparent_window). Shortly after it was created,
+                 * an enter_notify will follow. */
+                LOG("enter_notify for a client on a different workspace, ignoring\n");
+                return 1;
+        }
+
         set_focus(conn, client, false);
 
         return 1;
index 5b51bd5b39bb8ca70a2bd14d15f68d5c16f0c4cd..a1146251ddbb45d23e906e73c4dec06ae7361e06 100644 (file)
@@ -263,8 +263,18 @@ void unmap_workspace(xcb_connection_t *conn, Workspace *u_ws) {
                 }
 
         /* If we did not unmap any clients, the workspace is empty and we can destroy it */
-        if (unmapped_clients == 0)
+        if (unmapped_clients == 0) {
+                /* Re-assign the workspace of all dock clients which use this workspace */
+                Client *dock;
+                SLIST_FOREACH(dock, &(u_ws->screen->dock_clients), dock_clients) {
+                        if (dock->workspace != u_ws)
+                                continue;
+
+                        LOG("Re-assigning dock client to c_ws (%p)\n", c_ws);
+                        dock->workspace = c_ws;
+                }
                 u_ws->screen = NULL;
+        }
 
         /* Unmap the stack windows on the current workspace, if any */
         SLIST_FOREACH(stack_win, &stack_wins, stack_windows)