Fix #134733: NDOF jumps when switching between applications
Window de-activation wasn't reliably clearing the NDOF motion state. See code-comments for details.
This commit is contained in:
@@ -674,6 +674,17 @@ static bool nearHomePosition(const GHOST_TEventNDOFMotionData *ndof, float thres
|
||||
bool GHOST_NDOFManager::sendMotionEvent()
|
||||
{
|
||||
if (!motion_event_pending_) {
|
||||
if (motion_state_ != GHOST_kNotStarted) {
|
||||
/* Detect window de-activation and change the `motion_state_` even when no motion is pending.
|
||||
* Without this check it's possible the window is de-activated before the NDOF
|
||||
* motion callbacks have run, while the `motion_state_` is active.
|
||||
* In this case, activating the window again would create an event
|
||||
* with a large time-delta, see: #134733. */
|
||||
if (system_.getWindowManager()->getActiveWindow() == nullptr) {
|
||||
/* Avoid large `dt` times when changing windows. */
|
||||
motion_state_ = GHOST_kNotStarted;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user