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
@@ -51,6 +51,7 @@ def check_scripts() -> None:
|
||||
script_files = [
|
||||
"scripts/detect-env.sh",
|
||||
"scripts/anode-apply-scale",
|
||||
"scripts/anode-apply-display",
|
||||
"scripts/anode-apply-theme",
|
||||
"scripts/anode-sync-gtk-theme",
|
||||
"scripts/anode-sync-dunst-theme",
|
||||
@@ -91,7 +92,56 @@ def check_scripts() -> None:
|
||||
assert not re.search(pat, code), f"{rel}:{lineno}: {desc}: {line}"
|
||||
|
||||
|
||||
def test_optional_touchd_staged_install() -> None:
|
||||
import tempfile
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
dest0 = os.path.join(tmp, "d0")
|
||||
res0 = subprocess.run(
|
||||
["make", "install", f"DESTDIR={dest0}", "PREFIX=/usr/local", "XSESSIONSDIR=/usr/share/xsessions"],
|
||||
cwd=ROOT, capture_output=True, text=True,
|
||||
)
|
||||
assert res0.returncode == 0, f"default install failed: {res0.stderr}"
|
||||
assert not os.path.exists(os.path.join(dest0, "usr", "local", "bin", "anode-touchd"))
|
||||
assert os.path.isfile(os.path.join(dest0, "usr", "local", "bin", "anode-vkbd"))
|
||||
assert os.path.isfile(os.path.join(dest0, "usr", "local", "bin", "anode-apply-display"))
|
||||
assert os.path.isfile(os.path.join(dest0, "usr", "local", "share", "anode", "themes", "Anodized.xth"))
|
||||
assert not os.path.exists(os.path.join(dest0, "usr", "local", "share", "anode", "themes", "AnodeDefault.xth"))
|
||||
|
||||
dest1 = os.path.join(tmp, "d1")
|
||||
res1 = subprocess.run(
|
||||
["make", "WITH_TOUCHD=1", "install", f"DESTDIR={dest1}", "PREFIX=/usr/local", "XSESSIONSDIR=/usr/share/xsessions"],
|
||||
cwd=ROOT, capture_output=True, text=True,
|
||||
)
|
||||
assert res1.returncode == 0, f"WITH_TOUCHD=1 install failed: {res1.stderr}"
|
||||
assert os.path.isfile(os.path.join(dest1, "usr", "local", "bin", "anode-touchd"))
|
||||
assert os.path.isfile(os.path.join(dest1, "usr", "local", "bin", "anode-vkbd"))
|
||||
|
||||
hres = subprocess.run(["make", "help"], cwd=ROOT, capture_output=True, text=True)
|
||||
assert hres.returncode == 0, f"make help failed: {hres.stderr}"
|
||||
for kw in ("rebuild", "install-touch", "install-system", "WITH_TOUCHD"):
|
||||
assert kw in hres.stdout, f"make help missing {kw!r}: {hres.stdout}"
|
||||
|
||||
dest2 = os.path.join(tmp, "d2")
|
||||
res2 = subprocess.run(
|
||||
["make", "install-touch", f"DESTDIR={dest2}", "PREFIX=/usr/local"],
|
||||
cwd=ROOT, capture_output=True, text=True,
|
||||
)
|
||||
assert res2.returncode == 0, f"install-touch failed: {res2.stderr}"
|
||||
assert os.path.isfile(os.path.join(dest2, "usr", "local", "bin", "anode-touchd"))
|
||||
assert os.path.isfile(os.path.join(dest2, "usr", "local", "bin", "anode-vkbd"))
|
||||
|
||||
dest3 = os.path.join(tmp, "d3")
|
||||
res3 = subprocess.run(
|
||||
["make", "install-system", f"DESTDIR={dest3}", "PREFIX=/usr/local"],
|
||||
cwd=ROOT, capture_output=True, text=True,
|
||||
)
|
||||
assert res3.returncode == 0, f"install-system failed: {res3.stderr}"
|
||||
assert os.path.isfile(os.path.join(dest3, "usr", "share", "xsessions", "anode.desktop"))
|
||||
assert not os.path.exists(os.path.join(dest3, "usr", "local", "bin", "anode-touchd"))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
check_makefile()
|
||||
check_scripts()
|
||||
test_optional_touchd_staged_install()
|
||||
print("test_posix_make: OK")
|
||||
@@ -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
|
||||
|
||||
|
||||
+103
-14
@@ -121,9 +121,9 @@ def test_fractional_scales():
|
||||
assert f'gtk-font-name="{exp_ui} 10"' in gtk2, gtk2
|
||||
assert f"gtk-cursor-theme-size={exp_cur}" in gtk2, gtk2
|
||||
|
||||
assert os.path.isfile(os.path.join(tmp, ".themes", "ANODE-AnodeDefault", "index.theme"))
|
||||
assert os.path.islink(os.path.join(tmp, ".local", "share", "themes", "ANODE-AnodeDefault"))
|
||||
with open(os.path.join(tmp, ".themes", "ANODE-AnodeDefault", "gtk-2.0", "gtkrc"), "r", encoding="utf-8") as f:
|
||||
assert os.path.isfile(os.path.join(tmp, ".themes", "ANODE-Anodized", "index.theme"))
|
||||
assert os.path.islink(os.path.join(tmp, ".local", "share", "themes", "ANODE-Anodized"))
|
||||
with open(os.path.join(tmp, ".themes", "ANODE-Anodized", "gtk-2.0", "gtkrc"), "r", encoding="utf-8") as f:
|
||||
gtk2rc = f.read()
|
||||
assert "GtkButton::inner-border" in gtk2rc, gtk2rc
|
||||
assert "GtkEntry::inner-border" in gtk2rc, gtk2rc
|
||||
@@ -140,7 +140,7 @@ def test_fractional_scales():
|
||||
for bad in ("min-height:", "min-width:", "padding:", "margin:", "font-family:"):
|
||||
assert bad not in gcss, f"Unexpected {bad} in .config/{gver}/gtk.css"
|
||||
|
||||
tcss_p = os.path.join(tmp, ".themes", "ANODE-AnodeDefault", gver, "gtk.css")
|
||||
tcss_p = os.path.join(tmp, ".themes", "ANODE-Anodized", gver, "gtk.css")
|
||||
with open(tcss_p, "r", encoding="utf-8") as f:
|
||||
tcss = f.read()
|
||||
exp_imp = (
|
||||
@@ -253,8 +253,8 @@ def test_st_overrides_and_xresources_local():
|
||||
f.write("St.alpha: 0.95\n")
|
||||
|
||||
# Repeated theme applications must preserve St.* cleanly without duplication
|
||||
run_env(env, [APPLY_THEME, "AnodeDefault"])
|
||||
run_env(env, [APPLY_THEME, "AnodeDefault"])
|
||||
run_env(env, [APPLY_THEME, "Anodized"])
|
||||
run_env(env, [APPLY_THEME, "Anodized"])
|
||||
with open(xres_p, "r", encoding="utf-8") as f:
|
||||
content = f.read()
|
||||
assert content.count("St.font:") == 1, content
|
||||
@@ -267,8 +267,8 @@ def test_st_overrides_and_xresources_local():
|
||||
f.write("St.font: Fira Code:size=16:antialias=true\n")
|
||||
f.write("*.cursorBlink: true\n")
|
||||
|
||||
run_env(env, [APPLY_THEME, "AnodeDefault"])
|
||||
run_env(env, [APPLY_THEME, "AnodeDefault"])
|
||||
run_env(env, [APPLY_THEME, "Anodized"])
|
||||
run_env(env, [APPLY_THEME, "Anodized"])
|
||||
with open(xres_p, "r", encoding="utf-8") as f:
|
||||
content2 = f.read()
|
||||
assert content2.count("St.font:") == 1, content2
|
||||
@@ -343,7 +343,7 @@ def test_stale_env_does_not_override_scale_conf():
|
||||
assert "gtk-cursor-theme-size=24" in f.read()
|
||||
|
||||
# Re-applying theme with stale ANODE_SCALE/ANODE_TOUCH still honors scale.conf
|
||||
run_env(stale_env, [APPLY_THEME, "AnodeDefault"])
|
||||
run_env(stale_env, [APPLY_THEME, "Anodized"])
|
||||
xres2 = parse_xres(os.path.join(tmp, ".Xresources"))
|
||||
assert xres2["theme.scale"] == "1.25" and xres2["Xft.dpi"] == "120" and xres2["theme.touchMode"] == "0"
|
||||
|
||||
@@ -372,8 +372,8 @@ def test_gtk_theme_light_dark_detection_and_css_parse():
|
||||
assert txt3.splitlines()[0] == '@import url("resource:///org/gtk/libgtk/theme/Adwaita/gtk-contained.css");'
|
||||
assert txt4.splitlines()[0] == '@import url("resource:///org/gtk/libgtk/theme/Default/Default-light.css");'
|
||||
|
||||
run_env(env, [APPLY_THEME, "AnodeDefault"])
|
||||
t3_dark = os.path.join(tmp, ".themes", "ANODE-AnodeDefault", "gtk-3.0", "gtk.css")
|
||||
run_env(env, [APPLY_THEME, "Anodized"])
|
||||
t3_dark = os.path.join(tmp, ".themes", "ANODE-Anodized", "gtk-3.0", "gtk.css")
|
||||
with open(t3_dark, "r", encoding="utf-8") as f:
|
||||
t3_txt = f.read()
|
||||
assert "menu separator" in t3_txt, t3_txt
|
||||
@@ -412,8 +412,8 @@ def test_gtk_theme_light_dark_detection_and_css_parse():
|
||||
sys.executable,
|
||||
"-c",
|
||||
gtk4_check,
|
||||
os.path.join(tmp, ".themes", "ANODE-AnodeDefault", "gtk-4.0", "gtk.css"),
|
||||
os.path.join(tmp, ".themes", "ANODE-AnodeDefault", "gtk-4.0", "gtk-dark.css"),
|
||||
os.path.join(tmp, ".themes", "ANODE-Anodized", "gtk-4.0", "gtk.css"),
|
||||
os.path.join(tmp, ".themes", "ANODE-Anodized", "gtk-4.0", "gtk-dark.css"),
|
||||
os.path.join(tmp, ".config", "gtk-4.0", "gtk.css"),
|
||||
],
|
||||
env=env,
|
||||
@@ -472,6 +472,93 @@ def test_ui_font_fallback_roboto_to_noto_sans():
|
||||
assert aliases.get("monospace") == ["Fira Code"], aliases
|
||||
|
||||
|
||||
def test_deprecated_anodedefault_fallback_and_install():
|
||||
assert not os.path.exists(os.path.join(THEMES_DIR, "AnodeDefault.xth"))
|
||||
assert os.path.isfile(os.path.join(THEMES_DIR, "Anodized.xth"))
|
||||
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
env = dict(os.environ)
|
||||
env.pop("DISPLAY", None)
|
||||
env["HOME"] = tmp
|
||||
env["XDG_CONFIG_HOME"] = os.path.join(tmp, ".config")
|
||||
env["XDG_DATA_HOME"] = os.path.join(tmp, ".local", "share")
|
||||
env["ANODE_PREFIX"] = ROOT
|
||||
env["ANODE_NO_SIGNAL"] = "1"
|
||||
env["ANODE_NO_DBUS"] = "1"
|
||||
|
||||
res = run_env(env, [APPLY_THEME, "AnodeDefault"])
|
||||
assert "deprecated" in res.stderr.lower(), res.stderr
|
||||
with open(os.path.join(tmp, ".config", "anode", "theme.conf"), "r", encoding="utf-8") as f:
|
||||
assert "THEME=Anodized" in f.read()
|
||||
|
||||
dl_dir = os.path.join(tmp, "custom_downloads")
|
||||
os.makedirs(dl_dir)
|
||||
custom_src = os.path.join(dl_dir, "SteelMint.xth")
|
||||
with open(custom_src, "w", encoding="utf-8") as f:
|
||||
f.write("theme.name: SteelMint\ntheme.bgMain: #0c1012\ntheme.fgMain: #dce4e8\ntheme.accent: #90c8b8\n")
|
||||
run_env(env, [APPLY_THEME, "--install", custom_src, "InstalledMint"])
|
||||
dest_p = os.path.join(tmp, ".config", "anode", "themes", "InstalledMint.xth")
|
||||
assert os.path.isfile(dest_p)
|
||||
xres = parse_xres(os.path.join(tmp, ".Xresources"))
|
||||
assert xres["theme.name"] == "InstalledMint"
|
||||
|
||||
|
||||
def test_primary_edid_and_apply_display():
|
||||
APPLY_DISP = os.path.join(ROOT, "scripts", "anode-apply-display")
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
fbin = os.path.join(tmp, "bin")
|
||||
os.makedirs(fbin)
|
||||
calls_log = os.path.join(tmp, "xrandr.calls")
|
||||
xr_p = os.path.join(fbin, "xrandr")
|
||||
with open(xr_p, "w", encoding="utf-8") as f:
|
||||
f.write(
|
||||
"#!/bin/sh\n"
|
||||
"if [ \"$1\" = \"--query\" ]; then\n"
|
||||
" cat <<'EOF'\n"
|
||||
"Screen 0: minimum 320 x 200, current 4480 x 1440, maximum 16384 x 16384\n"
|
||||
"DP-1 connected 2560x1440+0+0 (normal left inverted right x axis y axis) 600mm x 340mm\n"
|
||||
" 2560x1440 59.95*+\n"
|
||||
" 1920x1080 60.00\n"
|
||||
"eDP-1 connected primary 1920x1200+2560+0 (normal left inverted right x axis y axis) 301mm x 188mm\n"
|
||||
" 1920x1200 60.00*+\n"
|
||||
"EOF\n"
|
||||
"else\n"
|
||||
f" printf '%s\\n' \"$*\" >> {calls_log!r}\n"
|
||||
"fi\n"
|
||||
)
|
||||
os.chmod(xr_p, 0o755)
|
||||
|
||||
env = dict(os.environ)
|
||||
env["DISPLAY"] = ":99"
|
||||
env["HOME"] = tmp
|
||||
env["XDG_CONFIG_HOME"] = os.path.join(tmp, ".config")
|
||||
env["XDG_DATA_HOME"] = os.path.join(tmp, ".local", "share")
|
||||
env["ANODE_PREFIX"] = ROOT
|
||||
env["ANODE_NO_SIGNAL"] = "1"
|
||||
env["ANODE_NO_DBUS"] = "1"
|
||||
env["PATH"] = fbin + ":" + env.get("PATH", "")
|
||||
|
||||
# Without xdpyinfo overriding DPI, auto scale must pick connected primary eDP-1 (~162 DPI -> 1.70x)
|
||||
run_env(env, [APPLY_SCALE, "auto", "--no-apply"])
|
||||
with open(os.path.join(tmp, ".config", "anode", "scale.conf"), "r", encoding="utf-8") as f:
|
||||
sconf = f.read()
|
||||
assert "SCALE=1.70" in sconf, sconf
|
||||
|
||||
# Saved multi-monitor profile restores matching signature via atomic xrandr call
|
||||
os.makedirs(os.path.join(tmp, ".config", "anode"), exist_ok=True)
|
||||
with open(os.path.join(tmp, ".config", "anode", "displays.conf"), "w", encoding="utf-8") as f:
|
||||
f.write(
|
||||
"[profile:DP-1,eDP-1]\n"
|
||||
"output=eDP-1,1,1,1920x1200,60.00,0,0,normal\n"
|
||||
"output=DP-1,1,0,2560x1440,59.95,1920,0,left\n"
|
||||
)
|
||||
run_env(env, [APPLY_DISP])
|
||||
with open(calls_log, "r", encoding="utf-8") as f:
|
||||
applied = f.read().strip()
|
||||
assert "--output eDP-1 --mode 1920x1200 --rate 60.00 --pos 0x0 --rotate normal --primary" in applied, applied
|
||||
assert "--output DP-1 --mode 2560x1440 --rate 59.95 --pos 1920x0 --rotate left" in applied, applied
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
with open(os.path.join(ROOT, "data", "env.sh"), "r", encoding="utf-8") as f:
|
||||
env_sh = f.read()
|
||||
@@ -485,4 +572,6 @@ if __name__ == "__main__":
|
||||
test_stale_env_does_not_override_scale_conf()
|
||||
test_gtk_theme_light_dark_detection_and_css_parse()
|
||||
test_ui_font_fallback_roboto_to_noto_sans()
|
||||
print("test_theme_scale: ALL PASSED (7 fractional scales, 22 themes, legacy 192-DPI import, St overrides, auto DPI, scale.conf precedence, GTK light/dark, Roboto->Noto Sans fallback)")
|
||||
test_deprecated_anodedefault_fallback_and_install()
|
||||
test_primary_edid_and_apply_display()
|
||||
print("test_theme_scale: ALL PASSED (7 fractional scales, 22 themes, legacy 192-DPI import, St overrides, auto DPI, scale.conf precedence, GTK light/dark, Roboto->Noto Sans fallback, AnodeDefault fallback/install, primary/displays.conf)")
|
||||
@@ -2,7 +2,9 @@
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "anode_scale.h"
|
||||
#include "anode_plat.h"
|
||||
@@ -14,6 +16,9 @@
|
||||
#include "anode_power_policy.h"
|
||||
#include "anode_xkb_parse.h"
|
||||
#include "anode_sys_parse.h"
|
||||
#include "anode_xth.h"
|
||||
#include "anode_display_cfg.h"
|
||||
#include "anode_bar_fmt.h"
|
||||
#include "anode-touch-gesture.h"
|
||||
|
||||
static void test_scale_math(void) {
|
||||
@@ -174,6 +179,62 @@ static void test_power_policy_and_gestures(void) {
|
||||
anode_power_policy_step(&cfg, &st, 1000, false, 2, true, false, &act);
|
||||
assert(act.warn_low_batt && act.suspend_now);
|
||||
|
||||
/* lock_ms < dim_ms ordering must still trigger lock */
|
||||
cfg = anode_power_cfg_default();
|
||||
cfg.dim_ms = 600000U;
|
||||
cfg.lock_ms = 300000U;
|
||||
cfg.suspend_ms = 1800000U;
|
||||
st = ANODE_PWR_ACTIVE;
|
||||
anode_power_policy_step(&cfg, &st, 310000U, true, 90, true, false, &act);
|
||||
assert(st == ANODE_PWR_LOCKED && act.lock_now);
|
||||
assert(anode_power_policy_next_wake_ms(&cfg, 1000U, true, false) == 15000);
|
||||
assert(anode_power_policy_next_wake_ms(&cfg, 295000U, true, false) == 5000);
|
||||
|
||||
/* Dim and lock disabled, battery-only suspend */
|
||||
cfg.dim_ms = 0U;
|
||||
cfg.lock_ms = 0U;
|
||||
cfg.suspend_ms = 1800000U;
|
||||
cfg.suspend_on_ac = false;
|
||||
st = ANODE_PWR_ACTIVE;
|
||||
anode_power_policy_step(&cfg, &st, 1900000U, true, 90, true, false, &act);
|
||||
assert(st == ANODE_PWR_ACTIVE && !act.suspend_now && !act.lock_now && !act.dim_now);
|
||||
anode_power_policy_step(&cfg, &st, 1900000U, false, 90, true, false, &act);
|
||||
assert(st == ANODE_PWR_SUSPENDED && act.suspend_now);
|
||||
|
||||
cfg.suspend_on_ac = true;
|
||||
assert(anode_power_policy_next_wake_ms(&cfg, 1796000U, true, false) == 4000);
|
||||
|
||||
/* Preset stepping & timeout formatting */
|
||||
char tfmt[16];
|
||||
anode_power_format_timeout(0U, tfmt, sizeof(tfmt));
|
||||
assert(strcmp(tfmt, "Off") == 0);
|
||||
anode_power_format_timeout(30000U, tfmt, sizeof(tfmt));
|
||||
assert(strcmp(tfmt, "30s") == 0);
|
||||
anode_power_format_timeout(300000U, tfmt, sizeof(tfmt));
|
||||
assert(strcmp(tfmt, "5m") == 0);
|
||||
anode_power_format_timeout(3600000U, tfmt, sizeof(tfmt));
|
||||
assert(strcmp(tfmt, "1h") == 0);
|
||||
assert(anode_power_step_screen_timeout_ms(0U, 1) == 30000U);
|
||||
assert(anode_power_step_screen_timeout_ms(45000U, 1) == 60000U);
|
||||
assert(anode_power_step_screen_timeout_ms(45000U, -1) == 30000U);
|
||||
assert(anode_power_step_suspend_timeout_ms(1800000U, 1) == 2700000U);
|
||||
assert(anode_power_step_suspend_timeout_ms(0U, -1) == 0U);
|
||||
|
||||
/* Atomic power.conf save/load round-trip */
|
||||
char ptmpl[] = "/tmp/anode-u-pwr-XXXXXX";
|
||||
char *pdir = mkdtemp(ptmpl);
|
||||
assert(pdir != NULL);
|
||||
char pconf[256];
|
||||
snprintf(pconf, sizeof(pconf), "%s/power.conf", pdir);
|
||||
anode_power_cfg_t wcfg = {0U, 180000U, 900000U, 10, true};
|
||||
assert(anode_power_cfg_save(pconf, &wcfg));
|
||||
anode_power_cfg_t rcfg;
|
||||
assert(anode_power_cfg_load(pconf, &rcfg));
|
||||
assert(rcfg.dim_ms == 0U && rcfg.lock_ms == 180000U && rcfg.suspend_ms == 900000U &&
|
||||
rcfg.crit_batt_pct == 10 && rcfg.suspend_on_ac == true);
|
||||
remove(pconf);
|
||||
rmdir(pdir);
|
||||
|
||||
/* Gestures at 1.0x and 2.0x scales */
|
||||
anode_touch_track_t tr = {0};
|
||||
anode_touch_begin(&tr, 1, 500, 1070, 1000);
|
||||
@@ -292,6 +353,156 @@ static void test_platform_probe(void) {
|
||||
assert(buf[0] == '/');
|
||||
}
|
||||
|
||||
static void test_xth_editor_and_import(void) {
|
||||
anode_xth_t x;
|
||||
anode_xth_init_anodized(&x);
|
||||
assert(strcmp(x.name, "Anodized") == 0);
|
||||
assert(strcmp(x.colors[ANODE_XTH_BG_MAIN], "#08090b") == 0);
|
||||
assert(strcmp(x.colors[ANODE_XTH_ACCENT], "#cfd6e0") == 0);
|
||||
assert(anode_xth_contrast_ratio("#08090b", "#cfd6e0") > 12.0);
|
||||
|
||||
char sname[64];
|
||||
anode_xth_sanitize_name(" My Cool Theme! 2.0 ", sname, sizeof(sname));
|
||||
assert(strcmp(sname, "My_Cool_Theme_2_0") == 0);
|
||||
anode_xth_sanitize_name("../..", sname, sizeof(sname));
|
||||
assert(sname[0] == '\0');
|
||||
|
||||
snprintf(x.name, sizeof(x.name), "SilverCustom");
|
||||
snprintf(x.colors[ANODE_XTH_BG_BAR], 16, "#101216");
|
||||
snprintf(x.colors[ANODE_XTH_SEL_BG], 16, "#445566");
|
||||
anode_xth_sync_derived(&x);
|
||||
assert(strcmp(x.colors[ANODE_XTH_DWM_NORM_BG], "#101216") == 0);
|
||||
assert(strcmp(x.colors[ANODE_XTH_DMENU_SEL_BG], "#445566") == 0);
|
||||
assert(strcmp(x.colors[ANODE_XTH_ST_CURSOR], "#cfd6e0") == 0);
|
||||
|
||||
char dir_tmpl[] = "/tmp/anode-u-xth-XXXXXX";
|
||||
char *tdir = mkdtemp(dir_tmpl);
|
||||
assert(tdir != NULL);
|
||||
|
||||
char p1[256], p2[256], badp[256], dest[512];
|
||||
snprintf(p1, sizeof(p1), "%s/src.xth", tdir);
|
||||
snprintf(badp, sizeof(badp), "%s/bad.bin", tdir);
|
||||
assert(anode_xth_save_file(p1, &x));
|
||||
|
||||
anode_xth_t loaded;
|
||||
assert(anode_xth_load_file(p1, &loaded));
|
||||
assert(strcmp(loaded.name, "SilverCustom") == 0);
|
||||
assert(strcmp(loaded.colors[ANODE_XTH_DWM_NORM_BG], "#101216") == 0);
|
||||
|
||||
assert(anode_xth_import_file(p1, tdir, "ImportedSilver!", dest, sizeof(dest)));
|
||||
assert(anode_xth_load_file(dest, &loaded));
|
||||
assert(strcmp(loaded.name, "ImportedSilver") == 0);
|
||||
|
||||
FILE *bf = fopen(badp, "wb");
|
||||
assert(bf != NULL);
|
||||
unsigned char zeros[8] = {0, 1, 2, 0, 3, 4, 5, 6};
|
||||
fwrite(zeros, 1, sizeof(zeros), bf);
|
||||
fclose(bf);
|
||||
assert(!anode_xth_load_file(badp, &loaded));
|
||||
|
||||
snprintf(p2, sizeof(p2), "%s/empty.xth", tdir);
|
||||
FILE *ef = fopen(p2, "w");
|
||||
assert(ef != NULL);
|
||||
fclose(ef);
|
||||
assert(!anode_xth_load_file(p2, &loaded));
|
||||
|
||||
remove(p1);
|
||||
remove(dest);
|
||||
remove(badp);
|
||||
remove(p2);
|
||||
rmdir(tdir);
|
||||
}
|
||||
|
||||
static void test_display_cfg_and_snap(void) {
|
||||
int ew = 0, eh = 0;
|
||||
anode_disp_eff_size(1920, 1080, 1, &ew, &eh);
|
||||
assert(ew == 1080 && eh == 1920);
|
||||
anode_disp_eff_size(1920, 1080, 0, &ew, &eh);
|
||||
assert(ew == 1920 && eh == 1080);
|
||||
|
||||
anode_disp_out_t outs[2];
|
||||
memset(outs, 0, sizeof(outs));
|
||||
snprintf(outs[0].name, 32, "eDP-1");
|
||||
outs[0].enabled = true; outs[0].primary = true;
|
||||
outs[0].w = 1920; outs[0].h = 1080; outs[0].hz = 60.0;
|
||||
snprintf(outs[1].name, 32, "HDMI-1");
|
||||
outs[1].enabled = true; outs[1].primary = false;
|
||||
outs[1].w = 2560; outs[1].h = 1440; outs[1].hz = 60.0;
|
||||
|
||||
anode_disp_apply_preset(outs, 2, 0, ANODE_DISP_PRESET_RIGHT);
|
||||
assert(outs[0].x == 0 && outs[0].y == 0 && outs[1].x == 1920 && outs[1].y == 0);
|
||||
|
||||
anode_disp_apply_preset(outs, 2, 0, ANODE_DISP_PRESET_LEFT);
|
||||
assert(outs[1].x == 0 && outs[0].x == 2560);
|
||||
|
||||
anode_disp_apply_preset(outs, 2, 0, ANODE_DISP_PRESET_ABOVE);
|
||||
assert(outs[1].y == 0 && outs[0].y == 1440);
|
||||
|
||||
anode_disp_apply_preset(outs, 2, 0, ANODE_DISP_PRESET_RIGHT);
|
||||
int sx = 0, sy = 0;
|
||||
anode_disp_snap(outs, 2, 1, 1900, 18, 32, &sx, &sy);
|
||||
assert(sx == 1920 && sy == 0);
|
||||
|
||||
char sig[128];
|
||||
anode_disp_signature(outs, 2, sig, sizeof(sig));
|
||||
assert(strcmp(sig, "HDMI-1,eDP-1") == 0);
|
||||
|
||||
char dir_tmpl[] = "/tmp/anode-u-disp-XXXXXX";
|
||||
char *tdir = mkdtemp(dir_tmpl);
|
||||
assert(tdir != NULL);
|
||||
char conf[256];
|
||||
snprintf(conf, sizeof(conf), "%s/displays.conf", tdir);
|
||||
assert(anode_disp_save_profile(conf, outs, 2));
|
||||
|
||||
anode_disp_out_t loaded[4];
|
||||
int nl = anode_disp_load_profile(conf, sig, loaded, 4);
|
||||
assert(nl == 2);
|
||||
assert(strcmp(loaded[0].name, "eDP-1") == 0 && loaded[0].primary);
|
||||
assert(strcmp(loaded[1].name, "HDMI-1") == 0 && loaded[1].x == 1920 && loaded[1].w == 2560);
|
||||
|
||||
const char *av[64];
|
||||
char tokbuf[512];
|
||||
int ac = anode_disp_build_xrandr_argv(loaded, nl, av, 64, tokbuf, sizeof(tokbuf));
|
||||
assert(ac > 8 && strcmp(av[0], "xrandr") == 0);
|
||||
|
||||
anode_disp_apply_preset(outs, 2, 0, ANODE_DISP_PRESET_PRIMARY_ONLY);
|
||||
assert(outs[0].enabled && outs[0].primary && !outs[1].enabled);
|
||||
|
||||
outs[0].enabled = false;
|
||||
assert(anode_disp_build_xrandr_argv(outs, 2, av, 64, tokbuf, sizeof(tokbuf)) == -1);
|
||||
|
||||
remove(conf);
|
||||
rmdir(tdir);
|
||||
}
|
||||
|
||||
static void test_bar_status_compaction(void) {
|
||||
const char *full = " VOL 75% | CPU 12% | RAM 45% | BAT 85%+ | us | 2026-11-27 08:02 ";
|
||||
char out[256];
|
||||
|
||||
anode_bar_compact_status(full, 0, out, sizeof(out));
|
||||
assert(strcmp(out, "VOL 75% | CPU 12% | RAM 45% | BAT 85%+ | us | 2026-11-27 08:02") == 0);
|
||||
|
||||
anode_bar_compact_status(full, 1, out, sizeof(out));
|
||||
assert(strcmp(out, "V:75% C:12% R:45% B:85%+ us 11-27 08:02") == 0);
|
||||
|
||||
anode_bar_compact_status(full, 2, out, sizeof(out));
|
||||
assert(strcmp(out, "V:75% B:85%+ us 08:02") == 0);
|
||||
|
||||
anode_bar_compact_status(full, 3, out, sizeof(out));
|
||||
assert(strcmp(out, "us 08:02") == 0);
|
||||
|
||||
const char *desk = " VOL MUTE | CPU 5% | RAM 30% | AC | de | 2026-11-27 08:02 ";
|
||||
anode_bar_compact_status(desk, 1, out, sizeof(out));
|
||||
assert(strcmp(out, "V:M C:5% R:30% AC de 11-27 08:02") == 0);
|
||||
anode_bar_compact_status(desk, 2, out, sizeof(out));
|
||||
assert(strcmp(out, "V:M de 08:02") == 0);
|
||||
anode_bar_compact_status(desk, 3, out, sizeof(out));
|
||||
assert(strcmp(out, "de 08:02") == 0);
|
||||
|
||||
anode_bar_compact_status("custom bar text", 2, out, sizeof(out));
|
||||
assert(strcmp(out, "custom bar text") == 0);
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
test_scale_math();
|
||||
test_dns_validation();
|
||||
@@ -302,6 +513,9 @@ int main(void) {
|
||||
test_xkb_layout_parser();
|
||||
test_sys_parsers();
|
||||
test_platform_probe();
|
||||
test_xth_editor_and_import();
|
||||
test_display_cfg_and_snap();
|
||||
test_bar_status_compaction();
|
||||
printf("test_units: ALL PASSED\n");
|
||||
return 0;
|
||||
}
|
||||
+56
-5
@@ -647,6 +647,11 @@ def test_lockscreen_overlaps_systray():
|
||||
|
||||
lock_win = wait_until(find_lock_win)
|
||||
assert lock_win, "anode-lock window did not map"
|
||||
la = XWindowAttributes()
|
||||
assert X11.XGetWindowAttributes(dpy, lock_win, ctypes.byref(la))
|
||||
assert la.x == 0 and la.y == 0 and la.width == 1280 and la.height == 800, (
|
||||
la.x, la.y, la.width, la.height
|
||||
)
|
||||
|
||||
# Trigger systray updates while locked: dock a 2nd icon and reload dwm via SIGUSR1
|
||||
dock_dummy_icon()
|
||||
@@ -1183,7 +1188,7 @@ def test_wine_take_focus_workspace_switch():
|
||||
env=env, check=True)
|
||||
time.sleep(0.25)
|
||||
|
||||
# Phase 2: switch away to Tag 2 via Super_L + 2, wait, then return via bar Tag 1 click (x=50, y=10)
|
||||
# Phase 2: switch away to Tag 2 via Super_L + 2, wait, then return via bar Tag 1 click (x=38, y=10)
|
||||
subprocess.run(["xdotool", "keydown", "Super_L"], env=env, check=True)
|
||||
time.sleep(0.06)
|
||||
subprocess.run(["xdotool", "key", "2"], env=env, check=True)
|
||||
@@ -1192,7 +1197,7 @@ def test_wine_take_focus_workspace_switch():
|
||||
time.sleep(0.25)
|
||||
subprocess.run(["xdotool", "mousemove", "400", "400", "click", "1"], env=env, check=True)
|
||||
time.sleep(0.2)
|
||||
subprocess.run(["xdotool", "mousemove", "50", "10", "click", "1"], env=env, check=True)
|
||||
subprocess.run(["xdotool", "mousemove", "38", "10", "click", "1"], env=env, check=True)
|
||||
time.sleep(0.3)
|
||||
subprocess.run(["xdotool", "mousemove", "520", "480", "click", "1", "mousemove", "720", "320", "key", "b"],
|
||||
env=env, check=True)
|
||||
@@ -1711,7 +1716,7 @@ def test_live_theme_reload_and_bar_artifacts():
|
||||
env.get("PATH", "")
|
||||
)
|
||||
subprocess.run([os.path.join(ROOT, "scripts", "anode-apply-scale"), "1.00", "--touch=0"], env=env, check=True)
|
||||
subprocess.run([os.path.join(ROOT, "scripts", "anode-apply-theme"), "AnodeDefault"], env=env, check=True)
|
||||
subprocess.run([os.path.join(ROOT, "scripts", "anode-apply-theme"), "Anodized"], env=env, check=True)
|
||||
|
||||
xvfb = subprocess.Popen(
|
||||
["Xvfb", disp, "-noreset", "-screen", "0", "1280x800x24", "-nolisten", "tcp"],
|
||||
@@ -1816,8 +1821,8 @@ def test_live_theme_reload_and_bar_artifacts():
|
||||
)
|
||||
return res
|
||||
|
||||
# Phase 1: Initial AnodeDefault
|
||||
check_palette("AnodeDefault", {0x11161F, 0x2B5278}, 0x0B0E14, 0x0B0E14)
|
||||
# Phase 1: Initial Anodized
|
||||
check_palette("Anodized", {0x0E1014, 0x38414F}, 0x08090B, 0x08090B)
|
||||
|
||||
# Phase 2: Switch to SolarizedLight via anode-apply-theme with ANODE_NO_SIGNAL=1
|
||||
# (must propagate purely via xrdb -load + live XA_RESOURCE_MANAGER lookup!)
|
||||
@@ -1851,6 +1856,50 @@ def test_live_theme_reload_and_bar_artifacts():
|
||||
terminate(xvfb)
|
||||
|
||||
|
||||
def test_themes_cli_install_and_arrange_smoke():
|
||||
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["LD_LIBRARY_PATH"] = os.path.join(BUILD, "libgemui") + (":" + env["LD_LIBRARY_PATH"] if env.get("LD_LIBRARY_PATH") else "")
|
||||
|
||||
src_xth = os.path.join(home, "NonStandardDir", "SilverSmoke.xth")
|
||||
os.makedirs(os.path.dirname(src_xth))
|
||||
with open(src_xth, "w", encoding="utf-8") as f:
|
||||
f.write("theme.name: SilverSmoke\ntheme.bgMain: #0a0b0e\ntheme.fgMain: #e0e5ec\ntheme.accent: #cfd6e0\n")
|
||||
|
||||
inst = subprocess.run(
|
||||
[os.path.join(BUILD, "apps", "anode-themes"), "--install", src_xth, "SmokeCustom"],
|
||||
env=env, capture_output=True, text=True, check=True,
|
||||
)
|
||||
installed_p = os.path.join(home, ".config", "anode", "themes", "SmokeCustom.xth")
|
||||
assert os.path.isfile(installed_p), inst.stdout
|
||||
|
||||
xvfb = subprocess.Popen(
|
||||
["Xvfb", disp, "-noreset", "-screen", "0", "1440x900x24", "-nolisten", "tcp"],
|
||||
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
|
||||
)
|
||||
dpy = None
|
||||
proc = None
|
||||
try:
|
||||
dpy = wait_until(lambda: X11.XOpenDisplay(disp.encode()))
|
||||
assert dpy, f"Failed to open Xvfb {disp}"
|
||||
proc = subprocess.Popen(
|
||||
[os.path.join(BUILD, "apps", "anode-display"), "--arrange"],
|
||||
env=env, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
|
||||
)
|
||||
time.sleep(0.4)
|
||||
assert proc.poll() is None, f"anode-display --arrange exited with {proc.returncode}"
|
||||
finally:
|
||||
terminate(proc)
|
||||
if dpy:
|
||||
X11.XCloseDisplay(dpy)
|
||||
terminate(xvfb)
|
||||
|
||||
|
||||
def main():
|
||||
if not shutil.which("Xvfb"):
|
||||
print("test_x11_xvfb: Xvfb not installed (skipping)")
|
||||
@@ -1879,6 +1928,8 @@ def main():
|
||||
print("test_x11_xvfb: systray XEmbed dock/map race OK")
|
||||
test_live_theme_reload_and_bar_artifacts()
|
||||
print("test_x11_xvfb: live theme reload & bar artifact check OK")
|
||||
test_themes_cli_install_and_arrange_smoke()
|
||||
print("test_x11_xvfb: anode-themes --install & anode-display --arrange smoke OK")
|
||||
return 0
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user