[0.4.12][DDRAW] ddraw.c ddraw7_FlipToGDISurface() to Wine-6.8 (#3827) CORE-15128
authorJoachim Henze <Joachim.Henze@reactos.org>
Fri, 21 Jan 2022 04:59:02 +0000 (05:59 +0100)
committerJoachim Henze <Joachim.Henze@reactos.org>
Fri, 21 Jan 2022 04:59:02 +0000 (05:59 +0100)
fixes CORE-15128 "Fall 0.1.3, black controls all over the desktop after exiting the game"
which regressed by 0.4.9-dev-155-g 9987f02917539e05268ba2ad11e62d24a3636972
(the sync to Wine Staging 3.3)

the patch on top of 0.4.15-dev-2923-g2210d23:
KVM: https://reactos.org/testman/compare.php?ids=78290,78295 LGTM
VBox: https://reactos.org/testman/compare.php?ids=78291,78294 LGTM

fix picked from 0.4.15-dev-2929-g 34d5d1dbd43af0d51fa09cb4b7b1b5d830e18c6d

dll/directx/wine/ddraw/ddraw.c

index e5205c0..e5acf2c 100644 (file)
@@ -2093,15 +2093,31 @@ static HRESULT WINAPI d3d1_Initialize(IDirect3D *iface, REFIID riid)
 static HRESULT WINAPI ddraw7_FlipToGDISurface(IDirectDraw7 *iface)
 {
     struct ddraw *ddraw = impl_from_IDirectDraw7(iface);
+    IDirectDrawSurface7 *gdi_surface;
+    struct ddraw_surface *gdi_impl;
+    HRESULT hr;
 
     TRACE("iface %p.\n", iface);
 
-    ddraw->flags |= DDRAW_GDI_FLIP;
+    wined3d_mutex_lock();
 
-    if (ddraw->primary)
-        ddraw_surface_update_frontbuffer(ddraw->primary, NULL, FALSE);
+    if (FAILED(hr = IDirectDraw7_GetGDISurface(iface, &gdi_surface)))
+    {
+        WARN("Failed to retrieve GDI surface, hr %#x.\n", hr);
+        wined3d_mutex_unlock();
+        return hr;
+    }
 
-    return DD_OK;
+    gdi_impl = impl_from_IDirectDrawSurface7(gdi_surface);
+    if (gdi_impl->surface_desc.ddsCaps.dwCaps & DDSCAPS_FRONTBUFFER)
+        hr = DD_OK;
+    else
+        hr = IDirectDrawSurface7_Flip(&ddraw->primary->IDirectDrawSurface7_iface, gdi_surface, DDFLIP_WAIT);
+    IDirectDrawSurface7_Release(gdi_surface);
+
+    wined3d_mutex_unlock();
+
+    return hr;
 }
 
 static HRESULT WINAPI ddraw4_FlipToGDISurface(IDirectDraw4 *iface)