MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / _dispatch

Function _dispatch

Engine/source/windowManager/win32/winDispatch.cpp:175–498  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

173//-----------------------------------------------------------------------------
174
175static bool _dispatch(HWND hWnd,UINT message,WPARAM wParam,WPARAM lParam)
176{
177 static bool button[3] = {false,false,false};
178 static S32 mouseNCState = -1; // -1 denotes unchanged,
179 // 0 denotes changed but was hidden
180 // 1 denotes changed but was visible
181 Win32Window* window = hWnd?(Win32Window*)GetWindowLongPtr(hWnd, GWLP_USERDATA): 0;
182 const WindowId devId = window ? window->getWindowId() : 0;
183
184 // State tracking for focus/lose focus cursor management
185 static bool cursorLocked = false;
186 static bool cursorVisible = true;
187
188 switch(message)
189 {
190 case WM_MOUSEMOVE:
191 {
192 // Skip it if we have no window!
193 if (!window || !window->getCursorController())
194 break;
195
196
197 PlatformCursorController *pController = window->getCursorController();
198
199 // If we're locked and unfocused, ignore it.
200 if(window->shouldLockMouse() && !window->isFocused())
201 break;
202
203 // If the mouse was shown to accommodate a NC mouse move
204 // we need to change it back to what it was
205 if( mouseNCState != -1 )
206 {
207 pController->setCursorVisible( mouseNCState );
208 mouseNCState = -1; // reset to unchanged
209 }
210
211 // Let the cursor manager update the native cursor.
212 pController->refreshCursor();
213
214 // Grab the mouse pos so we can modify it.
215 S32 mouseX = S16(LOWORD(lParam));
216 S32 mouseY = S16(HIWORD(lParam));
217
218 // Ensure mouse lock when appropriate
219 window->setMouseLocked( window->shouldLockMouse() );
220
221 // Are we locked?
222 if(window->isMouseLocked())
223 {
224 // Always invisible when locked.
225 if( window->isCursorVisible() )
226 window->setCursorVisible( false );
227
228 RECT r;
229 GetWindowRect(window->getHWND(), &r);
230
231 // See Win32Window::setMouseLocked for explanation
232 RECT rCopy = r;

Callers 2

DispatchFunction · 0.85
DispatchNextFunction · 0.85

Calls 15

_keyboardEventFunction · 0.85
compareFunction · 0.85
IsPlayingFunction · 0.85
RemoveMessagesFunction · 0.85
getCursorControllerMethod · 0.80
refreshCursorMethod · 0.80
dMemsetFunction · 0.50
isActiveFunction · 0.50
getWindowIdMethod · 0.45
shouldLockMouseMethod · 0.45
isFocusedMethod · 0.45
setCursorVisibleMethod · 0.45

Tested by

no test coverage detected