Browse Source

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.
jp9000 5 năm trước cách đây
mục cha
commit
b3ca1bd059
1 tập tin đã thay đổi với 4 bổ sung2 xóa
  1. 4 2
      plugins/win-capture/game-capture.c

+ 4 - 2
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;
 		}
 	}