DXGL r789 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r788‎ | r789 | r790 >
Date:03:25, 2 March 2018
Author:admin
Status:new
Tags:
Comment:
Save window position and size at close in forced window mode.
Implement remembering position and size of window in forced window mode.
Modified paths:
  • /ddraw/glRenderer.cpp (modified) (history)

Diff [purge]

Index: ddraw/glRenderer.cpp
@@ -1804,6 +1804,22 @@
18051805 WaitForSingleObject(This->busy,INFINITE);
18061806 }
18071807
 1808+__inline BOOL UnadjustWindowRectEx(LPRECT lpRect, DWORD dwStyle, BOOL bMenu, DWORD dwExStyle)
 1809+{
 1810+ RECT r;
 1811+ ZeroMemory(&r, sizeof(RECT));
 1812+ BOOL ret = AdjustWindowRectEx(&r, dwStyle, bMenu, dwExStyle);
 1813+ if (!ret) return ret;
 1814+ else
 1815+ {
 1816+ lpRect->left -= r.left;
 1817+ lpRect->top -= r.top;
 1818+ lpRect->right -= r.right;
 1819+ lpRect->bottom -= r.bottom;
 1820+ return ret;
 1821+ }
 1822+}
 1823+
18081824 /**
18091825 * Deletes a glRenderer object
18101826 * @param This
@@ -1811,11 +1827,27 @@
18121828 */
18131829 void glRenderer_Delete(glRenderer *This)
18141830 {
 1831+ BOOL hasmenu;
 1832+ RECT wndrect;
 1833+ LONG_PTR winstyle, winstyleex;
18151834 switch (dxglcfg.fullmode)
18161835 {
18171836 case 2:
18181837 case 3:
18191838 case 4:
 1839+ GetWindowRect(This->hWnd, &wndrect);
 1840+ if (dxglcfg.fullmode != 4)
 1841+ {
 1842+ winstyle = GetWindowLongPtrA(This->hWnd, GWL_STYLE);
 1843+ winstyleex = GetWindowLongPtrA(This->hWnd, GWL_EXSTYLE);
 1844+ if (GetMenu(This->hWnd)) hasmenu = TRUE;
 1845+ else hasmenu = FALSE;
 1846+ UnadjustWindowRectEx(&wndrect, winstyle, hasmenu, winstyleex);
 1847+ }
 1848+ dxglcfg.WindowX = wndrect.left;
 1849+ dxglcfg.WindowY = wndrect.top;
 1850+ dxglcfg.WindowWidth = wndrect.right - wndrect.left;
 1851+ dxglcfg.WindowHeight = wndrect.bottom - wndrect.top;
18201852 SaveWindowSettings(&dxglcfg);
18211853 break;
18221854 default:
@@ -2095,22 +2127,6 @@
20962128 LeaveCriticalSection(&This->cs);
20972129 }
20982130
2099 -__inline BOOL UnadjustWindowRectEx(LPRECT lpRect, DWORD dwStyle, BOOL bMenu, DWORD dwExStyle)
2100 -{
2101 - RECT r;
2102 - ZeroMemory(&r, sizeof(RECT));
2103 - BOOL ret = AdjustWindowRectEx(&r, dwStyle, bMenu, dwExStyle);
2104 - if (!ret) return ret;
2105 - else
2106 - {
2107 - lpRect->left -= r.left;
2108 - lpRect->top -= r.top;
2109 - lpRect->right -= r.right;
2110 - lpRect->bottom -= r.bottom;
2111 - return ret;
2112 - }
2113 -}
2114 -
21152131 /**
21162132 * Changes the window used for rendering.
21172133 * @param This
@@ -2205,13 +2221,19 @@
22062222 }
22072223 else
22082224 {
 2225+ if (dxglcfg.NoResizeWindow) break;
22092226 screenx = GetSystemMetrics(SM_CXSCREEN);
22102227 screeny = GetSystemMetrics(SM_CYSCREEN);
22112228 wndrect.left = (screenx / 2) - (width / 2);
22122229 wndrect.top = (screeny / 2) - (height / 2);
22132230 }
2214 - wndrect.right = wndrect.left + width;
2215 - wndrect.bottom = wndrect.top + height;
 2231+ if (!dxglcfg.NoResizeWindow)
 2232+ {
 2233+ wndrect.right = wndrect.left + width;
 2234+ wndrect.bottom = wndrect.top + height;
 2235+ }
 2236+ else glDirectDraw7_SetWindowSize(This->ddInterface, wndrect.right - wndrect.left,
 2237+ wndrect.bottom - wndrect.top);
22162238 dxglcfg.WindowX = wndrect.left;
22172239 dxglcfg.WindowY = wndrect.top;
22182240 dxglcfg.WindowWidth = wndrect.right - wndrect.left;