Henri Verbeet : ddraw: Resize the swapchain window on mode changes in exclusive mode.

Alexandre Julliard julliard at winehq.org
Wed Nov 30 14:19:19 CST 2011


Module: wine
Branch: master
Commit: 82dd612d50f8557714f204ca6fa90bee571ca9df
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=82dd612d50f8557714f204ca6fa90bee571ca9df

Author: Henri Verbeet <hverbeet at codeweavers.com>
Date:   Wed Nov 30 06:01:44 2011 +0100

ddraw: Resize the swapchain window on mode changes in exclusive mode.

---

 dlls/d3d10core/device.c |    6 ++++++
 dlls/d3d8/device.c      |    6 ++++++
 dlls/d3d9/device.c      |    6 ++++++
 dlls/ddraw/ddraw.c      |   36 +++++++++++++++++++++++++++++++++---
 dlls/ddraw/tests/d3d.c  |    5 +----
 dlls/wined3d/device.c   |    4 ++++
 include/wine/wined3d.h  |    1 +
 7 files changed, 57 insertions(+), 7 deletions(-)

diff --git a/dlls/d3d10core/device.c b/dlls/d3d10core/device.c
index 45b7c3a..2a84c98 100644
--- a/dlls/d3d10core/device.c
+++ b/dlls/d3d10core/device.c
@@ -1357,6 +1357,11 @@ static void CDECL device_parent_wined3d_device_created(struct wined3d_device_par
     device->wined3d_device = wined3d_device;
 }
 
+static void CDECL device_parent_mode_changed(struct wined3d_device_parent *device_parent)
+{
+    TRACE("device_parent %p.\n", device_parent);
+}
+
 static HRESULT CDECL device_parent_create_surface(struct wined3d_device_parent *device_parent,
         void *container_parent, UINT width, UINT height, enum wined3d_format_id format, DWORD usage,
         WINED3DPOOL pool, UINT level, WINED3DCUBEMAP_FACES face, struct wined3d_surface **surface)
@@ -1538,6 +1543,7 @@ static HRESULT CDECL device_parent_create_swapchain(struct wined3d_device_parent
 static const struct wined3d_device_parent_ops d3d10_wined3d_device_parent_ops =
 {
     device_parent_wined3d_device_created,
+    device_parent_mode_changed,
     device_parent_create_surface,
     device_parent_create_rendertarget,
     device_parent_create_depth_stencil,
diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c
index a8c042d..bbc69b4 100644
--- a/dlls/d3d8/device.c
+++ b/dlls/d3d8/device.c
@@ -2798,6 +2798,11 @@ static void CDECL device_parent_wined3d_device_created(struct wined3d_device_par
     TRACE("device_parent %p, device %p\n", device_parent, device);
 }
 
+static void CDECL device_parent_mode_changed(struct wined3d_device_parent *device_parent)
+{
+    TRACE("device_parent %p.\n", device_parent);
+}
+
 static HRESULT CDECL device_parent_create_surface(struct wined3d_device_parent *device_parent,
         void *container_parent, UINT width, UINT height, enum wined3d_format_id format, DWORD usage,
         WINED3DPOOL pool, UINT level, WINED3DCUBEMAP_FACES face, struct wined3d_surface **surface)
@@ -2999,6 +3004,7 @@ static HRESULT CDECL device_parent_create_swapchain(struct wined3d_device_parent
 static const struct wined3d_device_parent_ops d3d8_wined3d_device_parent_ops =
 {
     device_parent_wined3d_device_created,
+    device_parent_mode_changed,
     device_parent_create_surface,
     device_parent_create_rendertarget,
     device_parent_create_depth_stencil,
diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c
index f8044ff..e5c9d1e 100644
--- a/dlls/d3d9/device.c
+++ b/dlls/d3d9/device.c
@@ -3043,6 +3043,11 @@ static void CDECL device_parent_wined3d_device_created(struct wined3d_device_par
     TRACE("device_parent %p, device %p.\n", device_parent, device);
 }
 
+static void CDECL device_parent_mode_changed(struct wined3d_device_parent *device_parent)
+{
+    TRACE("device_parent %p.\n", device_parent);
+}
+
 static HRESULT CDECL device_parent_create_surface(struct wined3d_device_parent *device_parent,
         void *container_parent, UINT width, UINT height, enum wined3d_format_id format, DWORD usage,
         WINED3DPOOL pool, UINT level, WINED3DCUBEMAP_FACES face, struct wined3d_surface **surface)
@@ -3247,6 +3252,7 @@ static HRESULT CDECL device_parent_create_swapchain(struct wined3d_device_parent
 static const struct wined3d_device_parent_ops d3d9_wined3d_device_parent_ops =
 {
     device_parent_wined3d_device_created,
+    device_parent_mode_changed,
     device_parent_create_surface,
     device_parent_create_rendertarget,
     device_parent_create_depth_stencil,
diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c
index dfe7b37..098165a 100644
--- a/dlls/ddraw/ddraw.c
+++ b/dlls/ddraw/ddraw.c
@@ -1008,9 +1008,6 @@ static HRESULT ddraw_set_display_mode(IDirectDrawImpl *ddraw, DWORD Width, DWORD
     /* TODO: Lose the primary surface */
     hr = wined3d_device_set_display_mode(ddraw->wined3d_device, 0, &mode);
 
-    if (ddraw->cooperative_level & DDSCL_EXCLUSIVE)
-        SetWindowPos(ddraw->dest_window, HWND_TOP, 0, 0, Width, Height, SWP_SHOWWINDOW | SWP_NOACTIVATE);
-
     wined3d_mutex_unlock();
 
     switch(hr)
@@ -5268,6 +5265,38 @@ static void CDECL device_parent_wined3d_device_created(struct wined3d_device_par
     TRACE("device_parent %p, device %p.\n", device_parent, device);
 }
 
+static void CDECL device_parent_mode_changed(struct wined3d_device_parent *device_parent)
+{
+    struct IDirectDrawImpl *ddraw = ddraw_from_device_parent(device_parent);
+    MONITORINFO monitor_info;
+    HMONITOR monitor;
+    BOOL ret;
+    RECT *r;
+
+    TRACE("device_parent %p.\n", device_parent);
+
+    if (!(ddraw->cooperative_level & DDSCL_EXCLUSIVE) || !ddraw->swapchain_window)
+    {
+        TRACE("Nothing to resize.\n");
+        return;
+    }
+
+    monitor = MonitorFromWindow(ddraw->swapchain_window, MONITOR_DEFAULTTOPRIMARY);
+    monitor_info.cbSize = sizeof(monitor_info);
+    if (!(ret = GetMonitorInfoW(monitor, &monitor_info)))
+    {
+        ERR("Failed to get monitor info.\n");
+        return;
+    }
+
+    r = &monitor_info.rcMonitor;
+    TRACE("Resizing window %p to %s.\n", ddraw->swapchain_window, wine_dbgstr_rect(r));
+
+    if (!(ret = SetWindowPos(ddraw->swapchain_window, HWND_TOP, r->left, r->top,
+            r->right - r->left, r->bottom - r->top, SWP_SHOWWINDOW | SWP_NOACTIVATE)))
+        ERR("Failed to resize window.\n");
+}
+
 static HRESULT CDECL device_parent_create_surface(struct wined3d_device_parent *device_parent,
         void *container_parent, UINT width, UINT height, enum wined3d_format_id format, DWORD usage,
         WINED3DPOOL pool, UINT level, WINED3DCUBEMAP_FACES face, struct wined3d_surface **surface)
@@ -5424,6 +5453,7 @@ static HRESULT CDECL device_parent_create_swapchain(struct wined3d_device_parent
 static const struct wined3d_device_parent_ops ddraw_wined3d_device_parent_ops =
 {
     device_parent_wined3d_device_created,
+    device_parent_mode_changed,
     device_parent_create_surface,
     device_parent_create_rendertarget,
     device_parent_create_depth_stencil,
diff --git a/dlls/ddraw/tests/d3d.c b/dlls/ddraw/tests/d3d.c
index 0a42083..153d39f 100644
--- a/dlls/ddraw/tests/d3d.c
+++ b/dlls/ddraw/tests/d3d.c
@@ -4175,10 +4175,7 @@ static void test_coop_level_mode_set(void)
         WM_WINDOWPOSCHANGING,
         WM_WINDOWPOSCHANGED,
         WM_SIZE,
-        /* WM_DISPLAYCHANGE,    This message is received after WM_SIZE on native. However, the
-         *                      more important behaviour is that at the time the WM_SIZE message
-         *                      is processed SM_CXSCREEN and SM_CYSCREEN already have the new
-         *                      values. */
+        WM_DISPLAYCHANGE,
         0,
     };
 
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 0c71232..4c585d4 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -6033,6 +6033,10 @@ LRESULT device_process_message(struct wined3d_device *device, HWND window, BOOL
         if (device->focus_window == window) device->focus_window = NULL;
         else ERR("Window %p is not the focus window for device %p.\n", window, device);
     }
+    else if (message == WM_DISPLAYCHANGE)
+    {
+        device->device_parent->ops->mode_changed(device->device_parent);
+    }
 
     if (unicode)
         return CallWindowProcW(proc, window, message, wparam, lparam);
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
index 1ee94b7..0ba3a08 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -2066,6 +2066,7 @@ struct wined3d_device_parent
 struct wined3d_device_parent_ops
 {
     void (__cdecl *wined3d_device_created)(struct wined3d_device_parent *device_parent, struct wined3d_device *device);
+    void (__cdecl *mode_changed)(struct wined3d_device_parent *device_parent);
     HRESULT (__cdecl *create_surface)(struct wined3d_device_parent *device_parent, void *container_parent,
             UINT width, UINT height, enum wined3d_format_id format_id, DWORD usage, WINED3DPOOL pool,
             UINT level, WINED3DCUBEMAP_FACES face, struct wined3d_surface **surface);




More information about the wine-cvs mailing list