X11 dock bridge: show and control host EWMH windows under --x11
CI / test (push) Failing after 2m37s

Under --x11 with a host EWMH window manager (e.g. Openbox in Gamerig),
Chandra is one top-level X11 client while other apps run directly on Xorg,
so the dock only saw Chandra's Wayland windows.

- compositor/x11: intern EWMH/ICCCM atoms and track _NET_CLIENT_LIST,
  _NET_ACTIVE_WINDOW, titles, and window states via PropertyChangeMask,
  filtering non-taskbar/child windows and adding focus, close, minimize,
  and toggle-maximize EWMH/ICCCM actions.
- compositor/shell: add resolve_external_app_id (matching WM_CLASS and
  StartupWMClass against installed .desktop files) and publish_windows.
- compositor/host: bridge ExternalWindow entries with bit-30 tagged IDs
  into shell.windows/win_list while keeping Wayland wm.windows and session
  snapshots untouched, and route activate_task / window_command actions.
- compositor/app, compositor/bin, docs/x11.md: wire external window sync
  before X11 input handling and register ExternalWindowHandler.

Verified: moon test --target native compositor/x11 compositor/shell (38/38),
external_windows_test.mbt + dock_test.mbt (3/3), build-compositor-wasm.sh,
and moon build --target native compositor/bin.
This commit is contained in:
nandi committed 2026-11-27 14:33:26 -08:00
1 parent 15b7c3f0e3
commit 1871d50a3e
12 files changed
+949 -68

No files matched your search

+93
View File
@@ -52,3 +52,96 @@ test "xauth_cookie: picks this host's entry for the display" {
let wild = Bytes::from_array(xauth_entry(0xFFFF, "", "0", [b'\x09']))
assert_eq(@x11.xauth_cookie(wild, 0, "rig").to_array(), [b'\x09'])
}
///|
fn utf8_bytes(s : String) -> Array[Byte] {
let out : Array[Byte] = []
for c in s {
out.push(c.to_int().to_byte())
}
out
}
///|
fn le32_bytes(vals : Array[Int]) -> Array[Byte] {
let out : Array[Byte] = []
for v in vals {
out.push((v & 0xFF).to_byte())
out.push(((v >> 8) & 0xFF).to_byte())
out.push(((v >> 16) & 0xFF).to_byte())
out.push(((v >> 24) & 0xFF).to_byte())
}
out
}
///|
fn rd32(b : Array[Byte], off : Int) -> Int {
b[off].to_int() |
(b[off + 1].to_int() << 8) |
(b[off + 2].to_int() << 16) |
(b[off + 3].to_int() << 24)
}
///|
test "parse_wm_class splits instance and class" {
assert_eq(@x11.parse_wm_class(utf8_bytes("ghostty\u0000com.mitchellh.ghostty\u0000")), ("ghostty", "com.mitchellh.ghostty"))
assert_eq(@x11.parse_wm_class(utf8_bytes("steamwebhelper\u0000steam\u0000")), ("steamwebhelper", "steam"))
assert_eq(@x11.parse_wm_class(utf8_bytes("astra\u0000astra\u0000")), ("astra", "astra"))
assert_eq(@x11.parse_wm_class(utf8_bytes("single")), ("single", ""))
assert_eq(@x11.parse_wm_class([]), ("", ""))
}
///|
test "parse_u32_list decodes little-endian 32-bit properties" {
assert_eq(@x11.parse_u32_list([]), [])
assert_eq(@x11.parse_u32_list(le32_bytes([0x01200007])), [0x01200007])
assert_eq(@x11.parse_u32_list(le32_bytes([0x00400001, 0x01200007, 0x01400003])), [0x00400001, 0x01200007, 0x01400003])
}
///|
test "is_taskbar_window filters self, skip-taskbar, non-task types, and child dialogs" {
let clients : Map[Int, Bool] = { 100: true, 200: true }
let skip = 10
let t_norm = 20
let t_dlg = 21
let t_dock = 22
let t_util = 23
// Chandra's own window and zero are skipped.
assert_false(@x11.is_taskbar_window(0, 50, [], skip, [t_norm], t_norm, t_dlg, 0, clients))
assert_false(@x11.is_taskbar_window(50, 50, [], skip, [t_norm], t_norm, t_dlg, 0, clients))
// _NET_WM_STATE_SKIP_TASKBAR is skipped.
assert_false(@x11.is_taskbar_window(100, 50, [skip], skip, [t_norm], t_norm, t_dlg, 0, clients))
// Dock/utility/unknown window types are skipped when window types are present.
assert_false(@x11.is_taskbar_window(100, 50, [], skip, [t_dock], t_norm, t_dlg, 0, clients))
assert_false(@x11.is_taskbar_window(100, 50, [], skip, [t_util], t_norm, t_dlg, 0, clients))
// Transient child dialog whose parent is in client_set is skipped.
assert_false(@x11.is_taskbar_window(200, 50, [], skip, [t_dlg], t_norm, t_dlg, 100, clients))
// Normal window, standalone dialog (or transient for root 1), and untyped ICCCM window appear.
assert_true(@x11.is_taskbar_window(100, 50, [], skip, [t_norm], t_norm, t_dlg, 0, clients))
assert_true(@x11.is_taskbar_window(200, 50, [], skip, [t_dlg], t_norm, t_dlg, 0, clients))
assert_true(@x11.is_taskbar_window(200, 50, [], skip, [t_dlg], t_norm, t_dlg, 1, clients))
assert_true(@x11.is_taskbar_window(100, 50, [], skip, [], t_norm, t_dlg, 0, clients))
}
///|
test "build_client_msg_body and build_raise_body encode exact X11 wire payloads" {
let msg = @x11.build_client_msg_body(0x200, 0x01200007, 300, 2, 11, 12, 2, 0)
assert_eq(msg.length(), 40)
assert_eq(rd32(msg, 0), 0x200) // root
assert_eq(rd32(msg, 4), 0x180000) // SubstructureRedirectMask | SubstructureNotifyMask
assert_eq(msg[8].to_int(), 33) // ClientMessage
assert_eq(msg[9].to_int(), 32) // format 32
assert_eq(rd32(msg, 12), 0x01200007) // target window
assert_eq(rd32(msg, 16), 300) // message type atom
assert_eq(rd32(msg, 20), 2)
assert_eq(rd32(msg, 24), 11)
assert_eq(rd32(msg, 28), 12)
assert_eq(rd32(msg, 32), 2)
assert_eq(rd32(msg, 36), 0)
let raise_body = @x11.build_raise_body(0x01200007)
assert_eq(raise_body.length(), 12)
assert_eq(rd32(raise_body, 0), 0x01200007)
assert_eq(raise_body[4].to_int() | (raise_body[5].to_int() << 8), 0x40) // CWStackMode
assert_eq(rd32(raise_body, 8), 0) // Above
}