]> git.sur5r.net Git - i3/i3/blobdiff - src/handlers.c
Grab XCB_GRAB_SYNC and replay the event so it doesn’t get lost
[i3/i3] / src / handlers.c
index e1edd5c64c159195deea5a48797046b3eff006d2..d058b650eec5f39c2224742ad4982d7eae221d3e 100644 (file)
@@ -147,6 +147,8 @@ int handle_button_press(void *ignored, xcb_connection_t *conn, xcb_button_press_
 
         if (con == NULL) {
                 printf("dock. done.\n");
+                xcb_allow_events(conn, XCB_ALLOW_REPLAY_POINTER, event->time);
+                xcb_flush(conn);
                 return 1;
         }
 
@@ -154,6 +156,8 @@ int handle_button_press(void *ignored, xcb_connection_t *conn, xcb_button_press_
 
         if (!border_click) {
                 printf("client. done.\n");
+                xcb_allow_events(conn, XCB_ALLOW_REPLAY_POINTER, event->time);
+                xcb_flush(conn);
                 return 1;
         }
 
@@ -329,9 +333,14 @@ int handle_unmap_notify_event(void *data, xcb_connection_t *c, xcb_unmap_notify_
         }
 
         if (client->container != NULL) {
+                Client *to_focus = CIRCLEQ_NEXT_OR_NULL(&(client->container->clients), client, clients);
+                if (to_focus == NULL)
+                        to_focus = CIRCLEQ_PREV_OR_NULL(&(client->container->clients), client, clients);
                 if (client->container->currently_focused == client)
-                        client->container->currently_focused = NULL;
+                        client->container->currently_focused = to_focus;
                 CIRCLEQ_REMOVE(&(client->container->clients), client, clients);
+                if (to_focus != NULL)
+                        set_focus(c, to_focus);
         }
 
         printf("child of 0x%08x.\n", client->frame);
@@ -339,6 +348,9 @@ int handle_unmap_notify_event(void *data, xcb_connection_t *c, xcb_unmap_notify_
         xcb_destroy_window(c, client->frame);
         xcb_flush(c);
         table_remove(byParent, client->frame);
+
+        cleanup_table(client->container->workspace);
+
         free(client);
 
         render_layout(c);