From ff6f733810e8008075395dcdac3c5ff5a78de6f3 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 26 Nov 2026 04:39:45 +0000 Subject: [PATCH] chandra-ctl windows: how Chandra sees each window, and what the pointer is over For "this window won't resize" reports (V's Gajim still not resizing on real hardware, while a libadwaita window built like Gajim's resizes headless on both hosts): one line per window with its frame kind (client-frame / chandra-frame), layout state (floating, tiled, maximized, fullscreen), box, buffer, the client's shadow per side, min/max size and title, then the pointer position and what it's over (a resize grip and which edge, a window, a title bar, a tiling divider, the panel, the desktop). Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01DPL5hiu4r7mEXBdKY6cgv6 --- compositor/host/control.mbt | 104 +++++++++++++++++++++++++++++++++++ compositor/host/csd_test.mbt | 15 +++++ docs/reloading.md | 2 + session/chandra-ctl | 3 +- 4 files changed, 123 insertions(+), 1 deletion(-) diff --git a/compositor/host/control.mbt b/compositor/host/control.mbt index 82be04b..4b3b194 100644 --- a/compositor/host/control.mbt +++ b/compositor/host/control.mbt @@ -210,6 +210,7 @@ pub fn ChandraCompositor::control_command(self : ChandraCompositor, line : Strin "reload load every panel module again from disk", "reload NAME only the modules whose name, slot or path is NAME", "shortcut ID do what shortcut ID does (launcher, overview, show-desktop, ...)", "kiosk [lock|unlock|status] kiosk mode (--kiosk): lock it down or unlock it for admin work", + "windows each window: frame, layout, box, shadow, size limits; and what is under the pointer", "ok", ], true, @@ -272,6 +273,109 @@ pub fn ChandraCompositor::control_command(self : ChandraCompositor, line : Strin _ => (["error usage: kiosk [lock|unlock|status]"], false) } } + "windows" => { + let out = self.window_report() + out.push("ok " + self.windows.length().to_string() + " windows") + (out, true) + } other => (["error unknown command '" + other + "' (try: help)"], false) } } + +///| `chandra-ctl windows`: how Chandra sees each window, for "this window won't resize/move" +/// reports. One line per window, top of the stack first, then what is under the pointer. +fn ChandraCompositor::window_report(self : ChandraCompositor) -> Array[String] { + let out : Array[String] = [] + let order = self.wm.stacking_order() + let mut i = order.length() - 1 + while i >= 0 { + let id = order[i] + i = i - 1 + match self.windows.get(id) { + Some(w) => { + let r = w.client_rect() + let sb = StringBuilder() + sb.write_string(id.to_string() + " " + (if w.app_id == "" { "-" } else { w.app_id })) + sb.write_string(if w.csd { " client-frame" } else { " chandra-frame" }) + match self.wm.windows.get(id) { + Some(rec) => { + sb.write_string( + if rec.fullscreen { + " fullscreen" + } else if rec.maximized { + " maximized" + } else if rec.is_floating { + " floating" + } else { + " tiled" + }, + ) + if rec.minimized { + sb.write_string(" minimized") + } + sb.write_string(" min=" + rec.min_size.w.to_string() + "x" + rec.min_size.h.to_string()) + match rec.max_size { + Some(m) => sb.write_string(" max=" + m.w.to_string() + "x" + m.h.to_string()) + None => () + } + } + None => sb.write_string(" unmanaged") + } + sb.write_string(" box=" + r.x.to_string() + "," + r.y.to_string() + "+" + r.w.to_string() + "x" + r.h.to_string()) + match w.surface { + Some(s) => { + sb.write_string(" buffer=" + s.width.to_string() + "x" + s.height.to_string()) + if w.csd { + // The client's shadow on each side: left, top, right, bottom. + sb.write_string( + " shadow=" + w.geo_x.to_string() + "," + w.geo_y.to_string() + "," + + (s.width - w.geo_x - r.w).to_string() + "," + (s.height - w.geo_y - r.h).to_string(), + ) + } + } + None => sb.write_string(" no-buffer") + } + if w.subs.length() > 0 { + sb.write_string(" subsurfaces=" + w.subs.length().to_string()) + } + sb.write_string(" \"" + w.title + "\"") + out.push(sb.to_string()) + } + None => () + } + } + let x = self.ptr_x.to_int() + let y = self.ptr_y.to_int() + let under = if self.popup_at(x, y) is Some(_) { + "a popup menu" + } else if self.shell.hit(x, y) { + "the panel" + } else { + match self.resize_at(x, y) { + Some((wid, mode)) => "resize grip " + drag_mode_name(mode) + " of " + wid.to_string() + None => + match self.window_at(x, y) { + Some((wid, true)) => "window " + wid.to_string() + Some((wid, false)) => "title bar of " + wid.to_string() + None => if self.handle_at(x, y) is Some(_) { "a tiling divider" } else { "the desktop" } + } + } + } + out.push("pointer " + x.to_string() + "," + y.to_string() + " over " + under) + out +} + +///| +fn drag_mode_name(m : @wm.DragMode) -> String { + match m { + ResizeN => "top" + ResizeS => "bottom" + ResizeW => "left" + ResizeE => "right" + ResizeNW => "top-left" + ResizeNE => "top-right" + ResizeSW => "bottom-left" + ResizeSE => "bottom-right" + _ => "move" + } +} diff --git a/compositor/host/csd_test.mbt b/compositor/host/csd_test.mbt index e7445b7..e740d76 100644 --- a/compositor/host/csd_test.mbt +++ b/compositor/host/csd_test.mbt @@ -396,3 +396,18 @@ test "a subsurface (Chrome's toolbar bubbles) is drawn over its window and gets assert_eq(comp.windows.get(1UL).unwrap().subs.length(), 0) assert_true(comp.compose_frame().pixel(ox + 110, oy + 60) != blue) } + +///| +test "chandra-ctl windows says how a GTK window is framed and what the pointer is over" { + let (comp, c, shm, surf, xdg, tl) = csd_setup("report") + ignore(gtk_frame(comp, c, shm, surf, xdg, tl)) + ignore(gtk_frame(comp, c, shm, surf, xdg, tl)) + let r = comp.windows.get(1UL).unwrap().client_rect() + comp.handle_input(@nested.InputEvent::PointerMove((r.x + r.w + 5).to_double(), (r.y + r.h / 2).to_double()), 60U) + let (lines, ok) = comp.control_command("windows") + assert_true(ok) + assert_true(lines[0].has_prefix("1 org.gnome.Nautilus client-frame floating ")) + assert_true(lines[0].contains(" shadow=24,24,24,24 ")) + assert_true(lines.contains("pointer " + (r.x + r.w + 5).to_string() + "," + (r.y + r.h / 2).to_string() + " over resize grip right of 1")) + assert_eq(lines[lines.length() - 1], "ok 1 windows") +} diff --git a/docs/reloading.md b/docs/reloading.md index 0ff94df..98c1ee3 100644 --- a/docs/reloading.md +++ b/docs/reloading.md @@ -33,6 +33,8 @@ chandra-ctl reload NAME # modules whose name (clock-digital), slot (w3) chandra-ctl list # loaded modules in panel order: slot, module, path chandra-ctl ping # is the compositor answering? chandra-ctl shortcut overview # run a keyboard shortcut by its id (see Settings > Shortcuts) +chandra-ctl windows # each window's frame, layout state, box, shadow and size limits, + # then what the pointer is over (a resize grip, a window, ...) chandra-ctl help ``` diff --git a/session/chandra-ctl b/session/chandra-ctl index 0b5b46c..97c6cc7 100755 --- a/session/chandra-ctl +++ b/session/chandra-ctl @@ -7,6 +7,7 @@ chandra-ctl ping check the compositor answers chandra-ctl shortcut ID do what a keyboard shortcut does (overview, launcher, show-desktop...) chandra-ctl kiosk [lock|unlock|status] kiosk mode (--kiosk, docs/kiosk.md) + chandra-ctl windows how Chandra sees each window, and what is under the pointer The socket is $XDG_RUNTIME_DIR/chandra/.sock (the session's is wayland-moon-0.sock). It is found in this order: --socket PATH, $CHANDRA_CONTROL, the one for @@ -19,7 +20,7 @@ import os import socket import sys -USAGE = "usage: chandra-ctl [--socket PATH] [--quiet] {reload [NAME] | list | ping | shortcut ID | kiosk [lock|unlock|status] | help}" +USAGE = "usage: chandra-ctl [--socket PATH] [--quiet] {reload [NAME] | list | ping | shortcut ID | kiosk [lock|unlock|status] | windows | help}" def runtime_dir():