From 992e3055b53b00ca290d8ffbec4923f155fe5726 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Iv=C4=83ncescu?= Date: Thu, 30 Jul 2020 16:42:29 +0430 Subject: [PATCH] ddraw: Check the foreground window in addition to the device state in ddraw_update_lost_surfaces(). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Gabriel Ivăncescu Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- dlls/ddraw/ddraw.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c index 3cbde6ea84b..d7545e5c82c 100644 --- a/dlls/ddraw/ddraw.c +++ b/dlls/ddraw/ddraw.c @@ -4975,6 +4975,19 @@ void ddraw_update_lost_surfaces(struct ddraw *ddraw) { struct ddraw_surface *surface; + /* Railroad Tycoon 2 tries to restore surfaces from within a + * WM_QUERYNEWPALETTE message handler and expects it to succeed. We + * haven't received the WM_ACTIVATEAPP message by that point, so the + * device state is still DDRAW_DEVICE_STATE_LOST, even though we are in + * the foreground. */ + if (ddraw->device_state == DDRAW_DEVICE_STATE_LOST) + { + HWND window = ddraw->focuswindow ? ddraw->focuswindow : ddraw->dest_window; + + if (window && GetForegroundWindow() == window) + ddraw->device_state = DDRAW_DEVICE_STATE_NOT_RESTORED; + } + if (ddraw->device_state != DDRAW_DEVICE_STATE_NOT_RESTORED) return;