X11 dock bridge: show and control host EWMH windows under --x11
CI / test (push) Failing after 2m37s
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:
1 parent
15b7c3f0e3
commit
1871d50a3e
12 files changed
+949
-68
No files matched your search
@@ -217,3 +217,48 @@ test "resolve_app_id finds the desktop file for a window's app id" {
|
||||
assert_eq(resolve_app_id("unknown", exec, wm), None)
|
||||
assert_eq(resolve_app_id("", exec, wm), None)
|
||||
}
|
||||
|
||||
///| Canonical app id for an external X11 window: resolve WM_CLASS class then instance against
|
||||
/// installed .desktop files (including StartupWMClass, e.g. `astra` -> `gamerig-astra`),
|
||||
/// falling back to the raw class, instance, or title.
|
||||
pub fn DesktopShell::resolve_external_app_id(
|
||||
self : DesktopShell,
|
||||
wm_class : String,
|
||||
wm_instance : String,
|
||||
title : String,
|
||||
) -> String {
|
||||
match resolve_app_id(wm_class, self.exec, self.wm_classes) {
|
||||
Some(id) => return id
|
||||
None => ()
|
||||
}
|
||||
match resolve_app_id(wm_instance, self.exec, self.wm_classes) {
|
||||
Some(id) => return id
|
||||
None => ()
|
||||
}
|
||||
if wm_class.length() > 0 {
|
||||
wm_class
|
||||
} else if wm_instance.length() > 0 {
|
||||
wm_instance
|
||||
} else {
|
||||
title
|
||||
}
|
||||
}
|
||||
|
||||
///|
|
||||
test "resolve_external_app_id resolves StartupWMClass and falls back cleanly" {
|
||||
let sh = DesktopShell::new(":0")
|
||||
sh.exec.clear()
|
||||
sh.wm_classes.clear()
|
||||
sh.exec.set("com.mitchellh.ghostty", "gamerig-open terminal")
|
||||
sh.exec.set("steam", "gamerig-open steam")
|
||||
sh.exec.set("gamerig-astra", "gamerig-open astra")
|
||||
sh.wm_classes.set("com.mitchellh.ghostty", "com.mitchellh.ghostty")
|
||||
sh.wm_classes.set("steam", "steam")
|
||||
sh.wm_classes.set("astra", "gamerig-astra")
|
||||
assert_eq(sh.resolve_external_app_id("com.mitchellh.ghostty", "ghostty", "Terminal"), "com.mitchellh.ghostty")
|
||||
assert_eq(sh.resolve_external_app_id("steam", "steamwebhelper", "Steam"), "steam")
|
||||
assert_eq(sh.resolve_external_app_id("astra", "astra", "Space Rage: Astra Incognita"), "gamerig-astra")
|
||||
assert_eq(sh.resolve_external_app_id("steam_app_1145360", "steam_app_1145360", "Hades"), "steam_app_1145360")
|
||||
assert_eq(sh.resolve_external_app_id("", "my-inst", "Fallback"), "my-inst")
|
||||
assert_eq(sh.resolve_external_app_id("", "", "Window Title"), "Window Title")
|
||||
}
|
||||
@@ -1090,13 +1090,10 @@ pub fn DesktopShell::render(
|
||||
self.ensure_booted()
|
||||
self.poll_picker()
|
||||
self.publish_host_data()
|
||||
// Machine state and the rich window list only matter to modules that import them.
|
||||
// Machine state only matters to modules that import it.
|
||||
if self.any_cap("system") {
|
||||
self.sampler.refresh() // reads /proc once a second
|
||||
}
|
||||
if self.any_cap("system") || self.any_cap("windows") {
|
||||
@wasm.set_windows(self.win_list)
|
||||
}
|
||||
self.settle_dock_pins()
|
||||
if self.any_cap("icons") {
|
||||
self.publish_icons()
|
||||
|
||||
@@ -692,6 +692,22 @@ pub fn DesktopShell::slot_popup_texts(self : DesktopShell, slot : String) -> Arr
|
||||
out
|
||||
}
|
||||
|
||||
///| Publish the current window list (`Windows` table and `windows.all` blob) to modules.
|
||||
pub fn DesktopShell::publish_windows(self : DesktopShell) -> Unit {
|
||||
let wt = @wasm.Table::new()
|
||||
for win in self.windows {
|
||||
wt.int(win.id.to_int())
|
||||
wt.str(win.title)
|
||||
wt.int(if win.focused { 1 } else { 0 })
|
||||
wt.int(if win.minimized { 1 } else { 0 })
|
||||
wt.end_row()
|
||||
}
|
||||
@wasm.publish(Windows, wt)
|
||||
if self.any_cap("system") || self.any_cap("windows") {
|
||||
@wasm.set_windows(self.win_list)
|
||||
}
|
||||
}
|
||||
|
||||
///| Publish what modules can read through their capabilities (apps, windows, layout, loaded modules).
|
||||
fn DesktopShell::publish_host_data(self : DesktopShell) -> Unit {
|
||||
if self.apps_dirty {
|
||||
@@ -707,15 +723,7 @@ fn DesktopShell::publish_host_data(self : DesktopShell) -> Unit {
|
||||
}
|
||||
@wasm.publish(Apps, t)
|
||||
}
|
||||
let wt = @wasm.Table::new()
|
||||
for win in self.windows {
|
||||
wt.int(win.id.to_int())
|
||||
wt.str(win.title)
|
||||
wt.int(if win.focused { 1 } else { 0 })
|
||||
wt.int(if win.minimized { 1 } else { 0 })
|
||||
wt.end_row()
|
||||
}
|
||||
@wasm.publish(Windows, wt)
|
||||
self.publish_windows()
|
||||
let lt = @wasm.Table::new()
|
||||
for n in self.layout_names {
|
||||
lt.str(n)
|
||||
|
||||
Reference in new issue
Block a user