|
| 1 | +import pytest |
| 2 | +from Xlib import Xatom |
| 3 | + |
| 4 | + |
| 5 | +@pytest.mark.parametrize("which_pad, pad_size, geometry", [ |
| 6 | + ("pad_left", 10, (-1, 0, 11, 400)), |
| 7 | + ("pad_right", 20, (800 - 20, 23, 20, 400)), |
| 8 | + ("pad_up", 40, (-5, 0, 805, 40)), |
| 9 | + ("pad_down", 15, (4, 600 - 15, 200, 40)), |
| 10 | + # cases where no pad is applied because the width/height ratio is ambiguous: |
| 11 | + ("pad_left", 0, (0, 0, 40, 40)), |
| 12 | + ("pad_down", 0, (800 - 40, 600 - 40, 40, 40)), |
| 13 | +]) |
| 14 | +def test_panel_based_on_intersection(hlwm, x11, which_pad, pad_size, geometry): |
| 15 | + # monitor 0 is affected by the panel, but the other monitor is not |
| 16 | + hlwm.call('add othertag') |
| 17 | + hlwm.call('set_monitors 800x600+0+0 800x600+800+0') |
| 18 | + winhandle, _ = x11.create_client(geometry=geometry, |
| 19 | + window_type='_NET_WM_WINDOW_TYPE_DOCK') |
| 20 | + |
| 21 | + assert int(hlwm.attr.monitors[0][which_pad]()) == pad_size |
| 22 | + for p in ["pad_left", "pad_right", "pad_up", "pad_down"]: |
| 23 | + assert hlwm.attr.monitors[1][p]() == '0', \ |
| 24 | + "monitor 1 must never be affected" |
| 25 | + if p == which_pad: |
| 26 | + continue |
| 27 | + assert hlwm.attr.monitors[0][p]() == '0' |
| 28 | + |
| 29 | + |
| 30 | +@pytest.mark.parametrize("which_pad, pad_size, geometry, wm_strut", [ |
| 31 | + ("pad_left", 20, (-1, 0, 21, 4), [20, 0, 0, 0]), |
| 32 | + ("pad_right", 30, (800 - 30, -2, 40, 11), [0, 20, 0, 0]), |
| 33 | + ("pad_up", 40, (0, 0, 30, 40), [0, 0, 40, 0]), |
| 34 | + ("pad_down", 15, (80, 600 - 15, 2, 15), [0, 0, 0, 15]), |
| 35 | +]) |
| 36 | +@pytest.mark.parametrize("strut_before_map", [True, False]) |
| 37 | +def test_panel_based_on_wmstrut(hlwm, x11, which_pad, pad_size, geometry, wm_strut, strut_before_map): |
| 38 | + # monitor 0 is affected by the panel, but the other monitor is not |
| 39 | + hlwm.call('add othertag') |
| 40 | + hlwm.call('set_monitors 800x600+0+0 800x600+800+0') |
| 41 | + |
| 42 | + def set_wm_strut(winhandle): |
| 43 | + xproperty = x11.display.intern_atom('_NET_WM_STRUT') |
| 44 | + winhandle.change_property(xproperty, Xatom.CARDINAL, 32, wm_strut) |
| 45 | + |
| 46 | + def noop(winhandle): |
| 47 | + pass |
| 48 | + |
| 49 | + winhandle, _ = x11.create_client(geometry=geometry, |
| 50 | + window_type='_NET_WM_WINDOW_TYPE_DOCK', |
| 51 | + pre_map=set_wm_strut if strut_before_map else noop, |
| 52 | + ) |
| 53 | + if not strut_before_map: |
| 54 | + set_wm_strut(winhandle) |
| 55 | + # sync hlwm and x11 |
| 56 | + x11.display.sync() |
| 57 | + hlwm.call('true') |
| 58 | + |
| 59 | + assert int(hlwm.attr.monitors[0][which_pad]()) == pad_size |
| 60 | + for p in ["pad_left", "pad_right", "pad_up", "pad_down"]: |
| 61 | + assert hlwm.attr.monitors[1][p]() == '0', \ |
| 62 | + "monitor 1 must never be affected" |
| 63 | + if p == which_pad: |
| 64 | + continue |
| 65 | + assert hlwm.attr.monitors[0][p]() == '0' |
0 commit comments