DXGL r682 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r681‎ | r682 | r683 >
Date:01:08, 22 August 2016
Author:admin
Status:new
Tags:
Comment:
Consolidate new borderless window mode code
Modified paths:
  • /ddraw/glRenderer.cpp (modified) (history)
  • /ddraw/hooks.c (modified) (history)

Diff [purge]

Index: ddraw/glRenderer.cpp
@@ -368,6 +368,8 @@
369369 ShowWindow(This->hWnd, SW_MAXIMIZE);
370370 break;
371371 case 1: // Non-exclusive Fullscreen
 372+ case 4: // Windowed borderless
 373+ case 5: // Windowed borderless scaled
372374 winstyle = GetWindowLongPtrA(This->hWnd, GWL_STYLE);
373375 winstyleex = GetWindowLongPtrA(This->hWnd, GWL_EXSTYLE);
374376 SetWindowLongPtrA(This->hWnd, GWL_EXSTYLE, winstyleex & ~(WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE));
@@ -388,20 +390,6 @@
389391 SetWindowLongPtrA(This->hWnd, GWL_STYLE, (winstyle | WS_OVERLAPPEDWINDOW) & ~WS_POPUP);
390392 ShowWindow(This->hWnd, SW_MAXIMIZE);
391393 break;
392 - case 4: // Windowed borderless
393 - winstyle = GetWindowLongPtrA(This->hWnd, GWL_STYLE);
394 - winstyleex = GetWindowLongPtrA(This->hWnd, GWL_EXSTYLE);
395 - SetWindowLongPtrA(This->hWnd, GWL_EXSTYLE, winstyleex & ~(WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE));
396 - SetWindowLongPtrA(This->hWnd, GWL_STYLE, winstyle & ~(WS_CAPTION | WS_THICKFRAME | WS_BORDER | WS_POPUP));
397 - ShowWindow(This->hWnd, SW_MAXIMIZE);
398 - 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;
406394 }
407395 }
408396 if(width)
@@ -706,6 +694,7 @@
707695 ShowWindow(newwnd, SW_MAXIMIZE);
708696 break;
709697 case 1: // Non-exclusive Fullscreen
 698+ case 5: // Windowed borderless scaled
710699 winstyle = GetWindowLongPtrA(newwnd, GWL_STYLE);
711700 winstyleex = GetWindowLongPtrA(newwnd, GWL_EXSTYLE);
712701 SetWindowLongPtrA(newwnd, GWL_EXSTYLE, winstyleex & ~(WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE));
@@ -759,13 +748,6 @@
760749 SetWindowPos(newwnd, 0, wndrect.left, wndrect.top, wndrect.right - wndrect.left,
761750 wndrect.bottom - wndrect.top, SWP_ASYNCWINDOWPOS | SWP_NOACTIVATE | SWP_NOOWNERZORDER);
762751 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;
770752 }
771753 }
772754 This->inputs[0] = (void*)width;
Index: ddraw/hooks.c
@@ -312,6 +312,10 @@
313313 break;
314314 case 1:
315315 // Fix non-exclusive fullscreen mode
 316+ case 4:
 317+ // Fix borderless window mode
 318+ case 5:
 319+ // Fix scaled borderless window mode
316320 if (lpDD7)
317321 {
318322 glDirectDraw7_GetSizes(lpDD7, sizes);
@@ -368,46 +372,6 @@
369373 }
370374 }
371375 break;
372 - case 4:
373 - // Fix borderless window mode
374 - if (lpDD7)
375 - {
376 - glDirectDraw7_GetSizes(lpDD7, sizes);
377 - GetWindowRect(hWnd, &r1);
378 - GetClientRect(hWnd, &r2);
379 - winstyle = GetWindowLong(hWnd, GWL_STYLE);
380 - exstyle = GetWindowLong(hWnd, GWL_EXSTYLE);
381 - if (winstyle & (WS_CAPTION | WS_THICKFRAME | WS_BORDER | WS_POPUP)) fixstyle = TRUE;
382 - if (exstyle & (WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE)) fixstyle = TRUE;
383 - if (!((r1.left == 0) && (r1.top == 0) && (r2.right == sizes[4]) && (r2.bottom == sizes[5]))) fixstyle = TRUE;
384 - if (fixstyle)
385 - {
386 - SetWindowLongPtrA(hWnd, GWL_EXSTYLE, exstyle & ~(WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE));
387 - SetWindowLongPtrA(hWnd, GWL_STYLE, winstyle & ~(WS_CAPTION | WS_THICKFRAME | WS_BORDER | WS_POPUP));
388 - SetWindowPos(hWnd, NULL, 0, 0, sizes[4], sizes[5], SWP_NOOWNERZORDER | SWP_NOZORDER | SWP_FRAMECHANGED);
389 - }
390 - }
391 - 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;
412376 }
413377 }
414378 break;