Add test for floating types
Patch status: merged
Patch by Tony Crisci
Long description:
Add a test that verifies that windows with properties that indicate they should be floating are indeed opened floating.
To apply this patch, use:
curl http://cr.i3wm.org/patch/451/raw.patch | git am
b/testcases/t/221-floating-type-hints.t
| 17 |
@@ -0,0 +1,119 @@ |
| 18 |
+#!perl |
| 19 |
+# vim:ts=4:sw=4:expandtab |
| 20 |
+# |
| 21 |
+# Please read the following documents before working on tests: |
| 22 |
+# • http://build.i3wm.org/docs/testsuite.html |
| 23 |
+# (or docs/testsuite) |
| 24 |
+# |
| 25 |
+# • http://build.i3wm.org/docs/lib-i3test.html |
| 26 |
+# (alternatively: perldoc ./testcases/lib/i3test.pm) |
| 27 |
+# |
| 28 |
+# • http://build.i3wm.org/docs/ipc.html |
| 29 |
+# (or docs/ipc) |
| 30 |
+# |
| 31 |
+# • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf |
| 32 |
+# (unless you are already familiar with Perl) |
| 33 |
+# |
| 34 |
+# Verifies that windows with properties that indicate they should be floating |
| 35 |
+# are indeed opened floating. |
| 36 |
+# Ticket: #1182 |
| 37 |
+# Bug still in: 4.7.2-97-g84fc808 |
| 38 |
+use i3test; |
| 39 |
+use X11::XCB qw(PROP_MODE_REPLACE); |
| 40 |
+ |
| 41 |
+sub open_with_type {
|
| 42 |
+ my $window_type = shift; |
| 43 |
+ |
| 44 |
+ my $window = open_window( |
| 45 |
+ window_type => $x->atom(name => $window_type), |
| 46 |
+ ); |
| 47 |
+ return $window; |
| 48 |
+} |
| 49 |
+ |
| 50 |
+sub open_with_state {
|
| 51 |
+ my $window_state = shift; |
| 52 |
+ |
| 53 |
+ my $window = open_window( |
| 54 |
+ before_map => sub {
|
| 55 |
+ my ($window) = @_; |
| 56 |
+ |
| 57 |
+ my $atomname = $x->atom(name => '_NET_WM_STATE'); |
| 58 |
+ my $atomtype = $x->atom(name => 'ATOM'); |
| 59 |
+ $x->change_property( |
| 60 |
+ PROP_MODE_REPLACE, |
| 61 |
+ $window->id, |
| 62 |
+ $atomname->id, |
| 63 |
+ $atomtype->id, |
| 64 |
+ 32, |
| 65 |
+ 1, |
| 66 |
+ pack('L1', $x->atom(name => $window_state)->id),
|
| 67 |
+ ); |
| 68 |
+ }, |
| 69 |
+ ); |
| 70 |
+ |
| 71 |
+ return $window; |
| 72 |
+} |
| 73 |
+ |
| 74 |
+sub open_with_fixed_size {
|
| 75 |
+ # The type of the WM_NORMAL_HINTS property is WM_SIZE_HINTS |
| 76 |
+ # http://tronche.com/gui/x/icccm/sec-4.html#s-4.1.2.3 |
| 77 |
+ my $XCB_ICCCM_SIZE_HINT_P_MIN_SIZE = 0x32; |
| 78 |
+ my $XCB_ICCCM_SIZE_HINT_P_MAX_SIZE = 0x16; |
| 79 |
+ |
| 80 |
+ my $flags = $XCB_ICCCM_SIZE_HINT_P_MIN_SIZE | $XCB_ICCCM_SIZE_HINT_P_MAX_SIZE; |
| 81 |
+ |
| 82 |
+ my $min_width = 55; |
| 83 |
+ my $max_width = 55; |
| 84 |
+ my $min_height = 77; |
| 85 |
+ my $max_height = 77; |
| 86 |
+ |
| 87 |
+ my $pad = 0x00; |
| 88 |
+ |
| 89 |
+ my $window = open_window( |
| 90 |
+ before_map => sub {
|
| 91 |
+ my ($window) = @_; |
| 92 |
+ |
| 93 |
+ my $atomname = $x->atom(name => 'WM_NORMAL_HINTS'); |
| 94 |
+ my $atomtype = $x->atom(name => 'WM_SIZE_HINTS'); |
| 95 |
+ $x->change_property( |
| 96 |
+ PROP_MODE_REPLACE, |
| 97 |
+ $window->id, |
| 98 |
+ $atomname->id, |
| 99 |
+ $atomtype->id, |
| 100 |
+ 32, |
| 101 |
+ 12, |
| 102 |
+ pack('C5N8', $flags, $pad, $pad, $pad, $pad, 0, 0, 0, $min_width, $min_height, $max_width, $max_height),
|
| 103 |
+ ); |
| 104 |
+ }, |
| 105 |
+ ); |
| 106 |
+ |
| 107 |
+ return $window; |
| 108 |
+} |
| 109 |
+ |
| 110 |
+my $ws = fresh_workspace; |
| 111 |
+ |
| 112 |
+my $window = open_with_type '_NET_WM_WINDOW_TYPE_DIALOG'; |
| 113 |
+is(get_ws($ws)->{floating_nodes}[0]->{nodes}[0]->{window}, $window->id, 'Dialog window opened floating');
|
| 114 |
+$window->unmap; |
| 115 |
+ |
| 116 |
+$window = open_with_type '_NET_WM_WINDOW_TYPE_UTILITY'; |
| 117 |
+is(get_ws($ws)->{floating_nodes}[0]->{nodes}[0]->{window}, $window->id, 'Utility window opened floating');
|
| 118 |
+$window->unmap; |
| 119 |
+ |
| 120 |
+$window = open_with_type '_NET_WM_WINDOW_TYPE_TOOLBAR'; |
| 121 |
+is(get_ws($ws)->{floating_nodes}[0]->{nodes}[0]->{window}, $window->id, 'Toolbar window opened floating');
|
| 122 |
+$window->unmap; |
| 123 |
+ |
| 124 |
+$window = open_with_type '_NET_WM_WINDOW_TYPE_SPLASH'; |
| 125 |
+is(get_ws($ws)->{floating_nodes}[0]->{nodes}[0]->{window}, $window->id, 'Splash window opened floating');
|
| 126 |
+$window->unmap; |
| 127 |
+ |
| 128 |
+$window = open_with_state '_NET_WM_STATE_MODAL'; |
| 129 |
+is(get_ws($ws)->{floating_nodes}[0]->{nodes}[0]->{window}, $window->id, 'Modal window opened floating');
|
| 130 |
+$window->unmap; |
| 131 |
+ |
| 132 |
+$window = open_with_fixed_size; |
| 133 |
+is(get_ws($ws)->{floating_nodes}[0]->{nodes}[0]->{window}, $window->id, 'Fixed size window opened floating');
|
| 134 |
+$window->unmap; |
| 135 |
+ |
| 136 |
+done_testing; |