i3 - improved tiling WM


Do not reposition floating containers if unmapped

Patch status: needinfo

Patch by Tony Crisci

Long description:

`floating_reposition` will not reposition windows that are not mapped.

Fixes an issue that caused i3 to crash when a user is dragging or
resizing a floating window that becomes destroyed.

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

b/src/floating.c

18
@@ -701,8 +701,9 @@ drag_result_t drag_pointer(Con *con, const xcb_button_press_event_t *event, xcb_
19
 
20
 /*
21
  * Repositions the CT_FLOATING_CON to have the coordinates specified by
22
- * newrect, but only if the coordinates are not out-of-bounds. Also reassigns
23
- * the floating con to a different workspace if this move was across different
24
+ * newrect, but only if the coordinates are not out-of-bounds and the container
25
+ * is mapped. Also reassigns the floating con to a different workspace if this
26
+ * move was across different
27
  * outputs.
28
  *
29
  */
30
@@ -714,6 +715,12 @@ void floating_reposition(Con *con, Rect newrect) {
31
         return;
32
     }
33
 
34
+    /* Sanity check: Is the container mapped? If not, we ignore the request. */
35
+    if (!con->mapped) {
36
+        ELOG("Container not mapped. Not repositioning.\n");
37
+        return;
38
+    }
39
+
40
     con->rect = newrect;
41
 
42
     floating_maybe_reassign_ws(con);

b/testcases/t/112-floating-resize.t

47
@@ -34,6 +34,7 @@ my ($na, $nt) = $window->rect;
48
 is_deeply($na, $a, 'Rects are equal after configurerequest');
49
 
50
 sub test_resize {
51
+    my $window = open_floating_window;
52
     $window->rect(X11::XCB::Rect->new(x => 0, y => 0, width => 100, height => 100));
53
 
54
     sync_with_i3;