DXGL r811 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r810‎ | r811 | r812 >
Date:13:36, 12 May 2018
Author:admin
Status:new
Tags:
Comment:
Move mouse window events to window hook (with forwarding from the render window) and fix WM_MOUSEWHEEL and WM_MOUSEHWHEEL positions.
Modified paths:
  • /ddraw/glDirectDraw.cpp (modified) (history)
  • /ddraw/glRenderWindow.cpp (modified) (history)
  • /ddraw/hooks.c (modified) (history)

Diff [purge]

Index: ddraw/glDirectDraw.cpp
@@ -1750,6 +1750,7 @@
17511751 }
17521752 extern "C" BOOL glDirectDraw7_GetFullscreen(glDirectDraw7 *glDD7)
17531753 {
 1754+ if (!glDD7) return FALSE;
17541755 if (glDD7->GetFullscreen()) return TRUE;
17551756 else return FALSE;
17561757 }
Index: ddraw/glRenderWindow.cpp
@@ -177,28 +177,7 @@
178178 case WM_XBUTTONDBLCLK:
179179 case WM_MOUSEHWHEEL:
180180 hParent = GetParent(hwnd);
181 - if(((dxglcfg.scaler != 0) || ((dxglcfg.fullmode >= 2) && (dxglcfg.fullmode <= 4)))
182 - && ddInterface->GetFullscreen())
183 - {
184 - oldx = LOWORD(lParam);
185 - oldy = HIWORD(lParam);
186 - ddInterface->GetSizes(sizes);
187 - mulx = (float)sizes[2] / (float)sizes[0];
188 - muly = (float)sizes[3] / (float)sizes[1];
189 - translatex = (sizes[4]-sizes[0])/2;
190 - translatey = (sizes[5]-sizes[1])/2;
191 - oldx -= translatex;
192 - oldy -= translatey;
193 - oldx = (int)((float)oldx * mulx);
194 - oldy = (int)((float)oldy * muly);
195 - if(oldx < 0) oldx = 0;
196 - if(oldy < 0) oldy = 0;
197 - if(oldx >= sizes[2]) oldx = sizes[2]-1;
198 - if(oldy >= sizes[3]) oldy = sizes[3]-1;
199 - newpos = oldx + (oldy << 16);
200 - return SendMessage(hParent,msg,wParam,newpos);
201 - }
202 - else return SendMessage(hParent,msg,wParam,lParam);
 181+ return SendMessage(hParent,msg,wParam,lParam);
203182 case WM_CLOSE:
204183 DestroyWindow(hWnd);
205184 return 0;
Index: ddraw/hooks.c
@@ -272,10 +272,15 @@
273273 HWND_HOOK *wndhook;
274274 STYLESTRUCT *style;
275275 RECT r1, r2;
 276+ POINT pt;
276277 LONG sizes[6];
277278 BOOL fixstyle = FALSE;
278279 LONG winstyle, exstyle;
279280 LPDIRECTDRAW7 lpDD7;
 281+ int oldx, oldy;
 282+ float mulx, muly;
 283+ int translatex, translatey;
 284+ LPARAM newpos;
280285 wndhook = GetWndHook(hWnd);
281286 if (!wndhook)
282287 {
@@ -398,6 +403,78 @@
399404 if (lpDD7 && (dxglcfg.fullmode < 2)) glDirectDraw7_UnrestoreDisplayMode(lpDD7);
400405 }
401406 break;
 407+ case WM_MOUSEMOVE:
 408+ case WM_LBUTTONDOWN:
 409+ case WM_LBUTTONUP:
 410+ case WM_LBUTTONDBLCLK:
 411+ case WM_RBUTTONDOWN:
 412+ case WM_RBUTTONUP:
 413+ case WM_RBUTTONDBLCLK:
 414+ case WM_MBUTTONDOWN:
 415+ case WM_MBUTTONUP:
 416+ case WM_MBUTTONDBLCLK:
 417+ case WM_XBUTTONDOWN:
 418+ case WM_XBUTTONUP:
 419+ case WM_XBUTTONDBLCLK:
 420+ if (lpDD7)
 421+ {
 422+ if (((dxglcfg.scaler != 0) || ((dxglcfg.fullmode >= 2) && (dxglcfg.fullmode <= 4)))
 423+ && glDirectDraw7_GetFullscreen(lpDD7))
 424+ {
 425+ oldx = LOWORD(lParam);
 426+ oldy = HIWORD(lParam);
 427+ glDirectDraw7_GetSizes(lpDD7, sizes);
 428+ mulx = (float)sizes[2] / (float)sizes[0];
 429+ muly = (float)sizes[3] / (float)sizes[1];
 430+ translatex = (sizes[4] - sizes[0]) / 2;
 431+ translatey = (sizes[5] - sizes[1]) / 2;
 432+ oldx -= translatex;
 433+ oldy -= translatey;
 434+ oldx = (int)((float)oldx * mulx);
 435+ oldy = (int)((float)oldy * muly);
 436+ if (oldx < 0) oldx = 0;
 437+ if (oldy < 0) oldy = 0;
 438+ if (oldx >= sizes[2]) oldx = sizes[2] - 1;
 439+ if (oldy >= sizes[3]) oldy = sizes[3] - 1;
 440+ newpos = oldx + (oldy << 16);
 441+ return CallWindowProc(parentproc, hWnd, uMsg, wParam, newpos);
 442+ }
 443+ else return CallWindowProc(parentproc, hWnd, uMsg, wParam, lParam);
 444+ }
 445+ else return CallWindowProc(parentproc, hWnd, uMsg, wParam, lParam);
 446+ case WM_MOUSEWHEEL:
 447+ case WM_MOUSEHWHEEL:
 448+ if (lpDD7)
 449+ {
 450+ if (((dxglcfg.scaler != 0) || ((dxglcfg.fullmode >= 2) && (dxglcfg.fullmode <= 4)))
 451+ && glDirectDraw7_GetFullscreen(lpDD7))
 452+ {
 453+ oldx = LOWORD(lParam);
 454+ oldy = HIWORD(lParam);
 455+ glDirectDraw7_GetSizes(lpDD7, sizes);
 456+ mulx = (float)sizes[2] / (float)sizes[0];
 457+ muly = (float)sizes[3] / (float)sizes[1];
 458+ translatex = (sizes[4] - sizes[0]) / 2;
 459+ translatey = (sizes[5] - sizes[1]) / 2;
 460+ oldx -= translatex;
 461+ oldy -= translatey;
 462+ pt.x = 0;
 463+ pt.y = 0;
 464+ ClientToScreen(hWnd, &pt);
 465+ oldx -= pt.x;
 466+ oldy -= pt.y;
 467+ oldx = (int)((float)oldx * mulx);
 468+ oldy = (int)((float)oldy * muly);
 469+ if (oldx < 0) oldx = 0;
 470+ if (oldy < 0) oldy = 0;
 471+ if (oldx >= sizes[2]) oldx = sizes[2] - 1;
 472+ if (oldy >= sizes[3]) oldy = sizes[3] - 1;
 473+ newpos = oldx + (oldy << 16);
 474+ return CallWindowProc(parentproc, hWnd, uMsg, wParam, newpos);
 475+ }
 476+ else return CallWindowProc(parentproc, hWnd, uMsg, wParam, lParam);
 477+ }
 478+ else return CallWindowProc(parentproc, hWnd, uMsg, wParam, lParam);
402479 case WM_SIZE:
403480 if (wParam != SIZE_MINIMIZED)
404481 {