]> git.sur5r.net Git - i3/i3/commitdiff
Merge pull request #3138 from clawoflight/default-border
authorIngo Bürk <admin@airblader.de>
Mon, 19 Feb 2018 06:03:03 +0000 (07:03 +0100)
committerGitHub <noreply@github.com>
Mon, 19 Feb 2018 06:03:03 +0000 (07:03 +0100)
[WIP] Add default_{,floating_}border

docs/userguide
src/tree.c
testcases/t/294-update-ewmh-atoms.t [new file with mode: 0644]

index 9b367feeee6eed7d1c480698670ee709ad2f852a..ba314af111a62493477dad54d4f030d743fdd0b4 100644 (file)
@@ -1,7 +1,6 @@
 i3 User’s Guide
 ===============
 Michael Stapelberg <michael@i3wm.org>
-March 2013
 
 This document contains all the information you need to configure and use the i3
 window manager. If it does not, please check https://www.reddit.com/r/i3wm/
index b8bc732bca6625f8d27f2c9624cebfa2d73eebea..6c6a614e22d46479381e74447fd12f55dd378bb1 100644 (file)
@@ -330,6 +330,13 @@ bool tree_close_internal(Con *con, kill_window_t kill_window, bool dont_kill_par
         DLOG("parent container killed\n");
     }
 
+    if (ws == con) {
+        DLOG("Closing a workspace container, updating EWMH atoms\n");
+        ewmh_update_number_of_desktops();
+        ewmh_update_desktop_names();
+        ewmh_update_wm_desktop();
+    }
+
     con_free(con);
 
     /* in the case of floating windows, we already focused another container
diff --git a/testcases/t/294-update-ewmh-atoms.t b/testcases/t/294-update-ewmh-atoms.t
new file mode 100644 (file)
index 0000000..047cc11
--- /dev/null
@@ -0,0 +1,111 @@
+#!perl
+# vim:ts=4:sw=4:expandtab
+#
+# Please read the following documents before working on tests:
+# • https://build.i3wm.org/docs/testsuite.html
+#   (or docs/testsuite)
+#
+# • https://build.i3wm.org/docs/lib-i3test.html
+#   (alternatively: perldoc ./testcases/lib/i3test.pm)
+#
+# • https://build.i3wm.org/docs/ipc.html
+#   (or docs/ipc)
+#
+# • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
+#   (unless you are already familiar with Perl)
+#
+# Verifies _NET_DESKTOP_NAMES, _NET_CURRENT_DESKTOP and _NET_CURRENT_DESKTOP
+# are updated properly when closing an inactive workspace container.
+# See github issue #3126
+
+use i3test;
+
+sub get_desktop_names {
+    sync_with_i3;
+
+    my $cookie = $x->get_property(
+        0,
+        $x->get_root_window(),
+        $x->atom(name => '_NET_DESKTOP_NAMES')->id,
+        $x->atom(name => 'UTF8_STRING')->id,
+        0,
+        4096,
+    );
+
+    my $reply = $x->get_property_reply($cookie->{sequence});
+
+    return 0 if $reply->{value_len} == 0;
+
+    # the property is a null-delimited list of utf8 strings ;;
+    return split /\0/, $reply->{value};
+}
+
+sub get_num_of_desktops {
+    sync_with_i3;
+
+    my $cookie = $x->get_property(
+        0,
+        $x->get_root_window(),
+        $x->atom(name => '_NET_NUMBER_OF_DESKTOPS')->id,
+        $x->atom(name => 'CARDINAL')->id,
+        0,
+        4,
+    );
+
+    my $reply = $x->get_property_reply($cookie->{sequence});
+
+    return undef if $reply->{value_len} != 1;
+    return undef if $reply->{format} != 32;
+    return undef if $reply->{type} != $x->atom(name => 'CARDINAL')->id,;
+
+    return unpack 'L', $reply->{value};
+}
+
+sub get_current_desktop {
+    sync_with_i3;
+
+    my $cookie = $x->get_property(
+        0,
+        $x->get_root_window(),
+        $x->atom(name => '_NET_CURRENT_DESKTOP')->id,
+        $x->atom(name => 'CARDINAL')->id,
+        0,
+        4,
+    );
+
+    my $reply = $x->get_property_reply($cookie->{sequence});
+
+    return undef if $reply->{value_len} != 1;
+    return undef if $reply->{format} != 32;
+    return undef if $reply->{type} != $x->atom(name => 'CARDINAL')->id,;
+
+    return unpack 'L', $reply->{value};
+}
+
+cmd 'workspace 0';
+my $first = open_window;
+
+cmd 'workspace 1';
+my $second = open_window;
+
+cmd 'workspace 2';
+my $third = open_window;
+
+# Sanity check
+is(get_current_desktop, 2);
+is(get_num_of_desktops, 3);
+my @actual_names = get_desktop_names;
+my @expected_names = ('0', '1', '2');
+is_deeply(\@actual_names, \@expected_names);
+
+# Kill first window to close a workspace.
+cmd '[id="' . $second->id . '"] kill';
+
+is(get_current_desktop, 2, '_NET_CURRENT_DESKTOP should be updated');
+is(get_num_of_desktops, 2, '_NET_NUMBER_OF_DESKTOPS should be updated');
+my @actual_names = get_desktop_names;
+my @expected_names = ('0', '2');
+is_deeply(\@actual_names, \@expected_names, '_NET_DESKTOP_NAMES should be updated');
+
+
+done_testing;