DXGL r813 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r812‎ | r813 | r814 >
Date:01:46, 13 May 2018
Author:admin
Status:new
Tags:
Comment:
Add capture mouse option to DXGL Config.
Fix regression preventing profiles list from loading.
Modified paths:
  • /cfgmgr/cfgmgr.c (modified) (history)
  • /cfgmgr/cfgmgr.h (modified) (history)
  • /ddraw/hooks.c (modified) (history)
  • /dxglcfg/dxglcfg.cpp (modified) (history)
  • /dxglcfg/dxglcfg.rc (modified) (history)
  • /dxglcfg/resource.h (modified) (history)

Diff [purge]

Index: cfgmgr/cfgmgr.c
@@ -648,6 +648,7 @@
649649 cfg->WindowWidth = ReadDWORD(hKey, cfg->WindowWidth, &cfgmask->WindowWidth, _T("WindowWidth"));
650650 cfg->WindowHeight = ReadDWORD(hKey, cfg->WindowHeight, &cfgmask->WindowHeight, _T("WindowHeight"));
651651 cfg->WindowMaximized = ReadDWORD(hKey, cfg->WindowMaximized, &cfgmask->WindowMaximized, _T("WindowMaximized"));
 652+ cfg->CaptureMouse = ReadDWORD(hKey, cfg->CaptureMouse, &cfgmask->CaptureMouse, _T("CaptureMouse"));
652653 ReadWindowPos(hKey, cfg, cfgmask);
653654 cfg->Windows8Detected = ReadBool(hKey,cfg->Windows8Detected,&cfgmask->Windows8Detected,_T("Windows8Detected"));
654655 cfg->DPIScale = ReadDWORD(hKey,cfg->DPIScale,&cfgmask->DPIScale,_T("DPIScale"));
@@ -802,6 +803,7 @@
803804 WriteDWORD(hKey, cfg->WindowWidth, cfgmask->WindowWidth, _T("WindowWidth"));
804805 WriteDWORD(hKey, cfg->WindowHeight, cfgmask->WindowHeight, _T("WindowHeight"));
805806 WriteDWORD(hKey, cfg->WindowMaximized, cfgmask->WindowMaximized, _T("WindowMaximized"));
 807+ WriteDWORD(hKey, cfg->CaptureMouse, cfgmask->CaptureMouse, _T("CaptureMouse"));
806808 WriteBool(hKey,cfg->Windows8Detected,cfgmask->Windows8Detected,_T("Windows8Detected"));
807809 WriteDWORD(hKey,cfg->DPIScale,cfgmask->DPIScale,_T("DPIScale"));
808810 WriteFloat(hKey, cfg->aspect, cfgmask->aspect, _T("ScreenAspect"));
@@ -1084,6 +1086,7 @@
10851087 if (!_stricmp(name, "WindowWidth")) cfg->WindowWidth = INIIntValue(value);
10861088 if (!_stricmp(name, "WindowHeight")) cfg->WindowHeight = INIIntValue(value);
10871089 if (!_stricmp(name, "WindowMaximized")) cfg->WindowMaximized = INIBoolValue(value);
 1090+ if (!_stricmp(name, "CaptureMouse")) cfg->CaptureMouse = INIBoolValue(value);
10881091 }
10891092 if (!_stricmp(section, "debug"))
10901093 {
Index: cfgmgr/cfgmgr.h
@@ -78,6 +78,7 @@
7979 DWORD WindowWidth;
8080 DWORD WindowHeight;
8181 BOOL WindowMaximized;
 82+ BOOL CaptureMouse;
8283 // [debug]
8384 BOOL DebugNoExtFramebuffer;
8485 BOOL DebugNoArbFramebuffer;
Index: ddraw/hooks.c
@@ -403,8 +403,34 @@
404404 if (lpDD7 && (dxglcfg.fullmode < 2)) glDirectDraw7_UnrestoreDisplayMode(lpDD7);
405405 }
406406 break;
 407+ case WM_LBUTTONDOWN:
 408+ if (lpDD7)
 409+ {
 410+ if (((dxglcfg.scaler != 0) || ((dxglcfg.fullmode >= 2) && (dxglcfg.fullmode <= 4)))
 411+ && glDirectDraw7_GetFullscreen(lpDD7))
 412+ {
 413+ oldx = LOWORD(lParam);
 414+ oldy = HIWORD(lParam);
 415+ glDirectDraw7_GetSizes(lpDD7, sizes);
 416+ mulx = (float)sizes[2] / (float)sizes[0];
 417+ muly = (float)sizes[3] / (float)sizes[1];
 418+ translatex = (sizes[4] - sizes[0]) / 2;
 419+ translatey = (sizes[5] - sizes[1]) / 2;
 420+ oldx -= translatex;
 421+ oldy -= translatey;
 422+ oldx = (int)((float)oldx * mulx);
 423+ oldy = (int)((float)oldy * muly);
 424+ if (oldx < 0) oldx = 0;
 425+ if (oldy < 0) oldy = 0;
 426+ if (oldx >= sizes[2]) oldx = sizes[2] - 1;
 427+ if (oldy >= sizes[3]) oldy = sizes[3] - 1;
 428+ newpos = oldx + (oldy << 16);
 429+ return CallWindowProc(parentproc, hWnd, uMsg, wParam, newpos);
 430+ }
 431+ else return CallWindowProc(parentproc, hWnd, uMsg, wParam, lParam);
 432+ }
 433+ else return CallWindowProc(parentproc, hWnd, uMsg, wParam, lParam);
407434 case WM_MOUSEMOVE:
408 - case WM_LBUTTONDOWN:
409435 case WM_LBUTTONUP:
410436 case WM_LBUTTONDBLCLK:
411437 case WM_RBUTTONDOWN:
Index: dxglcfg/dxglcfg.cpp
@@ -2056,6 +2056,11 @@
20572057 EnableWindow(GetDlgItem(hDialog, IDC_APPLY), TRUE);
20582058 *dirty = TRUE;
20592059 break;
 2060+ case IDC_CAPTUREMOUSE:
 2061+ cfg->CaptureMouse = GetCheck(hWnd, IDC_CAPTUREMOUSE, &cfgmask->CaptureMouse);
 2062+ EnableWindow(GetDlgItem(hDialog, IDC_APPLY), TRUE);
 2063+ *dirty = TRUE;
 2064+ break;
20602065 default:
20612066 break;
20622067 }
@@ -2606,7 +2611,6 @@
26072612 int newtab;
26082613 DWORD dpisupport;
26092614 TCITEM tab;
2610 - int progresscount;
26112615 HWND hProgressWnd;
26122616 switch (Msg)
26132617 {
@@ -3114,6 +3118,9 @@
31153119 // No autosize
31163120 if (cfg->NoResizeWindow) SendDlgItemMessage(hTabs[3], IDC_NOAUTOSIZE, BM_SETCHECK, BST_CHECKED, 0);
31173121 else SendDlgItemMessage(hTabs[3], IDC_NOAUTOSIZE, BM_SETCHECK, BST_UNCHECKED, 0);
 3122+ // Capture mouse
 3123+ if (cfg->CaptureMouse) SendDlgItemMessage(hTabs[3], IDC_CAPTUREMOUSE, BM_SETCHECK, BST_CHECKED, 0);
 3124+ else SendDlgItemMessage(hTabs[3], IDC_CAPTUREMOUSE, BM_SETCHECK, BST_UNCHECKED, 0);
31183125 // DPI
31193126 dpisupport = GetDPISupportLevel();
31203127 _tcscpy(buffer, _T("Disabled"));
@@ -3244,7 +3251,6 @@
32453252 // Add installed programs
32463253 current_app = 1;
32473254 appcount = 1;
3248 - progresscount = 1;
32493255 regbuffersize = 1024;
32503256 regbuffer = (LPTSTR)malloc(regbuffersize * sizeof(TCHAR));
32513257 RegCreateKeyEx(HKEY_CURRENT_USER, _T("Software\\DXGL\\Profiles"), 0, NULL, 0, KEY_READ, NULL, &hKeyBase, NULL);
@@ -3254,9 +3260,6 @@
32553261 keysize2 = keysize;
32563262 i = 0;
32573263 while (RegEnumKeyEx(hKeyBase, i, keyname, &keysize2, NULL, NULL, NULL, NULL) == ERROR_SUCCESS)
3258 - progresscount++;
3259 - i = 0;
3260 - while (RegEnumKeyEx(hKeyBase, i, keyname, &keysize2, NULL, NULL, NULL, NULL) == ERROR_SUCCESS)
32613264 {
32623265 keysize2 = keysize;
32633266 i++;
@@ -3540,6 +3543,7 @@
35413544 SendDlgItemMessage(hTabs[3], IDC_REMEMBERWINDOWSIZE, BM_SETSTYLE, BS_AUTO3STATE, TRUE);
35423545 SendDlgItemMessage(hTabs[3], IDC_WINDOWMAXIMIZED, BM_SETSTYLE, BS_AUTO3STATE, TRUE);
35433546 SendDlgItemMessage(hTabs[3], IDC_NOAUTOSIZE, BM_SETSTYLE, BS_AUTO3STATE, TRUE);
 3547+ SendDlgItemMessage(hTabs[3], IDC_CAPTUREMOUSE, BM_SETSTYLE, BS_AUTO3STATE, TRUE);
35443548 // Debug tab
35453549 SendDlgItemMessage(hTabs[4], IDC_GLVERSION, CB_ADDSTRING, 0, (LPARAM)strdefault);
35463550 }
@@ -3699,6 +3703,7 @@
37003704 SetInteger(hTabs[3], IDC_WINDOWHEIGHT, cfg->WindowHeight, cfgmask->WindowHeight);
37013705 SetCheck(hTabs[3], IDC_WINDOWMAXIMIZED, cfg->WindowMaximized, cfgmask->WindowMaximized, tristate);
37023706 SetCheck(hTabs[3], IDC_NOAUTOSIZE, cfg->NoResizeWindow, cfgmask->NoResizeWindow, tristate);
 3707+ SetCheck(hTabs[3], IDC_CAPTUREMOUSE, cfg->CaptureMouse, cfgmask->CaptureMouse, tristate);
37033708 // Debug tab
37043709 RedrawWindow(GetDlgItem(hTabs[4], IDC_DEBUGLIST), NULL, NULL, RDW_INVALIDATE);
37053710 SetGLCombo(hTabs[4], IDC_GLVERSION, &cfg->DebugMaxGLVersionMajor, &cfg->DebugMaxGLVersionMinor,
Index: dxglcfg/dxglcfg.rc
@@ -130,6 +130,7 @@
131131 EDITTEXT IDC_WINDOWHEIGHT, 172, 69, 40, 14, ES_AUTOHSCROLL, WS_EX_LEFT
132132 AUTOCHECKBOX "Start resizable window maximized", IDC_WINDOWMAXIMIZED, 7, 88, 120, 8, 0, WS_EX_LEFT
133133 AUTOCHECKBOX "Don't auto-size window in resizable window mode", IDC_NOAUTOSIZE, 7, 101, 171, 8, 0, WS_EX_LEFT
 134+ AUTOCHECKBOX "Capture mouse in window mode (Press Ctrl+Alt to release)", IDC_CAPTUREMOUSE, 7, 114, 196, 8, 0, WS_EX_LEFT
134135 LTEXT "Installation path", IDC_PATHLABEL, 7, 124, 51, 9, SS_LEFT, WS_EX_LEFT
135136 EDITTEXT IDC_PROFILEPATH, 7, 135, 331, 14, NOT WS_BORDER | NOT WS_TABSTOP | ES_AUTOHSCROLL | ES_READONLY, WS_EX_LEFT
136137 // Removed for DXGL 0.5.13 release
Index: dxglcfg/resource.h
@@ -115,9 +115,10 @@
116116 #define IDC_WINDOWHEIGHT 2311
117117 #define IDC_WINDOWMAXIMIZED 2312
118118 #define IDC_NOAUTOSIZE 2313
119 -#define IDC_PATHLABEL 2314
120 -#define IDC_PROFILEPATH 2315
121 -#define IDC_WRITEINI 2316
 119+#define IDC_CAPTUREMOUSE 2314
 120+#define IDC_PATHLABEL 2315
 121+#define IDC_PROFILEPATH 2316
 122+#define IDC_WRITEINI 2317
122123
123124 // Controls - Debug Tab
124125 #define IDC_DEBUGLIST 2401