DXGL r574 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r573‎ | r574 | r575 >
Date:16:18, 20 December 2014
Author:admin
Status:new
Tags:
Comment:
Minimize fullscreen window on focus loss.
Modified paths:
  • /ddraw/glRenderWindow.cpp (modified) (history)

Diff [purge]

Index: ddraw/glRenderWindow.cpp
@@ -27,6 +27,36 @@
2828 bool hotkeyregistered = false;
2929 #endif
3030
 31+const TCHAR *wndprop = _T("DXGLWndProc");
 32+
 33+LRESULT CALLBACK DXGLWndHookProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
 34+void InstallDXGLHook(HWND hWnd)
 35+{
 36+ if (GetProp(hWnd, wndprop)) return;
 37+ SetProp(hWnd, wndprop, (HANDLE)GetWindowLongPtr(hWnd, GWLP_WNDPROC));
 38+ SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR)DXGLWndHookProc);
 39+}
 40+void UninstallDXGLHook(HWND hWnd)
 41+{
 42+ if (!GetProp(hWnd, wndprop)) return;
 43+ SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR)GetProp(hWnd, wndprop));
 44+ RemoveProp(hWnd, wndprop);
 45+}
 46+LRESULT CALLBACK DXGLWndHookProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 47+{
 48+ WNDPROC parentproc = (WNDPROC)GetProp(hWnd, wndprop);
 49+ switch (uMsg)
 50+ {
 51+ case WM_DESTROY:
 52+ UninstallDXGLHook(hWnd);
 53+ break;
 54+ case WM_ACTIVATEAPP:
 55+ if (!wParam) ShowWindow(hWnd, SW_MINIMIZE);
 56+ break;
 57+ }
 58+ return parentproc(hWnd,uMsg,wParam,lParam);
 59+}
 60+
3161 void WaitForObjectAndMessages(HANDLE object)
3262 {
3363 MSG Msg;
@@ -98,6 +128,7 @@
99129 hWnd = CreateWindowA("DirectDrawDeviceWnd",windowname,WS_CHILD|WS_VISIBLE,0,0,rectRender.right - rectRender.left,
100130 rectRender.bottom - rectRender.top,hParentWnd,NULL,wndclass.hInstance,this);
101131 SetWindowPos(hWnd,HWND_TOP,0,0,rectRender.right,rectRender.bottom,SWP_SHOWWINDOW);
 132+ if (fullscreen) InstallDXGLHook(hParentWnd);
102133 }
103134 else
104135 {
@@ -199,6 +230,7 @@
200231 }
201232 else return SendMessage(hParent,msg,wParam,lParam);
202233 case WM_CLOSE:
 234+ if (fullscreen) UninstallDXGLHook(hParentWnd);
203235 DestroyWindow(hWnd);
204236 return 0;
205237 case WM_DESTROY: