81 lines
3.2 KiB
Python
81 lines
3.2 KiB
Python
"""Reparented client fixtures for private X11 frame geometry tests."""
|
|
|
|
import json
|
|
import os
|
|
import sys
|
|
|
|
from Xlib import X, Xatom, display
|
|
|
|
|
|
connection = display.Display()
|
|
root = connection.screen().root
|
|
activeAtom = connection.intern_atom("_NET_ACTIVE_WINDOW")
|
|
extentsAtom = connection.intern_atom("_NET_FRAME_EXTENTS")
|
|
stateAtom = connection.intern_atom("WM_STATE")
|
|
pidAtom = connection.intern_atom("_NET_WM_PID")
|
|
|
|
|
|
def make_window(parent, x, y, width, height, managed=False):
|
|
window = parent.create_window(x, y, width, height, 0,
|
|
connection.screen().root_depth,
|
|
X.InputOutput, X.CopyFromParent)
|
|
if managed:
|
|
window.change_property(stateAtom, stateAtom, 32, [1, 0])
|
|
window.change_property(pidAtom, Xatom.CARDINAL, 32, [os.getpid()])
|
|
window.map()
|
|
return window
|
|
|
|
|
|
frame = make_window(root, 0, 0, 1916, 994)
|
|
client = make_window(frame, 2, 18, 1912, 974, managed=True)
|
|
otherFrame = make_window(root, 2000, 0, 500, 400)
|
|
other = make_window(otherFrame, 3, 20, 494, 377, managed=True)
|
|
plain = make_window(root, 50, 60, 400, 300, managed=True)
|
|
container = make_window(root, 0, 1100, 800, 600)
|
|
shared = make_window(container, 2, 18, 396, 580, managed=True)
|
|
make_window(container, 402, 18, 396, 580, managed=True)
|
|
managedParent = make_window(root, 900, 1100, 500, 400, managed=True)
|
|
nested = make_window(managedParent, 2, 18, 496, 380, managed=True)
|
|
largeFrame = make_window(root, 0, 2000, 4000, 3000)
|
|
oversized = make_window(largeFrame, 1200, 1100, 400, 300, managed=True)
|
|
smallFrame = make_window(root, 1000, 2000, 200, 100)
|
|
overflow = make_window(smallFrame, 0, 0, 400, 300, managed=True)
|
|
windows = dict(client=client, other=other, plain=plain, shared=shared,
|
|
nested=nested, oversized=oversized, overflow=overflow)
|
|
|
|
|
|
def configure(action):
|
|
frame.change_attributes(override_redirect=False)
|
|
frame.configure(x=0, y=0, width=1916, height=994, border_width=0)
|
|
client.configure(x=2, y=18, width=1912, height=974)
|
|
client.delete_property(extentsAtom)
|
|
selected = windows.get(action, client)
|
|
if action == "zero-extents":
|
|
client.change_property(extentsAtom, Xatom.CARDINAL, 32, [0, 0, 0, 0])
|
|
elif action == "stale-extents":
|
|
client.change_property(extentsAtom, Xatom.CARDINAL, 32, [8, 8, 40, 8])
|
|
elif action == "resize":
|
|
frame.configure(width=1000, height=700)
|
|
client.configure(width=996, height=680)
|
|
elif action == "move":
|
|
frame.configure(x=-30, y=40)
|
|
elif action == "border":
|
|
frame.configure(border_width=2)
|
|
elif action == "i3-frame":
|
|
frame.change_attributes(override_redirect=True)
|
|
elif action == "i3-run-dialog":
|
|
frame.change_attributes(override_redirect=True)
|
|
frame.configure(y=24, width=1916, height=989)
|
|
client.configure(y=0, width=1912, height=987)
|
|
root.change_property(activeAtom, Xatom.WINDOW, 32,
|
|
[0 if action == "empty" else selected.id])
|
|
connection.sync()
|
|
|
|
|
|
configure("client")
|
|
print(json.dumps({name: window.id for name, window in windows.items()}), flush=True)
|
|
for line in sys.stdin:
|
|
configure(line.strip())
|
|
print("ready", flush=True)
|
|
connection.close()
|