feat(theme,display,wm,power,make): add Anodized theme, editors, multi-monitor arrangement, power timeouts, bar compaction, and replace state preservation
- Replace deprecated AnodeDefault with dark-silvery Anodized default theme - Add interactive theme editor, duplicator, and non-standard .xth importer to anode-themes (+ CLI --install) - Fix multi-monitor dwm/lock/vkbd/EDID edge cases and integrate monitor arrangement + 15s revert into anode-display and anode-apply-display - Gate anode-touchd behind WITH_TOUCHD=1 (keeping anode-vkbd unconditional) and add help/rebuild/install-touch/install-system targets to Makefile - Add idle screen dim, lock, suspend, and suspend-on-AC timeout controls to anode-power and anode-display backed by power.conf + SIGUSR1 - Prevent lockscreen subtitle overflow and progressively compact status bar segments so focused window titles remain visible - Preserve workspaces, active desktop, monitor state, floating/fullscreen states, and focus across anode-replace and restarts
This commit is contained in:
1 parent
bb81541b42
commit
4ec3f59e02
40 files changed
+5843
-768
No files matched your search
@@ -69,12 +69,61 @@ X11.XCreateSimpleWindow.argtypes = [
|
||||
]
|
||||
X11.XCreateSimpleWindow.restype = Window
|
||||
X11.XMapWindow.argtypes = [Display_p, Window]
|
||||
X11.XUnmapWindow.argtypes = [Display_p, Window]
|
||||
X11.XMoveResizeWindow.argtypes = [Display_p, Window, ctypes.c_int, ctypes.c_int, ctypes.c_uint, ctypes.c_uint]
|
||||
X11.XChangeProperty.argtypes = [
|
||||
Display_p, Window, Atom, Atom, ctypes.c_int, ctypes.c_int, ctypes.c_void_p, ctypes.c_int,
|
||||
]
|
||||
X11.XSendEvent.argtypes = [Display_p, Window, ctypes.c_int, ctypes.c_long, ctypes.c_void_p]
|
||||
X11.XDestroyWindow.argtypes = [Display_p, Window]
|
||||
X11.XGetWindowAttributes.argtypes = [Display_p, Window, ctypes.POINTER(XWindowAttributes)]
|
||||
X11.XGetWindowAttributes.restype = ctypes.c_int
|
||||
X11.XSync.argtypes = [Display_p, ctypes.c_int]
|
||||
|
||||
|
||||
def get_win_prop_ulong_list(dpy, win, atom_name, max_items=64):
|
||||
atom = X11.XInternAtom(dpy, atom_name.encode(), 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, max_items, 0, 0,
|
||||
ctypes.byref(da), ctypes.byref(di), ctypes.byref(n), ctypes.byref(dl), ctypes.byref(prop),
|
||||
)
|
||||
vals = []
|
||||
if rc == 0 and prop and di.value == 32 and n.value >= 1:
|
||||
arr = ctypes.cast(prop, ctypes.POINTER(ctypes.c_ulong))
|
||||
vals = [int(arr[i]) for i in range(n.value)]
|
||||
if prop:
|
||||
X11.XFree(prop)
|
||||
return vals
|
||||
|
||||
|
||||
def send_ewmh_msg(dpy, root, win, atom_name, data_l):
|
||||
class CMData(ctypes.Union):
|
||||
_fields_ = [("b", ctypes.c_char * 20), ("s", ctypes.c_short * 10), ("l", ctypes.c_long * 5)]
|
||||
|
||||
class CMEvent(ctypes.Structure):
|
||||
_fields_ = [
|
||||
("type", ctypes.c_int), ("serial", ctypes.c_ulong), ("send_event", ctypes.c_int),
|
||||
("display", Display_p), ("window", Window), ("message_type", Atom),
|
||||
("format", ctypes.c_int), ("data", CMData),
|
||||
]
|
||||
|
||||
ev = CMEvent()
|
||||
ev.type = 33 # ClientMessage
|
||||
ev.display = dpy
|
||||
ev.window = win
|
||||
ev.message_type = X11.XInternAtom(dpy, atom_name.encode(), 0)
|
||||
ev.format = 32
|
||||
for i, val in enumerate(data_l[:5]):
|
||||
ev.data.l[i] = val
|
||||
X11.XSendEvent(dpy, root, 0, (1 << 19) | (1 << 20), ctypes.byref(ev))
|
||||
X11.XSync(dpy, 0)
|
||||
|
||||
|
||||
def pick_display():
|
||||
for d in range(70, 120):
|
||||
if not os.path.exists(f"/tmp/.X{d}-lock") and not os.path.exists(f"/tmp/.X11-unix/X{d}"):
|
||||
@@ -898,6 +947,256 @@ def test_replace_display_scoped_daemon_cleanup():
|
||||
terminate(xvfb)
|
||||
|
||||
|
||||
def test_replace_preserves_workspaces_and_states():
|
||||
# Subtest A: ANODE -> ANODE replace preserves desktops, focus, floating geometry, and fullscreen
|
||||
disp = pick_display()
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
env = make_env(tmp, disp)
|
||||
xvfb = subprocess.Popen(
|
||||
["Xvfb", disp, "-screen", "0", "1280x720x24", "-nolisten", "tcp"],
|
||||
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
|
||||
)
|
||||
dwm1 = None
|
||||
dpy = None
|
||||
new_pid = None
|
||||
wins = []
|
||||
try:
|
||||
dpy = wait_until(lambda: X11.XOpenDisplay(disp.encode()), timeout=5.0)
|
||||
assert dpy
|
||||
root = X11.XDefaultRootWindow(dpy)
|
||||
|
||||
dwm1 = subprocess.Popen([DWM_BIN], env=env, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||
wm1 = wait_until(lambda: get_win_prop_ulong(dpy, root, "_NET_SUPPORTING_WM_CHECK"), timeout=5.0)
|
||||
assert wm1
|
||||
|
||||
a_type = X11.XInternAtom(dpy, b"_NET_WM_WINDOW_TYPE", 0)
|
||||
a_dlg = X11.XInternAtom(dpy, b"_NET_WM_WINDOW_TYPE_DIALOG", 0)
|
||||
a_atom = X11.XInternAtom(dpy, b"ATOM", 0)
|
||||
a_fs = X11.XInternAtom(dpy, b"_NET_WM_STATE_FULLSCREEN", 0)
|
||||
|
||||
w1 = X11.XCreateSimpleWindow(dpy, root, 10, 40, 300, 200, 0, 0, 0xffffff)
|
||||
w2 = X11.XCreateSimpleWindow(dpy, root, 120, 140, 420, 300, 0, 0, 0xffffff)
|
||||
dlg_val = ctypes.c_ulong(a_dlg)
|
||||
X11.XChangeProperty(dpy, w2, a_type, a_atom, 32, 0, ctypes.byref(dlg_val), 1)
|
||||
w3 = X11.XCreateSimpleWindow(dpy, root, 20, 50, 300, 200, 0, 0, 0xffffff)
|
||||
w4 = X11.XCreateSimpleWindow(dpy, root, 30, 60, 300, 200, 0, 0, 0xffffff)
|
||||
wins = [w1, w2, w3, w4]
|
||||
for w in wins:
|
||||
X11.XMapWindow(dpy, w)
|
||||
X11.XSync(dpy, 0)
|
||||
|
||||
assert wait_until(lambda: all(w in get_win_prop_ulong_list(dpy, root, "_NET_CLIENT_LIST") for w in wins), timeout=5.0)
|
||||
|
||||
send_ewmh_msg(dpy, root, w2, "_NET_WM_DESKTOP", [1, 2, 0, 0, 0])
|
||||
send_ewmh_msg(dpy, root, w3, "_NET_WM_DESKTOP", [2, 2, 0, 0, 0])
|
||||
send_ewmh_msg(dpy, root, w4, "_NET_WM_DESKTOP", [1, 2, 0, 0, 0])
|
||||
send_ewmh_msg(dpy, root, w3, "_NET_WM_STATE", [1, a_fs, 0, 2, 0])
|
||||
send_ewmh_msg(dpy, root, root, "_NET_CURRENT_DESKTOP", [1, 0, 0, 0, 0])
|
||||
send_ewmh_msg(dpy, root, w4, "_NET_ACTIVE_WINDOW", [2, 0, 0, 0, 0])
|
||||
|
||||
def pre_state_ready():
|
||||
return (
|
||||
get_win_prop_ulong(dpy, root, "_NET_CURRENT_DESKTOP") == 1
|
||||
and get_win_prop_ulong(dpy, root, "_NET_ACTIVE_WINDOW") == w4
|
||||
and get_win_prop_ulong(dpy, w1, "_NET_WM_DESKTOP") == 0
|
||||
and get_win_prop_ulong(dpy, w2, "_NET_WM_DESKTOP") == 1
|
||||
and get_win_prop_ulong(dpy, w3, "_NET_WM_DESKTOP") == 2
|
||||
and get_win_prop_ulong(dpy, w4, "_NET_WM_DESKTOP") == 1
|
||||
and a_fs in get_win_prop_ulong_list(dpy, w3, "_NET_WM_STATE")
|
||||
)
|
||||
|
||||
assert wait_until(pre_state_ready, timeout=5.0), "Pre-replace EWMH states did not settle"
|
||||
X11.XMoveResizeWindow(dpy, w2, 120, 140, 420, 300)
|
||||
X11.XSync(dpy, 0)
|
||||
time.sleep(0.15)
|
||||
|
||||
rep = subprocess.run(
|
||||
[REPLACE_BIN, "--no-autostart", "--keep-panels"],
|
||||
env=env, capture_output=True, text=True,
|
||||
)
|
||||
assert rep.returncode == 0, f"anode-replace failed: stdout={rep.stdout} stderr={rep.stderr}"
|
||||
assert wait_until(lambda: dwm1.poll() is not None, timeout=5.0)
|
||||
assert dwm1.returncode == 75
|
||||
wm2 = get_win_prop_ulong(dpy, root, "_NET_SUPPORTING_WM_CHECK")
|
||||
assert wm2 and wm2 != wm1
|
||||
new_pid = get_win_prop_ulong(dpy, wm2, "_NET_WM_PID")
|
||||
|
||||
def post_state_ready():
|
||||
if get_win_prop_ulong(dpy, root, "_NET_CURRENT_DESKTOP") != 1:
|
||||
return False
|
||||
if get_win_prop_ulong(dpy, root, "_NET_ACTIVE_WINDOW") != w4:
|
||||
return False
|
||||
if get_win_prop_ulong(dpy, w1, "_NET_WM_DESKTOP") != 0:
|
||||
return False
|
||||
if get_win_prop_ulong(dpy, w2, "_NET_WM_DESKTOP") != 1:
|
||||
return False
|
||||
if get_win_prop_ulong(dpy, w3, "_NET_WM_DESKTOP") != 2:
|
||||
return False
|
||||
if get_win_prop_ulong(dpy, w4, "_NET_WM_DESKTOP") != 1:
|
||||
return False
|
||||
return a_fs in get_win_prop_ulong_list(dpy, w3, "_NET_WM_STATE")
|
||||
|
||||
assert wait_until(post_state_ready, timeout=5.0), (
|
||||
f"Post-replace EWMH mismatch: cur={get_win_prop_ulong(dpy, root, '_NET_CURRENT_DESKTOP')} "
|
||||
f"act={get_win_prop_ulong(dpy, root, '_NET_ACTIVE_WINDOW')} "
|
||||
f"desks={[get_win_prop_ulong(dpy, w, '_NET_WM_DESKTOP') for w in wins]}"
|
||||
)
|
||||
|
||||
attrs = {}
|
||||
for w in wins:
|
||||
a = XWindowAttributes()
|
||||
assert X11.XGetWindowAttributes(dpy, w, ctypes.byref(a)) != 0
|
||||
attrs[w] = (a.x, a.y, a.width, a.height)
|
||||
assert attrs[w1][0] < 0 and attrs[w3][0] < 0, f"Hidden desktop windows not offscreen: {attrs}"
|
||||
assert attrs[w2][0] >= 0 and attrs[w4][0] >= 0, f"Active desktop windows offscreen: {attrs}"
|
||||
assert attrs[w2] == (120, 140, 420, 300), f"Floating geometry lost across replace: {attrs[w2]}"
|
||||
finally:
|
||||
if dpy:
|
||||
for w in wins:
|
||||
X11.XDestroyWindow(dpy, w)
|
||||
terminate(dwm1)
|
||||
kill_pid_and_wait(new_pid)
|
||||
if dpy:
|
||||
X11.XCloseDisplay(dpy)
|
||||
terminate(xvfb)
|
||||
|
||||
# Subtest B: Third-party EWMH WM -> ANODE replace preserves desktops even when old WM unmaps & strips props
|
||||
disp2 = pick_display()
|
||||
cc = os.environ.get("CC", "cc")
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
env = make_env(tmp, disp2)
|
||||
ewmh_c = os.path.join(tmp, "mock_ewmh.c")
|
||||
ewmh_bin = os.path.join(tmp, "bin", "mock_ewmh")
|
||||
with open(ewmh_c, "w", encoding="utf-8") as f:
|
||||
f.write(
|
||||
"#define _POSIX_C_SOURCE 200809L\n"
|
||||
"#include <signal.h>\n"
|
||||
"#include <time.h>\n"
|
||||
"#include <unistd.h>\n"
|
||||
"#include <X11/Xatom.h>\n"
|
||||
"#include <X11/Xlib.h>\n"
|
||||
"static volatile sig_atomic_t alive = 1;\n"
|
||||
"static void on_sig(int s) { (void)s; alive = 0; }\n"
|
||||
"int main(void) {\n"
|
||||
" signal(SIGTERM, on_sig);\n"
|
||||
" Display *d = XOpenDisplay(NULL);\n"
|
||||
" if (!d) return 1;\n"
|
||||
" Window root = DefaultRootWindow(d);\n"
|
||||
" XSelectInput(d, root, SubstructureRedirectMask);\n"
|
||||
" Window wmc = XCreateSimpleWindow(d, root, 0, 0, 1, 1, 0, 0, 0);\n"
|
||||
" Atom ac = XInternAtom(d, \"_NET_SUPPORTING_WM_CHECK\", False);\n"
|
||||
" Atom an = XInternAtom(d, \"_NET_WM_NAME\", False);\n"
|
||||
" Atom ap = XInternAtom(d, \"_NET_WM_PID\", False);\n"
|
||||
" Atom au = XInternAtom(d, \"UTF8_STRING\", False);\n"
|
||||
" Atom acl = XInternAtom(d, \"_NET_CLIENT_LIST\", False);\n"
|
||||
" Atom acd = XInternAtom(d, \"_NET_CURRENT_DESKTOP\", False);\n"
|
||||
" Atom aact = XInternAtom(d, \"_NET_ACTIVE_WINDOW\", False);\n"
|
||||
" unsigned long pid = (unsigned long)getpid();\n"
|
||||
" XChangeProperty(d, wmc, ac, XA_WINDOW, 32, PropModeReplace, (unsigned char *)&wmc, 1);\n"
|
||||
" XChangeProperty(d, wmc, an, au, 8, PropModeReplace, (unsigned char *)\"MockEWMH\", 8);\n"
|
||||
" XChangeProperty(d, wmc, ap, XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&pid, 1);\n"
|
||||
" XChangeProperty(d, root, ac, XA_WINDOW, 32, PropModeReplace, (unsigned char *)&wmc, 1);\n"
|
||||
" XSync(d, False);\n"
|
||||
" while (alive) { struct timespec ts = {0, 50000000L}; nanosleep(&ts, NULL); }\n"
|
||||
" XDeleteProperty(d, root, acd);\n"
|
||||
" XDeleteProperty(d, root, acl);\n"
|
||||
" XDeleteProperty(d, root, aact);\n"
|
||||
" XDestroyWindow(d, wmc);\n"
|
||||
" XSync(d, False);\n"
|
||||
" XCloseDisplay(d);\n"
|
||||
" return 0;\n"
|
||||
"}\n"
|
||||
)
|
||||
subprocess.run([cc, "-O2", ewmh_c, "-o", ewmh_bin] + compile_x11_flags(), check=True)
|
||||
|
||||
xvfb = subprocess.Popen(
|
||||
["Xvfb", disp2, "-screen", "0", "1280x720x24", "-nolisten", "tcp"],
|
||||
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
|
||||
)
|
||||
mwm = None
|
||||
dpy = None
|
||||
new_pid = None
|
||||
app_wins = []
|
||||
try:
|
||||
dpy = wait_until(lambda: X11.XOpenDisplay(disp2.encode()), timeout=5.0)
|
||||
assert dpy
|
||||
root = X11.XDefaultRootWindow(dpy)
|
||||
a_card = X11.XInternAtom(dpy, b"CARDINAL", 0)
|
||||
a_win = X11.XInternAtom(dpy, b"WINDOW", 0)
|
||||
a_atom = X11.XInternAtom(dpy, b"ATOM", 0)
|
||||
a_cl = X11.XInternAtom(dpy, b"_NET_CLIENT_LIST", 0)
|
||||
a_cd = X11.XInternAtom(dpy, b"_NET_CURRENT_DESKTOP", 0)
|
||||
a_wd = X11.XInternAtom(dpy, b"_NET_WM_DESKTOP", 0)
|
||||
a_act = X11.XInternAtom(dpy, b"_NET_ACTIVE_WINDOW", 0)
|
||||
a_wms = X11.XInternAtom(dpy, b"_NET_WM_STATE", 0)
|
||||
a_fs = X11.XInternAtom(dpy, b"_NET_WM_STATE_FULLSCREEN", 0)
|
||||
|
||||
wa = X11.XCreateSimpleWindow(dpy, root, 10, 40, 280, 180, 0, 0, 0xffffff)
|
||||
wb = X11.XCreateSimpleWindow(dpy, root, 0, 0, 1280, 720, 0, 0, 0xffffff)
|
||||
wc = X11.XCreateSimpleWindow(dpy, root, 50, 60, 320, 220, 0, 0, 0xffffff)
|
||||
app_wins = [wa, wb, wc]
|
||||
X11.XMapWindow(dpy, wc)
|
||||
for w, desk in ((wa, 0), (wb, 1), (wc, 2)):
|
||||
dv = ctypes.c_ulong(desk)
|
||||
X11.XChangeProperty(dpy, w, a_wd, a_card, 32, 0, ctypes.byref(dv), 1)
|
||||
fs_v = ctypes.c_ulong(a_fs)
|
||||
X11.XChangeProperty(dpy, wb, a_wms, a_atom, 32, 0, ctypes.byref(fs_v), 1)
|
||||
cl_arr = (ctypes.c_ulong * 3)(wa, wb, wc)
|
||||
X11.XChangeProperty(dpy, root, a_cl, a_win, 32, 0, cl_arr, 3)
|
||||
cd_v = ctypes.c_ulong(2)
|
||||
X11.XChangeProperty(dpy, root, a_cd, a_card, 32, 0, ctypes.byref(cd_v), 1)
|
||||
act_v = ctypes.c_ulong(wc)
|
||||
X11.XChangeProperty(dpy, root, a_act, a_win, 32, 0, ctypes.byref(act_v), 1)
|
||||
X11.XSync(dpy, 0)
|
||||
|
||||
mwm = subprocess.Popen([ewmh_bin], env=env)
|
||||
wm1 = wait_until(lambda: get_win_prop_ulong(dpy, root, "_NET_SUPPORTING_WM_CHECK"), timeout=5.0)
|
||||
assert wm1
|
||||
|
||||
rep = subprocess.run(
|
||||
[REPLACE_BIN, "--no-autostart", "--keep-panels"],
|
||||
env=env, capture_output=True, text=True,
|
||||
)
|
||||
assert rep.returncode == 0, f"3rd-party replace failed: stdout={rep.stdout} stderr={rep.stderr}"
|
||||
wm2 = get_win_prop_ulong(dpy, root, "_NET_SUPPORTING_WM_CHECK")
|
||||
assert wm2 and wm2 != wm1
|
||||
new_pid = get_win_prop_ulong(dpy, wm2, "_NET_WM_PID")
|
||||
|
||||
def third_party_ok():
|
||||
clist = get_win_prop_ulong_list(dpy, root, "_NET_CLIENT_LIST")
|
||||
return (
|
||||
get_win_prop_ulong(dpy, root, "_NET_CURRENT_DESKTOP") == 2
|
||||
and all(w in clist for w in (wa, wb, wc))
|
||||
and get_win_prop_ulong(dpy, root, "_NET_ACTIVE_WINDOW") == wc
|
||||
and get_win_prop_ulong(dpy, wa, "_NET_WM_DESKTOP") == 0
|
||||
and get_win_prop_ulong(dpy, wb, "_NET_WM_DESKTOP") == 1
|
||||
and get_win_prop_ulong(dpy, wc, "_NET_WM_DESKTOP") == 2
|
||||
and a_fs in get_win_prop_ulong_list(dpy, wb, "_NET_WM_STATE")
|
||||
)
|
||||
|
||||
assert wait_until(third_party_ok, timeout=5.0), (
|
||||
f"3rd-party preserve mismatch: cur={get_win_prop_ulong(dpy, root, '_NET_CURRENT_DESKTOP')} "
|
||||
f"clist={get_win_prop_ulong_list(dpy, root, '_NET_CLIENT_LIST')} "
|
||||
f"act={get_win_prop_ulong(dpy, root, '_NET_ACTIVE_WINDOW')}"
|
||||
)
|
||||
for w, expect_vis in ((wa, False), (wb, False), (wc, True)):
|
||||
a = XWindowAttributes()
|
||||
assert X11.XGetWindowAttributes(dpy, w, ctypes.byref(a)) != 0
|
||||
if expect_vis:
|
||||
assert a.x >= 0, f"Active desktop window {w} offscreen: {a.x}"
|
||||
else:
|
||||
assert a.x < 0, f"Hidden desktop window {w} not offscreen: {a.x}"
|
||||
finally:
|
||||
if dpy:
|
||||
for w in app_wins:
|
||||
X11.XDestroyWindow(dpy, w)
|
||||
terminate(mwm)
|
||||
kill_pid_and_wait(new_pid)
|
||||
if dpy:
|
||||
X11.XCloseDisplay(dpy)
|
||||
terminate(xvfb)
|
||||
|
||||
|
||||
def main():
|
||||
if not shutil.which("Xvfb"):
|
||||
print("test_replace: Xvfb not installed (skipping)")
|
||||
@@ -911,6 +1210,7 @@ def main():
|
||||
test_switch_session_xprofile_handoff()
|
||||
test_switch_session_stale_i3sock_fallback()
|
||||
test_replace_display_scoped_daemon_cleanup()
|
||||
test_replace_preserves_workspaces_and_states()
|
||||
print("test_replace: OK")
|
||||
return 0
|
||||
|
||||
|
||||
Reference in new issue
Block a user