From b3ca1bd0599829b3dbb6fafb6fe0b7db65c370ca Mon Sep 17 00:00:00 2001 From: jp9000 Date: Wed, 18 Mar 2020 07:51:00 -0700 Subject: [PATCH] win-capture: Retry with last known window if first fails This fixes a bug where games like "Don't Starve Together" wouldn't capture because their actual render window is a completely different window than their actual window on the screen. So, because we already have the hook info by this point with the last known window handle available, instead of using 0 here, we can just use the window handle provided by the shared memory. And we didn't even have to change the hook! That's nice. --- plugins/win-capture/game-capture.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plugins/win-capture/game-capture.c b/plugins/win-capture/game-capture.c index 57d33cfcc..9d0b0f2c2 100644 --- a/plugins/win-capture/game-capture.c +++ b/plugins/win-capture/game-capture.c @@ -1265,10 +1265,12 @@ static inline enum capture_result init_capture_data(struct game_capture *gc) DWORD error = 0; if (!init_data_map(gc, gc->window)) { + HWND retry_hwnd = (HWND)(uintptr_t)gc->global_hook_info->window; error = GetLastError(); - /* if there's an error, try with 0 (for UWP programs) */ - if (init_data_map(gc, NULL)) { + /* if there's an error, just override. some windows don't play + * nice. */ + if (init_data_map(gc, retry_hwnd)) { error = 0; } }