Tig 1 gadu atpakaļ
vecāks
revīzija
523019f0bf

+ 12 - 11
Terminal.Gui/Application.cs

@@ -4,6 +4,7 @@ using System.Globalization;
 using System.Reflection;
 using System.Reflection.Metadata.Ecma335;
 using System.Text.Json.Serialization;
+using Microsoft.CodeAnalysis;
 using static Unix.Terminal.Curses;
 
 namespace Terminal.Gui;
@@ -967,7 +968,7 @@ public static partial class Application
 
         if (PositionCursor (state.Toplevel))
         {
-            Driver.UpdateCursor();
+            Driver.UpdateCursor ();
         }
 
         //        else
@@ -1226,10 +1227,10 @@ public static partial class Application
     /// <value>The current.</value>
     public static Toplevel Current { get; private set; }
 
-    private static void EnsureModalOrVisibleAlwaysOnTop (Toplevel Toplevel)
+    private static void EnsureModalOrVisibleAlwaysOnTop (Toplevel topLevel)
     {
-        if (!Toplevel.Running
-            || (Toplevel == Current && Toplevel.Visible)
+        if (!topLevel.Running
+            || (topLevel == Current && topLevel.Visible)
             || OverlappedTop == null
             || _topLevels.Peek ().Modal)
         {
@@ -1246,24 +1247,24 @@ public static partial class Application
             }
         }
 
-        if (!Toplevel.Visible && Toplevel == Current)
+        if (!topLevel.Visible && topLevel == Current)
         {
             OverlappedMoveNext ();
         }
     }
 
 #nullable enable
-    private static Toplevel? FindDeepestTop (Toplevel start, int x, int y)
+    private static Toplevel? FindDeepestTop (Toplevel start, in Point location)
     {
-        if (!start.Frame.Contains (x, y))
+        if (!start.Frame.Contains (location))
         {
             return null;
         }
 
         if (_topLevels is { Count: > 0 })
         {
-            int rx = x - start.Frame.X;
-            int ry = y - start.Frame.Y;
+            int rx = location.X - start.Frame.X;
+            int ry = location.Y - start.Frame.Y;
 
             foreach (Toplevel t in _topLevels)
             {
@@ -1617,10 +1618,10 @@ public static partial class Application
             {
                 // This occurs when there are multiple overlapped "tops"
                 // E.g. "Mdi" - in the Background Worker Scenario
-                View? top = FindDeepestTop (Top, mouseEvent.Position.X, mouseEvent.Position.Y);
+                View? top = FindDeepestTop (Top, mouseEvent.Position);
                 view = View.FindDeepestView (top, mouseEvent.Position);
 
-                if (view is { } && view != OverlappedTop && top != Current)
+                if (view is { } && view != OverlappedTop && top != Current && top is { })
                 {
                     MoveCurrent ((Toplevel)top);
                 }

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

@@ -523,7 +523,7 @@ public partial class View
             maxDimension -= superView.GetAdornmentsThickness ().Left + superView.GetAdornmentsThickness ().Right;
         }
 
-        if (viewToMove.Frame.Width <= maxDimension)
+        if (viewToMove!.Frame.Width <= maxDimension)
         {
             nx = Math.Max (targetX, 0);
             nx = nx + viewToMove.Frame.Width > maxDimension ? Math.Max (maxDimension - viewToMove.Frame.Width, 0) : nx;
@@ -555,9 +555,9 @@ public partial class View
                 t = t.SuperView;
             }
 
-            if (t is Toplevel toplevel)
+            if (t is Toplevel topLevel)
             {
-                menuVisible = toplevel.MenuBar?.Visible == true;
+                menuVisible = topLevel.MenuBar?.Visible == true;
             }
         }
 

+ 3 - 0
Terminal.Gui/View/ViewContent.cs

@@ -431,6 +431,8 @@ public partial class View
     /// <remarks>
     ///     Viewport-relative means relative to the top-left corner of the inner rectangle of the <see cref="Padding"/>.
     /// </remarks>
+    /// <param name="location">Viewport-relative location.</param>
+    /// <returns>Screen-relative location.</returns>
     public Rectangle ViewportToScreen (in Rectangle location)
     {
         // Translate bounds to Frame (our SuperView's Viewport-relative coordinates)
@@ -447,6 +449,7 @@ public partial class View
     ///     Viewport-relative means relative to the top-left corner of the inner rectangle of the <see cref="Padding"/>.
     /// </remarks>
     /// <param name="location">Screen-Relative Coordinate.</param>
+    /// <returns>Viewport-relative location.</returns>
     public Point ScreenToViewport (in Point location)
     {
         Point viewportOffset = GetViewportOffsetFromFrame ();

+ 1 - 1
Terminal.Gui/Views/Menu/MenuBar.cs

@@ -1496,7 +1496,7 @@ public class MenuBar : View
     // Set in OnInvokingKeyBindings. null means no sub-menu is selected for activation.
     private MenuItem _menuItemToSelect;
     private bool _openedByAltKey;
-    private bool _openedByHotKey;
+    //private bool _openedByHotKey;
 
     /// <summary>
     ///     Called when a key bound to Command.Select is pressed. Either activates the menu item or runs it, depending on