feat(posix): allow optional HOS_WINDOW_TITLE and HOS_WM_CLASS env overrides #2116

Merged
Cloudiny merged 1 commit from posix/window-title-class-env into main 2026-11-12 03:04:01 +00:00
Cloudiny commented 2026-11-11 03:36:43 +00:00 (Migrated from github.com)

Status Note vs Hookshot v2.1.0

Upstream v2.1.0 / main already merged:

  • hos_renderer_wait() (517f029 / 6076069)
  • hos_sdl_identity() (SDL_SetAppMetadata on SDL3, SDL_APP_NAME / SDL_VIDEO_WAYLAND_WMCLASS / SDL_VIDEO_X11_WMCLASS on SDL2)
  • Window icon loading (hookshot.png via hos_sdl_icon())

This narrowed PR only keeps the remaining quality-of-life feature not yet in upstream: optional runtime environment overrides for window title and Wayland/X11 app_id / WM_CLASS.

Summary

In host/posix/display_sdl.c, adds window_title(fallback) and reads HOS_WINDOW_TITLE / HOS_WM_CLASS:

  • When unset or empty, preserves exact upstream behavior ("Hookshot" / HOS_GAME_TITLE and HOS_APP_ID).
  • When set, overrides the SDL identity app name, HOS_APP_ID passed to hos_sdl_identity() (working across both SDL3 SDL_SetAppMetadata and SDL2 WMClass vars), and the SDL window title.

NVIDIA & Cross-Platform Compatibility

  • POSIX/SDL-only change; zero impact on Windows builds or GPU drivers unless HOS_WINDOW_TITLE / HOS_WM_CLASS are explicitly exported.

Files Changed

  • host/posix/display_sdl.c

Test Plan / Verification

  • Verified clean git apply --check against main (ca082bf).
  • Syntax-checked host/posix/display_sdl.c (clang -fsyntax-only -std=gnu11 -Wall -Wextra -Wno-macro-redefined -Wno-unused-parameter): 0 errors, 0 warnings.
## Status Note vs Hookshot v2.1.0 Upstream `v2.1.0` / `main` **already merged**: - `hos_renderer_wait()` (`517f029` / `6076069`) - `hos_sdl_identity()` (`SDL_SetAppMetadata` on SDL3, `SDL_APP_NAME` / `SDL_VIDEO_WAYLAND_WMCLASS` / `SDL_VIDEO_X11_WMCLASS` on SDL2) - Window icon loading (`hookshot.png` via `hos_sdl_icon()`) This narrowed PR only keeps the remaining quality-of-life feature not yet in upstream: optional runtime environment overrides for window title and Wayland/X11 `app_id` / `WM_CLASS`. ## Summary In `host/posix/display_sdl.c`, adds `window_title(fallback)` and reads `HOS_WINDOW_TITLE` / `HOS_WM_CLASS`: - When unset or empty, preserves exact upstream behavior (`"Hookshot"` / `HOS_GAME_TITLE` and `HOS_APP_ID`). - When set, overrides the SDL identity app name, `HOS_APP_ID` passed to `hos_sdl_identity()` (working across both SDL3 `SDL_SetAppMetadata` and SDL2 WMClass vars), and the SDL window title. ## NVIDIA & Cross-Platform Compatibility - POSIX/SDL-only change; zero impact on Windows builds or GPU drivers unless `HOS_WINDOW_TITLE` / `HOS_WM_CLASS` are explicitly exported. ## Files Changed - `host/posix/display_sdl.c` ## Test Plan / Verification - [x] Verified clean `git apply --check` against `main` (`ca082bf`). - [x] Syntax-checked `host/posix/display_sdl.c` (`clang -fsyntax-only -std=gnu11 -Wall -Wextra -Wno-macro-redefined -Wno-unused-parameter`): 0 errors, 0 warnings.
hckrman101 (Migrated from github.com) reviewed 2026-11-11 18:24:14 +00:00
hckrman101 (Migrated from github.com) left a comment

Thanks, small and contained, and with both vars unset the behaviour is unchanged ("Hookshot" / HOS_GAME_TITLE / HOS_APP_ID). The mapping looks right: hos_sdl_identity covers SDL3 app id and the SDL2 WMCLASS vars, the title goes to the window. I only read the diff, I did not run it.

What I'd like before merge:

  • Docs. The env switches are listed in docs/development.md (the HOS_WINDOW_SIZE=<w>x<h> row, about line 79). Please add rows for HOS_WINDOW_TITLE and HOS_WM_CLASS there, and say that HOS_WM_CLASS replaces the app id / WM_CLASS the desktop file is matched on, so a value that differs from the .desktop name or StartupWMClass loses the taskbar icon grouping.
  • A test. tests/ has nothing for this, and the PR only syntax-checks. Following the other source-reading checks (e.g. tests/test_env_file.py cuts a function out and compiles it with stubs), a small one that cuts out window_title and checks unset, empty and set would do, and that the file is declared for run_all.
  • Env helpers. main now reads switches with env_on/env_int from gpu/vk/compat/hookshot_env.h (HOS_HEADLESS is env_on(...) there now; this branch's base still shows the old getenv). These two are strings so plain getenv is fine, and the empty-means-unset check matches that file's rule. Since values can also come from hookshot_env.txt, it would be good for the test or docs to say whether a title with spaces survives that file's parsing; I did not verify it.

Nits: window_title is a one-line helper while HOS_WM_CLASS is open-coded; one helper env_str(name, fallback) would serve both. Titles are passed through as the raw bytes of the environment, which is UTF-8 on Linux, so no conversion is needed here. The change is POSIX only; on Windows the switches do nothing, which the PR says, fine.

CI: only the title check ran and passes; no test coverage of the change.

Thanks, small and contained, and with both vars unset the behaviour is unchanged ("Hookshot" / HOS_GAME_TITLE / HOS_APP_ID). The mapping looks right: hos_sdl_identity covers SDL3 app id and the SDL2 WMCLASS vars, the title goes to the window. I only read the diff, I did not run it. What I'd like before merge: - **Docs.** The env switches are listed in docs/development.md (the `HOS_WINDOW_SIZE=<w>x<h>` row, about line 79). Please add rows for HOS_WINDOW_TITLE and HOS_WM_CLASS there, and say that HOS_WM_CLASS replaces the app id / WM_CLASS the desktop file is matched on, so a value that differs from the .desktop name or StartupWMClass loses the taskbar icon grouping. - **A test.** tests/ has nothing for this, and the PR only syntax-checks. Following the other source-reading checks (e.g. tests/test_env_file.py cuts a function out and compiles it with stubs), a small one that cuts out `window_title` and checks unset, empty and set would do, and that the file is declared for run_all. - **Env helpers.** main now reads switches with `env_on`/`env_int` from gpu/vk/compat/hookshot_env.h (HOS_HEADLESS is `env_on(...)` there now; this branch's base still shows the old getenv). These two are strings so plain getenv is fine, and the empty-means-unset check matches that file's rule. Since values can also come from hookshot_env.txt, it would be good for the test or docs to say whether a title with spaces survives that file's parsing; I did not verify it. Nits: window_title is a one-line helper while HOS_WM_CLASS is open-coded; one helper `env_str(name, fallback)` would serve both. Titles are passed through as the raw bytes of the environment, which is UTF-8 on Linux, so no conversion is needed here. The change is POSIX only; on Windows the switches do nothing, which the PR says, fine. CI: only the title check ran and passes; no test coverage of the change.
@ -205,2 +205,4 @@
/* main(), before the game: SDL's video on this, the main, thread; the screen's size for GetSystemMetrics.
Returns 1 when ready, 0 for explicit headless, -1 for startup failure. */
static const char *window_title(const char *fallback) {
const char *e = getenv("HOS_WINDOW_TITLE");
hckrman101 (Migrated from github.com) commented 2026-11-11 18:24:15 +00:00

Nit: an env_str(name, fallback) helper used here and for HOS_WM_CLASS below would avoid the two spellings of the same empty-means-unset rule.

Nit: an `env_str(name, fallback)` helper used here and for HOS_WM_CLASS below would avoid the two spellings of the same empty-means-unset rule.
Joey-Magnus (Migrated from github.com) reviewed 2026-11-11 21:26:10 +00:00
Joey-Magnus (Migrated from github.com) left a comment

It no longer applies to main (hos_display_init now starts with env_on("HOS_HEADLESS"), display_sdl.c:211), though the rebase is trivial. Things to consider:

  • HOS_WM_CLASS replaces HOS_APP_ID, which the builder writes as StartupWMClass (hookshot_builder.py:162), so overriding it breaks icon and menu grouping.
  • Neither switch is in docs/development.md.
  • The helper sits between hos_display_init's doc comment and the function.

#2042 just trimmed switches, so is there a user asking for these?

It no longer applies to main (`hos_display_init` now starts with `env_on("HOS_HEADLESS")`, `display_sdl.c:211`), though the rebase is trivial. Things to consider: - `HOS_WM_CLASS` replaces `HOS_APP_ID`, which the builder writes as `StartupWMClass` (`hookshot_builder.py:162`), so overriding it breaks icon and menu grouping. - Neither switch is in `docs/development.md`. - The helper sits between `hos_display_init`'s doc comment and the function. #2042 just trimmed switches, so is there a user asking for these?
Commenting is not possible because the repository is archived.
No description provided.