Skip to content

rust: Port the window match rating and window list filters to obs-util #3154

Closed

Description

@rdoupe

Unit

Port the pure decisions of libobs/util/windows/window-helpers.c.h to rust/obs-util, as a new module window_match, next to platform_windows and dstr. On Windows they decide which windows the window and game capture property lists show, and which window a capture source reattaches to when its window reopens:

  • is_microsoft_internal_window_exe (210-226), with its tables internal_microsoft_exes_exact (185-202) and internal_microsoft_exes_partial (205-208): 15 exact names compared case-insensitively, and the prefix windowsinternal;
  • the skip filter in add_window (236-248): an internal exe is skipped, and so is explorer.exe with an empty title (a case-sensitive compare, unlike the list above);
  • the score in window_rating (431-455): the generic-class demotion, the UWP title-only match, and the class, title and exe priorities, with 0x7FFFFFFF as "no match" and the 0x1000 exe penalty under the class priority;
  • is_generic_class (464-481): a case-insensitive substring search for Chrome or SDL_app;
  • is_uwp_class (483-487): an exact compare with Windows.UI.Core.CoreWindow or WinUIDesktopWin32WindowClass.

These stay in C: ms_get_window_exe, ms_get_window_title and ms_get_window_class and every call to them (the reads in window_rating and add_window stay where they are), the three dstr_cmpi compares of window_rating, check_window_valid, IsWindowCloaked, ms_is_uwp_window, ms_get_uwp_actual_window, first_window, next_window, ms_fill_window_list, EnumWindows and enum_windows_proc's stop rule, the best-so-far compares in ms_find_window and enum_windows_proc, the callback, the string building and obs_property_list_add_string in add_window, every dstr_free, ms_build_window_strings and ms_check_window_property_setting.

Phase and position

Phase 6, Windows host code in the windows+ unity group, beside the WASAPI monitor delay port (#3105). Tracking: #4.

Dependencies and existing tests

  • No dependency; no open PR touches window-helpers.c.h or the windows+ group.
  • Real libobs: no test reaches these functions; they build only on Windows.
  • No characterization: test_window_match_steps lands first in the same PR. The moved file includes no Windows header, so it builds and runs on every OS.

Notes

One PR, separate commits: the behaviour-neutral move into libobs/util/windows/window-match.c.h (hidden functions over C strings, bools and ints; the three compares stay in window_rating, which passes their results), characterization, RED, GREEN (group libobs.ported-window-match), Tier 3 (exhaustive over the priorities, the flags and title distances; every internal name in each case pattern; the class substrings at every offset and case, with non-ASCII bytes), docs.

No intentional difference is expected. astrcmpi, astrcmpi_n and astrstri fold with tolower per byte; the Rust folds ASCII only, which is the same in the C locale libobs runs in, and Tier 3 runs over every byte value to show it.

Activity

  1. added
    enhancement
    port
    on Oct 31, 2026
  2. rdoupe commented on Oct 31, 2026

    @rdoupe
    CollaboratorAuthor

    Claiming: the window match rating and window list filters port.

    Plan, one PR:

    1. Move the internal-exe, generic-class and UWP-class tests, add_window's skip test and window_rating's score chain into libobs/util/windows/window-match.c.h as hidden functions; window_rating keeps its three reads and three compares.
    2. Characterize them with test_window_match_steps (cmocka, every OS).
    3. RED: obs_util::window_match Tier 1 against todo!().
    4. GREEN: the safe core and src/ffi/window_match.rs, in libobs.ported-window-match.
    5. Tier 3: an oracle of the moved file and parity tests, with a mutation check.
    6. Docs.

    Draft PR with the RED commit expected within a few hours.

  3. added
    ready
    on Oct 31, 2026
  4. rdoupe commented on Oct 31, 2026

    @rdoupe
    CollaboratorAuthor

    Fixed by the pull request that ports the window match decisions (PR #3156), merged through the merge queue. The pure decisions of libobs/util/windows/window-helpers.c.h (which windows the window and game capture lists hide, and how well a window matches a capture source's saved window) now run in obs_util::window_match, with all four test tiers and no change in behaviour.

    What is left: nothing of this unit. The window reads, the three dstr_cmpi compares, check_window_valid, the window enumeration and the list building stay in C by design, as the issue lists. Two behaviours are characterized, not endorsed: Explorer.exe (any case but lower) with an empty title is listed, and a priority outside the three matches nothing but a UWP window by its exact title.

    Follow-up issue: none; there is no remainder to port.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementportready

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions