From dd47f60c4f69e23fdc821b6ee44a9deea2c3c81d Mon Sep 17 00:00:00 2001 From: qhukz13 Date: Thu, 26 Nov 2026 00:41:50 +0200 Subject: [PATCH] title_window, xgameruntime_offline: skip what needs a desktop when there is no interactive window station Over OpenSSH or as a service (session 0) the process's window station is not interactive: no window is visible there, so find_title_window has nothing to pick, and PowerSetRequest(PowerRequestDisplayRequired) answers ERROR_NOT_SUPPORTED, so XDisplayAcquireTimeoutDeferral fails (measured on Windows 10 19045 over SSH; the system and away-mode requests work there). From a desktop session both tests pass (measured in an RDP session on the same machine). title_window returns 77 (SKIP) without an interactive station; xgameruntime_offline skips only its two display-deferral checks, and only when the request is refused with ERROR_NOT_SUPPORTED there. Both use window_station.h's has_interactive_window_station(), as the DXGI tests do. #1217 documents the SSH difference. Co-Authored-By: Claude Opus 5.5 --- runtime/CMakeLists.txt | 1 + runtime/test/title_window_test.cpp | 5 +++++ runtime/test/xgameruntime_offline_test.cpp | 22 +++++++++++++++------- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/runtime/CMakeLists.txt b/runtime/CMakeLists.txt index bea9a82d88..f3aa483cf4 100644 --- a/runtime/CMakeLists.txt +++ b/runtime/CMakeLists.txt @@ -765,6 +765,7 @@ if(BUILD_TESTING) endif() target_link_libraries(title_window_test PRIVATE user32) add_test(NAME title_window COMMAND title_window_test) + set_tests_properties(title_window PROPERTIES SKIP_RETURN_CODE 77) # no interactive window station (SSH, service) # LEONIDA_TITLE_HUD's counters in the title bar of another thread's window (shims/title_hud.h): user32 and DXGI. add_executable(title_hud_test test/title_hud_test.cpp) diff --git a/runtime/test/title_window_test.cpp b/runtime/test/title_window_test.cpp index b3ea9ac825..c6edce94b2 100644 --- a/runtime/test/title_window_test.cpp +++ b/runtime/test/title_window_test.cpp @@ -5,6 +5,7 @@ // sent message (WM_GETTEXT, what GetWindowTextW sends across threads, times out), so a lookup that sent one would block. #include "title_window.h" +#include "window_station.h" #include #include @@ -32,6 +33,10 @@ HWND make(const wchar_t* name, DWORD ex_style, DWORD style, int width, int heigh } // namespace int main() { + if (!has_interactive_window_station()) { + std::printf("SKIP: no interactive window station (an SSH or service session): no window is visible here\n"); + return 77; + } WNDCLASSW window_class{}; window_class.lpfnWndProc = DefWindowProcW; window_class.hInstance = GetModuleHandleW(nullptr); diff --git a/runtime/test/xgameruntime_offline_test.cpp b/runtime/test/xgameruntime_offline_test.cpp index b441868ba5..f94bf3ccc9 100644 --- a/runtime/test/xgameruntime_offline_test.cpp +++ b/runtime/test/xgameruntime_offline_test.cpp @@ -15,6 +15,7 @@ #include #include "shims.h" +#include "window_station.h" namespace rt::shims { long xgameruntime_offline_game_events(); @@ -379,13 +380,20 @@ int main() { "XLaunchUri is not available offline"); check(at(launcher, 4)(launcher, nullptr) == E_POINTER, "XDisplayAcquireTimeoutDeferral rejects null out pointer"); - check(at(launcher, 4)(launcher, &deferral) == S_OK && deferral != nullptr, - "XDisplayAcquireTimeoutDeferral acquires a display power request handle"); - void* second = nullptr; - check(at(launcher, 4)(launcher, &second) == S_OK && second && second != deferral, - "concurrent display deferrals have distinct handles"); - at(launcher, 5)(launcher, second); - at(launcher, 5)(launcher, deferral); + const HRESULT acquired = at(launcher, 4)(launcher, &deferral); + if (acquired == HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED) && !has_interactive_window_station()) { + // No desktop to keep on: the request is refused, and the shim passes that on with nothing to close. + check(deferral == nullptr, "a refused display deferral leaves no handle"); + std::printf("SKIP display deferral handles: no interactive window station (an SSH or service session)\n"); + } else { + check(acquired == S_OK && deferral != nullptr, + "XDisplayAcquireTimeoutDeferral acquires a display power request handle"); + void* second = nullptr; + check(at(launcher, 4)(launcher, &second) == S_OK && second && second != deferral, + "concurrent display deferrals have distinct handles"); + at(launcher, 5)(launcher, second); + at(launcher, 5)(launcher, deferral); + } at(launcher, 5)(launcher, nullptr); check(true, "XDisplayCloseTimeoutDeferralHandle closes handle and ignores null"); GUID other = kLauncherClass;