From: Paul Gofman <pgofman@codeweavers.com> --- dlls/win32u/opengl.c | 10 ++++++++-- include/wine/opengl_driver.h | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/dlls/win32u/opengl.c b/dlls/win32u/opengl.c index 3617712a4ae..ff8e40666bc 100644 --- a/dlls/win32u/opengl.c +++ b/dlls/win32u/opengl.c @@ -1429,7 +1429,7 @@ static struct opengl_drawable *get_window_unused_drawable( HWND hwnd, int format static void set_dc_opengl_drawable( HDC hdc, struct opengl_drawable *new_drawable ) { - void *old_drawable = NULL; + struct opengl_drawable *old_drawable = NULL; DC *dc; TRACE( "hdc %p, new_drawable %s\n", hdc, debugstr_opengl_drawable( new_drawable ) ); @@ -1437,7 +1437,12 @@ static void set_dc_opengl_drawable( HDC hdc, struct opengl_drawable *new_drawabl if ((dc = get_dc_ptr( hdc ))) { old_drawable = dc->opengl_drawable; - if ((dc->opengl_drawable = new_drawable)) opengl_drawable_add_ref( new_drawable ); + if ((dc->opengl_drawable = new_drawable)) + { + new_drawable->owner_hdc = hdc; + opengl_drawable_add_ref( new_drawable ); + } + if (old_drawable) old_drawable->owner_hdc = 0; release_dc_ptr( dc ); } @@ -1809,6 +1814,7 @@ static struct opengl_drawable *get_updated_drawable( HDC hdc, int format, struct } /* retrieve D3D internal drawables from the DCs if they have any */ + if (!hdc && drawable) hdc = drawable->owner_hdc; if (hdc && (drawable = get_dc_opengl_drawable( hdc ))) return drawable; /* get an updated drawable with the desired format */ diff --git a/include/wine/opengl_driver.h b/include/wine/opengl_driver.h index 470850c9d49..7b2cea0a87b 100644 --- a/include/wine/opengl_driver.h +++ b/include/wine/opengl_driver.h @@ -191,6 +191,7 @@ struct opengl_drawable LONG ref; /* reference count */ struct list entry; /* entry in cleanup lists */ struct client_surface *client; /* underlying client surface */ + HDC owner_hdc; /* HDC owning the drawable, if any (for pbuffer / D3D swapchains) */ int format; /* pixel format of the drawable */ int interval; /* last set surface swap interval */ BOOL doublebuffer; /* pixel format is double buffered */ -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10190