@@ -89,14 +89,24 @@ static bool operator==(const Ss3ToVkey& pair, const Ss3ActionCodes code) noexcep
89
89
return pair.action == code;
90
90
}
91
91
92
- InputStateMachineEngine::InputStateMachineEngine (std::unique_ptr<IInteractDispatch> pDispatch, const bool lookingForDSR ) :
93
- _pDispatch( std::move(pDispatch)) ,
94
- _lookingForDSR(lookingForDSR) ,
95
- _doubleClickTime( std::chrono::milliseconds(GetDoubleClickTime()))
92
+ InputStateMachineEngine::InputStateMachineEngine (std::unique_ptr<IInteractDispatch> pDispatch, std::function< void ()> capturedCPR ) :
93
+ _pDispatch{ std::move (pDispatch) } ,
94
+ _capturedCPR{ std::move (capturedCPR) } ,
95
+ _doubleClickTime{ std::chrono::milliseconds (GetDoubleClickTime ()) }
96
96
{
97
97
THROW_HR_IF_NULL (E_INVALIDARG, _pDispatch.get ());
98
98
}
99
99
100
+ IInteractDispatch& InputStateMachineEngine::GetDispatch () const noexcept
101
+ {
102
+ return *_pDispatch.get ();
103
+ }
104
+
105
+ void InputStateMachineEngine::CaptureNextCPR () noexcept
106
+ {
107
+ _lookingForCPR = true ;
108
+ }
109
+
100
110
til::enumset<DeviceAttribute, uint64_t > InputStateMachineEngine::WaitUntilDA1 (DWORD timeout) const noexcept
101
111
{
102
112
uint64_t val = 0 ;
@@ -413,13 +423,19 @@ bool InputStateMachineEngine::ActionCsiDispatch(const VTID id, const VTParameter
413
423
// The F3 case is special - it shares a code with the DeviceStatusResponse.
414
424
// If we're looking for that response, then do that, and break out.
415
425
// Else, fall though to the _GetCursorKeysModifierState handler.
416
- if (_lookingForDSR )
426
+ if (_lookingForCPR )
417
427
{
418
- _pDispatch->MoveCursor (parameters.at (0 ), parameters.at (1 ));
419
- // Right now we're only looking for on initial cursor
420
- // position response. After that, only look for F3.
421
- _lookingForDSR = false ;
422
- return true ;
428
+ _lookingForCPR = false ;
429
+ _capturedCPR ();
430
+
431
+ const auto y = parameters.at (0 ).value ();
432
+ const auto x = parameters.at (1 ).value ();
433
+
434
+ if (y > 0 && x > 0 )
435
+ {
436
+ _pDispatch->MoveCursor (y, x);
437
+ return true ;
438
+ }
423
439
}
424
440
// Heuristic: If the hosting terminal used the win32 input mode, chances are high
425
441
// that this is a CPR requested by the terminal application as opposed to a F3 key.
@@ -491,10 +507,6 @@ bool InputStateMachineEngine::ActionCsiDispatch(const VTID id, const VTParameter
491
507
492
508
_deviceAttributes.fetch_or (attributes.bits (), std::memory_order_relaxed);
493
509
til::atomic_notify_all (_deviceAttributes);
494
-
495
- // VtIo first sends a DSR CPR and then a DA1 request.
496
- // If we encountered a DA1 response here, the DSR request is definitely done now.
497
- _lookingForDSR = false ;
498
510
return true ;
499
511
}
500
512
return false ;
0 commit comments