DXGL r895 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r894‎ | r895 | r896 >
Date:01:40, 4 March 2019
Author:admin
Status:new
Tags:
Comment:
Support window mode on multiple monitors, when primary monitor is at coordinates 0,0
Modified paths:
  • /ddraw/glDirectDraw.cpp (modified) (history)
  • /ddraw/glDirectDrawSurface.cpp (modified) (history)

Diff [purge]

Index: ddraw/glDirectDraw.cpp
@@ -1797,6 +1797,9 @@
17981798 if(hWnd && !IsWindow(hWnd)) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
17991799 if ((dwFlags & DDSCL_EXCLUSIVE) && !hWnd) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
18001800 if(dwFlags & 0xFFFFE020) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
 1801+ DWORD winver = GetVersion();
 1802+ DWORD winvermajor = (DWORD)(LOBYTE(LOWORD(winver)));
 1803+ DWORD winverminor = (DWORD)(HIBYTE(LOWORD(winver)));
18011804 /*if (((hWnd != this->hWnd) && this->hWnd) || (this->hWnd && (dwFlags & DDSCL_NORMAL)))
18021805 {
18031806 if (winstyle)
@@ -1877,8 +1880,16 @@
18781881 GetClientRect(hWnd,&rect);
18791882 x = rect.right - rect.left;
18801883 y = rect.bottom - rect.top;
1881 - internalx = screenx = primaryx = devmode.dmPelsWidth;
1882 - internaly = screeny = primaryy = devmode.dmPelsHeight;
 1884+ if ((winvermajor > 4) || ((winvermajor == 4) && (winverminor >= 1)))
 1885+ {
 1886+ internalx = screenx = primaryx = GetSystemMetrics(SM_CXVIRTUALSCREEN);
 1887+ internaly = screeny = primaryy = GetSystemMetrics(SM_CYVIRTUALSCREEN);
 1888+ }
 1889+ else
 1890+ {
 1891+ internalx = screenx = primaryx = devmode.dmPelsWidth;
 1892+ internaly = screeny = primaryy = devmode.dmPelsHeight;
 1893+ }
18831894 }
18841895 bpp = devmode.dmBitsPerPel;
18851896 internalrefresh = primaryrefresh = screenrefresh = devmode.dmDisplayFrequency;
Index: ddraw/glDirectDrawSurface.cpp
@@ -75,6 +75,7 @@
7676 LONG sizes[6];
7777 int i;
7878 float xscale, yscale;
 79+ DWORD winver, winvermajor, winverminor;
7980 ddInterface->GetSizes(sizes);
8081 if(ddsd.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
8182 {
@@ -184,8 +185,19 @@
185186 }
186187 else
187188 {
188 - fakex = ddsd.dwWidth = GetSystemMetrics(SM_CXSCREEN);
189 - fakey = ddsd.dwHeight = GetSystemMetrics(SM_CYSCREEN);
 189+ winver = GetVersion();
 190+ winvermajor = (DWORD)(LOBYTE(LOWORD(winver)));
 191+ winverminor = (DWORD)(HIBYTE(LOWORD(winver)));
 192+ if ((winvermajor > 4) || ((winvermajor == 4) && (winverminor >= 1)))
 193+ {
 194+ fakex = ddsd.dwWidth = GetSystemMetrics(SM_CXVIRTUALSCREEN);
 195+ fakey = ddsd.dwHeight = GetSystemMetrics(SM_CYVIRTUALSCREEN);
 196+ }
 197+ else
 198+ {
 199+ fakex = ddsd.dwWidth = GetSystemMetrics(SM_CXSCREEN);
 200+ fakey = ddsd.dwHeight = GetSystemMetrics(SM_CYSCREEN);
 201+ }
190202 ddsd.dwFlags |= (DDSD_WIDTH | DDSD_HEIGHT);
191203 *error = DD_OK;
192204 }