FLOATING_USER_ON = 3
} floating;
+ /** This counter contains the number of UnmapNotify events for this
+ * container (or, more precisely, for its ->frame) which should be ignored.
+ * UnmapNotify events need to be ignored when they are caused by i3 itself,
+ * for example when reparenting or when unmapping the window on a workspace
+ * change. */
+ uint8_t ignore_unmap;
TAILQ_ENTRY(Con) nodes;
TAILQ_ENTRY(Con) focused;
*/
int handle_unmap_notify_event(void *data, xcb_connection_t *conn, xcb_unmap_notify_event_t *event) {
- bool ignored = event_is_ignored(event->sequence);
-
/* FIXME: we cannot ignore this sequence because more UnmapNotifys with the same sequence
* numbers but different window IDs may follow */
/* we need to ignore EnterNotify events which will be generated because a
//add_ignore_event(event->sequence);
DLOG("UnmapNotify for 0x%08x (received from 0x%08x), serial %d\n", event->window, event->event, event->sequence);
- if (ignored) {
- DLOG("Ignoring UnmapNotify (generated by reparenting)\n");
- unignore_event(event->sequence);
- return 1;
- }
Con *con = con_by_window_id(event->window);
if (con == NULL) {
- LOG("Not a managed window, ignoring\n");
+ /* This could also be an UnmapNotify for the frame. We need to
+ * decrement the ignore_unmap counter. */
+ con = con_by_frame_id(event->window);
+ if (con == NULL) {
+ LOG("Not a managed window, ignoring UnmapNotify event\n");
+ return 1;
+ }
+ if (con->ignore_unmap > 0)
+ con->ignore_unmap--;
+ DLOG("ignore_unmap = %d for frame of container %p\n", con->ignore_unmap, con);
+ return 1;
+ }
+
+ if (con->ignore_unmap > 0) {
+ DLOG("ignore_unmap = %d, dec\n", con->ignore_unmap);
+ con->ignore_unmap--;
return 1;
}
static void mark_unmapped(Con *con) {
Con *current;
+ DLOG("marking container %p unmapped\n", con);
con->mapped = false;
TAILQ_FOREACH(current, &(con->nodes_head), nodes)
mark_unmapped(current);
+ if (con->type == CT_WORKSPACE) {
+ TAILQ_FOREACH(current, &(con->floating_head), floating_windows) {
+ DLOG("Marking unmapped for floating %p\n", current);
+ current->mapped = false;
+ Con *child = TAILQ_FIRST(&(current->nodes_head));
+ DLOG(" unmapping floating child %p\n", child);
+ child->mapped = false;
+ }
+ }
+ DLOG("mark_unmapped done\n");
}
/*
state->old_frame = XCB_NONE;
state->need_reparent = false;
+
+ con->ignore_unmap++;
+ DLOG("ignore_unmap for reparenting of con %p (win 0x%08x) is now %d\n",
+ con, con->window->id, con->ignore_unmap);
}
/* map/unmap if map state changed, also ensure that the child window
cookie = xcb_unmap_window(conn, con->frame);
LOG("unmapping container (serial %d)\n", cookie.sequence);
+ /* we need to increase ignore_unmap for this container (if it contains a window) and for every window "under" this one which contains a window */
+ if (con->window != NULL) {
+ con->ignore_unmap++;
+ DLOG("ignore_unmap for con %p (frame 0x%08x) now %d\n", con, con->frame, con->ignore_unmap);
+ }
/* Ignore enter_notifies which are generated when unmapping */
add_ignore_event(cookie.sequence);
} else {
--- /dev/null
+#!perl
+# vim:ts=4:sw=4:expandtab
+# Regression test: Floating windows were not correctly unmapped when switching
+# to a different workspace.
+
+use i3test tests => 5;
+use X11::XCB qw(:all);
+use Time::HiRes qw(sleep);
+
+BEGIN {
+ use_ok('X11::XCB::Window');
+}
+
+my $i3 = i3("/tmp/nestedcons");
+
+my $tmp = get_unused_workspace();
+$i3->command("workspace $tmp")->recv;
+
+#############################################################################
+# 1: open a floating window, get it mapped
+#############################################################################
+
+my $x = X11::XCB::Connection->new;
+
+# FIXME: we open a tiling container as long as t/37* is not done (should swap positions with t/36* then)
+my $twindow = $x->root->create_child(
+ class => WINDOW_CLASS_INPUT_OUTPUT,
+ rect => [ 0, 0, 30, 30],
+ background_color => '#C0C0C0',
+);
+
+isa_ok($twindow, 'X11::XCB::Window');
+
+$twindow->map;
+
+sleep 0.25;
+
+# Create a floating window which is smaller than the minimum enforced size of i3
+my $window = $x->root->create_child(
+ class => WINDOW_CLASS_INPUT_OUTPUT,
+ rect => [ 0, 0, 30, 30],
+ background_color => '#C0C0C0',
+ # replace the type with 'utility' as soon as the coercion works again in X11::XCB
+ window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_UTILITY'),
+);
+
+isa_ok($window, 'X11::XCB::Window');
+
+$window->map;
+
+sleep 0.25;
+
+ok($window->mapped, 'Window is mapped');
+
+# switch to a different workspace, see if the window is still mapped?
+
+my $otmp = get_unused_workspace();
+$i3->command("workspace $otmp")->recv;
+
+sleep 0.25;
+
+ok(!$window->mapped, 'Window is not mapped after switching ws');
+
+$i3->command("nop testcase done")->recv;