DXGL r576 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r575‎ | r576 | r577 >
Date:20:13, 21 December 2014
Author:admin
Status:new
Tags:
Comment:
Force screen redraw when losing fullscreen window focus to force display out of exclusive mode.
Modified paths:
  • /ddraw/glDirectDraw.cpp (modified) (history)
  • /ddraw/hooks.c (modified) (history)
  • /ddraw/hooks.h (modified) (history)

Diff [purge]

Index: ddraw/glDirectDraw.cpp
@@ -1513,7 +1513,7 @@
15141514 internalrefresh = primaryrefresh = screenrefresh = devmode.dmDisplayFrequency;
15151515 primarybpp = bpp;
15161516 InitGL(x,y,bpp,fullscreen,internalrefresh,hWnd,this,devwnd);
1517 - if (fullscreen) InstallDXGLFullscreenHook(hWnd);
 1517+ if (fullscreen) InstallDXGLFullscreenHook(hWnd,this);
15181518 cooplevel = dwFlags;
15191519 TRACE_EXIT(23,DD_OK);
15201520 return DD_OK;
@@ -1587,6 +1587,12 @@
15881588 TRACE_ENTER(6,14,this,8,dwWidth,8,dwHeight,8,dwBPP,8,dwRefreshRate,9,dwFlags);
15891589 if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
15901590 if (dwFlags & 0xFFFFFFFE) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
 1591+ if ((dwWidth == -1) && (dwHeight == -1) && (dwBPP == -1) && (dwRefreshRate == -1))
 1592+ {
 1593+ WaitForVerticalBlank(0, NULL);
 1594+ WaitForVerticalBlank(0, NULL);
 1595+ TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
 1596+ }
15911597 if ((dwBPP != 4) && (dwBPP != 8) && (dwBPP != 15) && (dwBPP != 16) && (dwBPP != 24) && (dwBPP != 32))
15921598 TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
15931599 if (!fullscreen) TRACE_RET(HRESULT, 23, DDERR_NOEXCLUSIVEMODE);
Index: ddraw/hooks.c
@@ -19,12 +19,14 @@
2020 #include "hooks.h"
2121
2222 const TCHAR *wndprop = _T("DXGLWndProc");
 23+const TCHAR *wndpropdd7 = _T("DXGLWndDD7");
2324
24 -void InstallDXGLFullscreenHook(HWND hWnd)
 25+void InstallDXGLFullscreenHook(HWND hWnd, LPDIRECTDRAW7 lpDD7)
2526 {
2627 HANDLE wndproc = GetWindowLongPtr(hWnd, GWLP_WNDPROC);
2728 if (GetProp(hWnd, wndprop)) return;
2829 SetProp(hWnd, wndprop, wndproc);
 30+ SetProp(hWnd, wndpropdd7, lpDD7);
2931 SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR)DXGLWndHookProc);
3032 }
3133 void UninstallDXGLFullscreenHook(HWND hWnd)
@@ -32,10 +34,12 @@
3335 if (!GetProp(hWnd, wndprop)) return;
3436 SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR)GetProp(hWnd, wndprop));
3537 RemoveProp(hWnd, wndprop);
 38+ RemoveProp(hWnd, wndpropdd7);
3639 }
3740 LRESULT CALLBACK DXGLWndHookProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
3841 {
3942 WNDPROC parentproc = (WNDPROC)GetProp(hWnd, wndprop);
 43+ LPDIRECTDRAW7 lpDD7 = GetProp(hWnd, wndpropdd7);
4044 switch (uMsg)
4145 {
4246 case WM_DESTROY:
@@ -42,7 +46,11 @@
4347 UninstallDXGLFullscreenHook(hWnd);
4448 break;
4549 case WM_ACTIVATEAPP:
46 - if (!wParam) ShowWindow(hWnd, SW_MINIMIZE);
 50+ if (!wParam)
 51+ {
 52+ ShowWindow(hWnd, SW_MINIMIZE);
 53+ if (lpDD7) IDirectDraw7_SetDisplayMode(lpDD7, -1, -1, -1, -1, 0);
 54+ }
4755 break;
4856 }
4957 return CallWindowProc(parentproc, hWnd, uMsg, wParam, lParam);
Index: ddraw/hooks.h
@@ -22,7 +22,7 @@
2323 #endif
2424
2525 LRESULT CALLBACK DXGLWndHookProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
26 -void InstallDXGLFullscreenHook(HWND hWnd);
 26+void InstallDXGLFullscreenHook(HWND hWnd, LPDIRECTDRAW7 lpDD7);
2727 void UninstallDXGLFullscreenHook(HWND hWnd);
2828
2929 #ifdef __cplusplus