DXGL r819 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r818‎ | r819 | r820 >
Date:23:23, 9 June 2018
Author:admin
Status:new
Tags:
Comment:
Support upper left position for forced window mode.
Modified paths:
  • /ddraw/glRenderer.cpp (modified) (history)
  • /dxglcfg/dxglcfg.cpp (modified) (history)

Diff [purge]

Index: ddraw/glRenderer.cpp
@@ -1718,7 +1718,21 @@
17191719 wndrect.top = dxglcfg.WindowY;
17201720 wndrect.right = dxglcfg.WindowX + dxglcfg.WindowWidth;
17211721 wndrect.bottom = dxglcfg.WindowY + dxglcfg.WindowHeight;
 1722+ AdjustWindowRectEx(&wndrect, (winstyle | WS_OVERLAPPEDWINDOW) & ~(WS_THICKFRAME | WS_MAXIMIZEBOX), FALSE,
 1723+ (winstyleex | WS_EX_APPWINDOW));
17221724 }
 1725+ else if (dxglcfg.WindowPosition == 2)
 1726+ {
 1727+ wndrect.left = wndrect.top = 0;
 1728+ wndrect.right = dxglcfg.WindowWidth;
 1729+ wndrect.bottom = dxglcfg.WindowHeight;
 1730+ AdjustWindowRectEx(&wndrect, (winstyle | WS_OVERLAPPEDWINDOW) & ~(WS_THICKFRAME | WS_MAXIMIZEBOX), FALSE,
 1731+ (winstyleex | WS_EX_APPWINDOW));
 1732+ wndrect.right -= wndrect.left;
 1733+ wndrect.left = 0;
 1734+ wndrect.bottom -= wndrect.top;
 1735+ wndrect.top = 0;
 1736+ }
17231737 else
17241738 {
17251739 screenx = GetSystemMetrics(SM_CXSCREEN);
@@ -1727,9 +1741,9 @@
17281742 wndrect.bottom = dxglcfg.WindowHeight + (screeny / 2) - (dxglcfg.WindowHeight / 2);
17291743 wndrect.left = (screenx / 2) - (dxglcfg.WindowWidth / 2);
17301744 wndrect.top = (screeny / 2) - (dxglcfg.WindowHeight / 2);
 1745+ AdjustWindowRectEx(&wndrect, (winstyle | WS_OVERLAPPEDWINDOW) & ~(WS_THICKFRAME | WS_MAXIMIZEBOX), FALSE,
 1746+ (winstyleex | WS_EX_APPWINDOW));
17311747 }
1732 - AdjustWindowRectEx(&wndrect, (winstyle | WS_OVERLAPPEDWINDOW) & ~(WS_THICKFRAME | WS_MAXIMIZEBOX), FALSE,
1733 - (winstyleex | WS_EX_APPWINDOW));
17341748 SetWindowPos(This->hWnd, 0, wndrect.left, wndrect.top, wndrect.right - wndrect.left,
17351749 wndrect.bottom - wndrect.top, SWP_ASYNCWINDOWPOS | SWP_NOACTIVATE | SWP_NOOWNERZORDER);
17361750 break;
@@ -1745,7 +1759,19 @@
17461760 wndrect.top = dxglcfg.WindowY;
17471761 wndrect.right = dxglcfg.WindowX + dxglcfg.WindowWidth;
17481762 wndrect.bottom = dxglcfg.WindowY + dxglcfg.WindowHeight;
 1763+ AdjustWindowRectEx(&wndrect, winstyle | WS_OVERLAPPEDWINDOW, FALSE, (winstyleex | WS_EX_APPWINDOW));
17491764 }
 1765+ else if (dxglcfg.WindowPosition == 2)
 1766+ {
 1767+ wndrect.left = wndrect.top = 0;
 1768+ wndrect.right = dxglcfg.WindowWidth;
 1769+ wndrect.bottom = dxglcfg.WindowHeight;
 1770+ AdjustWindowRectEx(&wndrect, winstyle | WS_OVERLAPPEDWINDOW, FALSE, (winstyleex | WS_EX_APPWINDOW));
 1771+ wndrect.right -= wndrect.left;
 1772+ wndrect.left = 0;
 1773+ wndrect.bottom -= wndrect.top;
 1774+ wndrect.top = 0;
 1775+ }
17501776 else
17511777 {
17521778 screenx = GetSystemMetrics(SM_CXSCREEN);
@@ -1754,8 +1780,8 @@
17551781 wndrect.bottom = dxglcfg.WindowHeight + (screeny / 2) - (dxglcfg.WindowHeight / 2);
17561782 wndrect.left = (screenx / 2) - (dxglcfg.WindowWidth / 2);
17571783 wndrect.top = (screeny / 2) - (dxglcfg.WindowHeight / 2);
 1784+ AdjustWindowRectEx(&wndrect, winstyle | WS_OVERLAPPEDWINDOW, FALSE, (winstyleex | WS_EX_APPWINDOW));
17581785 }
1759 - AdjustWindowRectEx(&wndrect, winstyle | WS_OVERLAPPEDWINDOW, FALSE, (winstyleex | WS_EX_APPWINDOW));
17601786 wndplace.length = sizeof(WINDOWPLACEMENT);
17611787 GetWindowPlacement(This->hWnd, &wndplace);
17621788 wndplace.flags = WPF_ASYNCWINDOWPLACEMENT;
@@ -1777,6 +1803,12 @@
17781804 wndrect.right = dxglcfg.WindowX + dxglcfg.WindowWidth;
17791805 wndrect.bottom = dxglcfg.WindowY + dxglcfg.WindowHeight;
17801806 }
 1807+ else if (dxglcfg.WindowPosition == 2)
 1808+ {
 1809+ wndrect.left = wndrect.top = 0;
 1810+ wndrect.right = dxglcfg.WindowWidth;
 1811+ wndrect.bottom = dxglcfg.WindowHeight;
 1812+ }
17811813 else
17821814 {
17831815 screenx = GetSystemMetrics(SM_CXSCREEN);
@@ -2200,7 +2232,24 @@
22012233 else hasmenu = FALSE;
22022234 UnadjustWindowRectEx(&wndrect, (winstyle | WS_OVERLAPPEDWINDOW) & ~(WS_THICKFRAME | WS_MAXIMIZEBOX | WS_POPUP),
22032235 hasmenu, winstyleex | WS_EX_APPWINDOW);
 2236+ wndrect.right = wndrect.left + width;
 2237+ wndrect.bottom = wndrect.top + height;
 2238+ AdjustWindowRectEx(&wndrect, (winstyle | WS_OVERLAPPEDWINDOW) & ~(WS_THICKFRAME | WS_MAXIMIZEBOX), FALSE,
 2239+ (winstyleex | WS_EX_APPWINDOW));
22042240 }
 2241+ else if (dxglcfg.WindowPosition == 2)
 2242+ {
 2243+ wndrect.left = 0;
 2244+ wndrect.top = 0;
 2245+ wndrect.right = width;
 2246+ wndrect.bottom = height;
 2247+ AdjustWindowRectEx(&wndrect, (winstyle | WS_OVERLAPPEDWINDOW) & ~(WS_THICKFRAME | WS_MAXIMIZEBOX), FALSE,
 2248+ (winstyleex | WS_EX_APPWINDOW));
 2249+ wndrect.right -= wndrect.left;
 2250+ wndrect.left = 0;
 2251+ wndrect.bottom -= wndrect.top;
 2252+ wndrect.top = 0;
 2253+ }
22052254 else
22062255 {
22072256 screenx = GetSystemMetrics(SM_CXSCREEN);
@@ -2207,15 +2256,15 @@
22082257 screeny = GetSystemMetrics(SM_CYSCREEN);
22092258 wndrect.left = (screenx / 2) - (width / 2);
22102259 wndrect.top = (screeny / 2) - (height / 2);
 2260+ wndrect.right = wndrect.left + width;
 2261+ wndrect.bottom = wndrect.top + height;
 2262+ AdjustWindowRectEx(&wndrect, (winstyle | WS_OVERLAPPEDWINDOW) & ~(WS_THICKFRAME | WS_MAXIMIZEBOX), FALSE,
 2263+ (winstyleex | WS_EX_APPWINDOW));
22112264 }
2212 - wndrect.right = wndrect.left + width;
2213 - wndrect.bottom = wndrect.top + height;
22142265 dxglcfg.WindowX = wndrect.left;
22152266 dxglcfg.WindowY = wndrect.top;
22162267 dxglcfg.WindowWidth = wndrect.right - wndrect.left;
22172268 dxglcfg.WindowHeight = wndrect.bottom - wndrect.top;
2218 - AdjustWindowRectEx(&wndrect, (winstyle | WS_OVERLAPPEDWINDOW) & ~(WS_THICKFRAME | WS_MAXIMIZEBOX), FALSE,
2219 - (winstyleex | WS_EX_APPWINDOW));
22202269 SetWindowPos(newwnd, 0, wndrect.left, wndrect.top, wndrect.right - wndrect.left,
22212270 wndrect.bottom - wndrect.top, SWP_ASYNCWINDOWPOS | SWP_NOACTIVATE | SWP_NOOWNERZORDER);
22222271 SaveWindowSettings(&dxglcfg);
@@ -2239,7 +2288,35 @@
22402289 hasmenu, (winstyleex | WS_EX_APPWINDOW));
22412290 UnadjustWindowRectEx(&wndrect2, (winstyle | WS_OVERLAPPEDWINDOW) & ~WS_POPUP,
22422291 hasmenu, (winstyleex | WS_EX_APPWINDOW));
 2292+ if (!dxglcfg.NoResizeWindow)
 2293+ {
 2294+ wndrect.right = wndrect.left + width;
 2295+ wndrect.bottom = wndrect.top + height;
 2296+ }
22432297 }
 2298+ else if (dxglcfg.WindowPosition == 2)
 2299+ {
 2300+ if (dxglcfg.NoResizeWindow)
 2301+ {
 2302+ GetWindowRect(newwnd, &wndrect2);
 2303+ if (GetMenu(newwnd)) hasmenu = TRUE;
 2304+ else hasmenu = FALSE;
 2305+ UnadjustWindowRectEx(&wndrect2, (winstyle | WS_OVERLAPPEDWINDOW) & ~WS_POPUP,
 2306+ hasmenu, (winstyleex | WS_EX_APPWINDOW));
 2307+ glDirectDraw7_SetWindowSize(This->ddInterface,
 2308+ wndrect2.right - wndrect2.left, wndrect2.bottom - wndrect2.top);
 2309+ break;
 2310+ }
 2311+ wndrect.left = 0;
 2312+ wndrect.top = 0;
 2313+ wndrect.right = width;
 2314+ wndrect.bottom = height;
 2315+ AdjustWindowRectEx(&wndrect, winstyle | WS_OVERLAPPEDWINDOW, FALSE, (winstyleex | WS_EX_APPWINDOW));
 2316+ wndrect.right -= wndrect.left;
 2317+ wndrect.left = 0;
 2318+ wndrect.bottom -= wndrect.top;
 2319+ wndrect.top = 0;
 2320+ }
22442321 else
22452322 {
22462323 if (dxglcfg.NoResizeWindow)
@@ -2257,17 +2334,18 @@
22582335 screeny = GetSystemMetrics(SM_CYSCREEN);
22592336 wndrect.left = (screenx / 2) - (width / 2);
22602337 wndrect.top = (screeny / 2) - (height / 2);
 2338+ if (!dxglcfg.NoResizeWindow)
 2339+ {
 2340+ wndrect.right = wndrect.left + width;
 2341+ wndrect.bottom = wndrect.top + height;
 2342+ }
22612343 }
2262 - if (!dxglcfg.NoResizeWindow)
2263 - {
2264 - wndrect.right = wndrect.left + width;
2265 - wndrect.bottom = wndrect.top + height;
2266 - }
22672344 dxglcfg.WindowX = wndrect.left;
22682345 dxglcfg.WindowY = wndrect.top;
22692346 dxglcfg.WindowWidth = wndrect.right - wndrect.left;
22702347 dxglcfg.WindowHeight = wndrect.bottom - wndrect.top;
2271 - AdjustWindowRectEx(&wndrect, winstyle | WS_OVERLAPPEDWINDOW, FALSE, (winstyleex | WS_EX_APPWINDOW));
 2348+ if(dxglcfg.WindowPosition != 2)
 2349+ AdjustWindowRectEx(&wndrect, winstyle | WS_OVERLAPPEDWINDOW, FALSE, (winstyleex | WS_EX_APPWINDOW));
22722350 wndplace.flags = WPF_ASYNCWINDOWPLACEMENT;
22732351 if (!dxglcfg.NoResizeWindow) wndplace.showCmd = SW_SHOWNORMAL;
22742352 wndplace.rcNormalPosition = wndrect;
@@ -2285,6 +2363,11 @@
22862364 screenx = GetSystemMetrics(SM_CXSCREEN);
22872365 screeny = GetSystemMetrics(SM_CYSCREEN);
22882366 if (dxglcfg.WindowPosition == 1) GetWindowRect(newwnd, &wndrect);
 2367+ else if (dxglcfg.WindowPosition == 2)
 2368+ {
 2369+ wndrect.left = 0;
 2370+ wndrect.top = 0;
 2371+ }
22892372 else
22902373 {
22912374 screenx = GetSystemMetrics(SM_CXSCREEN);
Index: dxglcfg/dxglcfg.cpp
@@ -3152,6 +3152,8 @@
31533153 SendDlgItemMessage(hTabs[3], IDC_WINDOWPOS, CB_ADDSTRING, 0, (LPARAM)buffer);
31543154 _tcscpy(buffer, _T("Saved position"));
31553155 SendDlgItemMessage(hTabs[3], IDC_WINDOWPOS, CB_ADDSTRING, 0, (LPARAM)buffer);
 3156+ _tcscpy(buffer, _T("Top left"));
 3157+ SendDlgItemMessage(hTabs[3], IDC_WINDOWPOS, CB_ADDSTRING, 0, (LPARAM)buffer);
31563158 SendDlgItemMessage(hTabs[3], IDC_WINDOWPOS, CB_SETCURSEL, cfg->WindowPosition, 0);
31573159 // Remember window position
31583160 if (cfg->RememberWindowPosition) SendDlgItemMessage(hTabs[3], IDC_REMEMBERWINDOWPOS, BM_SETCHECK, BST_CHECKED, 0);