From a408faad22694f7dd6b9e24b3f47ac60fc6f4c4f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Wed, 3 Jun 2015 22:57:21 +0200
Subject: winex11.drv: Allow changing the opengl pixel format on the desktop
 window.

This patch is not 100% correct because the old behavior was more similar to
windows. However, Direct3D supports using the desktop window to create a
context and since Wine translates Direct3D to OpenGL, using the desktop
window will fail because of this limitation. Unless someone comes up with
a more correct solution or finds an application that breaks because of this,
it seems to be a suitable workaround as it fixes multiple applications.
---
 dlls/d3d9/tests/device.c  | 16 ++++++++++++++++
 dlls/winex11.drv/opengl.c |  5 ++++-
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/dlls/d3d9/tests/device.c b/dlls/d3d9/tests/device.c
index 5bf7121..0c2df95 100644
--- a/dlls/d3d9/tests/device.c
+++ b/dlls/d3d9/tests/device.c
@@ -10769,6 +10769,21 @@ static void test_check_device_format(void)
     IDirect3D9_Release(d3d);
 }
 
+static void test_desktop_window(void)
+{
+    IDirect3DDevice9 *device = NULL;
+    IDirect3D9 *d3d;
+
+    d3d = Direct3DCreate9(D3D_SDK_VERSION);
+    ok(!!d3d, "Failed to create a D3D object.\n");
+
+    device = create_device(d3d, GetDesktopWindow(), NULL);
+    ok(!!device, "Failed to created device on desktop window.\n");
+
+    if (device) IDirect3DDevice9_Release(device);
+    IDirect3D9_Release(d3d);
+}
+
 START_TEST(device)
 {
     WNDCLASSA wc = {0};
@@ -10883,6 +10898,7 @@ START_TEST(device)
     test_resource_priority();
     test_swapchain_parameters();
     test_check_device_format();
+    test_desktop_window();
 
     UnregisterClassA("d3d9_test_wc", GetModuleHandleA(NULL));
 }
diff --git a/dlls/winex11.drv/opengl.c b/dlls/winex11.drv/opengl.c
index 3d0bd24..845b022 100644
--- a/dlls/winex11.drv/opengl.c
+++ b/dlls/winex11.drv/opengl.c
@@ -1434,12 +1434,15 @@ static BOOL set_pixel_format(HDC hdc, int format, BOOL allow_change)
 
     TRACE("(%p,%d)\n", hdc, format);
 
-    if (!hwnd || hwnd == GetDesktopWindow())
+    if (!hwnd)
     {
         WARN( "not a valid window DC %p/%p\n", hdc, hwnd );
         return FALSE;
     }
 
+    if (hwnd == GetDesktopWindow())
+        FIXME("Using desktop window for OpenGL is not supported on windows\n");
+
     fmt = get_pixel_format(gdi_display, format, FALSE /* Offscreen */);
     if (!fmt)
     {
-- 
2.7.0

