Index: ddraw/glDirectDraw.cpp |
— | — | @@ -1,5 +1,5 @@ |
2 | 2 | // DXGL
|
3 | | -// Copyright (C) 2011-2014 William Feely
|
| 3 | +// Copyright (C) 2011-2015 William Feely
|
4 | 4 |
|
5 | 5 | // This library is free software; you can redistribute it and/or
|
6 | 6 | // modify it under the terms of the GNU Lesser General Public
|
— | — | @@ -1420,6 +1420,17 @@ |
1421 | 1421 | TRACE_EXIT(23,DD_OK);
|
1422 | 1422 | return DD_OK;
|
1423 | 1423 | }
|
| 1424 | +extern "C" void glDirectDraw7_UnrestoreDisplayMode(glDirectDraw7 *This)
|
| 1425 | +{
|
| 1426 | + if (!This) return;
|
| 1427 | + TRACE_ENTER(1, 14, This);
|
| 1428 | + if (This->currmode.dmSize != 0)
|
| 1429 | + {
|
| 1430 | + ChangeDisplaySettingsEx(NULL, &This->currmode, NULL, CDS_FULLSCREEN, NULL);
|
| 1431 | + }
|
| 1432 | + TRACE_EXIT(0, 0);
|
| 1433 | +}
|
| 1434 | +
|
1424 | 1435 | HRESULT WINAPI glDirectDraw7::SetCooperativeLevel(HWND hWnd, DWORD dwFlags)
|
1425 | 1436 | {
|
1426 | 1437 | TRACE_ENTER(3,14,this,13,hWnd,9,dwFlags);
|
— | — | @@ -1592,6 +1603,7 @@ |
1593 | 1604 | {
|
1594 | 1605 | WaitForVerticalBlank(0, NULL);
|
1595 | 1606 | WaitForVerticalBlank(0, NULL);
|
| 1607 | + RestoreDisplayMode();
|
1596 | 1608 | TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
|
1597 | 1609 | }
|
1598 | 1610 | if ((dwBPP != 4) && (dwBPP != 8) && (dwBPP != 15) && (dwBPP != 16) && (dwBPP != 24) && (dwBPP != 32))
|
— | — | @@ -1610,6 +1622,7 @@ |
1611 | 1623 | }
|
1612 | 1624 | currmode.dmSize = sizeof(DEVMODE);
|
1613 | 1625 | EnumDisplaySettings(NULL,ENUM_CURRENT_SETTINGS,&currmode);
|
| 1626 | + this->currmode.dmSize = 0;
|
1614 | 1627 | switch(dxglcfg.scaler)
|
1615 | 1628 | {
|
1616 | 1629 | case 0: // No scaling, switch mode
|
— | — | @@ -1630,6 +1643,7 @@ |
1631 | 1644 | switch(error)
|
1632 | 1645 | {
|
1633 | 1646 | case DISP_CHANGE_SUCCESSFUL:
|
| 1647 | + if (fullscreen) this->currmode = newmode;
|
1634 | 1648 | internalx = primaryx = screenx = newmode.dmPelsWidth;
|
1635 | 1649 | internaly = primaryy = screeny = newmode.dmPelsHeight;
|
1636 | 1650 | internalbpp = screenbpp = newmode.dmBitsPerPel;
|
— | — | @@ -1755,6 +1769,7 @@ |
1756 | 1770 | error = ChangeDisplaySettingsEx(NULL,&newmode2,NULL,flags,NULL);
|
1757 | 1771 | }
|
1758 | 1772 | else newmode2 = newmode;
|
| 1773 | + if (error == DISP_CHANGE_SUCCESSFUL) this->currmode = newmode2;
|
1759 | 1774 | switch(dxglcfg.scaler)
|
1760 | 1775 | {
|
1761 | 1776 | case 4:
|
Index: ddraw/glDirectDraw.h |
— | — | @@ -1,5 +1,5 @@ |
2 | 2 | // DXGL
|
3 | | -// Copyright (C) 2011-2014 William Feely
|
| 3 | +// Copyright (C) 2011-2015 William Feely
|
4 | 4 |
|
5 | 5 | // This library is free software; you can redistribute it and/or
|
6 | 6 | // modify it under the terms of the GNU Lesser General Public
|
— | — | @@ -115,6 +115,7 @@ |
116 | 116 | D3DDevice stored_devices[3];
|
117 | 117 | D3DDEVICEDESC7 d3ddesc;
|
118 | 118 | D3DDEVICEDESC d3ddesc3;
|
| 119 | + DEVMODE currmode;
|
119 | 120 | private:
|
120 | 121 | HRESULT error;
|
121 | 122 | ULONG refcount7, refcount4, refcount2, refcount1;
|
— | — | @@ -140,6 +141,8 @@ |
141 | 142 | DWORD cooplevel;
|
142 | 143 | };
|
143 | 144 |
|
| 145 | +extern "C" void glDirectDraw7_UnrestoreDisplayMode(glDirectDraw7 *This);
|
| 146 | +
|
144 | 147 | class glDirectDraw1 : public IDirectDraw
|
145 | 148 | {
|
146 | 149 | public:
|
Index: ddraw/hooks.c |
— | — | @@ -19,6 +19,7 @@ |
20 | 20 | #include "hooks.h"
|
21 | 21 | #include <tlhelp32.h>
|
22 | 22 | #include "../minhook-1.3/include/MinHook.h"
|
| 23 | +void glDirectDraw7_UnrestoreDisplayMode(LPDIRECTDRAW7 lpDD7); // temporary until glDirectDraw is converted to C
|
23 | 24 |
|
24 | 25 | const TCHAR *wndprop = _T("DXGLWndProc");
|
25 | 26 | const TCHAR *wndpropdd7 = _T("DXGLWndDD7");
|
— | — | @@ -268,6 +269,12 @@ |
269 | 270 | if (lpDD7) IDirectDraw7_SetDisplayMode(lpDD7, -1, -1, -1, -1, 0);
|
270 | 271 | }
|
271 | 272 | break;
|
| 273 | + case WM_SYSCOMMAND:
|
| 274 | + if (wParam == SC_RESTORE)
|
| 275 | + {
|
| 276 | + if (lpDD7) glDirectDraw7_UnrestoreDisplayMode(lpDD7);
|
| 277 | + }
|
| 278 | + break;
|
272 | 279 | }
|
273 | 280 | return CallWindowProc(parentproc, hWnd, uMsg, wParam, lParam);
|
274 | 281 | }
|