DXGL r814 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r813‎ | r814 | r815 >
Date:13:02, 19 May 2018
Author:admin
Status:new
Tags:
Comment:
Add option to confine mouse cursor to the application window in forced window mode.
Modified paths:
  • /Help/Help.vcxproj (modified) (history)
  • /Help/Help.vcxproj.filters (modified) (history)
  • /Help/dxgl.hhp (modified) (history)
  • /Help/html/config/advanced/capturemouseinwindowmode.htmlbody (added) (history)
  • /Help/html/config/advanced/capturemouseinwindowmode.htmltitle (added) (history)
  • /Help/html/config/advancedtab.htmlbody (modified) (history)
  • /Help/images/dxglcfg-advanced.png (modified) (history)
  • /Help/toc.hhc (modified) (history)
  • /ddraw/hooks.c (modified) (history)

Diff [purge]

Index: Help/Help.vcxproj
@@ -125,6 +125,8 @@
126126 <None Include="html\config\abouttab.htmltitle" />
127127 <None Include="html\config\advancedtab.htmlbody" />
128128 <None Include="html\config\advancedtab.htmltitle" />
 129+ <None Include="html\config\advanced\capturemouseinwindowmode.htmlbody" />
 130+ <None Include="html\config\advanced\capturemouseinwindowmode.htmltitle" />
129131 <None Include="html\config\advanced\defaultwindowposition.htmlbody" />
130132 <None Include="html\config\advanced\defaultwindowposition.htmltitle" />
131133 <None Include="html\config\advanced\dontautosizewindow.htmlbody" />
Index: Help/Help.vcxproj.filters
@@ -501,5 +501,11 @@
502502 <None Include="html\config\debug\disablemousecursorhooks.htmlbody">
503503 <Filter>Help files\html\config\debug</Filter>
504504 </None>
 505+ <None Include="html\config\advanced\capturemouseinwindowmode.htmltitle">
 506+ <Filter>Help files\html\config\advanced</Filter>
 507+ </None>
 508+ <None Include="html\config\advanced\capturemouseinwindowmode.htmlbody">
 509+ <Filter>Help files\html\config\advanced</Filter>
 510+ </None>
505511 </ItemGroup>
506512 </Project>
\ No newline at end of file
Index: Help/dxgl.hhp
@@ -70,6 +70,7 @@
7171 html\config\advanced\startresizablewindowmaximized.html
7272 html\config\advanced\textureaccessmethod.html
7373 html\config\advanced\textureformat.html
 74+html\config\advanced\capturemouseinwindowmode.html
7475 html\config\debug\debugblenddestinationcolor.html
7576 html\config\debug\disablearbdirectstateaccess.html
7677 html\config\debug\disablearbframebuffers.html
Index: Help/html/config/advanced/capturemouseinwindowmode.htmlbody
@@ -0,0 +1,2 @@
 2+<p><em>This option is available in DXGL 0.5.14 and newer.</em></p>
 3+<p>Captures the mouse when you first click inside the application window in forced window mode. You can exit mouse capture by pressing and releasing the Ctrl and Alt keys together.</p>
\ No newline at end of file
Index: Help/html/config/advanced/capturemouseinwindowmode.htmltitle
@@ -0,0 +1 @@
 2+Capture mouse in window mode (Press Ctrl+Alt to release)
\ No newline at end of file
Index: Help/html/config/advancedtab.htmlbody
@@ -30,5 +30,8 @@
3131 <a href="advanced/dontautosizewindow.html">Don't auto-size window in resizable window mode</a>
3232 </p>
3333 <p>
 34+ <a href="advanced/capturemouseinwindowmode.html">Capture mouse in window mode (Press Ctrl+Alt to release)</a>
 35+</p>
 36+<p>
3437 <a href="advanced/installationpath.html">Installation path</a>
3538 </p>
\ No newline at end of file
Index: Help/images/dxglcfg-advanced.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: Help/toc.hhc
@@ -172,6 +172,10 @@
173173 <param name="Name" value="Installation path">
174174 <param name="Local" value="html\config\advanced\installationpath.html">
175175 </OBJECT>
 176+ <LI> <OBJECT type="text/sitemap">
 177+ <param name="Name" value="Capture mouse in window mode (Press Ctrl+Alt to release)">
 178+ <param name="Local" value="html\config\advanced\capturemouseinwindowmode.html">
 179+ </OBJECT>
176180 </UL>
177181 <LI> <OBJECT type="text/sitemap">
178182 <param name="Name" value="Debug Tab">
Index: ddraw/hooks.c
@@ -55,6 +55,11 @@
5656 BOOL(WINAPI *_SetCursorPos)(int X, int Y) = NULL;
5757 HCURSOR(WINAPI *_SetCursor)(HCURSOR hCursor) = NULL;
5858 UINT wndhook_count = 0;
 59+static BOOL keyctrlalt = FALSE;
 60+static BOOL cursorclipped = FALSE;
 61+static RECT rcOldClip;
 62+static RECT rcClip;
 63+static RECT rcWindow;
5964
6065 int hwndhookcmp(const HWND_HOOK *key, const HWND_HOOK *cmp)
6166 {
@@ -292,8 +297,21 @@
293298 switch (uMsg)
294299 {
295300 case WM_DESTROY:
 301+ if (cursorclipped)
 302+ {
 303+ ClipCursor(NULL);
 304+ cursorclipped = FALSE;
 305+ }
296306 UninstallDXGLFullscreenHook(hWnd);
297307 break;
 308+ case WM_MOVE:
 309+ case WM_KILLFOCUS:
 310+ if (cursorclipped)
 311+ {
 312+ ClipCursor(NULL);
 313+ cursorclipped = FALSE;
 314+ }
 315+ break;
298316 case WM_ACTIVATEAPP:
299317 if (!wParam)
300318 {
@@ -398,6 +416,14 @@
399417 }
400418 break;
401419 case WM_SYSCOMMAND:
 420+ if ((wParam == SC_MOVE) || (wParam == SC_SIZE))
 421+ {
 422+ if (cursorclipped)
 423+ {
 424+ ClipCursor(NULL);
 425+ cursorclipped = FALSE;
 426+ }
 427+ }
402428 if (wParam == SC_RESTORE)
403429 {
404430 if (lpDD7 && (dxglcfg.fullmode < 2)) glDirectDraw7_UnrestoreDisplayMode(lpDD7);
@@ -404,6 +430,27 @@
405431 }
406432 break;
407433 case WM_LBUTTONDOWN:
 434+ if (dxglcfg.CaptureMouse)
 435+ {
 436+ if (!cursorclipped)
 437+ {
 438+ GetClipCursor(&rcOldClip);
 439+ ClipCursor(NULL);
 440+ GetClipCursor(&rcClip);
 441+ if (!memcmp(&rcOldClip, &rcClip, sizeof(RECT)))
 442+ {
 443+ // Cursor is not clipped
 444+ pt.x = 0;
 445+ pt.y = 0;
 446+ GetClientRect(hWnd, &rcWindow);
 447+ ClientToScreen(hWnd, &pt);
 448+ OffsetRect(&rcWindow, pt.x, pt.y);
 449+ ClipCursor(&rcWindow);
 450+ cursorclipped = TRUE;
 451+ }
 452+ else ClipCursor(&rcOldClip);
 453+ }
 454+ }
408455 if (lpDD7)
409456 {
410457 if (((dxglcfg.scaler != 0) || ((dxglcfg.fullmode >= 2) && (dxglcfg.fullmode <= 4)))
@@ -430,6 +477,38 @@
431478 else return CallWindowProc(parentproc, hWnd, uMsg, wParam, lParam);
432479 }
433480 else return CallWindowProc(parentproc, hWnd, uMsg, wParam, lParam);
 481+ case WM_KEYDOWN:
 482+ case WM_SYSKEYDOWN:
 483+ if (dxglcfg.CaptureMouse)
 484+ {
 485+ if (wParam == VK_CONTROL)
 486+ {
 487+ if (GetKeyState(VK_MENU)) keyctrlalt = TRUE;
 488+ }
 489+ if (wParam == VK_MENU)
 490+ {
 491+ if (GetKeyState(VK_CONTROL)) keyctrlalt = TRUE;
 492+ }
 493+ }
 494+ break;
 495+ case WM_KEYUP:
 496+ case WM_SYSKEYUP:
 497+ if (dxglcfg.CaptureMouse)
 498+ {
 499+ if ((wParam == VK_CONTROL) || (wParam == VK_MENU))
 500+ {
 501+ if (keyctrlalt)
 502+ {
 503+ keyctrlalt = FALSE;
 504+ if (cursorclipped)
 505+ {
 506+ ClipCursor(NULL);
 507+ cursorclipped = FALSE;
 508+ }
 509+ }
 510+ }
 511+ }
 512+ break;
434513 case WM_MOUSEMOVE:
435514 case WM_LBUTTONUP:
436515 case WM_LBUTTONDBLCLK:
@@ -502,6 +581,11 @@
503582 }
504583 else return CallWindowProc(parentproc, hWnd, uMsg, wParam, lParam);
505584 case WM_SIZE:
 585+ if (cursorclipped)
 586+ {
 587+ ClipCursor(NULL);
 588+ cursorclipped = FALSE;
 589+ }
506590 if (wParam != SIZE_MINIMIZED)
507591 {
508592 if (((dxglcfg.fullmode == 0) || (dxglcfg.fullmode == 1)) && lpDD7 && (dxglcfg.scaler != 0))