"""Panel replication and popup ordering in the desktop cube.""" import io import subprocess import sys import time from PIL import Image from ipc import ipc, ENV baseline = '--baseline' in sys.argv def check(ok, label, value): print(label, value, 'PASS' if ok else 'FAIL', flush=True) if not baseline: assert ok, (label, value) def solid(key, layer, color, box): r, g, b, a = color x, y, w, h = box ipc('test/solid', dict(key=key, layer=layer, output='HEADLESS-1', r=r, g=g, b=b, a=a, x=x, y=y, w=w, h=h)) # A shared top-layer panel must appear on every face, including empty workspaces. ipc('wayfire/set-config-options', {'cube/rotate_layer_shell': '*'}) solid('panel', 3, (0., 1., 1., 1.), (0, 0, 100, 20)) try: for x in range(3): value = ipc('test/workspace-panel', {'output': 'HEADLESS-1', 'x': x, 'y': 0})['cyan'] check(value == 2000, f'Panel pixels on workspace {x}', value) finally: ipc('test/solid', {'key': 'panel', 'close': True}) ipc('wayfire/set-config-options', {'cube/rotate_layer_shell': ''}) # Overlay launchers stay above the transformed desktop, with or without a panel namespace. ipc('test/rectangle', {'show': True}) solid('popup', 5, (1., 0., 1., 1.), (0, 0, 10000, 10000)) try: for namespace in ['', 'waybar']: ipc('wayfire/set-config-options', {'cube/rotate_layer_shell': namespace}) ipc('test/cube', {'output': 'HEADLESS-1'}) time.sleep(1) shot = Image.open(io.BytesIO(subprocess.check_output( ['grim', '-o', 'HEADLESS-1', '-'], env=ENV))).convert('RGB') leaks = sum(p != (255, 0, 255) for p in shot.get_flattened_data()) check(leaks == 0, f'Desktop pixels above overlay ({namespace or "fixed panels"})', leaks) ipc('test/cube', {'output': 'HEADLESS-1', 'stop': True}) time.sleep(.5) finally: ipc('test/rectangle', {'show': False}) ipc('test/solid', {'key': 'popup', 'close': True}) ipc('test/cube', {'output': 'HEADLESS-1', 'stop': True}) ipc('wayfire/set-config-options', {'cube/rotate_layer_shell': ''})