i3 - improved tiling WM


Add sensible discretion to UnmapNotify drag abort

Patch status: merged

Patch by Tony Crisci

Long description:

Only abort a drag action 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/301/raw.patch | git am

b/src/floating.c

17
@@ -629,6 +629,8 @@ 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
+
23
     drag_result_t drag_result = DRAGGING;
24
     /* I’ve always wanted to have my own eventhandler… */
25
     while (drag_result == DRAGGING && (inside_event = xcb_wait_for_event(conn))) {
26
@@ -654,8 +656,16 @@ drag_result_t drag_pointer(Con *con, const xcb_button_press_event_t *event, xcb_
27
                     break;
28
 
29
                 case XCB_UNMAP_NOTIFY:
30
-                    DLOG("Unmap-notify, aborting\n");
31
-                    drag_result = DRAG_ABORT;
32
+                    inside_con = con_by_window_id(((xcb_unmap_notify_event_t*)inside_event)->window);
33
+
34
+                    if (inside_con != NULL) {
35
+                        DLOG("UnmapNotify for window 0x%08x (container %p)\n", ((xcb_unmap_notify_event_t*)inside_event)->window, inside_con);
36
+
37
+                        if (con_get_workspace(inside_con) == con_get_workspace(focused)) {
38
+                            DLOG("UnmapNotify for a managed window on the current workspace, aborting\n");
39
+                            drag_result = DRAG_ABORT;
40
+                        }
41
+                    }
42
 
43
                     handle_event(type, inside_event);
44
                     break;