Browse Source

Merge branch 'master' of tig:migueldeicaza/gui.cs

Charlie Kindel 5 years ago
parent
commit
dcd1e9fe45
2 changed files with 19 additions and 19 deletions
  1. 15 15
      Terminal.Gui/Core/Window.cs
  2. 4 4
      UnitTests/MainLoopTests.cs

+ 15 - 15
Terminal.Gui/Core/Window.cs

@@ -205,8 +205,21 @@ namespace Terminal.Gui {
 			// a pending mouse event activated.
 			// a pending mouse event activated.
 
 
 			int nx, ny;
 			int nx, ny;
-			if ((mouseEvent.Flags == (MouseFlags.Button1Pressed | MouseFlags.ReportMousePosition) ||
-				mouseEvent.Flags == MouseFlags.Button3Pressed)) {
+			if (!dragPosition.HasValue && mouseEvent.Flags == (MouseFlags.Button1Pressed)) {
+				// Only start grabbing if the user clicks on the title bar.
+				if (mouseEvent.Y == 0) {
+					start = new Point (mouseEvent.X, mouseEvent.Y);
+					dragPosition = new Point ();
+					nx = mouseEvent.X - mouseEvent.OfX;
+					ny = mouseEvent.Y - mouseEvent.OfY;
+					dragPosition = new Point (nx, ny);
+					Application.GrabMouse (this);
+				}
+
+				//Demo.ml2.Text = $"Starting at {dragPosition}";
+				return true;
+			} else if (mouseEvent.Flags == (MouseFlags.Button1Pressed | MouseFlags.ReportMousePosition) ||
+				mouseEvent.Flags == MouseFlags.Button3Pressed) {
 				if (dragPosition.HasValue) {
 				if (dragPosition.HasValue) {
 					if (SuperView == null) {
 					if (SuperView == null) {
 						Application.Top.SetNeedsDisplay (Frame);
 						Application.Top.SetNeedsDisplay (Frame);
@@ -229,19 +242,6 @@ namespace Terminal.Gui {
 					// FIXED: optimize, only SetNeedsDisplay on the before/after regions.
 					// FIXED: optimize, only SetNeedsDisplay on the before/after regions.
 					SetNeedsDisplay ();
 					SetNeedsDisplay ();
 					return true;
 					return true;
-				} else {
-					// Only start grabbing if the user clicks on the title bar.
-					if (mouseEvent.Y == 0) {
-						start = new Point (mouseEvent.X, mouseEvent.Y);
-						dragPosition = new Point ();
-						nx = mouseEvent.X - mouseEvent.OfX;
-						ny = mouseEvent.Y - mouseEvent.OfY;
-						dragPosition = new Point (nx, ny);
-						Application.GrabMouse (this);
-					}
-
-					//Demo.ml2.Text = $"Starting at {dragPosition}";
-					return true;
 				}
 				}
 			}
 			}
 
 

+ 4 - 4
UnitTests/MainLoopTests.cs

@@ -289,9 +289,9 @@ namespace Terminal.Gui {
 			var token = ml.AddTimeout (ms, callback);
 			var token = ml.AddTimeout (ms, callback);
 			watch.Start ();
 			watch.Start ();
 			ml.Run ();
 			ml.Run ();
-			// +/- 10ms should be good enuf
+			// +/- 100ms should be good enuf
 			// https://github.com/xunit/assert.xunit/pull/25
 			// https://github.com/xunit/assert.xunit/pull/25
-			Assert.Equal<TimeSpan> (ms * callbackCount, watch.Elapsed, new MillisecondTolerance (10));
+			Assert.Equal<TimeSpan> (ms * callbackCount, watch.Elapsed, new MillisecondTolerance (100));
 
 
 			ml.RemoveTimeout (token);
 			ml.RemoveTimeout (token);
 			Assert.Equal (1, callbackCount);
 			Assert.Equal (1, callbackCount);
@@ -317,9 +317,9 @@ namespace Terminal.Gui {
 			var token = ml.AddTimeout (ms, callback);
 			var token = ml.AddTimeout (ms, callback);
 			watch.Start ();
 			watch.Start ();
 			ml.Run ();
 			ml.Run ();
-			// +/- 10ms should be good enuf
+			// +/- 100ms should be good enuf
 			// https://github.com/xunit/assert.xunit/pull/25
 			// https://github.com/xunit/assert.xunit/pull/25
-			Assert.Equal<TimeSpan> (ms * callbackCount, watch.Elapsed, new MillisecondTolerance (10));
+			Assert.Equal<TimeSpan> (ms * callbackCount, watch.Elapsed, new MillisecondTolerance (100));
 
 
 			ml.RemoveTimeout (token);
 			ml.RemoveTimeout (token);
 			Assert.Equal (2, callbackCount);
 			Assert.Equal (2, callbackCount);