Skip to content

feat(desktop): find the owner's windows, what is never granted, and a picture of one - #169

Merged
httpsphl merged 2 commits into
mainfrom
feat/desktop-see-windows
Oct 4, 2026
Merged

httpsphl merged 2 commits into
mainfrom
feat/desktop-see-windows

Conversation

@httpsphl

@httpsphl httpsphl commented Oct 4, 2026

Copy link
Copy Markdown
Owner

What

The first part of D1 (spec 24.3, 24.4). It is only the platform layer: nothing calls it yet, and the bot's tools come in D1c.

  • Windows. platform::desktop::windows() lists the top-level windows of the owner's session:
    • shown or minimized, with a title;
    • not tool windows, and not cloaked ones (hidden Store apps, other virtual desktops).
  • Each window's program:
    • its executable, named by the FileDescription in its version info (for example "Microsoft Excel");
    • a Store app by the core window inside its ApplicationFrameHost frame;
    • whether it runs as administrator. A process whose rights cannot be read counts as administrator.
  • Never granted (blocked.rs), pure code with tests:
    • Botloft itself;
    • elevated windows;
    • terminals and command boxes: cmd, PowerShell and its ISE, Windows Terminal, WSL, Git Bash, the Run box, regedit, mmc consoles, Task Manager;
    • password managers, Windows Security, the credential prompt, and the Credential Manager (known by its title in en, pt-BR and es).
  • Picture. platform::desktop::picture(id):
    • uses PrintWindow with PW_RENDERFULLCONTENT, measured in real pixels (per-monitor DPI on the thread);
    • is cropped to the DWM frame, without the invisible resize border;
    • is shrunk to logical pixels, up to 1600×1200, and encoded as a JPEG at quality 70. This adds the jpeg-encoder crate (pure Rust, no dependencies).
  • Other systems: Linux and macOS answer that the desktop is not available yet.
  • Spec 24.3 and 24.4 are updated with these details. Section 19 notes what the real test showed.

Checks

  • cargo fmt and clippy -D warnings pass on Windows.
  • Unit tests cover the never-granted list and the picture shrink.
  • Three tests use a real window of the test's own on Windows 11:
    • it is listed with its app;
    • its picture is red and the right size;
    • minimized, it is listed and has no picture; closed, it is gone.
  • Linux and macOS are checked by CI only. The shrink code there is test-only, so it is marked to avoid dead-code warnings.
  • Still to check (spec 19): PrintWindow on GPU apps (Chromium, Electron) and while the screen is locked.

… picture of one

The first part of D1 (spec 24.3, 24.4), in the platform layer: the
top-level windows of the owner's session (shown or minimized, with a
title, not tool windows nor cloaked ones), the program each one is from
(its executable, named by its file description; a Store app by the core
window inside its frame) and whether it runs as administrator. The list
of what is never granted (Botloft, elevated windows, terminals and
command boxes with the Run box, Task Manager, password managers and the
Credential Manager) is pure code with tests. A picture of a window comes
from PrintWindow with full content, in real pixels, cropped to the DWM
frame, shrunk to logical pixels up to 1600 x 1200 and encoded as a JPEG
(jpeg-encoder). Other systems say the desktop is not there yet.

Tested with a real window of the test's own on Windows 11: listed with
its app, pictured red behind others, minimized, closed.
@httpsphl
httpsphl merged commit bde45c3 into main Oct 4, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant