Преглед на файлове

Fixed issue with enter/leave

Tig преди 9 месеца
родител
ревизия
ed05e17913
променени са 3 файла, в които са добавени 33 реда и са изтрити 14 реда
  1. 9 0
      Terminal.Gui/Application/Application.Mouse.cs
  2. 23 14
      Terminal.Gui/Application/Application.Run.cs
  3. 1 0
      Terminal.Gui/Views/FileDialog.cs

+ 9 - 0
Terminal.Gui/Application/Application.Mouse.cs

@@ -249,6 +249,15 @@ public static partial class Application // Mouse handling
                 View = deepestViewUnderMouse
             };
         }
+
+        // TODO: There should be a clearner way to to this
+        // Add a timeout to ensure at least one application iteration happens after each
+        // mouse event, enabling Refresh to be called.
+        Application.AddTimeout(new (0,0,0,0, 200),
+                               () =>
+                               {
+                                   return false;
+                               });
     }
 
 

+ 23 - 14
Terminal.Gui/Application/Application.Run.cs

@@ -169,11 +169,17 @@ public static partial class Application // Run (Begin, Run, End, Stop)
                     Top.HasFocus = false;
                 }
 
+                // Force leave events for any entered views in the old Top
+                if (GetLastMousePosition () is { })
+                {
+                    RaiseMouseEnterLeaveEvents (GetLastMousePosition ()!.Value, new List<View?> ());
+                }
+
                 Top?.OnDeactivate (toplevel);
-                Toplevel previousCurrent = Top!;
+                Toplevel previousTop = Top!;
 
                 Top = toplevel;
-                Top.OnActivate (previousCurrent);
+                Top.OnActivate (previousTop);
             }
         }
 
@@ -182,10 +188,6 @@ public static partial class Application // Run (Begin, Run, End, Stop)
         {
             toplevel.BeginInit ();
             toplevel.EndInit (); // Calls Layout
-
-            //// Force a layout - normally this is done each iteration of the main loop but we prime it here.
-            //toplevel.SetLayoutNeeded ();
-            //toplevel.Layout (Screen.Size);
         }
 
         // Try to set initial focus to any TabStop
@@ -194,11 +196,6 @@ public static partial class Application // Run (Begin, Run, End, Stop)
             toplevel.SetFocus ();
         }
 
-        // DEBATE: Should Begin call Refresh (or Draw) here? It previously did.
-        //   FOR: the screen has something on it after Begin is called.
-        //   AGAINST: the screen is cleared and then redrawn in RunLoop. We don't want to draw twice.
-        //Refresh ();
-
         toplevel.OnLoaded ();
 
         if (PositionCursor ())
@@ -513,14 +510,26 @@ public static partial class Application // Run (Begin, Run, End, Stop)
             //Driver?.ClearContents ();
         }
 
-        foreach (Toplevel tl in TopLevels.Reverse ())
+        Stack<Toplevel> redrawStack = new (TopLevels);
+
+        while  (redrawStack.Count > 0)
         {
+            Toplevel? tlToDraw = redrawStack.Pop ();
+
             if (clear || forceRedraw)
             {
-                tl.SetNeedsDisplay ();
+                tlToDraw.SetNeedsDisplay ();
             }
 
-            tl.Draw ();
+            if (!(!View.CanBeVisible (tlToDraw) || tlToDraw is { NeedsDisplay: false, SubViewNeedsDisplay: false }))
+            {
+                tlToDraw.Draw ();
+
+                if (redrawStack.TryPeek (out var nexToplevel))
+                {
+                    nexToplevel.SetNeedsDisplay();
+                }
+            }
         }
 
         Driver?.Refresh ();

+ 1 - 0
Terminal.Gui/Views/FileDialog.cs

@@ -494,6 +494,7 @@ public class FileDialog : Dialog
             MoveSubviewTowardsStart (_btnCancel);
         }
 
+        SetNeedsDisplay();
         SetNeedsLayout();
     }