DXGL r681 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r680‎ | r681 | r682 >
Date:00:56, 22 August 2016
Author:admin
Status:new
Tags:
Comment:
Add scaled borderless window mode.
Modified paths:
  • /Help/configuration.htm (modified) (history)
  • /ddraw/glDirectDraw.cpp (modified) (history)
  • /ddraw/glRenderer.cpp (modified) (history)
  • /ddraw/hooks.c (modified) (history)
  • /dxglcfg/dxglcfg.c (modified) (history)

Diff [purge]

Index: Help/configuration.htm
@@ -98,5 +98,8 @@
9999 Forces the fullscreen application to display in a floating window that can be resized or maximized. Please note that some applications may capture the mouse and thus may cause compatibility issues.
100100 <h3>Borderless window</h3>
101101 Forces the application to display in a borderless pop-up window. If the application is not running at the same resolution as the display, the window will be the same size as the application's display resolution.
 102+ <h3>Borderless window (scaled)</h3>
 103+ Forces the application to display in a borderless pop-up window. Sizes the window to fill the screen. Similar to Non-exclusive fullscreen except that the window does not minimize when focus is lost.
 104+ Depending on the "Video mode" setting, the graphics resolution may be changed to accomodate the application.
102105 </body>
103106 </html>
\ No newline at end of file
Index: ddraw/glDirectDraw.cpp
@@ -1642,7 +1642,8 @@
16431643 {
16441644 case 0:
16451645 case 1:
1646 - default: // Fullscreen modes and fallback
 1646+ case 5:
 1647+ default: // Fullscreen modes, scaled borderless window, and fallback
16471648 switch (dxglcfg.scaler)
16481649 {
16491650 case 0: // No scaling, switch mode
Index: ddraw/glRenderer.cpp
@@ -395,6 +395,13 @@
396396 SetWindowLongPtrA(This->hWnd, GWL_STYLE, winstyle & ~(WS_CAPTION | WS_THICKFRAME | WS_BORDER | WS_POPUP));
397397 ShowWindow(This->hWnd, SW_MAXIMIZE);
398398 break;
 399+ case 5: // Windowed borderless scaled
 400+ winstyle = GetWindowLongPtrA(This->hWnd, GWL_STYLE);
 401+ winstyleex = GetWindowLongPtrA(This->hWnd, GWL_EXSTYLE);
 402+ SetWindowLongPtrA(This->hWnd, GWL_EXSTYLE, winstyleex & ~(WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE));
 403+ SetWindowLongPtrA(This->hWnd, GWL_STYLE, winstyle & ~(WS_CAPTION | WS_THICKFRAME | WS_BORDER | WS_POPUP));
 404+ ShowWindow(This->hWnd, SW_MAXIMIZE);
 405+ break;
399406 }
400407 }
401408 if(width)
@@ -698,7 +705,7 @@
699706 SetWindowLongPtrA(newwnd, GWL_STYLE, (winstyle | WS_POPUP) & ~(WS_CAPTION | WS_THICKFRAME | WS_BORDER));
700707 ShowWindow(newwnd, SW_MAXIMIZE);
701708 break;
702 - case 1: // Borderless Fullscreen
 709+ case 1: // Non-exclusive Fullscreen
703710 winstyle = GetWindowLongPtrA(newwnd, GWL_STYLE);
704711 winstyleex = GetWindowLongPtrA(newwnd, GWL_EXSTYLE);
705712 SetWindowLongPtrA(newwnd, GWL_EXSTYLE, winstyleex & ~(WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE));
@@ -752,6 +759,13 @@
753760 SetWindowPos(newwnd, 0, wndrect.left, wndrect.top, wndrect.right - wndrect.left,
754761 wndrect.bottom - wndrect.top, SWP_ASYNCWINDOWPOS | SWP_NOACTIVATE | SWP_NOOWNERZORDER);
755762 break;
 763+ case 5: // Windowed borderless scaled
 764+ winstyle = GetWindowLongPtrA(newwnd, GWL_STYLE);
 765+ winstyleex = GetWindowLongPtrA(newwnd, GWL_EXSTYLE);
 766+ SetWindowLongPtrA(newwnd, GWL_EXSTYLE, winstyleex & ~(WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE));
 767+ SetWindowLongPtrA(newwnd, GWL_STYLE, winstyle & ~(WS_CAPTION | WS_THICKFRAME | WS_BORDER | WS_POPUP));
 768+ ShowWindow(newwnd, SW_MAXIMIZE);
 769+ break;
756770 }
757771 }
758772 This->inputs[0] = (void*)width;
Index: ddraw/hooks.c
@@ -388,6 +388,26 @@
389389 }
390390 }
391391 break;
 392+ case 5:
 393+ // Fix scaled borderless window mode
 394+ if (lpDD7)
 395+ {
 396+ glDirectDraw7_GetSizes(lpDD7, sizes);
 397+ GetWindowRect(hWnd, &r1);
 398+ GetClientRect(hWnd, &r2);
 399+ winstyle = GetWindowLong(hWnd, GWL_STYLE);
 400+ exstyle = GetWindowLong(hWnd, GWL_EXSTYLE);
 401+ if (winstyle & (WS_CAPTION | WS_THICKFRAME | WS_BORDER | WS_POPUP)) fixstyle = TRUE;
 402+ if (exstyle & (WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE)) fixstyle = TRUE;
 403+ if (!((r1.left == 0) && (r1.top == 0) && (r2.right == sizes[4]) && (r2.bottom == sizes[5]))) fixstyle = TRUE;
 404+ if (fixstyle)
 405+ {
 406+ SetWindowLongPtrA(hWnd, GWL_EXSTYLE, exstyle & ~(WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE));
 407+ SetWindowLongPtrA(hWnd, GWL_STYLE, winstyle & ~(WS_CAPTION | WS_THICKFRAME | WS_BORDER | WS_POPUP));
 408+ SetWindowPos(hWnd, NULL, 0, 0, sizes[4], sizes[5], SWP_NOOWNERZORDER | SWP_NOZORDER | SWP_FRAMECHANGED);
 409+ }
 410+ }
 411+ break;
392412 }
393413 }
394414 break;
Index: dxglcfg/dxglcfg.c
@@ -569,6 +569,8 @@
570570 SendDlgItemMessage(hWnd, IDC_FULLMODE, CB_ADDSTRING, 3, (LPARAM)buffer);
571571 _tcscpy(buffer, _T("Borderless window"));
572572 SendDlgItemMessage(hWnd, IDC_FULLMODE, CB_ADDSTRING, 4, (LPARAM)buffer);
 573+ _tcscpy(buffer, _T("Borderless window (scaled)"));
 574+ SendDlgItemMessage(hWnd, IDC_FULLMODE, CB_ADDSTRING, 5, (LPARAM)buffer);
573575 SendDlgItemMessage(hWnd, IDC_FULLMODE, CB_SETCURSEL, cfg->fullmode, 0);
574576 // colormode
575577 if(cfg->colormode) SendDlgItemMessage(hWnd,IDC_COLOR,BM_SETCHECK,BST_CHECKED,0);