feat(posix): allow optional HOS_WINDOW_TITLE and HOS_WM_CLASS env overrides #2116
No reviewers
Labels
No labels
accessibility
autorelease: pending
autorelease: tagged
bug
dependencies
documentation
duplicate
enhancement
github_actions
good first issue
help wanted
invalid
question
testing wanted
wontfix
No milestone
No assignees
1 participant
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Hookshot!2116
Loading…
Reference in a new issue
No description provided.
Delete branch "posix/window-title-class-env"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Status Note vs Hookshot v2.1.0
Upstream
v2.1.0/mainalready merged:hos_renderer_wait()(517f029/6076069)hos_sdl_identity()(SDL_SetAppMetadataon SDL3,SDL_APP_NAME/SDL_VIDEO_WAYLAND_WMCLASS/SDL_VIDEO_X11_WMCLASSon SDL2)hookshot.pngviahos_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, addswindow_title(fallback)and readsHOS_WINDOW_TITLE/HOS_WM_CLASS:"Hookshot"/HOS_GAME_TITLEandHOS_APP_ID).HOS_APP_IDpassed tohos_sdl_identity()(working across both SDL3SDL_SetAppMetadataand SDL2 WMClass vars), and the SDL window title.NVIDIA & Cross-Platform Compatibility
HOS_WINDOW_TITLE/HOS_WM_CLASSare explicitly exported.Files Changed
host/posix/display_sdl.cTest Plan / Verification
git apply --checkagainstmain(ca082bf).host/posix/display_sdl.c(clang -fsyntax-only -std=gnu11 -Wall -Wextra -Wno-macro-redefined -Wno-unused-parameter): 0 errors, 0 warnings.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:
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.window_titleand checks unset, empty and set would do, and that the file is declared for run_all.env_on/env_intfrom gpu/vk/compat/hookshot_env.h (HOS_HEADLESS isenv_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");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.It no longer applies to main (
hos_display_initnow starts withenv_on("HOS_HEADLESS"),display_sdl.c:211), though the rebase is trivial. Things to consider:HOS_WM_CLASSreplacesHOS_APP_ID, which the builder writes asStartupWMClass(hookshot_builder.py:162), so overriding it breaks icon and menu grouping.docs/development.md.hos_display_init's doc comment and the function.#2042 just trimmed switches, so is there a user asking for these?
github-sync referenced this pull request2026-11-12 06:22:54 +00:00