@@ -238,12 +238,45 @@ void MouseEngine::OnMouseMoveCross(MouseEventArg& e)
238
238
239
239
int stallCount = 0 ;
240
240
241
+ bool canCross (bool checkEdge, MouseEngine* engine, MouseEventArg& e) {
242
+ if (!checkEdge) {
243
+ #if defined(_DEBUG)
244
+ std::cout << " edge not checked\n " ;
245
+ #endif
246
+ stallCount = 0 ;
247
+ // Allow transistion
248
+ return true ;
249
+ }
250
+
251
+ bool isTriggerKeyPressed = engine->enableCtrlKeyCrossing && ((GetAsyncKeyState (VK_CONTROL) & 0x8000 ) == 0x8000 );
252
+ if (isTriggerKeyPressed) {
253
+ #if defined(_DEBUG)
254
+ std::cout << " trigger key pressed\n " ;
255
+ #endif
256
+ stallCount = 0 ;
257
+ // Allow transistion
258
+ return true ;
259
+ }
260
+
261
+ stallCount++;
262
+ #if defined(_DEBUG)
263
+ std::cout << " count " << stallCount << " \n " ;
264
+ #endif
265
+ if (stallCount < engine->controlCrossingThreshold ) {
266
+ // Cannot cross yet
267
+ return false ;
268
+ }
269
+
270
+ stallCount = 0 ;
271
+ // Allow transistion
272
+ return true ;
273
+ }
274
+
241
275
void MouseEngine::OnMouseMoveStraight (MouseEventArg& e)
242
276
{
243
277
ResetClip ();
244
278
if (CheckForStopped (e)) return ;
245
279
246
- int triggerKey = VK_CONTROL;
247
280
const auto pIn = e.Point ;
248
281
249
282
const ZoneLink* zoneOut;
@@ -254,26 +287,8 @@ void MouseEngine::OnMouseMoveStraight(MouseEventArg& e)
254
287
if (pIn.X () >= bounds.Right ())
255
288
{
256
289
zoneOut = _oldZone->RightZones ->AtPixel (pIn.Y ());
257
- if (zoneOut->Target )
290
+ if (zoneOut->Target && canCross (enableControlVertEdgeCrossing, this , e) )
258
291
{
259
- bool isTriggerKeyPressed = enableCtrlKeyCrossing && ((GetAsyncKeyState (triggerKey) & 0x8000 ) == 0x8000 );
260
- if (enableControlVertEdgeCrossing && !isTriggerKeyPressed)
261
- {
262
- stallCount++;
263
- if (stallCount < controlCrossingThreshold) {
264
- #if defined(_DEBUG)
265
- std::cout << " count " << stallCount << " \n " ;
266
- #endif
267
- NoZoneMatches (e);
268
- return ;
269
- }
270
- else {
271
- stallCount = 0 ;
272
- }
273
- }
274
- stallCount = 0 ;
275
- pOut = { zoneOut->ToTargetPixel (pIn.X ()), zoneOut->Target ->PixelsBounds ().Top () };
276
-
277
292
pOut = { zoneOut->Target ->PixelsBounds ().Left (),zoneOut->ToTargetPixel (pIn.Y ()) };
278
293
}
279
294
else
@@ -286,26 +301,8 @@ void MouseEngine::OnMouseMoveStraight(MouseEventArg& e)
286
301
else if (pIn.X () < bounds.Left ())
287
302
{
288
303
zoneOut = _oldZone->LeftZones ->AtPixel (pIn.Y ());
289
- if (zoneOut->Target )
304
+ if (zoneOut->Target && canCross (enableControlVertEdgeCrossing, this , e) )
290
305
{
291
- bool isTriggerKeyPressed = enableCtrlKeyCrossing && ((GetAsyncKeyState (triggerKey) & 0x8000 ) == 0x8000 );
292
- if (enableControlVertEdgeCrossing && !isTriggerKeyPressed)
293
- {
294
- stallCount++;
295
- if (stallCount < controlCrossingThreshold) {
296
- #if defined(_DEBUG)
297
- std::cout << " count " << stallCount << " \n " ;
298
- #endif
299
- NoZoneMatches (e);
300
- return ;
301
- }
302
- else {
303
- stallCount = 0 ;
304
- }
305
- }
306
- stallCount = 0 ;
307
- pOut = { zoneOut->ToTargetPixel (pIn.X ()), zoneOut->Target ->PixelsBounds ().Top () };
308
-
309
306
pOut = { zoneOut->Target ->PixelsBounds ().Right () - 1 ,zoneOut->ToTargetPixel (pIn.Y ()) };
310
307
}
311
308
else
@@ -318,29 +315,13 @@ void MouseEngine::OnMouseMoveStraight(MouseEventArg& e)
318
315
else if (pIn.Y () >= bounds.Bottom ())
319
316
{
320
317
zoneOut = _oldZone->BottomZones ->AtPixel (pIn.X ());
321
- if (zoneOut->Target )
318
+ if (zoneOut->Target && canCross (enableControlHorzEdgeCrossing, this , e) )
322
319
{
323
- bool isTriggerKeyPressed = enableCtrlKeyCrossing && ((GetAsyncKeyState (triggerKey) & 0x8000 ) == 0x8000 );
324
- if (enableControlHorzEdgeCrossing && !isTriggerKeyPressed)
325
- {
326
- stallCount++;
327
- if (stallCount < controlCrossingThreshold) {
328
- #if defined(_DEBUG)
329
- std::cout << " count " << stallCount << " \n " ;
330
- #endif
331
- NoZoneMatches (e);
332
- return ;
333
- }
334
- else {
335
- stallCount = 0 ;
336
- }
337
- }
338
- stallCount = 0 ;
339
320
pOut = { zoneOut->ToTargetPixel (pIn.X ()), zoneOut->Target ->PixelsBounds ().Top () };
340
321
}
341
322
else
342
323
{
343
- stallCount = 0 ;
324
+ // stallCount = 0;
344
325
NoZoneMatches (e);
345
326
return ;
346
327
}
@@ -349,28 +330,13 @@ void MouseEngine::OnMouseMoveStraight(MouseEventArg& e)
349
330
else if (pIn.Y () < _oldZone->PixelsBounds ().Top ())
350
331
{
351
332
zoneOut = _oldZone->TopZones ->AtPixel (pIn.X ());
352
- if (zoneOut->Target )
333
+ if (zoneOut->Target && canCross (enableControlHorzEdgeCrossing, this , e) )
353
334
{
354
- bool isTriggerKeyPressed = enableCtrlKeyCrossing && ((GetAsyncKeyState (triggerKey) & 0x8000 ) == 0x8000 );
355
- if (enableControlHorzEdgeCrossing && !isTriggerKeyPressed)
356
- {
357
- stallCount++;
358
- if (stallCount < controlCrossingThreshold) {
359
- #if defined(_DEBUG)
360
- std::cout << " count " << stallCount << " \n " ;
361
- #endif
362
- NoZoneMatches (e);
363
- return ;
364
- }
365
- else {
366
- stallCount = 0 ;
367
- }
368
- }
369
335
pOut = { zoneOut->ToTargetPixel (pIn.X ()),zoneOut->Target ->PixelsBounds ().Bottom () - 1 };
370
336
}
371
337
else
372
338
{
373
- stallCount = 0 ;
339
+ // stallCount = 0;
374
340
NoZoneMatches (e);
375
341
return ;
376
342
}
0 commit comments