mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-11-23 08:54:16 +01:00
fix(windowtrack): mark komorebi for Mac's border windows in the window track
komorebi for Mac draws each border as an untitled, ordinary-level NSWindow owned by the komorebi process. The Mac listing kept them but never set `border`, so a recording gave an agent no way to tell a border from a window. They are now marked, which lets `lag` compare a border with its window. `border_of` stays unset: a Mac border does not name its window.
This commit is contained in:
1 parent
e9f57115ae
commit
eab0b6af35
6 files changed
+35
-9
No files matched your search
+1
-1
@@ -123,7 +123,7 @@ that a contact sheet never decodes more pixels than it shows.
|
||||
| `visible` | `kCGWindowIsOnscreen` (false for windows on other spaces) | `IsWindowVisible`; invisible windows and tool windows are not listed |
|
||||
| `minimized` | always false: the window server does not say | `IsIconic` |
|
||||
| `cloaked` | absent | `DWMWA_CLOAKED` |
|
||||
| `border` | never set | `komoborder-<id>` tool windows are listed (other tool windows are not), with `border` true, and `border_of` when the id is a window handle (a floating window); a tiled window's border is named for its container, see `windowtrack.rs` |
|
||||
| `border` | set on the layer-0 windows owned by the `komorebi` process, which are komorebi's borders (`border_of` is never set; pair one with its window by rect, as `lag` does) | `komoborder-<id>` tool windows are listed (other tool windows are not), with `border` true, and `border_of` when the id is a window handle (a floating window); a tiled window's border is named for its container, see `windowtrack.rs` |
|
||||
| `title` | `kCGWindowName` | `GetWindowTextW` |
|
||||
| status | written against the `objc2` sources and not built or run | built and run |
|
||||
|
||||
|
||||
@@ -250,7 +250,7 @@ question is different: _which window was where, in this frame_. `record --window
|
||||
visible or minimized and, on Windows, whether it is cloaked, front to back, into `windows.jsonl`. A
|
||||
row is written only when something changed, plus a full row each second, so a still desktop costs
|
||||
about one row a second and a busy one a few kilobytes a second. The recorder's own windows and tool
|
||||
windows (tooltips, toasts) are left out, except komorebi's border windows on Windows, which are kept and marked `border` so that a border that lagged its window can be seen. It is on by default on every host that can list windows (Windows, macOS, KDE); `--no-window-track` turns it off and `--window-track=HZ` picks another rate (30 Hz is the default; the sampler does not catch up when a sample is late, it counts it and says so in the warnings). `komorebi-recorder sheet
|
||||
windows (tooltips, toasts) are left out, except komorebi's border windows (Windows and macOS), which are kept and marked `border` so that a border that lagged its window can be seen. It is on by default on every host that can list windows (Windows, macOS, KDE); `--no-window-track` turns it off and `--window-track=HZ` picks another rate (30 Hz is the default; the sampler does not catch up when a sample is late, it counts it and says so in the warnings). `komorebi-recorder sheet
|
||||
<session> --windows` then draws each window's rect, labelled with its program and id, on every
|
||||
frame of the sheet; a session with no track says so and gets a plain sheet. A recording that cannot
|
||||
keep the rate says so in its warnings.
|
||||
|
||||
@@ -120,7 +120,7 @@ locations as hints.
|
||||
visibility and minimized state (and `cloaked` on Windows) sampled at video rate, front to back,
|
||||
so "which window was where in this frame" has an answer. `sheet --windows` draws the rects on
|
||||
each frame (`windows` in the answer names the ones drawn). Rects are in the display's own units
|
||||
(pixels on Windows, points on a Mac). On Windows komorebi's border windows are in the track too, marked `border`
|
||||
(pixels on Windows, points on a Mac). On Windows and macOS komorebi's border windows are in the track too, marked `border`
|
||||
(`border_of` names the window for a floating window's border; a tiled one is named for its container in the
|
||||
`title`, to be joined with `State`; pairing by rect is a heuristic, not recorded). Without it (`--no-window-track`, or a host that cannot list windows) only the sparse per-event probes exist.
|
||||
`lag <session>` (also the `geometry-lag:window` and `geometry-lag:border` findings) compares that track
|
||||
|
||||
@@ -109,7 +109,8 @@ fn bounds_value(bounds: &CFDictionary, key: &str) -> Option<f64> {
|
||||
/// Returns the ordinary windows (layer 0, with a frame) the window server lists, front to back,
|
||||
/// as [`WindowSample`]s, without this process's own windows. `rect` is `kCGWindowBounds` in
|
||||
/// display points rounded to whole points, `visible` is `kCGWindowIsOnscreen`, and `cloaked` is
|
||||
/// `None` because a Mac has no such thing. This is how [`crate::platform::window::list`] is
|
||||
/// `None` because a Mac has no such thing. `border` is true for komorebi's own border windows, which
|
||||
/// are ordinary-level windows owned by the `komorebi` process. This is how [`crate::platform::window::list`] is
|
||||
/// answered here.
|
||||
///
|
||||
/// Not built or run when this was written: it was checked against the `objc2` sources only.
|
||||
@@ -156,6 +157,7 @@ pub fn window_list() -> Vec<WindowSample> {
|
||||
if pid == own || layer.unwrap_or_default() != 0 {
|
||||
continue;
|
||||
}
|
||||
let owner = owner.unwrap_or_default();
|
||||
let Ok(id) = u32::try_from(number) else {
|
||||
continue;
|
||||
};
|
||||
@@ -174,9 +176,10 @@ pub fn window_list() -> Vec<WindowSample> {
|
||||
continue;
|
||||
}
|
||||
|
||||
let border = crate::sources::windowtrack::mac_border_owner(&owner);
|
||||
windows.push(WindowSample {
|
||||
id,
|
||||
owner: owner.unwrap_or_default(),
|
||||
owner,
|
||||
title: title.filter(|title| !title.is_empty()),
|
||||
rect: [
|
||||
x.round() as i32,
|
||||
@@ -187,7 +190,7 @@ pub fn window_list() -> Vec<WindowSample> {
|
||||
visible: onscreen.unwrap_or(false),
|
||||
minimized: false,
|
||||
cloaked: None,
|
||||
border: false,
|
||||
border,
|
||||
border_of: None,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -546,7 +546,7 @@ pub fn readme(dir: &Path, manifest: &Manifest) -> String {
|
||||
"| `state-start.json`, `state-end.json` | `State` when recording started / stopped |\n",
|
||||
);
|
||||
if manifest.window_track.is_some() {
|
||||
out.push_str("| `windows.jsonl` | The window track: every top-level window's rect and state, front to back, written when something changed and in full once a second: `{mach_ns, key?, windows: [{id, owner, title?, rect: [l,t,r,b], visible, minimized, cloaked?, border?, border_of?}]}`; `border` marks komorebi's own border windows (Windows). `sheet --windows` draws it on frames |
|
||||
out.push_str("| `windows.jsonl` | The window track: every top-level window's rect and state, front to back, written when something changed and in full once a second: `{mach_ns, key?, windows: [{id, owner, title?, rect: [l,t,r,b], visible, minimized, cloaked?, border?, border_of?}]}`; `border` marks komorebi's own border windows (Windows and macOS; `border_of` is Windows only). `sheet --windows` draws it on frames |
|
||||
");
|
||||
}
|
||||
out.push_str(os_trace_rows(&host));
|
||||
|
||||
@@ -40,8 +40,11 @@
|
||||
//! border's `title`), which komorebi's `State` maps to the container's focused window: that join
|
||||
//! is exact but is the analysis's to make; when the container id is not enough (or the state is
|
||||
//! missing), pairing a border with a window by rect and z-order is a heuristic and is not done
|
||||
//! here. Neither field is ever guessed. macOS komorebi has no such windows this crate knows of
|
||||
//! (any border window there is not layer 0, which the Mac listing leaves out), and komorebi for KDE
|
||||
//! here. Neither field is ever guessed. komorebi for Mac draws its borders as untitled windows at
|
||||
//! the ordinary level owned by the `komorebi` process, which the Mac listing marks `"border":true`
|
||||
//! (see [`mac_border_owner`]); it cannot say which window one is for, so `border_of` is never set
|
||||
//! there, and its place in the front-to-back order does not say which window it is for (in a
|
||||
//! recording, the borders were listed ahead of the windows they surround). komorebi for KDE
|
||||
//! draws no border windows at all: KWin's rounded-corners effect paints them.
|
||||
//!
|
||||
//! # Threads and cost
|
||||
@@ -194,6 +197,25 @@ pub fn border_class(class: &str) -> Option<Option<u32>> {
|
||||
Some(id.strip_prefix('-').and_then(|id| id.parse().ok()))
|
||||
}
|
||||
|
||||
/// Whether a window of this owner, at the ordinary layer, is one of komorebi for Mac's borders.
|
||||
///
|
||||
/// komorebi for Mac draws each border as a borderless, untitled `NSWindow` of its own at the
|
||||
/// ordinary window level, so the window server lists it like any other window, owned by the `komorebi` process. Nothing else komorebi draws is at that
|
||||
/// level (the animation's ghost window floats above it). A border says nothing of which window it
|
||||
/// is for, so `border_of` is not set from this.
|
||||
///
|
||||
/// ```rust
|
||||
/// use komorebi_recorder::sources::windowtrack::mac_border_owner;
|
||||
///
|
||||
/// assert!(mac_border_owner("komorebi"));
|
||||
/// assert!(!mac_border_owner("komorebic"));
|
||||
/// assert!(!mac_border_owner("Safari"));
|
||||
/// ```
|
||||
#[must_use]
|
||||
pub fn mac_border_owner(owner: &str) -> bool {
|
||||
owner == "komorebi"
|
||||
}
|
||||
|
||||
/// Decides which samples become rows: the first, any that differ from the previous sample, and one
|
||||
/// per [`KEYFRAME_INTERVAL_NS`] otherwise. See the module docs for an example.
|
||||
#[derive(Debug, Default)]
|
||||
@@ -475,6 +497,7 @@ mod tests {
|
||||
assert_eq!(border_class("komoborder-42"), Some(Some(42)));
|
||||
assert_eq!(border_class("komoborder"), Some(None));
|
||||
assert_eq!(border_class("notkomoborder-1"), None);
|
||||
assert!(mac_border_owner("komorebi") && !mac_border_owner("komorebic"));
|
||||
let old = r#"{"mach_ns":1,"windows":[{"id":1,"owner":"a","rect":[0,0,1,1],"visible":true,"minimized":false}]}"#;
|
||||
let row: TrackRow = serde_json::from_str(old).unwrap();
|
||||
assert!(!row.windows[0].border && row.windows[0].border_of.is_none());
|
||||
|
||||
Reference in new issue
Block a user