i3 - improved tiling WM


Improve dragging pointer UnmapNotify policy

Patch status: needinfo

Patch by Tony Crisci

Long description:

Only cancel a drag operation on UnmapNotify when the unmapping window is
managed on the current workspace.

fixes #1108

To apply this patch, use:
curl http://cr.i3wm.org/patch/290/raw.patch | git am

b/src/floating.c

17
@@ -629,6 +629,7 @@ drag_result_t drag_pointer(Con *con, const xcb_button_press_event_t *event, xcb_
18
     xcb_flush(conn);
19
 
20
     xcb_generic_event_t *inside_event, *last_motion_notify = NULL;
21
+    Con *inside_con = NULL;
22
     bool loop_done = false;
23
     /* The return value, set to DRAG_CANCEL on user cancel */
24
     drag_result_t drag_result = DRAG_SUCCESS;
25
@@ -656,10 +657,16 @@ drag_result_t drag_pointer(Con *con, const xcb_button_press_event_t *event, xcb_
26
                     break;
27
 
28
                 case XCB_UNMAP_NOTIFY:
29
-                    DLOG("Unmap-notify, aborting\n");
30
+                    inside_con = con_by_window_id(((xcb_unmap_notify_event_t*)inside_event)->window);
31
+
32
+                    DLOG("UnmapNotify for window 0x%08x (container %p)\n", ((xcb_unmap_notify_event_t*)inside_event)->window, inside_con);
33
+                    /* cancel the drag if a window is unmapped on the focused workspace */
34
+                    if (con_get_workspace(inside_con) == con_get_workspace(focused)) {
35
+                        DLOG("UnmapNotify for a managed window on the current workspace, aborting\n");
36
+                        loop_done = true;
37
+                    }
38
+
39
                     handle_event(type, inside_event);
40
-                    loop_done = true;
41
-                    drag_result = DRAG_CANCEL;
42
                     break;
43
 
44
                 case XCB_KEY_PRESS: