From 5626edf43d3af335551253dd9f129891aea74bb0 Mon Sep 17 00:00:00 2001
From: alyosha-tas <alexei.f.k@gmail.com>
Date: Tue, 12 Oct 2021 19:04:43 -0400
Subject: [PATCH] TAStudio: do not seek when needing to load greenzone on paint

---
 .../tools/TAStudio/TAStudio.ListView.cs                | 10 +++++-----
 .../tools/TAStudio/TAStudio.Navigation.cs              |  8 ++++----
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs b/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs
index e4ab397c3e..bf058bfb01 100644
--- a/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs
+++ b/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs
@@ -67,11 +67,11 @@ namespace BizHawk.Client.EmuHawk
 		public AutoPatternBool[] BoolPatterns;
 		public AutoPatternAxis[] AxisPatterns;
 
-		public void JumpToGreenzone()
+		public void JumpToGreenzone(bool OnLeftMouseDown = false)
 		{
 			if (Emulator.Frame > CurrentTasMovie.LastEditedFrame)
 			{
-				GoToLastEmulatedFrameIfNecessary(CurrentTasMovie.LastEditedFrame);
+				GoToLastEmulatedFrameIfNecessary(CurrentTasMovie.LastEditedFrame, OnLeftMouseDown);
 			}
 		}
 
@@ -611,7 +611,7 @@ namespace BizHawk.Client.EmuHawk
 				if (TasView.CurrentCell.Column.Name == CursorColumnName)
 				{
 					_startCursorDrag = true;
-					GoToFrame(TasView.CurrentCell.RowIndex.Value);
+					GoToFrame(TasView.CurrentCell.RowIndex.Value, false, false, true);
 				}
 				else if (TasView.CurrentCell.Column.Name == FrameColumnName)
 				{
@@ -673,7 +673,7 @@ namespace BizHawk.Client.EmuHawk
 							CurrentTasMovie.SetBoolStates(firstSel, (frame - firstSel) + 1, buttonName, !allPressed);
 							_boolPaintState = CurrentTasMovie.BoolIsPressed(frame, buttonName);
 							_triggerAutoRestore = true;
-							JumpToGreenzone();
+							JumpToGreenzone(true);
 							RefreshDialog();
 						}
 						else if (ModifierKeys == Keys.Shift && ModifierKeys == Keys.Alt) // Does not work?
@@ -687,7 +687,7 @@ namespace BizHawk.Client.EmuHawk
 							CurrentTasMovie.ToggleBoolState(TasView.CurrentCell.RowIndex.Value, buttonName);
 							_boolPaintState = CurrentTasMovie.BoolIsPressed(frame, buttonName);
 							_triggerAutoRestore = true;
-							JumpToGreenzone();
+							JumpToGreenzone(true);
 							RefreshDialog();
 						}
 					}
diff --git a/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.Navigation.cs b/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.Navigation.cs
index 17ba30d740..7b49ef194a 100644
--- a/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.Navigation.cs
+++ b/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.Navigation.cs
@@ -7,7 +7,7 @@ namespace BizHawk.Client.EmuHawk
 		/// <summary>
 		/// Only goes to go to the frame if it is an event before current emulation, otherwise it is just a future event that can freely be edited
 		/// </summary>
-		private void GoToLastEmulatedFrameIfNecessary(int frame)
+		private void GoToLastEmulatedFrameIfNecessary(int frame, bool OnLeftMouseDown = false)
 		{
 			if (frame != Emulator.Frame) // Don't go to a frame if you are already on it!
 			{
@@ -20,12 +20,12 @@ namespace BizHawk.Client.EmuHawk
 						CurrentTasMovie.LastPositionStable = true; // until new frame is emulated
 					}
 
-					GoToFrame(frame);
+					GoToFrame(frame, false, false, OnLeftMouseDown);
 				}
 			}
 		}
 
-		public void GoToFrame(int frame, bool fromLua = false, bool fromRewinding = false)
+		public void GoToFrame(int frame, bool fromLua = false, bool fromRewinding = false, bool OnLeftMouseDown = false)
 		{
 			// If seeking to a frame before or at the end of the movie, use StartAtNearestFrameAndEmulate
 			// Otherwise, load the latest state (if not already there) and seek while recording.
@@ -35,7 +35,7 @@ namespace BizHawk.Client.EmuHawk
 			{
 				// Get as close as we can then emulate there
 				StartAtNearestFrameAndEmulate(frame, fromLua, fromRewinding);
-				MaybeFollowCursor();
+				if (!OnLeftMouseDown) { MaybeFollowCursor(); }			
 			}
 			else // Emulate to a future frame
 			{