Browse Source

Fixed core bug. Wasn't what we thought it was.

Tig 1 year ago
parent
commit
f68adf77ae

+ 7 - 2
Terminal.Gui/View/Adornment/Border.cs

@@ -198,9 +198,14 @@ public class Border : Adornment
             return true;
         }
 
-        if (!Parent.CanFocus || !Parent.Arrangement.HasFlag (ViewArrangement.Movable))
+        if (!Parent.CanFocus)
         {
-            return true;
+            return false;
+        }
+
+        if (!Parent.Arrangement.HasFlag (ViewArrangement.Movable))
+        {
+            return false;
         }
 
         // BUGBUG: See https://github.com/gui-cs/Terminal.Gui/issues/3312

+ 1 - 1
Terminal.Gui/View/Layout/ViewLayout.cs

@@ -975,7 +975,7 @@ public partial class View
         // First try SuperView.Bounds, then Application.Top, then Driver.Bounds.
         // Finally, if none of those are valid, use int.MaxValue (for Unit tests).
         Rectangle relativeBounds = SuperView is { IsInitialized: true } ? SuperView.Bounds :
-                                   Application.Top is { } && Application.Top.IsInitialized ? Application.Top.Bounds :
+                                   Application.Top is { } && Application.Top != this && Application.Top.IsInitialized ? Application.Top.Bounds :
                                    Application.Driver?.Bounds ?? new Rectangle (0, 0, int.MaxValue, int.MaxValue);
         SetRelativeLayout (relativeBounds);
 

+ 4 - 4
UnitTests/View/MouseTests.cs

@@ -38,22 +38,22 @@ public class MouseTests (ITestOutputHelper output)
     [Theory]
     [InlineData (0, 0, 0, 0, false)]
     [InlineData (0, 0, 0, 4, false)]
-    [InlineData (1, 0, 0, 4, true)]
+    [InlineData (1, 0, 0, 4, false)]
     [InlineData (0, 1, 0, 4, true)]
     [InlineData (0, 0, 1, 4, false)]
 
     [InlineData (1, 1, 0, 3, false)]
-    [InlineData (1, 1, 0, 4, true)]
+    [InlineData (1, 1, 0, 4, false)]
     [InlineData (1, 1, 0, 5, true)]
     [InlineData (1, 1, 0, 6, false)]
 
 
     [InlineData (1, 1, 0, 11, false)]
     [InlineData (1, 1, 0, 12, true)]
-    [InlineData (1, 1, 0, 13, true)]
+    [InlineData (1, 1, 0, 13, false)]
     [InlineData (1, 1, 0, 14, false)]
     [AutoInitShutdown]
-    public void ButtonPressed_In_Margin_Or_Border_Starts_Drag (int marginThickness, int borderThickness, int paddingThickness, int xy, bool expectedMoved)
+    public void ButtonPressed_In_Border_Starts_Drag (int marginThickness, int borderThickness, int paddingThickness, int xy, bool expectedMoved)
     {
         var testView = new View
         {