fix: sync GTK/Qt themes on session start, follow GTK-3 in Qt, and keep anode-lock above systray
This commit is contained in:
1 parent
0d8b7994bc
commit
c4bee91e6b
11 files changed
+352
-25
No files matched your search
@@ -504,6 +504,124 @@ def test_st_font_override_and_dunst():
|
||||
terminate(xvfb)
|
||||
|
||||
|
||||
def get_wm_class(dpy, win):
|
||||
atom = X11.XInternAtom(dpy, b"WM_CLASS", 0)
|
||||
da = Atom()
|
||||
di = ctypes.c_int()
|
||||
n = ctypes.c_ulong()
|
||||
dl = ctypes.c_ulong()
|
||||
prop = ctypes.POINTER(ctypes.c_ubyte)()
|
||||
rc = X11.XGetWindowProperty(dpy, win, atom, 0, 64, 0, 31, # XA_STRING=31
|
||||
ctypes.byref(da), ctypes.byref(di),
|
||||
ctypes.byref(n), ctypes.byref(dl), ctypes.byref(prop))
|
||||
if rc != 0 or not prop:
|
||||
return []
|
||||
raw = bytes(prop[:n.value]) if n.value > 0 else b""
|
||||
X11.XFree(prop)
|
||||
return [s for s in raw.decode("utf-8", errors="ignore").split("\0") if s]
|
||||
|
||||
|
||||
def test_lockscreen_overlaps_systray():
|
||||
disp = pick_display()
|
||||
with tempfile.TemporaryDirectory() as home:
|
||||
env = dict(os.environ)
|
||||
env["DISPLAY"] = disp
|
||||
env["HOME"] = home
|
||||
env["XDG_CONFIG_HOME"] = os.path.join(home, ".config")
|
||||
env["ANODE_PREFIX"] = ROOT
|
||||
env["ANODE_NO_SIGNAL"] = "1"
|
||||
env["LD_LIBRARY_PATH"] = os.path.join(BUILD, "libgemui") + (":" + env["LD_LIBRARY_PATH"] if env.get("LD_LIBRARY_PATH") else "")
|
||||
env["PATH"] = (
|
||||
os.path.join(BUILD, "dwm") + ":" +
|
||||
os.path.join(BUILD, "apps") + ":" +
|
||||
os.path.join(ROOT, "scripts") + ":" +
|
||||
env.get("PATH", "")
|
||||
)
|
||||
subprocess.run([os.path.join(ROOT, "scripts", "anode-apply-scale"), "1.00", "--touch=0"], env=env, check=True)
|
||||
|
||||
xvfb = subprocess.Popen(
|
||||
["Xvfb", disp, "-screen", "0", "1280x800x24", "-nolisten", "tcp"],
|
||||
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
|
||||
)
|
||||
dpy = None
|
||||
procs = []
|
||||
try:
|
||||
dpy = wait_until(lambda: X11.XOpenDisplay(disp.encode()))
|
||||
assert dpy, f"Failed to open Xvfb {disp}"
|
||||
root = X11.XDefaultRootWindow(dpy)
|
||||
|
||||
dwm = subprocess.Popen([os.path.join(BUILD, "dwm", "dwm")], env=env)
|
||||
procs.append(dwm)
|
||||
|
||||
tray_atom = X11.XInternAtom(dpy, b"_NET_SYSTEM_TRAY_S0", 0)
|
||||
tray_win = wait_until(lambda: X11.XGetSelectionOwner(dpy, tray_atom))
|
||||
assert tray_win, "DWM failed to acquire _NET_SYSTEM_TRAY_S0"
|
||||
|
||||
def find_bar_win():
|
||||
for w in query_children(dpy, root):
|
||||
if "anode-wm" in get_wm_class(dpy, w):
|
||||
return w
|
||||
return None
|
||||
|
||||
bar_win = wait_until(find_bar_win)
|
||||
assert bar_win, "DWM barwin not found"
|
||||
|
||||
xembed_info = X11.XInternAtom(dpy, b"_XEMBED_INFO", 0)
|
||||
op_atom = X11.XInternAtom(dpy, b"_NET_SYSTEM_TRAY_OPCODE", 0)
|
||||
info_arr = (ctypes.c_ulong * 2)(0, 1)
|
||||
|
||||
def dock_dummy_icon():
|
||||
ic = X11.XCreateSimpleWindow(dpy, root, 0, 0, 20, 20, 0, 0, 0xffffff)
|
||||
X11.XChangeProperty(dpy, ic, xembed_info, xembed_info, 32, 0, info_arr, 2)
|
||||
ev = XClientMessageEvent()
|
||||
ev.type = 33
|
||||
ev.display = dpy
|
||||
ev.window = tray_win
|
||||
ev.message_type = op_atom
|
||||
ev.format = 32
|
||||
ev.data.l[0] = 0
|
||||
ev.data.l[1] = 0
|
||||
ev.data.l[2] = ic
|
||||
X11.XSendEvent(dpy, tray_win, 0, 0, ctypes.byref(ev))
|
||||
X11.XSync(dpy, 0)
|
||||
assert wait_until(lambda: ic in query_children(dpy, tray_win)), "Dummy icon failed to dock"
|
||||
return ic
|
||||
|
||||
dock_dummy_icon()
|
||||
lockp = subprocess.Popen([os.path.join(BUILD, "apps", "anode-lock")], env=env)
|
||||
procs.append(lockp)
|
||||
|
||||
def find_lock_win():
|
||||
for w in query_children(dpy, root):
|
||||
if "anode-lock" in get_wm_class(dpy, w):
|
||||
a = XWindowAttributes()
|
||||
if X11.XGetWindowAttributes(dpy, w, ctypes.byref(a)) and a.map_state == 2:
|
||||
return w
|
||||
return None
|
||||
|
||||
lock_win = wait_until(find_lock_win)
|
||||
assert lock_win, "anode-lock window did not map"
|
||||
|
||||
# Trigger systray updates while locked: dock a 2nd icon and reload dwm via SIGUSR1
|
||||
dock_dummy_icon()
|
||||
dwm.send_signal(signal.SIGUSR1)
|
||||
time.sleep(0.3)
|
||||
|
||||
def lock_on_top():
|
||||
stack = query_children(dpy, root)
|
||||
if lock_win not in stack or tray_win not in stack or bar_win not in stack:
|
||||
return False
|
||||
return stack.index(lock_win) > stack.index(tray_win) and stack.index(lock_win) > stack.index(bar_win)
|
||||
|
||||
assert wait_until(lock_on_top), f"anode-lock did not overlap systray/bar: stack={query_children(dpy, root)}, lock={lock_win}, tray={tray_win}, bar={bar_win}"
|
||||
finally:
|
||||
for p in reversed(procs):
|
||||
terminate(p)
|
||||
if dpy:
|
||||
X11.XCloseDisplay(dpy)
|
||||
terminate(xvfb)
|
||||
|
||||
|
||||
def main():
|
||||
if not shutil.which("Xvfb"):
|
||||
print("test_x11_xvfb: Xvfb not installed (skipping)")
|
||||
@@ -518,6 +636,8 @@ def main():
|
||||
print(f"test_x11_xvfb: {res} @ {sc}x OK")
|
||||
test_st_font_override_and_dunst()
|
||||
print("test_x11_xvfb: St.font override & Dunst scale=1 OK")
|
||||
test_lockscreen_overlaps_systray()
|
||||
print("test_x11_xvfb: lockscreen overlaps systray OK")
|
||||
return 0
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user