Fix Strange position on window focus
by Brandon Maness · 05/08/2005 (3:29 pm) · 3 comments
We only needed to skip the first render frame when the app gains focus again, so I just used an additional variable to keep track of that first frame.
Go to your .\engine\platformWin32\winWindow.cc file and make these changes:
At the start of winWindow.cc add this variable.
Now go to the setMouseClipping code block around line 150 and make these changes:
Then go to the windowProc code block around line 500 and make these changes to the WM_ACTIVATE code block:
Ok, so with this fix we don
Go to your .\engine\platformWin32\winWindow.cc file and make these changes:
At the start of winWindow.cc add this variable.
static BYTE keyboardState[256]; static bool mouseButtonState[3]; static bool capsLockDown = false; static S32 modifierKeys = 0; static bool windowActive = true; //----Addition here static bool windowNotActive = false; //---- static Point2I lastCursorPos(0,0); static Point2I windowSize; static HANDLE gMutexHandle = NULL;
Now go to the setMouseClipping code block around line 150 and make these changes:
S32 centerX = (r.right + r.left) >> 1;
S32 centerY = (r.bottom + r.top) >> 1;
//<---- Add the IF switch to the SetCursorPos routine
if(!windowNotActive) SetCursorPos(centerX, centerY);
//<----
}
else
//<---- Add the IF switch to the SetCursorPos Here also!
if(!windowNotActive) SetCursorPos(lastCursorPos.x + r.left, lastCursorPos.y + r.top);
//<----
}Then go to the windowProc code block around line 500 and make these changes to the WM_ACTIVATE code block:
case WM_ACTIVATE:
windowActive = LOWORD(wParam) != WA_INACTIVE;
if ( windowActive )
{
//---- ADD THIS HERE!
setMouseClipping();
windowNotActive = false;
//---- END CHANGE
Game->refreshWindow();
Input::activate();
}
else
{
//---- CHANGES HERE
setMouseClipping();
windowNotActive = true;
//----END CHANGES
DInputManager* mgr = dynamic_cast<DInputManager*>( Input::getManager() );
if ( !mgr || !mgr->isMouseActive() )
{
// Deactivate all the mouse triggers:
for ( U32 i = 0; i < 3; i++ )
{
if ( mouseButtonState[i] )
mouseButtonEvent( SI_BREAK, KEY_BUTTON0 + i );
}
}
Input::deactivate();
}
//---- COMMENT THIS LINE OUT
//setMouseClipping();
//----
break;Ok, so with this fix we don
About the author
#2
08/01/2005 (2:27 pm)
nice one :)
#3
from the setMouseClipping() function. Adding the if statement solved the problem for quick clicking, but not clicking and dragging.
06/11/2006 (11:20 pm)
I just did this on TGE 1.3, and I found that it did not work properly until I commented out the line SetCursorPos(lastCursorPos.x + r.left, lastCursorPos.y + r.top);
from the setMouseClipping() function. Adding the if statement solved the problem for quick clicking, but not clicking and dragging.

Torque Owner Nick Zafiris
Nick