i3 - improved tiling WM


Improve drag-cancel 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/286/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,20 @@ 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
+                    /* cancel the drag if a window is unmapped on the focused workspace */
33
+                    if (inside_con != NULL && inside_con->type != CT_DOCKAREA && (
34
+                            con_get_workspace(inside_con) == NULL ||
35
+                            con_get_workspace(focused) == NULL ||
36
+                            strcasecmp(con_get_workspace(inside_con)->name, con_get_workspace(focused)->name) == 0)
37
+                       ) {
38
+                        DLOG("Unmap-notify on focused workspace, aborting\n");
39
+                        loop_done = true;
40
+                        drag_result = DRAG_CANCEL;
41
+                    }
42
+
43
                     handle_event(type, inside_event);
44
-                    loop_done = true;
45
-                    drag_result = DRAG_CANCEL;
46
                     break;
47
 
48
                 case XCB_KEY_PRESS: