Browse Source

Phase 1: Core API rename - Application.Top→Current, TopLevels→SessionStack

Co-authored-by: tig <[email protected]>
copilot-swe-agent[bot] 1 month ago
parent
commit
06d010ce6e
88 changed files with 782 additions and 782 deletions
  1. 1 1
      Examples/CommunityToolkitExample/Program.cs
  2. 1 1
      Examples/ReactiveExample/Program.cs
  3. 2 2
      Examples/UICatalog/Scenario.cs
  4. 1 1
      Examples/UICatalog/Scenarios/AllViewsTester.cs
  5. 8 8
      Examples/UICatalog/Scenarios/Bars.cs
  6. 1 1
      Examples/UICatalog/Scenarios/CombiningMarks.cs
  7. 1 1
      Examples/UICatalog/Scenarios/ConfigurationEditor.cs
  8. 1 1
      Examples/UICatalog/Scenarios/CsvEditor.cs
  9. 3 3
      Examples/UICatalog/Scenarios/Mazing.cs
  10. 27 27
      Examples/UICatalog/Scenarios/Shortcuts.cs
  11. 2 2
      Examples/UICatalog/Scenarios/SingleBackgroundWorker.cs
  12. 1 1
      Examples/UICatalog/Scenarios/Themes.cs
  13. 6 6
      Examples/UICatalog/Scenarios/TreeUseCases.cs
  14. 1 1
      Examples/UICatalog/Scenarios/WindowsAndFrameViews.cs
  15. 2 2
      Examples/UICatalog/UICatalog.cs
  16. 1 1
      Examples/UICatalog/UICatalogTop.cs
  17. 1 1
      Terminal.Gui/App/Application.Lifecycle.cs
  18. 6 6
      Terminal.Gui/App/Application.Toplevel.cs
  19. 7 7
      Terminal.Gui/App/ApplicationImpl.Lifecycle.cs
  20. 41 41
      Terminal.Gui/App/ApplicationImpl.Run.cs
  21. 2 2
      Terminal.Gui/App/ApplicationImpl.Screen.cs
  22. 3 3
      Terminal.Gui/App/ApplicationImpl.cs
  23. 1 1
      Terminal.Gui/App/ApplicationNavigation.cs
  24. 4 4
      Terminal.Gui/App/ApplicationPopover.cs
  25. 7 7
      Terminal.Gui/App/IApplication.cs
  26. 1 1
      Terminal.Gui/App/IPopover.cs
  27. 6 6
      Terminal.Gui/App/Keyboard/KeyboardImpl.cs
  28. 4 4
      Terminal.Gui/App/MainLoop/ApplicationMainLoop.cs
  29. 2 2
      Terminal.Gui/App/Mouse/MouseImpl.cs
  30. 1 1
      Terminal.Gui/App/PopoverBaseImpl.cs
  31. 3 3
      Terminal.Gui/App/Toplevel/ToplevelTransitionManager.cs
  32. 1 1
      Terminal.Gui/ViewBase/Adornment/Border.Arrangment.cs
  33. 2 2
      Terminal.Gui/ViewBase/View.Hierarchy.cs
  34. 15 15
      Terminal.Gui/ViewBase/View.Layout.cs
  35. 6 6
      Terminal.Gui/ViewBase/View.Navigation.cs
  36. 1 1
      Terminal.Gui/Views/Dialog.cs
  37. 6 6
      Terminal.Gui/Views/Menuv1/Menu.cs
  38. 4 4
      Terminal.Gui/Views/Menuv1/MenuBar.cs
  39. 3 3
      Terminal.Gui/Views/Toplevel.cs
  40. 1 1
      Terminal.Gui/Views/Wizard/Wizard.cs
  41. 4 4
      Tests/IntegrationTests/FluentTests/GuiTestContextKeyEventTests.cs
  42. 1 1
      Tests/IntegrationTests/FluentTests/GuiTestContextTests.cs
  43. 23 23
      Tests/IntegrationTests/FluentTests/MenuBarv2Tests.cs
  44. 2 2
      Tests/IntegrationTests/FluentTests/NavigationTests.cs
  45. 16 16
      Tests/IntegrationTests/FluentTests/PopverMenuTests.cs
  46. 2 2
      Tests/StressTests/ApplicationStressTests.cs
  47. 2 2
      Tests/StressTests/ScenariosStressTests.cs
  48. 1 1
      Tests/TerminalGuiFluentTesting/FakeDriver/FakeApplicationLifecycle.cs
  49. 2 2
      Tests/TerminalGuiFluentTesting/GuiTestContext.Navigation.cs
  50. 4 4
      Tests/TerminalGuiFluentTesting/GuiTestContext.ViewBase.cs
  51. 16 16
      Tests/UnitTests/Application/Application.NavigationTests.cs
  52. 29 29
      Tests/UnitTests/Application/ApplicationImplTests.cs
  53. 7 7
      Tests/UnitTests/Application/ApplicationPopoverTests.cs
  54. 5 5
      Tests/UnitTests/Application/ApplicationScreenTests.cs
  55. 56 56
      Tests/UnitTests/Application/ApplicationTests.cs
  56. 20 20
      Tests/UnitTests/Application/Mouse/ApplicationMouseEnterLeaveTests.cs
  57. 8 8
      Tests/UnitTests/Application/Mouse/ApplicationMouseTests.cs
  58. 1 1
      Tests/UnitTests/Application/SessionTokenTests.cs
  59. 2 2
      Tests/UnitTests/Application/SynchronizatonContextTests.cs
  60. 15 15
      Tests/UnitTests/Dialogs/DialogTests.cs
  61. 7 7
      Tests/UnitTests/Dialogs/MessageBoxTests.cs
  62. 12 12
      Tests/UnitTests/View/Adornment/AdornmentSubViewTests.cs
  63. 16 16
      Tests/UnitTests/View/Adornment/MarginTests.cs
  64. 2 2
      Tests/UnitTests/View/Adornment/ShadowStyleTests.cs
  65. 3 3
      Tests/UnitTests/View/Keyboard/KeyBindingsTests.cs
  66. 92 92
      Tests/UnitTests/View/Layout/GetViewsUnderLocationTests.cs
  67. 11 11
      Tests/UnitTests/View/Layout/Pos.CombineTests.cs
  68. 8 8
      Tests/UnitTests/View/Layout/SetLayoutTests.cs
  69. 4 4
      Tests/UnitTests/View/Navigation/CanFocusTests.cs
  70. 5 5
      Tests/UnitTests/View/Navigation/NavigationTests.cs
  71. 1 1
      Tests/UnitTests/View/TextTests.cs
  72. 6 6
      Tests/UnitTests/View/ViewCommandTests.cs
  73. 3 3
      Tests/UnitTests/View/Viewport/ViewportSettings.TransparentMouseTests.cs
  74. 12 12
      Tests/UnitTests/Views/AppendAutocompleteTests.cs
  75. 1 1
      Tests/UnitTests/Views/ButtonTests.cs
  76. 4 4
      Tests/UnitTests/Views/CheckBoxTests.cs
  77. 5 5
      Tests/UnitTests/Views/ColorPickerTests.cs
  78. 2 2
      Tests/UnitTests/Views/ComboBoxTests.cs
  79. 29 29
      Tests/UnitTests/Views/HexViewTests.cs
  80. 19 19
      Tests/UnitTests/Views/LabelTests.cs
  81. 27 27
      Tests/UnitTests/Views/Menuv1/MenuBarv1Tests.cs
  82. 36 36
      Tests/UnitTests/Views/ShortcutTests.cs
  83. 3 3
      Tests/UnitTests/Views/SpinnerViewTests.cs
  84. 26 26
      Tests/UnitTests/Views/TableViewTests.cs
  85. 8 8
      Tests/UnitTests/Views/TextFieldTests.cs
  86. 1 1
      Tests/UnitTests/Views/TextViewTests.cs
  87. 34 34
      Tests/UnitTests/Views/ToplevelTests.cs
  88. 2 2
      Tests/UnitTestsParallelizable/TestSetup.cs

+ 1 - 1
Examples/CommunityToolkitExample/Program.cs

@@ -16,7 +16,7 @@ public static class Program
         Services = ConfigureServices ();
         Services = ConfigureServices ();
         Application.Init ();
         Application.Init ();
         Application.Run (Services.GetRequiredService<LoginView> ());
         Application.Run (Services.GetRequiredService<LoginView> ());
-        Application.Top?.Dispose ();
+        Application.Current?.Dispose ();
         Application.Shutdown ();
         Application.Shutdown ();
     }
     }
 
 

+ 1 - 1
Examples/ReactiveExample/Program.cs

@@ -16,7 +16,7 @@ public static class Program
         RxApp.MainThreadScheduler = TerminalScheduler.Default;
         RxApp.MainThreadScheduler = TerminalScheduler.Default;
         RxApp.TaskpoolScheduler = TaskPoolScheduler.Default;
         RxApp.TaskpoolScheduler = TaskPoolScheduler.Default;
         Application.Run (new LoginView (new LoginViewModel ()));
         Application.Run (new LoginView (new LoginViewModel ()));
-        Application.Top.Dispose ();
+        Application.Current.Dispose ();
         Application.Shutdown ();
         Application.Shutdown ();
     }
     }
 }
 }

+ 2 - 2
Examples/UICatalog/Scenario.cs

@@ -221,7 +221,7 @@ public class Scenario : IDisposable
 
 
     private void OnApplicationSessionBegun (object? sender, SessionTokenEventArgs e)
     private void OnApplicationSessionBegun (object? sender, SessionTokenEventArgs e)
     {
     {
-        SubscribeAllSubViews (Application.Top!);
+        SubscribeAllSubViews (Application.Current!);
 
 
         _demoKeys = GetDemoKeyStrokes ();
         _demoKeys = GetDemoKeyStrokes ();
 
 
@@ -241,7 +241,7 @@ public class Scenario : IDisposable
 
 
         return;
         return;
 
 
-        // Get a list of all subviews under Application.Top (and their subviews, etc.)
+        // Get a list of all subviews under Application.Current (and their subviews, etc.)
         // and subscribe to their DrawComplete event
         // and subscribe to their DrawComplete event
         void SubscribeAllSubViews (View view)
         void SubscribeAllSubViews (View view)
         {
         {

+ 1 - 1
Examples/UICatalog/Scenarios/AllViewsTester.cs

@@ -28,7 +28,7 @@ public class AllViewsTester : Scenario
 
 
     public override void Main ()
     public override void Main ()
     {
     {
-        // Don't create a sub-win (Scenario.Win); just use Application.Top
+        // Don't create a sub-win (Scenario.Win); just use Application.Current
         Application.Init ();
         Application.Init ();
 
 
         var app = new Window
         var app = new Window

+ 8 - 8
Examples/UICatalog/Scenarios/Bars.cs

@@ -28,7 +28,7 @@ public class Bars : Scenario
     // QuitKey and it only sticks if changed after init
     // QuitKey and it only sticks if changed after init
     private void App_Loaded (object sender, EventArgs e)
     private void App_Loaded (object sender, EventArgs e)
     {
     {
-        Application.Top!.Title = GetQuitKeyAndName ();
+        Application.Current!.Title = GetQuitKeyAndName ();
 
 
         ObservableCollection<string> eventSource = new ();
         ObservableCollection<string> eventSource = new ();
         ListView eventLog = new ListView ()
         ListView eventLog = new ListView ()
@@ -41,7 +41,7 @@ public class Bars : Scenario
             Source = new ListWrapper<string> (eventSource)
             Source = new ListWrapper<string> (eventSource)
         };
         };
         eventLog.Border!.Thickness = new (0, 1, 0, 0);
         eventLog.Border!.Thickness = new (0, 1, 0, 0);
-        Application.Top.Add (eventLog);
+        Application.Current.Add (eventLog);
 
 
         FrameView menuBarLikeExamples = new ()
         FrameView menuBarLikeExamples = new ()
         {
         {
@@ -51,7 +51,7 @@ public class Bars : Scenario
             Width = Dim.Fill () - Dim.Width (eventLog),
             Width = Dim.Fill () - Dim.Width (eventLog),
             Height = Dim.Percent(33),
             Height = Dim.Percent(33),
         };
         };
-        Application.Top.Add (menuBarLikeExamples);
+        Application.Current.Add (menuBarLikeExamples);
 
 
         Label label = new Label ()
         Label label = new Label ()
         {
         {
@@ -98,7 +98,7 @@ public class Bars : Scenario
             Width = Dim.Fill () - Dim.Width (eventLog),
             Width = Dim.Fill () - Dim.Width (eventLog),
             Height = Dim.Percent (33),
             Height = Dim.Percent (33),
         };
         };
-        Application.Top.Add (menuLikeExamples);
+        Application.Current.Add (menuLikeExamples);
 
 
         label = new Label ()
         label = new Label ()
         {
         {
@@ -212,7 +212,7 @@ public class Bars : Scenario
             Width = Dim.Width (menuLikeExamples),
             Width = Dim.Width (menuLikeExamples),
             Height = Dim.Percent (33),
             Height = Dim.Percent (33),
         };
         };
-        Application.Top.Add (statusBarLikeExamples);
+        Application.Current.Add (statusBarLikeExamples);
 
 
         label = new Label ()
         label = new Label ()
         {
         {
@@ -249,7 +249,7 @@ public class Bars : Scenario
         ConfigStatusBar (bar);
         ConfigStatusBar (bar);
         statusBarLikeExamples.Add (bar);
         statusBarLikeExamples.Add (bar);
 
 
-        foreach (FrameView frameView in Application.Top.SubViews.Where (f => f is FrameView)!)
+        foreach (FrameView frameView in Application.Current.SubViews.Where (f => f is FrameView)!)
         {
         {
             foreach (Bar barView in frameView.SubViews.Where (b => b is Bar)!)
             foreach (Bar barView in frameView.SubViews.Where (b => b is Bar)!)
             {
             {
@@ -269,8 +269,8 @@ public class Bars : Scenario
 
 
     //private void SetupContentMenu ()
     //private void SetupContentMenu ()
     //{
     //{
-    //    Application.Top.Add (new Label { Text = "Right Click for Context Menu", X = Pos.Center (), Y = 4 });
-    //    Application.Top.MouseClick += ShowContextMenu;
+    //    Application.Current.Add (new Label { Text = "Right Click for Context Menu", X = Pos.Center (), Y = 4 });
+    //    Application.Current.MouseClick += ShowContextMenu;
     //}
     //}
 
 
     //private void ShowContextMenu (object s, MouseEventEventArgs e)
     //private void ShowContextMenu (object s, MouseEventEventArgs e)

+ 1 - 1
Examples/UICatalog/Scenarios/CombiningMarks.cs

@@ -13,7 +13,7 @@ public class CombiningMarks : Scenario
         top.DrawComplete += (s, e) =>
         top.DrawComplete += (s, e) =>
         {
         {
             // Forces reset _lineColsOffset because we're dealing with direct draw
             // Forces reset _lineColsOffset because we're dealing with direct draw
-            Application.Top!.SetNeedsDraw ();
+            Application.Current!.SetNeedsDraw ();
 
 
             var i = -1;
             var i = -1;
             top.AddStr ("Terminal.Gui only supports combining marks that normalize. See Issue #2616.");
             top.AddStr ("Terminal.Gui only supports combining marks that normalize. See Issue #2616.");

+ 1 - 1
Examples/UICatalog/Scenarios/ConfigurationEditor.cs

@@ -75,7 +75,7 @@ public class ConfigurationEditor : Scenario
 
 
         void ConfigurationManagerOnApplied (object? sender, ConfigurationManagerEventArgs e)
         void ConfigurationManagerOnApplied (object? sender, ConfigurationManagerEventArgs e)
         {
         {
-            Application.Top?.SetNeedsDraw ();
+            Application.Current?.SetNeedsDraw ();
         }
         }
     }
     }
     public void Save ()
     public void Save ()

+ 1 - 1
Examples/UICatalog/Scenarios/CsvEditor.cs

@@ -502,7 +502,7 @@ public class CsvEditor : Scenario
             // Only set the current filename if we successfully loaded the entire file
             // Only set the current filename if we successfully loaded the entire file
             _currentFile = filename;
             _currentFile = filename;
             _selectedCellTextField.SuperView.Enabled = true;
             _selectedCellTextField.SuperView.Enabled = true;
-            Application.Top.Title = $"{GetName ()} - {Path.GetFileName (_currentFile)}";
+            Application.Current.Title = $"{GetName ()} - {Path.GetFileName (_currentFile)}";
         }
         }
         catch (Exception ex)
         catch (Exception ex)
         {
         {

+ 3 - 3
Examples/UICatalog/Scenarios/Mazing.cs

@@ -171,7 +171,7 @@ public class Mazing : Scenario
                 if (_m.PlayerHp <= 0)
                 if (_m.PlayerHp <= 0)
                 {
                 {
                     _message = "You died!";
                     _message = "You died!";
-                    Application.Top!.SetNeedsDraw (); // trigger redraw
+                    Application.Current!.SetNeedsDraw (); // trigger redraw
                     _dead = true;
                     _dead = true;
 
 
                     return; // Stop further action if dead
                     return; // Stop further action if dead
@@ -190,7 +190,7 @@ public class Mazing : Scenario
                 _message = string.Empty;
                 _message = string.Empty;
             }
             }
 
 
-            Application.Top!.SetNeedsDraw (); // trigger redraw
+            Application.Current!.SetNeedsDraw (); // trigger redraw
         }
         }
 
 
         // Optional win condition:
         // Optional win condition:
@@ -200,7 +200,7 @@ public class Mazing : Scenario
             _m = new (); // Generate a new maze
             _m = new (); // Generate a new maze
             _m.PlayerHp = hp;
             _m.PlayerHp = hp;
             GenerateNpcs ();
             GenerateNpcs ();
-            Application.Top!.SetNeedsDraw (); // trigger redraw
+            Application.Current!.SetNeedsDraw (); // trigger redraw
         }
         }
     }
     }
 }
 }

+ 27 - 27
Examples/UICatalog/Scenarios/Shortcuts.cs

@@ -28,7 +28,7 @@ public class Shortcuts : Scenario
     private void App_Loaded (object? sender, EventArgs e)
     private void App_Loaded (object? sender, EventArgs e)
     {
     {
         Application.QuitKey = Key.F4.WithCtrl;
         Application.QuitKey = Key.F4.WithCtrl;
-        Application.Top!.Title = GetQuitKeyAndName ();
+        Application.Current!.Title = GetQuitKeyAndName ();
 
 
         ObservableCollection<string> eventSource = new ();
         ObservableCollection<string> eventSource = new ();
 
 
@@ -46,14 +46,14 @@ public class Shortcuts : Scenario
 
 
         eventLog.Width = Dim.Func (
         eventLog.Width = Dim.Func (
                                    _ => Math.Min (
                                    _ => Math.Min (
-                                                  Application.Top.Viewport.Width / 2,
+                                                  Application.Current.Viewport.Width / 2,
                                                   eventLog?.MaxLength + eventLog!.GetAdornmentsThickness ().Horizontal ?? 0));
                                                   eventLog?.MaxLength + eventLog!.GetAdornmentsThickness ().Horizontal ?? 0));
 
 
         eventLog.Width = Dim.Func (
         eventLog.Width = Dim.Func (
                                    _ => Math.Min (
                                    _ => Math.Min (
                                                   eventLog.SuperView!.Viewport.Width / 2,
                                                   eventLog.SuperView!.Viewport.Width / 2,
                                                   eventLog?.MaxLength + eventLog!.GetAdornmentsThickness ().Horizontal ?? 0));
                                                   eventLog?.MaxLength + eventLog!.GetAdornmentsThickness ().Horizontal ?? 0));
-        Application.Top.Add (eventLog);
+        Application.Current.Add (eventLog);
 
 
         var alignKeysShortcut = new Shortcut
         var alignKeysShortcut = new Shortcut
         {
         {
@@ -86,7 +86,7 @@ public class Shortcuts : Scenario
                                                                           };
                                                                           };
 
 
 
 
-        Application.Top.Add (alignKeysShortcut);
+        Application.Current.Add (alignKeysShortcut);
 
 
         var commandFirstShortcut = new Shortcut
         var commandFirstShortcut = new Shortcut
         {
         {
@@ -115,7 +115,7 @@ public class Shortcuts : Scenario
                                                                                                       $"{commandFirstShortcut.Id}.CommandView.CheckedStateChanging: {cb.Text}");
                                                                                                       $"{commandFirstShortcut.Id}.CommandView.CheckedStateChanging: {cb.Text}");
                                                                                      eventLog.MoveDown ();
                                                                                      eventLog.MoveDown ();
 
 
-                                                                                     IEnumerable<View> toAlign = Application.Top.SubViews.OfType<Shortcut> ();
+                                                                                     IEnumerable<View> toAlign = Application.Current.SubViews.OfType<Shortcut> ();
                                                                                      IEnumerable<View> enumerable = toAlign as View [] ?? toAlign.ToArray ();
                                                                                      IEnumerable<View> enumerable = toAlign as View [] ?? toAlign.ToArray ();
 
 
                                                                                      foreach (View view in enumerable)
                                                                                      foreach (View view in enumerable)
@@ -134,7 +134,7 @@ public class Shortcuts : Scenario
                                                                                  }
                                                                                  }
                                                                              };
                                                                              };
 
 
-        Application.Top.Add (commandFirstShortcut);
+        Application.Current.Add (commandFirstShortcut);
 
 
         var canFocusShortcut = new Shortcut
         var canFocusShortcut = new Shortcut
         {
         {
@@ -159,7 +159,7 @@ public class Shortcuts : Scenario
                                                                                  SetCanFocus (e.Result == CheckState.Checked);
                                                                                  SetCanFocus (e.Result == CheckState.Checked);
                                                                              }
                                                                              }
                                                                          };
                                                                          };
-        Application.Top.Add (canFocusShortcut);
+        Application.Current.Add (canFocusShortcut);
 
 
         var appShortcut = new Shortcut
         var appShortcut = new Shortcut
         {
         {
@@ -173,7 +173,7 @@ public class Shortcuts : Scenario
             BindKeyToApplication = true
             BindKeyToApplication = true
         };
         };
 
 
-        Application.Top.Add (appShortcut);
+        Application.Current.Add (appShortcut);
 
 
         var buttonShortcut = new Shortcut
         var buttonShortcut = new Shortcut
         {
         {
@@ -193,7 +193,7 @@ public class Shortcuts : Scenario
         var button = (Button)buttonShortcut.CommandView;
         var button = (Button)buttonShortcut.CommandView;
         buttonShortcut.Accepting += Button_Clicked;
         buttonShortcut.Accepting += Button_Clicked;
 
 
-        Application.Top.Add (buttonShortcut);
+        Application.Current.Add (buttonShortcut);
 
 
         var optionSelectorShortcut = new Shortcut
         var optionSelectorShortcut = new Shortcut
         {
         {
@@ -221,7 +221,7 @@ public class Shortcuts : Scenario
                                                                                     }
                                                                                     }
                                                                                 };
                                                                                 };
 
 
-        Application.Top.Add (optionSelectorShortcut);
+        Application.Current.Add (optionSelectorShortcut);
 
 
         var sliderShortcut = new Shortcut
         var sliderShortcut = new Shortcut
         {
         {
@@ -248,7 +248,7 @@ public class Shortcuts : Scenario
                                                                            eventLog.MoveDown ();
                                                                            eventLog.MoveDown ();
                                                                        };
                                                                        };
 
 
-        Application.Top.Add (sliderShortcut);
+        Application.Current.Add (sliderShortcut);
 
 
         ListView listView = new ListView ()
         ListView listView = new ListView ()
         {
         {
@@ -270,7 +270,7 @@ public class Shortcuts : Scenario
             Key = Key.F5.WithCtrl,
             Key = Key.F5.WithCtrl,
         };
         };
 
 
-        Application.Top.Add (listViewShortcut);
+        Application.Current.Add (listViewShortcut);
 
 
         var noCommandShortcut = new Shortcut
         var noCommandShortcut = new Shortcut
         {
         {
@@ -282,7 +282,7 @@ public class Shortcuts : Scenario
             Key = Key.D0
             Key = Key.D0
         };
         };
 
 
-        Application.Top.Add (noCommandShortcut);
+        Application.Current.Add (noCommandShortcut);
 
 
         var noKeyShortcut = new Shortcut
         var noKeyShortcut = new Shortcut
         {
         {
@@ -295,7 +295,7 @@ public class Shortcuts : Scenario
             HelpText = "Keyless"
             HelpText = "Keyless"
         };
         };
 
 
-        Application.Top.Add (noKeyShortcut);
+        Application.Current.Add (noKeyShortcut);
 
 
         var noHelpShortcut = new Shortcut
         var noHelpShortcut = new Shortcut
         {
         {
@@ -308,7 +308,7 @@ public class Shortcuts : Scenario
             HelpText = ""
             HelpText = ""
         };
         };
 
 
-        Application.Top.Add (noHelpShortcut);
+        Application.Current.Add (noHelpShortcut);
         noHelpShortcut.SetFocus ();
         noHelpShortcut.SetFocus ();
 
 
         var framedShortcut = new Shortcut
         var framedShortcut = new Shortcut
@@ -340,7 +340,7 @@ public class Shortcuts : Scenario
         }
         }
 
 
         framedShortcut.SchemeName = SchemeManager.SchemesToSchemeName (Schemes.Toplevel);
         framedShortcut.SchemeName = SchemeManager.SchemesToSchemeName (Schemes.Toplevel);
-        Application.Top.Add (framedShortcut);
+        Application.Current.Add (framedShortcut);
 
 
         // Horizontal
         // Horizontal
         var progressShortcut = new Shortcut
         var progressShortcut = new Shortcut
@@ -387,7 +387,7 @@ public class Shortcuts : Scenario
                          };
                          };
         timer.Start ();
         timer.Start ();
 
 
-        Application.Top.Add (progressShortcut);
+        Application.Current.Add (progressShortcut);
 
 
         var textField = new TextField
         var textField = new TextField
         {
         {
@@ -408,7 +408,7 @@ public class Shortcuts : Scenario
         };
         };
         textField.CanFocus = true;
         textField.CanFocus = true;
 
 
-        Application.Top.Add (textFieldShortcut);
+        Application.Current.Add (textFieldShortcut);
 
 
         var bgColorShortcut = new Shortcut
         var bgColorShortcut = new Shortcut
         {
         {
@@ -450,19 +450,19 @@ public class Shortcuts : Scenario
                                         eventSource.Add ($"ColorChanged: {o.GetType ().Name} - {args.Result}");
                                         eventSource.Add ($"ColorChanged: {o.GetType ().Name} - {args.Result}");
                                         eventLog.MoveDown ();
                                         eventLog.MoveDown ();
 
 
-                                        Application.Top.SetScheme (
-                                                                   new (Application.Top.GetScheme ())
+                                        Application.Current.SetScheme (
+                                                                   new (Application.Current.GetScheme ())
                                                                    {
                                                                    {
                                                                        Normal = new (
                                                                        Normal = new (
-                                                                                     Application.Top!.GetAttributeForRole (VisualRole.Normal).Foreground,
+                                                                                     Application.Current!.GetAttributeForRole (VisualRole.Normal).Foreground,
                                                                                      args.Result,
                                                                                      args.Result,
-                                                                                     Application.Top!.GetAttributeForRole (VisualRole.Normal).Style)
+                                                                                     Application.Current!.GetAttributeForRole (VisualRole.Normal).Style)
                                                                    });
                                                                    });
                                     }
                                     }
                                 };
                                 };
         bgColorShortcut.CommandView = bgColor;
         bgColorShortcut.CommandView = bgColor;
 
 
-        Application.Top.Add (bgColorShortcut);
+        Application.Current.Add (bgColorShortcut);
 
 
         var appQuitShortcut = new Shortcut
         var appQuitShortcut = new Shortcut
         {
         {
@@ -476,9 +476,9 @@ public class Shortcuts : Scenario
         };
         };
         appQuitShortcut.Accepting += (o, args) => { Application.RequestStop (); };
         appQuitShortcut.Accepting += (o, args) => { Application.RequestStop (); };
 
 
-        Application.Top.Add (appQuitShortcut);
+        Application.Current.Add (appQuitShortcut);
 
 
-        foreach (Shortcut shortcut in Application.Top.SubViews.OfType<Shortcut> ())
+        foreach (Shortcut shortcut in Application.Current.SubViews.OfType<Shortcut> ())
         {
         {
             shortcut.Selecting += (o, args) =>
             shortcut.Selecting += (o, args) =>
                                   {
                                   {
@@ -529,7 +529,7 @@ public class Shortcuts : Scenario
 
 
         void SetCanFocus (bool canFocus)
         void SetCanFocus (bool canFocus)
         {
         {
-            foreach (Shortcut peer in Application.Top!.SubViews.OfType<Shortcut> ())
+            foreach (Shortcut peer in Application.Current!.SubViews.OfType<Shortcut> ())
             {
             {
                 if (peer.CanFocus)
                 if (peer.CanFocus)
                 {
                 {
@@ -542,7 +542,7 @@ public class Shortcuts : Scenario
         {
         {
             var max = 0;
             var max = 0;
 
 
-            IEnumerable<Shortcut> toAlign = Application.Top!.SubViews.OfType<Shortcut> ().Where(s => !s.Y.Has<PosAnchorEnd>(out _)).Cast<Shortcut>();
+            IEnumerable<Shortcut> toAlign = Application.Current!.SubViews.OfType<Shortcut> ().Where(s => !s.Y.Has<PosAnchorEnd>(out _)).Cast<Shortcut>();
             IEnumerable<Shortcut> enumerable = toAlign as Shortcut [] ?? toAlign.ToArray ();
             IEnumerable<Shortcut> enumerable = toAlign as Shortcut [] ?? toAlign.ToArray ();
 
 
             if (align)
             if (align)

+ 2 - 2
Examples/UICatalog/Scenarios/SingleBackgroundWorker.cs

@@ -179,9 +179,9 @@ public class SingleBackgroundWorker : Scenario
 
 
                                                   var builderUI =
                                                   var builderUI =
                                                       new StagingUIController (_startStaging, e.Result as ObservableCollection<string>);
                                                       new StagingUIController (_startStaging, e.Result as ObservableCollection<string>);
-                                                  Toplevel top = Application.Top;
+                                                  Toplevel top = Application.Current;
                                                   top.Visible = false;
                                                   top.Visible = false;
-                                                  Application.Top.Visible = false;
+                                                  Application.Current.Visible = false;
                                                   builderUI.Load ();
                                                   builderUI.Load ();
                                                   builderUI.Dispose ();
                                                   builderUI.Dispose ();
                                                   top.Visible = true;
                                                   top.Visible = true;

+ 1 - 1
Examples/UICatalog/Scenarios/Themes.cs

@@ -129,7 +129,7 @@ public sealed class Themes : Scenario
                                           {
                                           {
                                               if (_view is { })
                                               if (_view is { })
                                               {
                                               {
-                                                  Application.Top!.SchemeName = args.NewValue;
+                                                  Application.Current!.SchemeName = args.NewValue;
 
 
                                                   if (_view.HasScheme)
                                                   if (_view.HasScheme)
                                                   {
                                                   {

+ 6 - 6
Examples/UICatalog/Scenarios/TreeUseCases.cs

@@ -77,7 +77,7 @@ public class TreeUseCases : Scenario
 
 
         if (_currentTree != null)
         if (_currentTree != null)
         {
         {
-            Application.Top.Remove (_currentTree);
+            Application.Current.Remove (_currentTree);
             _currentTree.Dispose ();
             _currentTree.Dispose ();
         }
         }
 
 
@@ -97,7 +97,7 @@ public class TreeUseCases : Scenario
             tree.TreeBuilder = new GameObjectTreeBuilder ();
             tree.TreeBuilder = new GameObjectTreeBuilder ();
         }
         }
 
 
-        Application.Top.Add (tree);
+        Application.Current.Add (tree);
 
 
         tree.AddObject (army1);
         tree.AddObject (army1);
 
 
@@ -117,13 +117,13 @@ public class TreeUseCases : Scenario
 
 
         if (_currentTree != null)
         if (_currentTree != null)
         {
         {
-            Application.Top.Remove (_currentTree);
+            Application.Current.Remove (_currentTree);
             _currentTree.Dispose ();
             _currentTree.Dispose ();
         }
         }
 
 
         var tree = new TreeView { X = 0, Y = 1, Width = Dim.Fill(), Height = Dim.Fill (1) };
         var tree = new TreeView { X = 0, Y = 1, Width = Dim.Fill(), Height = Dim.Fill (1) };
 
 
-        Application.Top.Add (tree);
+        Application.Current.Add (tree);
 
 
         tree.AddObject (myHouse);
         tree.AddObject (myHouse);
 
 
@@ -134,13 +134,13 @@ public class TreeUseCases : Scenario
     {
     {
         if (_currentTree != null)
         if (_currentTree != null)
         {
         {
-            Application.Top.Remove (_currentTree);
+            Application.Current.Remove (_currentTree);
             _currentTree.Dispose ();
             _currentTree.Dispose ();
         }
         }
 
 
         var tree = new TreeView { X = 0, Y = 1, Width = Dim.Fill (), Height = Dim.Fill (1) };
         var tree = new TreeView { X = 0, Y = 1, Width = Dim.Fill (), Height = Dim.Fill (1) };
 
 
-        Application.Top.Add (tree);
+        Application.Current.Add (tree);
 
 
         var root1 = new TreeNode ("Root1");
         var root1 = new TreeNode ("Root1");
         root1.Children.Add (new TreeNode ("Child1.1"));
         root1.Children.Add (new TreeNode ("Child1.1"));

+ 1 - 1
Examples/UICatalog/Scenarios/WindowsAndFrameViews.cs

@@ -69,7 +69,7 @@ public class WindowsAndFrameViews : Scenario
         // add it to our list
         // add it to our list
         listWin.Add (win);
         listWin.Add (win);
 
 
-        // create 3 more Windows in a loop, adding them Application.Top
+        // create 3 more Windows in a loop, adding them Application.Current
         // Each with a
         // Each with a
         //	button
         //	button
         //  sub Window with
         //  sub Window with

+ 2 - 2
Examples/UICatalog/UICatalog.cs

@@ -242,7 +242,7 @@ public class UICatalog
 
 
     /// <summary>
     /// <summary>
     ///     Shows the UI Catalog selection UI. When the user selects a Scenario to run, the UI Catalog main app UI is
     ///     Shows the UI Catalog selection UI. When the user selects a Scenario to run, the UI Catalog main app UI is
-    ///     killed and the Scenario is run as though it were Application.Top. When the Scenario exits, this function exits.
+    ///     killed and the Scenario is run as though it were Application.Current. When the Scenario exits, this function exits.
     /// </summary>
     /// </summary>
     /// <returns></returns>
     /// <returns></returns>
     private static Scenario RunUICatalogTopLevel ()
     private static Scenario RunUICatalogTopLevel ()
@@ -332,7 +332,7 @@ public class UICatalog
 
 
     private static void ConfigFileChanged (object sender, FileSystemEventArgs e)
     private static void ConfigFileChanged (object sender, FileSystemEventArgs e)
     {
     {
-        if (Application.Top == null)
+        if (Application.Current == null)
         {
         {
             return;
             return;
         }
         }

+ 1 - 1
Examples/UICatalog/UICatalogTop.cs

@@ -691,7 +691,7 @@ public class UICatalogTop : Toplevel
         _disableMouseCb!.CheckedState = Application.IsMouseDisabled ? CheckState.Checked : CheckState.UnChecked;
         _disableMouseCb!.CheckedState = Application.IsMouseDisabled ? CheckState.Checked : CheckState.UnChecked;
         _force16ColorsShortcutCb!.CheckedState = Application.Force16Colors ? CheckState.Checked : CheckState.UnChecked;
         _force16ColorsShortcutCb!.CheckedState = Application.Force16Colors ? CheckState.Checked : CheckState.UnChecked;
 
 
-        Application.Top?.SetNeedsDraw ();
+        Application.Current?.SetNeedsDraw ();
     }
     }
 
 
     private void ConfigAppliedHandler (object? sender, ConfigurationManagerEventArgs? a) { ConfigApplied (); }
     private void ConfigAppliedHandler (object? sender, ConfigurationManagerEventArgs? a) { ConfigApplied (); }

+ 1 - 1
Terminal.Gui/App/Application.Lifecycle.cs

@@ -16,7 +16,7 @@ public static partial class Application // Lifecycle (Init/Shutdown)
     /// <para>Call this method once per instance (or after <see cref="Shutdown"/> has been called).</para>
     /// <para>Call this method once per instance (or after <see cref="Shutdown"/> has been called).</para>
     /// <para>
     /// <para>
     ///     This function loads the right <see cref="IDriver"/> for the platform, Creates a <see cref="Toplevel"/>. and
     ///     This function loads the right <see cref="IDriver"/> for the platform, Creates a <see cref="Toplevel"/>. and
-    ///     assigns it to <see cref="Top"/>
+    ///     assigns it to <see cref="Current"/>
     /// </para>
     /// </para>
     /// <para>
     /// <para>
     ///     <see cref="Shutdown"/> must be called when the application is closing (typically after
     ///     <see cref="Shutdown"/> must be called when the application is closing (typically after

+ 6 - 6
Terminal.Gui/App/Application.Toplevel.cs

@@ -5,14 +5,14 @@ namespace Terminal.Gui.App;
 
 
 public static partial class Application // Toplevel handling
 public static partial class Application // Toplevel handling
 {
 {
-    /// <inheritdoc cref="IApplication.TopLevels"/>
-    public static ConcurrentStack<Toplevel> TopLevels => ApplicationImpl.Instance.TopLevels;
+    /// <inheritdoc cref="IApplication.SessionStack"/>
+    public static ConcurrentStack<Toplevel> SessionStack => ApplicationImpl.Instance.SessionStack;
 
 
     /// <summary>The <see cref="Toplevel"/> that is currently active.</summary>
     /// <summary>The <see cref="Toplevel"/> that is currently active.</summary>
-    /// <value>The top.</value>
-    public static Toplevel? Top
+    /// <value>The current toplevel.</value>
+    public static Toplevel? Current
     {
     {
-        get => ApplicationImpl.Instance.Top;
-        internal set => ApplicationImpl.Instance.Top = value;
+        get => ApplicationImpl.Instance.Current;
+        internal set => ApplicationImpl.Instance.Current = value;
     }
     }
 }
 }

+ 7 - 7
Terminal.Gui/App/ApplicationImpl.Lifecycle.cs

@@ -157,7 +157,7 @@ public partial class ApplicationImpl
         // e.g. see Issue #537
         // e.g. see Issue #537
 
 
         // === 1. Stop all running toplevels ===
         // === 1. Stop all running toplevels ===
-        foreach (Toplevel? t in TopLevels)
+        foreach (Toplevel? t in SessionStack)
         {
         {
             t!.Running = false;
             t!.Running = false;
         }
         }
@@ -174,25 +174,25 @@ public partial class ApplicationImpl
         Popover = null;
         Popover = null;
 
 
         // === 3. Clean up toplevels ===
         // === 3. Clean up toplevels ===
-        TopLevels.Clear ();
+        SessionStack.Clear ();
 
 
 #if DEBUG_IDISPOSABLE
 #if DEBUG_IDISPOSABLE
 
 
-        // Don't dispose the Top. It's up to caller dispose it
-        if (View.EnableDebugIDisposableAsserts && !ignoreDisposed && Top is { })
+        // Don't dispose the Current. It's up to caller dispose it
+        if (View.EnableDebugIDisposableAsserts && !ignoreDisposed && Current is { })
         {
         {
-            Debug.Assert (Top.WasDisposed, $"Title = {Top.Title}, Id = {Top.Id}");
+            Debug.Assert (Current.WasDisposed, $"Title = {Current.Title}, Id = {Current.Id}");
 
 
             // If End wasn't called _CachedSessionTokenToplevel may be null
             // If End wasn't called _CachedSessionTokenToplevel may be null
             if (CachedSessionTokenToplevel is { })
             if (CachedSessionTokenToplevel is { })
             {
             {
                 Debug.Assert (CachedSessionTokenToplevel.WasDisposed);
                 Debug.Assert (CachedSessionTokenToplevel.WasDisposed);
-                Debug.Assert (CachedSessionTokenToplevel == Top);
+                Debug.Assert (CachedSessionTokenToplevel == Current);
             }
             }
         }
         }
 #endif
 #endif
 
 
-        Top = null;
+        Current = null;
         CachedSessionTokenToplevel = null;
         CachedSessionTokenToplevel = null;
 
 
         // === 4. Clean up driver ===
         // === 4. Clean up driver ===

+ 41 - 41
Terminal.Gui/App/ApplicationImpl.Run.cs

@@ -37,28 +37,28 @@ public partial class ApplicationImpl
         var rs = new SessionToken (toplevel);
         var rs = new SessionToken (toplevel);
 
 
 #if DEBUG_IDISPOSABLE
 #if DEBUG_IDISPOSABLE
-        if (View.EnableDebugIDisposableAsserts && Top is { } && toplevel != Top && !TopLevels.Contains (Top))
+        if (View.EnableDebugIDisposableAsserts && Current is { } && toplevel != Current && !SessionStack.Contains (Current))
         {
         {
-            // This assertion confirm if the Top was already disposed
-            Debug.Assert (Top.WasDisposed);
-            Debug.Assert (Top == CachedSessionTokenToplevel);
+            // This assertion confirm if the Current was already disposed
+            Debug.Assert (Current.WasDisposed);
+            Debug.Assert (Current == CachedSessionTokenToplevel);
         }
         }
 #endif
 #endif
 
 
-        lock (TopLevels)
+        lock (SessionStack)
         {
         {
-            if (Top is { } && toplevel != Top && !TopLevels.Contains (Top))
+            if (Current is { } && toplevel != Current && !SessionStack.Contains (Current))
             {
             {
-                // If Top was already disposed and isn't on the Toplevels Stack,
+                // If Current was already disposed and isn't on the Toplevels Stack,
                 // clean it up here if is the same as _CachedSessionTokenToplevel
                 // clean it up here if is the same as _CachedSessionTokenToplevel
-                if (Top == CachedSessionTokenToplevel)
+                if (Current == CachedSessionTokenToplevel)
                 {
                 {
-                    Top = null;
+                    Current = null;
                 }
                 }
                 else
                 else
                 {
                 {
                     // Probably this will never hit
                     // Probably this will never hit
-                    throw new ObjectDisposedException (Top.GetType ().FullName);
+                    throw new ObjectDisposedException (Current.GetType ().FullName);
                 }
                 }
             }
             }
 
 
@@ -67,56 +67,56 @@ public partial class ApplicationImpl
             if (string.IsNullOrEmpty (toplevel.Id))
             if (string.IsNullOrEmpty (toplevel.Id))
             {
             {
                 var count = 1;
                 var count = 1;
-                var id = (TopLevels.Count + count).ToString ();
+                var id = (SessionStack.Count + count).ToString ();
 
 
-                while (TopLevels.Count > 0 && TopLevels.FirstOrDefault (x => x.Id == id) is { })
+                while (SessionStack.Count > 0 && SessionStack.FirstOrDefault (x => x.Id == id) is { })
                 {
                 {
                     count++;
                     count++;
-                    id = (TopLevels.Count + count).ToString ();
+                    id = (SessionStack.Count + count).ToString ();
                 }
                 }
 
 
-                toplevel.Id = (TopLevels.Count + count).ToString ();
+                toplevel.Id = (SessionStack.Count + count).ToString ();
 
 
-                TopLevels.Push (toplevel);
+                SessionStack.Push (toplevel);
             }
             }
             else
             else
             {
             {
-                Toplevel? dup = TopLevels.FirstOrDefault (x => x.Id == toplevel.Id);
+                Toplevel? dup = SessionStack.FirstOrDefault (x => x.Id == toplevel.Id);
 
 
                 if (dup is null)
                 if (dup is null)
                 {
                 {
-                    TopLevels.Push (toplevel);
+                    SessionStack.Push (toplevel);
                 }
                 }
             }
             }
         }
         }
 
 
-        if (Top is null)
+        if (Current is null)
         {
         {
-            Top = toplevel;
+            Current = toplevel;
         }
         }
 
 
-        if ((Top?.Modal == false && toplevel.Modal)
-            || (Top?.Modal == false && !toplevel.Modal)
-            || (Top?.Modal == true && toplevel.Modal))
+        if ((Current?.Modal == false && toplevel.Modal)
+            || (Current?.Modal == false && !toplevel.Modal)
+            || (Current?.Modal == true && toplevel.Modal))
         {
         {
             if (toplevel.Visible)
             if (toplevel.Visible)
             {
             {
-                if (Top is { HasFocus: true })
+                if (Current is { HasFocus: true })
                 {
                 {
-                    Top.HasFocus = false;
+                    Current.HasFocus = false;
                 }
                 }
 
 
-                // Force leave events for any entered views in the old Top
+                // Force leave events for any entered views in the old Current
                 if (Mouse.GetLastMousePosition () is { })
                 if (Mouse.GetLastMousePosition () is { })
                 {
                 {
                     Mouse.RaiseMouseEnterLeaveEvents (Mouse.GetLastMousePosition ()!.Value, new ());
                     Mouse.RaiseMouseEnterLeaveEvents (Mouse.GetLastMousePosition ()!.Value, new ());
                 }
                 }
 
 
-                Top?.OnDeactivate (toplevel);
-                Toplevel previousTop = Top!;
+                Current?.OnDeactivate (toplevel);
+                Toplevel previousTop = Current!;
 
 
-                Top = toplevel;
-                Top.OnActivate (previousTop);
+                Current = toplevel;
+                Current.OnActivate (previousTop);
             }
             }
         }
         }
 
 
@@ -193,15 +193,15 @@ public partial class ApplicationImpl
             throw new InvalidOperationException ("Driver was inexplicably null when trying to Run view");
             throw new InvalidOperationException ("Driver was inexplicably null when trying to Run view");
         }
         }
 
 
-        Top = view;
+        Current = view;
 
 
         SessionToken rs = Application.Begin (view);
         SessionToken rs = Application.Begin (view);
 
 
-        Top.Running = true;
+        Current.Running = true;
 
 
         var firstIteration = true;
         var firstIteration = true;
 
 
-        while (TopLevels.TryPeek (out Toplevel? found) && found == view && view.Running)
+        while (SessionStack.TryPeek (out Toplevel? found) && found == view && view.Running)
         {
         {
             if (Coordinator is null)
             if (Coordinator is null)
             {
             {
@@ -237,7 +237,7 @@ public partial class ApplicationImpl
 
 
         // End the Session
         // End the Session
         // First, take it off the Toplevel Stack
         // First, take it off the Toplevel Stack
-        if (TopLevels.TryPop (out Toplevel? topOfStack))
+        if (SessionStack.TryPop (out Toplevel? topOfStack))
         {
         {
             if (topOfStack != sessionToken.Toplevel)
             if (topOfStack != sessionToken.Toplevel)
             {
             {
@@ -250,10 +250,10 @@ public partial class ApplicationImpl
         // Notify that it is closing
         // Notify that it is closing
         sessionToken.Toplevel?.OnClosed (sessionToken.Toplevel);
         sessionToken.Toplevel?.OnClosed (sessionToken.Toplevel);
 
 
-        if (TopLevels.TryPeek (out Toplevel? newTop))
+        if (SessionStack.TryPeek (out Toplevel? newTop))
         {
         {
-            Top = newTop;
-            Top?.SetNeedsDraw ();
+            Current = newTop;
+            Current?.SetNeedsDraw ();
         }
         }
 
 
         if (sessionToken.Toplevel is { HasFocus: true })
         if (sessionToken.Toplevel is { HasFocus: true })
@@ -261,9 +261,9 @@ public partial class ApplicationImpl
             sessionToken.Toplevel.HasFocus = false;
             sessionToken.Toplevel.HasFocus = false;
         }
         }
 
 
-        if (Top is { HasFocus: false })
+        if (Current is { HasFocus: false })
         {
         {
-            Top.SetFocus ();
+            Current.SetFocus ();
         }
         }
 
 
         CachedSessionTokenToplevel = sessionToken.Toplevel;
         CachedSessionTokenToplevel = sessionToken.Toplevel;
@@ -283,9 +283,9 @@ public partial class ApplicationImpl
     /// <inheritdoc/>
     /// <inheritdoc/>
     public void RequestStop (Toplevel? top)
     public void RequestStop (Toplevel? top)
     {
     {
-        Logging.Trace ($"Top: '{(top is { } ? top : "null")}'");
+        Logging.Trace ($"Current: '{(top is { } ? top : "null")}'");
 
 
-        top ??= Top;
+        top ??= Current;
 
 
         if (top == null)
         if (top == null)
         {
         {
@@ -325,7 +325,7 @@ public partial class ApplicationImpl
     public void Invoke (Action action)
     public void Invoke (Action action)
     {
     {
         // If we are already on the main UI thread
         // If we are already on the main UI thread
-        if (Top is { Running: true } && MainThreadId == Thread.CurrentThread.ManagedThreadId)
+        if (Current is { Running: true } && MainThreadId == Thread.CurrentThread.ManagedThreadId)
         {
         {
             action ();
             action ();
 
 

+ 2 - 2
Terminal.Gui/App/ApplicationImpl.Screen.cs

@@ -133,7 +133,7 @@ public partial class ApplicationImpl
 
 
         ScreenChanged?.Invoke (this, new (screen));
         ScreenChanged?.Invoke (this, new (screen));
 
 
-        foreach (Toplevel t in TopLevels)
+        foreach (Toplevel t in SessionStack)
         {
         {
             t.OnSizeChanging (new (screen.Size));
             t.OnSizeChanging (new (screen.Size));
             t.SetNeedsLayout ();
             t.SetNeedsLayout ();
@@ -147,7 +147,7 @@ public partial class ApplicationImpl
     /// <inheritdoc/>
     /// <inheritdoc/>
     public void LayoutAndDraw (bool forceRedraw = false)
     public void LayoutAndDraw (bool forceRedraw = false)
     {
     {
-        List<View> tops = [.. TopLevels];
+        List<View> tops = [.. SessionStack];
 
 
         if (Popover?.GetActivePopover () as View is { Visible: true } visiblePopover)
         if (Popover?.GetActivePopover () as View is { Visible: true } visiblePopover)
         {
         {

+ 3 - 3
Terminal.Gui/App/ApplicationImpl.cs

@@ -96,12 +96,12 @@ public partial class ApplicationImpl : IApplication
     public ApplicationNavigation? Navigation { get; set; }
     public ApplicationNavigation? Navigation { get; set; }
 
 
     /// <inheritdoc/>
     /// <inheritdoc/>
-    public Toplevel? Top { get; set; }
+    public Toplevel? Current { get; set; }
 
 
-    // BUGBUG: Technically, this is not the full lst of TopLevels. There be dragons here, e.g. see how Toplevel.Id is used. What
+    // BUGBUG: Technically, this is not the full lst of sessions. There be dragons here, e.g. see how Toplevel.Id is used. What
 
 
     /// <inheritdoc/>
     /// <inheritdoc/>
-    public ConcurrentStack<Toplevel> TopLevels { get; } = new ();
+    public ConcurrentStack<Toplevel> SessionStack { get; } = new ();
 
 
     /// <inheritdoc/>
     /// <inheritdoc/>
     public Toplevel? CachedSessionTokenToplevel { get; set; }
     public Toplevel? CachedSessionTokenToplevel { get; set; }

+ 1 - 1
Terminal.Gui/App/ApplicationNavigation.cs

@@ -109,6 +109,6 @@ public class ApplicationNavigation
         {
         {
             return visiblePopover.AdvanceFocus (direction, behavior);
             return visiblePopover.AdvanceFocus (direction, behavior);
         }
         }
-        return Application.Top is { } && Application.Top.AdvanceFocus (direction, behavior);
+        return Application.Current is { } && Application.Current.AdvanceFocus (direction, behavior);
     }
     }
 }
 }

+ 4 - 4
Terminal.Gui/App/ApplicationPopover.cs

@@ -37,8 +37,8 @@ public sealed class ApplicationPopover : IDisposable
     {
     {
         if (popover is { } && !_popovers.Contains (popover))
         if (popover is { } && !_popovers.Contains (popover))
         {
         {
-            // When created, set IPopover.Toplevel to the current Application.Top
-            popover.Toplevel ??= Application.Top;
+            // When created, set IPopover.Toplevel to the current Application.Current
+            popover.Toplevel ??= Application.Current;
 
 
             _popovers.Add (popover);
             _popovers.Add (popover);
         }
         }
@@ -148,7 +148,7 @@ public sealed class ApplicationPopover : IDisposable
         {
         {
             _activePopover = null;
             _activePopover = null;
             popoverView.Visible = false;
             popoverView.Visible = false;
-            Application.Top?.SetNeedsDraw ();
+            Application.Current?.SetNeedsDraw ();
         }
         }
     }
     }
 
 
@@ -197,7 +197,7 @@ public sealed class ApplicationPopover : IDisposable
         {
         {
             if (popover == activePopover
             if (popover == activePopover
                 || popover is not View popoverView
                 || popover is not View popoverView
-                || (popover.Toplevel is { } && popover.Toplevel != Application.Top))
+                || (popover.Toplevel is { } && popover.Toplevel != Application.Current))
             {
             {
                 continue;
                 continue;
             }
             }

+ 7 - 7
Terminal.Gui/App/IApplication.cs

@@ -296,14 +296,14 @@ public interface IApplication
     /// <remarks>
     /// <remarks>
     ///     <para>This will cause <see cref="Run(Toplevel, Func{Exception, bool})"/> to return.</para>
     ///     <para>This will cause <see cref="Run(Toplevel, Func{Exception, bool})"/> to return.</para>
     ///     <para>
     ///     <para>
-    ///         This is equivalent to calling <see cref="RequestStop(Toplevel)"/> with <see cref="Top"/> as the parameter.
+    ///         This is equivalent to calling <see cref="RequestStop(Toplevel)"/> with <see cref="Current"/> as the parameter.
     ///     </para>
     ///     </para>
     /// </remarks>
     /// </remarks>
     void RequestStop ();
     void RequestStop ();
 
 
     /// <summary>Requests that the currently running Session stop. The Session will stop after the current iteration completes.</summary>
     /// <summary>Requests that the currently running Session stop. The Session will stop after the current iteration completes.</summary>
     /// <param name="top">
     /// <param name="top">
-    ///     The <see cref="Toplevel"/> to stop. If <see langword="null"/>, stops the currently running <see cref="Top"/>.
+    ///     The <see cref="Toplevel"/> to stop. If <see langword="null"/>, stops the currently running <see cref="Current"/>.
     /// </param>
     /// </param>
     /// <remarks>
     /// <remarks>
     ///     <para>This will cause <see cref="Run(Toplevel, Func{Exception, bool})"/> to return.</para>
     ///     <para>This will cause <see cref="Run(Toplevel, Func{Exception, bool})"/> to return.</para>
@@ -351,22 +351,22 @@ public interface IApplication
 
 
     #region Toplevel Management
     #region Toplevel Management
 
 
-    /// <summary>Gets or sets the current Toplevel.</summary>
+    /// <summary>Gets or sets the currently active Toplevel.</summary>
     /// <remarks>
     /// <remarks>
     ///     <para>
     ///     <para>
     ///         This is set by <see cref="Begin(Toplevel)"/> and cleared by <see cref="End(SessionToken)"/>.
     ///         This is set by <see cref="Begin(Toplevel)"/> and cleared by <see cref="End(SessionToken)"/>.
     ///     </para>
     ///     </para>
     /// </remarks>
     /// </remarks>
-    Toplevel? Top { get; set; }
+    Toplevel? Current { get; set; }
 
 
-    /// <summary>Gets the stack of all Toplevels.</summary>
+    /// <summary>Gets the stack of all active Toplevel sessions.</summary>
     /// <remarks>
     /// <remarks>
     ///     <para>
     ///     <para>
     ///         Toplevels are added to this stack by <see cref="Begin(Toplevel)"/> and removed by
     ///         Toplevels are added to this stack by <see cref="Begin(Toplevel)"/> and removed by
     ///         <see cref="End(SessionToken)"/>.
     ///         <see cref="End(SessionToken)"/>.
     ///     </para>
     ///     </para>
     /// </remarks>
     /// </remarks>
-    ConcurrentStack<Toplevel> TopLevels { get; }
+    ConcurrentStack<Toplevel> SessionStack { get; }
 
 
     /// <summary>
     /// <summary>
     ///     Caches the Toplevel associated with the current Session.
     ///     Caches the Toplevel associated with the current Session.
@@ -428,7 +428,7 @@ public interface IApplication
     /// <remarks>
     /// <remarks>
     ///     <para>
     ///     <para>
     ///         This is typically set to <see langword="true"/> when a View's <see cref="View.Frame"/> changes and that view
     ///         This is typically set to <see langword="true"/> when a View's <see cref="View.Frame"/> changes and that view
-    ///         has no SuperView (e.g. when <see cref="Top"/> is moved or resized).
+    ///         has no SuperView (e.g. when <see cref="Current"/> is moved or resized).
     ///     </para>
     ///     </para>
     ///     <para>
     ///     <para>
     ///         Automatically reset to <see langword="false"/> after <see cref="LayoutAndDraw"/> processes it.
     ///         Automatically reset to <see langword="false"/> after <see cref="LayoutAndDraw"/> processes it.

+ 1 - 1
Terminal.Gui/App/IPopover.cs

@@ -56,7 +56,7 @@ public interface IPopover
     ///     events from the <see cref="Application"/>. If set, it will only receive keyboard events the Toplevel would normally
     ///     events from the <see cref="Application"/>. If set, it will only receive keyboard events the Toplevel would normally
     ///     receive.
     ///     receive.
     ///     When <see cref="ApplicationPopover.Register"/> is called, the <see cref="Toplevel"/> is set to the current
     ///     When <see cref="ApplicationPopover.Register"/> is called, the <see cref="Toplevel"/> is set to the current
-    ///     <see cref="Application.Top"/> if not already set.
+    ///     <see cref="Application.Current"/> if not already set.
     /// </summary>
     /// </summary>
     Toplevel? Toplevel { get; set; }
     Toplevel? Toplevel { get; set; }
 }
 }

+ 6 - 6
Terminal.Gui/App/Keyboard/KeyboardImpl.cs

@@ -141,11 +141,11 @@ internal class KeyboardImpl : IKeyboard
             return true;
             return true;
         }
         }
 
 
-        if (Application?.Top is null)
+        if (Application?.Current is null)
         {
         {
-            if (Application?.TopLevels is { })
+            if (Application?.SessionStack is { })
             {
             {
-                foreach (Toplevel topLevel in Application.TopLevels.ToList ())
+                foreach (Toplevel topLevel in Application.SessionStack.ToList ())
                 {
                 {
                     if (topLevel.NewKeyDownEvent (key))
                     if (topLevel.NewKeyDownEvent (key))
                     {
                     {
@@ -161,7 +161,7 @@ internal class KeyboardImpl : IKeyboard
         }
         }
         else
         else
         {
         {
-            if (Application.Top.NewKeyDownEvent (key))
+            if (Application.Current.NewKeyDownEvent (key))
             {
             {
                 return true;
                 return true;
             }
             }
@@ -194,9 +194,9 @@ internal class KeyboardImpl : IKeyboard
 
 
         // TODO: Add Popover support
         // TODO: Add Popover support
 
 
-        if (Application?.TopLevels is { })
+        if (Application?.SessionStack is { })
         {
         {
-            foreach (Toplevel topLevel in Application.TopLevels.ToList ())
+            foreach (Toplevel topLevel in Application.SessionStack.ToList ())
             {
             {
                 if (topLevel.NewKeyUpEvent (key))
                 if (topLevel.NewKeyUpEvent (key))
                 {
                 {

+ 4 - 4
Terminal.Gui/App/MainLoop/ApplicationMainLoop.cs

@@ -82,7 +82,7 @@ public class ApplicationMainLoop<TInputRecord> : IApplicationMainLoop<TInputReco
     }
     }
 
 
     /// <summary>
     /// <summary>
-    ///     Handles raising events and setting required draw status etc when <see cref="Application.Top"/> changes
+    ///     Handles raising events and setting required draw status etc when <see cref="Application.Current"/> changes
     /// </summary>
     /// </summary>
     public IToplevelTransitionManager ToplevelTransitionManager = new ToplevelTransitionManager ();
     public IToplevelTransitionManager ToplevelTransitionManager = new ToplevelTransitionManager ();
 
 
@@ -142,10 +142,10 @@ public class ApplicationMainLoop<TInputRecord> : IApplicationMainLoop<TInputReco
         ToplevelTransitionManager.RaiseReadyEventIfNeeded ();
         ToplevelTransitionManager.RaiseReadyEventIfNeeded ();
         ToplevelTransitionManager.HandleTopMaybeChanging ();
         ToplevelTransitionManager.HandleTopMaybeChanging ();
 
 
-        if (Application.Top != null)
+        if (Application.Current != null)
         {
         {
             bool needsDrawOrLayout = AnySubViewsNeedDrawn (Application.Popover?.GetActivePopover () as View)
             bool needsDrawOrLayout = AnySubViewsNeedDrawn (Application.Popover?.GetActivePopover () as View)
-                                     || AnySubViewsNeedDrawn (Application.Top)
+                                     || AnySubViewsNeedDrawn (Application.Current)
                                      || (Application.Mouse.MouseGrabView != null && AnySubViewsNeedDrawn (Application.Mouse.MouseGrabView));
                                      || (Application.Mouse.MouseGrabView != null && AnySubViewsNeedDrawn (Application.Mouse.MouseGrabView));
 
 
             bool sizeChanged = SizeMonitor.Poll ();
             bool sizeChanged = SizeMonitor.Poll ();
@@ -173,7 +173,7 @@ public class ApplicationMainLoop<TInputRecord> : IApplicationMainLoop<TInputReco
 
 
     private void SetCursor ()
     private void SetCursor ()
     {
     {
-        View? mostFocused = Application.Top!.MostFocused;
+        View? mostFocused = Application.Current!.MostFocused;
 
 
         if (mostFocused == null)
         if (mostFocused == null)
         {
         {

+ 2 - 2
Terminal.Gui/App/Mouse/MouseImpl.cs

@@ -119,9 +119,9 @@ internal class MouseImpl : IMouse
             return;
             return;
         }
         }
 
 
-        // if the mouse is outside the Application.Top or Application.Popover hierarchy, we don't want to
+        // if the mouse is outside the Application.Current or Application.Popover hierarchy, we don't want to
         // send the mouse event to the deepest view under the mouse.
         // send the mouse event to the deepest view under the mouse.
-        if (!View.IsInHierarchy (Application?.Top, deepestViewUnderMouse, true) && !View.IsInHierarchy (Application?.Popover?.GetActivePopover () as View, deepestViewUnderMouse, true))
+        if (!View.IsInHierarchy (Application?.Current, deepestViewUnderMouse, true) && !View.IsInHierarchy (Application?.Popover?.GetActivePopover () as View, deepestViewUnderMouse, true))
         {
         {
             return;
             return;
         }
         }

+ 1 - 1
Terminal.Gui/App/PopoverBaseImpl.cs

@@ -107,7 +107,7 @@ public abstract class PopoverBaseImpl : View, IPopover
             // Whenever visible is changing to false, we need to reset the focus
             // Whenever visible is changing to false, we need to reset the focus
             if (ApplicationNavigation.IsInHierarchy (this, Application.Navigation?.GetFocused ()))
             if (ApplicationNavigation.IsInHierarchy (this, Application.Navigation?.GetFocused ()))
             {
             {
-                Application.Navigation?.SetFocused (Application.Top?.MostFocused);
+                Application.Navigation?.SetFocused (Application.Current?.MostFocused);
             }
             }
         }
         }
 
 

+ 3 - 3
Terminal.Gui/App/Toplevel/ToplevelTransitionManager.cs

@@ -15,7 +15,7 @@ public class ToplevelTransitionManager : IToplevelTransitionManager
     /// <inheritdoc/>
     /// <inheritdoc/>
     public void RaiseReadyEventIfNeeded ()
     public void RaiseReadyEventIfNeeded ()
     {
     {
-        Toplevel? top = Application.Top;
+        Toplevel? top = Application.Current;
 
 
         if (top != null && !_readiedTopLevels.Contains (top))
         if (top != null && !_readiedTopLevels.Contains (top))
         {
         {
@@ -30,13 +30,13 @@ public class ToplevelTransitionManager : IToplevelTransitionManager
     /// <inheritdoc/>
     /// <inheritdoc/>
     public void HandleTopMaybeChanging ()
     public void HandleTopMaybeChanging ()
     {
     {
-        Toplevel? newTop = Application.Top;
+        Toplevel? newTop = Application.Current;
 
 
         if (_lastTop != null && _lastTop != newTop && newTop != null)
         if (_lastTop != null && _lastTop != newTop && newTop != null)
         {
         {
             newTop.SetNeedsDraw ();
             newTop.SetNeedsDraw ();
         }
         }
 
 
-        _lastTop = Application.Top;
+        _lastTop = Application.Current;
     }
     }
 }
 }

+ 1 - 1
Terminal.Gui/ViewBase/Adornment/Border.Arrangment.cs

@@ -652,7 +652,7 @@ public partial class Border
         if (Parent!.SuperView is null)
         if (Parent!.SuperView is null)
         {
         {
             // Redraw the entire app window.
             // Redraw the entire app window.
-            Application.Top!.SetNeedsDraw ();
+            Application.Current!.SetNeedsDraw ();
         }
         }
         else
         else
         {
         {

+ 2 - 2
Terminal.Gui/ViewBase/View.Hierarchy.cs

@@ -363,12 +363,12 @@ public partial class View // SuperView/SubView hierarchy management (SuperView,
 
 
     #endregion AddRemove
     #endregion AddRemove
 
 
-    // TODO: This drives a weird coupling of Application.Top and View. It's not clear why this is needed.
+    // TODO: This drives a weird coupling of Application.Current and View. It's not clear why this is needed.
     /// <summary>Get the top superview of a given <see cref="View"/>.</summary>
     /// <summary>Get the top superview of a given <see cref="View"/>.</summary>
     /// <returns>The superview view.</returns>
     /// <returns>The superview view.</returns>
     internal View? GetTopSuperView (View? view = null, View? superview = null)
     internal View? GetTopSuperView (View? view = null, View? superview = null)
     {
     {
-        View? top = superview ?? Application.Top;
+        View? top = superview ?? Application.Current;
 
 
         for (View? v = view?.SuperView ?? this?.SuperView; v != null; v = v.SuperView)
         for (View? v = view?.SuperView ?? this?.SuperView; v != null; v = v.SuperView)
         {
         {

+ 15 - 15
Terminal.Gui/ViewBase/View.Layout.cs

@@ -438,7 +438,7 @@ public partial class View // Layout APIs
 
 
     private void NeedsClearScreenNextIteration ()
     private void NeedsClearScreenNextIteration ()
     {
     {
-        if (Application.Top is { } && Application.Top == this && Application.TopLevels.Count == 1)
+        if (Application.Current is { } && Application.Current == this && Application.SessionStack.Count == 1)
         {
         {
             // If this is the only TopLevel, we need to redraw the screen
             // If this is the only TopLevel, we need to redraw the screen
             Application.ClearScreenNextIteration = true;
             Application.ClearScreenNextIteration = true;
@@ -1114,8 +1114,8 @@ public partial class View // Layout APIs
     {
     {
         // TODO: Get rid of refs to Top
         // TODO: Get rid of refs to Top
         Size superViewContentSize = SuperView?.GetContentSize ()
         Size superViewContentSize = SuperView?.GetContentSize ()
-                                    ?? (Application.Top is { } && Application.Top != this && Application.Top.IsInitialized
-                                            ? Application.Top.GetContentSize ()
+                                    ?? (Application.Current is { } && Application.Current != this && Application.Current.IsInitialized
+                                            ? Application.Current.GetContentSize ()
                                             : Application.Screen.Size);
                                             : Application.Screen.Size);
 
 
         return superViewContentSize;
         return superViewContentSize;
@@ -1130,7 +1130,7 @@ public partial class View // Layout APIs
     /// </summary>
     /// </summary>
     /// <remarks>
     /// <remarks>
     ///     If <paramref name="viewToMove"/> does not have a <see cref="View.SuperView"/> or it's SuperView is not
     ///     If <paramref name="viewToMove"/> does not have a <see cref="View.SuperView"/> or it's SuperView is not
-    ///     <see cref="Application.Top"/> the position will be bound by  <see cref="Application.Screen"/>.
+    ///     <see cref="Application.Current"/> the position will be bound by  <see cref="Application.Screen"/>.
     /// </remarks>
     /// </remarks>
     /// <param name="viewToMove">The View that is to be moved.</param>
     /// <param name="viewToMove">The View that is to be moved.</param>
     /// <param name="targetX">The target x location.</param>
     /// <param name="targetX">The target x location.</param>
@@ -1138,7 +1138,7 @@ public partial class View // Layout APIs
     /// <param name="nx">The new x location that will ensure <paramref name="viewToMove"/> will be fully visible.</param>
     /// <param name="nx">The new x location that will ensure <paramref name="viewToMove"/> will be fully visible.</param>
     /// <param name="ny">The new y location that will ensure <paramref name="viewToMove"/> will be fully visible.</param>
     /// <param name="ny">The new y location that will ensure <paramref name="viewToMove"/> will be fully visible.</param>
     /// <returns>
     /// <returns>
-    ///     Either <see cref="Application.Top"/> (if <paramref name="viewToMove"/> does not have a Super View) or
+    ///     Either <see cref="Application.Current"/> (if <paramref name="viewToMove"/> does not have a Super View) or
     ///     <paramref name="viewToMove"/>'s SuperView. This can be used to ensure LayoutSubViews is called on the correct View.
     ///     <paramref name="viewToMove"/>'s SuperView. This can be used to ensure LayoutSubViews is called on the correct View.
     /// </returns>
     /// </returns>
     internal static View? GetLocationEnsuringFullVisibility (
     internal static View? GetLocationEnsuringFullVisibility (
@@ -1152,10 +1152,10 @@ public partial class View // Layout APIs
         int maxDimension;
         int maxDimension;
         View? superView;
         View? superView;
 
 
-        if (viewToMove?.SuperView is null || viewToMove == Application.Top || viewToMove?.SuperView == Application.Top)
+        if (viewToMove?.SuperView is null || viewToMove == Application.Current || viewToMove?.SuperView == Application.Current)
         {
         {
             maxDimension = Application.Screen.Width;
             maxDimension = Application.Screen.Width;
-            superView = Application.Top;
+            superView = Application.Current;
         }
         }
         else
         else
         {
         {
@@ -1188,9 +1188,9 @@ public partial class View // Layout APIs
         var menuVisible = false;
         var menuVisible = false;
         var statusVisible = false;
         var statusVisible = false;
 
 
-        if (viewToMove?.SuperView is null || viewToMove == Application.Top || viewToMove?.SuperView == Application.Top)
+        if (viewToMove?.SuperView is null || viewToMove == Application.Current || viewToMove?.SuperView == Application.Current)
         {
         {
-            menuVisible = Application.Top?.MenuBar?.Visible == true;
+            menuVisible = Application.Current?.MenuBar?.Visible == true;
         }
         }
         else
         else
         {
         {
@@ -1207,7 +1207,7 @@ public partial class View // Layout APIs
             }
             }
         }
         }
 
 
-        if (viewToMove?.SuperView is null || viewToMove == Application.Top || viewToMove?.SuperView == Application.Top)
+        if (viewToMove?.SuperView is null || viewToMove == Application.Current || viewToMove?.SuperView == Application.Current)
         {
         {
             maxDimension = menuVisible ? 1 : 0;
             maxDimension = menuVisible ? 1 : 0;
         }
         }
@@ -1218,7 +1218,7 @@ public partial class View // Layout APIs
 
 
         ny = Math.Max (targetY, maxDimension);
         ny = Math.Max (targetY, maxDimension);
 
 
-        if (viewToMove?.SuperView is null || viewToMove == Application.Top || viewToMove?.SuperView == Application.Top)
+        if (viewToMove?.SuperView is null || viewToMove == Application.Current || viewToMove?.SuperView == Application.Current)
         {
         {
             maxDimension = statusVisible ? Application.Screen.Height - 1 : Application.Screen.Height;
             maxDimension = statusVisible ? Application.Screen.Height - 1 : Application.Screen.Height;
         }
         }
@@ -1286,9 +1286,9 @@ public partial class View // Layout APIs
         var checkedTop = false;
         var checkedTop = false;
 
 
         // Traverse all visible toplevels, topmost first (reverse stack order)
         // Traverse all visible toplevels, topmost first (reverse stack order)
-        if (Application.TopLevels.Count > 0)
+        if (Application.SessionStack.Count > 0)
         {
         {
-            foreach (Toplevel toplevel in Application.TopLevels)
+            foreach (Toplevel toplevel in Application.SessionStack)
             {
             {
                 if (toplevel.Visible && toplevel.Contains (screenLocation))
                 if (toplevel.Visible && toplevel.Contains (screenLocation))
                 {
                 {
@@ -1301,7 +1301,7 @@ public partial class View // Layout APIs
                     }
                     }
                 }
                 }
 
 
-                if (toplevel == Application.Top)
+                if (toplevel == Application.Current)
                 {
                 {
                     checkedTop = true;
                     checkedTop = true;
                 }
                 }
@@ -1309,7 +1309,7 @@ public partial class View // Layout APIs
         }
         }
 
 
         // Fallback: If TopLevels is empty or Top is not in TopLevels, check Top directly (for test compatibility)
         // Fallback: If TopLevels is empty or Top is not in TopLevels, check Top directly (for test compatibility)
-        if (!checkedTop && Application.Top is { Visible: true } top)
+        if (!checkedTop && Application.Current is { Visible: true } top)
         {
         {
             // For root toplevels, allow hit-testing even if location is outside bounds (for drag/move)
             // For root toplevels, allow hit-testing even if location is outside bounds (for drag/move)
             List<View?> result = GetViewsUnderLocation (top, screenLocation, excludeViewportSettingsFlags);
             List<View?> result = GetViewsUnderLocation (top, screenLocation, excludeViewportSettingsFlags);

+ 6 - 6
Terminal.Gui/ViewBase/View.Navigation.cs

@@ -396,7 +396,7 @@ public partial class View // Focus and cross-view navigation management (TabStop
     public event EventHandler<HasFocusEventArgs>? FocusedChanged;
     public event EventHandler<HasFocusEventArgs>? FocusedChanged;
 
 
     /// <summary>Returns a value indicating if this View is currently on Top (Active)</summary>
     /// <summary>Returns a value indicating if this View is currently on Top (Active)</summary>
-    public bool IsCurrentTop => Application.Top == this;
+    public bool IsCurrentTop => Application.Current == this;
 
 
     /// <summary>
     /// <summary>
     ///     Returns the most focused SubView down the subview-hierarchy.
     ///     Returns the most focused SubView down the subview-hierarchy.
@@ -854,18 +854,18 @@ public partial class View // Focus and cross-view navigation management (TabStop
                 }
                 }
             }
             }
 
 
-            // Application.Top?
-            if (newFocusedView is null && Application.Top is { CanFocus: true, HasFocus: false })
+            // Application.Current?
+            if (newFocusedView is null && Application.Current is { CanFocus: true, HasFocus: false })
             {
             {
                 // Temporarily ensure this view can't get focus
                 // Temporarily ensure this view can't get focus
                 bool prevCanFocus = _canFocus;
                 bool prevCanFocus = _canFocus;
                 _canFocus = false;
                 _canFocus = false;
-                bool restoredFocus = Application.Top.RestoreFocus ();
+                bool restoredFocus = Application.Current.RestoreFocus ();
                 _canFocus = prevCanFocus;
                 _canFocus = prevCanFocus;
 
 
-                if (Application.Top is { CanFocus: true, HasFocus: true })
+                if (Application.Current is { CanFocus: true, HasFocus: true })
                 {
                 {
-                    newFocusedView = Application.Top;
+                    newFocusedView = Application.Current;
                 }
                 }
                 else if (restoredFocus)
                 else if (restoredFocus)
                 {
                 {

+ 1 - 1
Terminal.Gui/Views/Dialog.cs

@@ -21,7 +21,7 @@ public class Dialog : Window
     /// <remarks>
     /// <remarks>
     ///     By default, <see cref="View.X"/>, <see cref="View.Y"/>, <see cref="View.Width"/>, and <see cref="View.Height"/> are
     ///     By default, <see cref="View.X"/>, <see cref="View.Y"/>, <see cref="View.Width"/>, and <see cref="View.Height"/> are
     ///     set
     ///     set
-    ///     such that the <see cref="Dialog"/> will be centered in, and no larger than 90% of <see cref="Application.Top"/>, if
+    ///     such that the <see cref="Dialog"/> will be centered in, and no larger than 90% of <see cref="Application.Current"/>, if
     ///     there is one. Otherwise,
     ///     there is one. Otherwise,
     ///     it will be bound by the screen dimensions.
     ///     it will be bound by the screen dimensions.
     /// </remarks>
     /// </remarks>

+ 6 - 6
Terminal.Gui/Views/Menuv1/Menu.cs

@@ -13,10 +13,10 @@ internal sealed class Menu : View
 {
 {
     public Menu ()
     public Menu ()
     {
     {
-        if (Application.Top is { })
+        if (Application.Current is { })
         {
         {
-            Application.Top.DrawComplete += Top_DrawComplete;
-            Application.Top.SizeChanging += Current_TerminalResized;
+            Application.Current.DrawComplete += Top_DrawComplete;
+            Application.Current.SizeChanging += Current_TerminalResized;
         }
         }
 
 
         Application.MouseEvent += Application_RootMouseEvent;
         Application.MouseEvent += Application_RootMouseEvent;
@@ -232,10 +232,10 @@ internal sealed class Menu : View
     {
     {
         RemoveKeyBindingsHotKey (_barItems);
         RemoveKeyBindingsHotKey (_barItems);
 
 
-        if (Application.Top is { })
+        if (Application.Current is { })
         {
         {
-            Application.Top.DrawComplete -= Top_DrawComplete;
-            Application.Top.SizeChanging -= Current_TerminalResized;
+            Application.Current.DrawComplete -= Top_DrawComplete;
+            Application.Current.SizeChanging -= Current_TerminalResized;
         }
         }
 
 
         Application.MouseEvent -= Application_RootMouseEvent;
         Application.MouseEvent -= Application_RootMouseEvent;

+ 4 - 4
Terminal.Gui/Views/Menuv1/MenuBar.cs

@@ -422,7 +422,7 @@ public class MenuBar : View, IDesignable
         _selected = 0;
         _selected = 0;
         SetNeedsDraw ();
         SetNeedsDraw ();
 
 
-        _previousFocused = (SuperView is null ? Application.Top?.Focused : SuperView.Focused)!;
+        _previousFocused = (SuperView is null ? Application.Current?.Focused : SuperView.Focused)!;
         OpenMenu (_selected);
         OpenMenu (_selected);
 
 
         if (!SelectEnabledItem (
         if (!SelectEnabledItem (
@@ -491,7 +491,7 @@ public class MenuBar : View, IDesignable
 
 
         if (_openMenu is null)
         if (_openMenu is null)
         {
         {
-            _previousFocused = (SuperView is null ? Application.Top?.Focused ?? null : SuperView.Focused)!;
+            _previousFocused = (SuperView is null ? Application.Current?.Focused ?? null : SuperView.Focused)!;
         }
         }
 
 
         OpenMenu (idx, sIdx, subMenu);
         OpenMenu (idx, sIdx, subMenu);
@@ -703,7 +703,7 @@ public class MenuBar : View, IDesignable
         }
         }
 
 
         Rectangle superViewFrame = SuperView?.Frame ?? Application.Screen;
         Rectangle superViewFrame = SuperView?.Frame ?? Application.Screen;
-        View? sv = SuperView ?? Application.Top;
+        View? sv = SuperView ?? Application.Current;
 
 
         if (sv is null)
         if (sv is null)
         {
         {
@@ -835,7 +835,7 @@ public class MenuBar : View, IDesignable
         {
         {
             case null:
             case null:
                 // Open a submenu below a MenuBar
                 // Open a submenu below a MenuBar
-                _lastFocused ??= SuperView is null ? Application.Top?.MostFocused : SuperView.MostFocused;
+                _lastFocused ??= SuperView is null ? Application.Current?.MostFocused : SuperView.MostFocused;
 
 
                 if (_openSubMenu is { } && !CloseMenu (false, true))
                 if (_openSubMenu is { } && !CloseMenu (false, true))
                 {
                 {

+ 3 - 3
Terminal.Gui/Views/Toplevel.cs

@@ -15,7 +15,7 @@ namespace Terminal.Gui.Views;
 ///     </para>
 ///     </para>
 ///     <para>
 ///     <para>
 ///         A Toplevel is created when an application initializes Terminal.Gui by calling <see cref="Application.Init"/>.
 ///         A Toplevel is created when an application initializes Terminal.Gui by calling <see cref="Application.Init"/>.
-///         The application Toplevel can be accessed via <see cref="Application.Top"/>. Additional Toplevels can be created
+///         The application Toplevel can be accessed via <see cref="Application.Current"/>. Additional Toplevels can be created
 ///         and run (e.g. <see cref="Dialog"/>s). To run a Toplevel, create the <see cref="Toplevel"/> and call
 ///         and run (e.g. <see cref="Dialog"/>s). To run a Toplevel, create the <see cref="Toplevel"/> and call
 ///         <see cref="Application.Run(Toplevel, Func{Exception, bool})"/>.
 ///         <see cref="Application.Run(Toplevel, Func{Exception, bool})"/>.
 ///     </para>
 ///     </para>
@@ -154,7 +154,7 @@ public partial class Toplevel : View
     /// </summary>
     /// </summary>
     public virtual void RequestStop ()
     public virtual void RequestStop ()
     {
     {
-        Application.RequestStop (Application.Top);
+        Application.RequestStop (Application.Current);
     }
     }
 
 
     /// <summary>
     /// <summary>
@@ -246,7 +246,7 @@ public partial class Toplevel : View
         }
         }
 
 
         // BUGBUG: The && true is a temp hack
         // BUGBUG: The && true is a temp hack
-        if ((superView != top || top?.SuperView is { } || (top != Application.Top && top!.Modal) || (top == Application.Top && top?.SuperView is null))
+        if ((superView != top || top?.SuperView is { } || (top != Application.Current && top!.Modal) || (top == Application.Current && top?.SuperView is null))
             && (top!.Frame.X + top.Frame.Width > maxWidth || ny > top.Frame.Y))
             && (top!.Frame.X + top.Frame.Width > maxWidth || ny > top.Frame.Y))
 
 
         {
         {

+ 1 - 1
Terminal.Gui/Views/Wizard/Wizard.cs

@@ -44,7 +44,7 @@ namespace Terminal.Gui.Views;
 ///     Application.RequestStop();
 ///     Application.RequestStop();
 /// };
 /// };
 /// 
 /// 
-/// Application.Top.Add (wizard);
+/// Application.Current.Add (wizard);
 /// Application.Run ();
 /// Application.Run ();
 /// Application.Shutdown ();
 /// Application.Shutdown ();
 /// </code>
 /// </code>

+ 4 - 4
Tests/IntegrationTests/FluentTests/GuiTestContextKeyEventTests.cs

@@ -16,9 +16,9 @@ public class GuiTestContextKeyEventTests (ITestOutputHelper outputHelper)
     public void QuitKey_ViaApplication_Stops (TestDriver d)
     public void QuitKey_ViaApplication_Stops (TestDriver d)
     {
     {
         using GuiTestContext context = With.A<Window> (40, 10, d);
         using GuiTestContext context = With.A<Window> (40, 10, d);
-        Assert.True (Application.Top!.Running);
+        Assert.True (Application.Current!.Running);
 
 
-        Toplevel top = Application.Top;
+        Toplevel top = Application.Current;
         context.Then (() => Application.RaiseKeyDownEvent (Application.QuitKey));
         context.Then (() => Application.RaiseKeyDownEvent (Application.QuitKey));
         Assert.False (top!.Running);
         Assert.False (top!.Running);
     }
     }
@@ -28,9 +28,9 @@ public class GuiTestContextKeyEventTests (ITestOutputHelper outputHelper)
     public void QuitKey_ViaEnqueueKey_Stops (TestDriver d)
     public void QuitKey_ViaEnqueueKey_Stops (TestDriver d)
     {
     {
         using GuiTestContext context = With.A<Window> (40, 10, d, _out);
         using GuiTestContext context = With.A<Window> (40, 10, d, _out);
-        Assert.True (Application.Top!.Running);
+        Assert.True (Application.Current!.Running);
 
 
-        Toplevel top = Application.Top;
+        Toplevel top = Application.Current;
         context.EnqueueKeyEvent (Application.QuitKey);
         context.EnqueueKeyEvent (Application.QuitKey);
 
 
         Assert.False (top!.Running);
         Assert.False (top!.Running);

+ 1 - 1
Tests/IntegrationTests/FluentTests/GuiTestContextTests.cs

@@ -43,7 +43,7 @@ public class GuiTestContextTests (ITestOutputHelper outputHelper)
     public void With_New_A_Runs (TestDriver d)
     public void With_New_A_Runs (TestDriver d)
     {
     {
         using GuiTestContext context = With.A<Window> (40, 10, d, _out);
         using GuiTestContext context = With.A<Window> (40, 10, d, _out);
-        Assert.True (Application.Top!.Running);
+        Assert.True (Application.Current!.Running);
         Assert.NotEqual (Rectangle.Empty, Application.Screen);
         Assert.NotEqual (Rectangle.Empty, Application.Screen);
     }
     }
 
 

+ 23 - 23
Tests/IntegrationTests/FluentTests/MenuBarv2Tests.cs

@@ -142,7 +142,7 @@ public class MenuBarv2Tests
                                      .Then (() =>
                                      .Then (() =>
                                             {
                                             {
                                                 menuBar = new MenuBarv2 ();
                                                 menuBar = new MenuBarv2 ();
-                                                Toplevel top = Application.Top!;
+                                                Toplevel top = Application.Current!;
 
 
                                                 top.Add (
                                                 top.Add (
                                                          new View ()
                                                          new View ()
@@ -152,7 +152,7 @@ public class MenuBarv2Tests
 
 
                                                          });
                                                          });
                                                 menuBar.EnableForDesign (ref top);
                                                 menuBar.EnableForDesign (ref top);
-                                                Application.Top!.Add (menuBar);
+                                                Application.Current!.Add (menuBar);
                                             })
                                             })
                                      .WaitIteration ()
                                      .WaitIteration ()
                                      .AssertIsNotType<MenuItemv2> (Application.Navigation!.GetFocused ())
                                      .AssertIsNotType<MenuItemv2> (Application.Navigation!.GetFocused ())
@@ -176,7 +176,7 @@ public class MenuBarv2Tests
                                      .Then (() =>
                                      .Then (() =>
                                             {
                                             {
                                                 menuBar = new MenuBarv2 ();
                                                 menuBar = new MenuBarv2 ();
-                                                Toplevel top = Application.Top!;
+                                                Toplevel top = Application.Current!;
 
 
                                                 top.Add (
                                                 top.Add (
                                                          new View ()
                                                          new View ()
@@ -186,7 +186,7 @@ public class MenuBarv2Tests
 
 
                                                          });
                                                          });
                                                 menuBar.EnableForDesign (ref top);
                                                 menuBar.EnableForDesign (ref top);
-                                                Application.Top!.Add (menuBar);
+                                                Application.Current!.Add (menuBar);
                                             })
                                             })
                                      .WaitIteration ()
                                      .WaitIteration ()
                                      .AssertIsNotType<MenuItemv2> (Application.Navigation!.GetFocused ())
                                      .AssertIsNotType<MenuItemv2> (Application.Navigation!.GetFocused ())
@@ -262,10 +262,10 @@ public class MenuBarv2Tests
                                      .Then (() =>
                                      .Then (() =>
                                             {
                                             {
                                                 var menuBar = new MenuBarv2 ();
                                                 var menuBar = new MenuBarv2 ();
-                                                Application.Top!.Add (menuBar);
+                                                Application.Current!.Add (menuBar);
 
 
                                                 // Call EnableForDesign
                                                 // Call EnableForDesign
-                                                Toplevel top = Application.Top!;
+                                                Toplevel top = Application.Current!;
                                                 bool result = menuBar.EnableForDesign (ref top);
                                                 bool result = menuBar.EnableForDesign (ref top);
 
 
                                                 // Should return true
                                                 // Should return true
@@ -296,9 +296,9 @@ public class MenuBarv2Tests
                                      .Then (() =>
                                      .Then (() =>
                                             {
                                             {
                                                 menuBar = new MenuBarv2 ();
                                                 menuBar = new MenuBarv2 ();
-                                                Toplevel top = Application.Top!;
+                                                Toplevel top = Application.Current!;
                                                 menuBar.EnableForDesign (ref top);
                                                 menuBar.EnableForDesign (ref top);
-                                                Application.Top!.Add (menuBar);
+                                                Application.Current!.Add (menuBar);
                                             })
                                             })
                                      .WaitIteration ()
                                      .WaitIteration ()
                                      .ScreenShot ("MenuBar initial state", _out)
                                      .ScreenShot ("MenuBar initial state", _out)
@@ -334,7 +334,7 @@ public class MenuBarv2Tests
                                      .Then (() =>
                                      .Then (() =>
                                             {
                                             {
                                                 menuBar = new MenuBarv2 ();
                                                 menuBar = new MenuBarv2 ();
-                                                Toplevel top = Application.Top!;
+                                                Toplevel top = Application.Current!;
 
 
                                                 top.Add (
                                                 top.Add (
                                                          new View ()
                                                          new View ()
@@ -344,7 +344,7 @@ public class MenuBarv2Tests
 
 
                                                          });
                                                          });
                                                 menuBar.EnableForDesign (ref top);
                                                 menuBar.EnableForDesign (ref top);
-                                                Application.Top!.Add (menuBar);
+                                                Application.Current!.Add (menuBar);
                                             })
                                             })
                                      .AssertIsNotType<MenuItemv2> (Application.Navigation!.GetFocused ())
                                      .AssertIsNotType<MenuItemv2> (Application.Navigation!.GetFocused ())
                                      .ScreenShot ("MenuBar initial state", _out)
                                      .ScreenShot ("MenuBar initial state", _out)
@@ -376,9 +376,9 @@ public class MenuBarv2Tests
                                      .Then (() =>
                                      .Then (() =>
                                             {
                                             {
                                                 menuBar = new MenuBarv2 ();
                                                 menuBar = new MenuBarv2 ();
-                                                Toplevel? toplevel = Application.Top;
+                                                Toplevel? toplevel = Application.Current;
                                                 menuBar.EnableForDesign (ref toplevel!);
                                                 menuBar.EnableForDesign (ref toplevel!);
-                                                Application.Top!.Add (menuBar);
+                                                Application.Current!.Add (menuBar);
                                             })
                                             })
                                      .WaitIteration ()
                                      .WaitIteration ()
                                      .AssertIsNotType<MenuItemv2> (Application.Navigation!.GetFocused ())
                                      .AssertIsNotType<MenuItemv2> (Application.Navigation!.GetFocused ())
@@ -405,7 +405,7 @@ public class MenuBarv2Tests
                                      .Then (() =>
                                      .Then (() =>
                                             {
                                             {
                                                 menuBar = new MenuBarv2 ();
                                                 menuBar = new MenuBarv2 ();
-                                                Toplevel top = Application.Top!;
+                                                Toplevel top = Application.Current!;
 
 
                                                 top.Add (
                                                 top.Add (
                                                          new View ()
                                                          new View ()
@@ -415,18 +415,18 @@ public class MenuBarv2Tests
 
 
                                                          });
                                                          });
                                                 menuBar.EnableForDesign (ref top);
                                                 menuBar.EnableForDesign (ref top);
-                                                Application.Top!.Add (menuBar);
+                                                Application.Current!.Add (menuBar);
                                             })
                                             })
                                      .WaitIteration ()
                                      .WaitIteration ()
                                      .AssertIsNotType<MenuItemv2> (Application.Navigation!.GetFocused ())
                                      .AssertIsNotType<MenuItemv2> (Application.Navigation!.GetFocused ())
                                      .ScreenShot ("MenuBar initial state", _out)
                                      .ScreenShot ("MenuBar initial state", _out)
                                      .EnqueueKeyEvent (MenuBarv2.DefaultKey)
                                      .EnqueueKeyEvent (MenuBarv2.DefaultKey)
                                      .AssertEqual ("_New file", Application.Navigation!.GetFocused ()!.Title)
                                      .AssertEqual ("_New file", Application.Navigation!.GetFocused ()!.Title)
-                                     .AssertTrue (Application.Top!.Running)
+                                     .AssertTrue (Application.Current!.Running)
                                      .ScreenShot ($"After {MenuBarv2.DefaultKey}", _out)
                                      .ScreenShot ($"After {MenuBarv2.DefaultKey}", _out)
                                      .EnqueueKeyEvent (Application.QuitKey)
                                      .EnqueueKeyEvent (Application.QuitKey)
                                      .AssertFalse (Application.Popover?.GetActivePopover () is PopoverMenu)
                                      .AssertFalse (Application.Popover?.GetActivePopover () is PopoverMenu)
-                                     .AssertTrue (Application.Top!.Running);
+                                     .AssertTrue (Application.Current!.Running);
     }
     }
 
 
     [Theory]
     [Theory]
@@ -439,7 +439,7 @@ public class MenuBarv2Tests
                                      .Then (() =>
                                      .Then (() =>
                                             {
                                             {
                                                 menuBar = new MenuBarv2 ();
                                                 menuBar = new MenuBarv2 ();
-                                                Toplevel top = Application.Top!;
+                                                Toplevel top = Application.Current!;
 
 
                                                 top.Add (
                                                 top.Add (
                                                          new View ()
                                                          new View ()
@@ -456,7 +456,7 @@ public class MenuBarv2Tests
                                                     item.Key = Key.Empty;
                                                     item.Key = Key.Empty;
                                                 }
                                                 }
 
 
-                                                Application.Top!.Add (menuBar);
+                                                Application.Current!.Add (menuBar);
                                             })
                                             })
                                      .WaitIteration ()
                                      .WaitIteration ()
                                      .AssertIsNotType<MenuItemv2> (Application.Navigation!.GetFocused ())
                                      .AssertIsNotType<MenuItemv2> (Application.Navigation!.GetFocused ())
@@ -466,7 +466,7 @@ public class MenuBarv2Tests
                                      .ScreenShot ($"After {MenuBarv2.DefaultKey}", _out)
                                      .ScreenShot ($"After {MenuBarv2.DefaultKey}", _out)
                                      .EnqueueKeyEvent (Application.QuitKey)
                                      .EnqueueKeyEvent (Application.QuitKey)
                                      .AssertFalse (Application.Popover?.GetActivePopover () is PopoverMenu)
                                      .AssertFalse (Application.Popover?.GetActivePopover () is PopoverMenu)
-                                     .AssertTrue (Application.Top!.Running);
+                                     .AssertTrue (Application.Current!.Running);
     }
     }
 
 
     [Theory]
     [Theory]
@@ -492,9 +492,9 @@ public class MenuBarv2Tests
                                      .Then (() =>
                                      .Then (() =>
                                             {
                                             {
                                                 var menuBar = new MenuBarv2 ();
                                                 var menuBar = new MenuBarv2 ();
-                                                Toplevel top = Application.Top!;
+                                                Toplevel top = Application.Current!;
                                                 menuBar.EnableForDesign (ref top);
                                                 menuBar.EnableForDesign (ref top);
-                                                Application.Top!.Add (menuBar);
+                                                Application.Current!.Add (menuBar);
                                             })
                                             })
                                      .Add (testView)
                                      .Add (testView)
                                      .WaitIteration ()
                                      .WaitIteration ()
@@ -526,9 +526,9 @@ public class MenuBarv2Tests
                                      .Then (() =>
                                      .Then (() =>
                                             {
                                             {
                                                 var menuBar = new MenuBarv2 ();
                                                 var menuBar = new MenuBarv2 ();
-                                                Toplevel top = Application.Top!;
+                                                Toplevel top = Application.Current!;
                                                 menuBar.EnableForDesign (ref top);
                                                 menuBar.EnableForDesign (ref top);
-                                                Application.Top!.Add (menuBar);
+                                                Application.Current!.Add (menuBar);
                                             })
                                             })
                                      .Add (testView)
                                      .Add (testView)
                                      .WaitIteration ()
                                      .WaitIteration ()

+ 2 - 2
Tests/IntegrationTests/FluentTests/NavigationTests.cs

@@ -29,8 +29,8 @@ public class NavigationTests (ITestOutputHelper outputHelper)
                                                 w2.Add (v3, v4);
                                                 w2.Add (v3, v4);
                                                 var w3 = new Window { Id = "w3" };
                                                 var w3 = new Window { Id = "w3" };
                                                 w3.Add (v5, v6);
                                                 w3.Add (v5, v6);
-                                                Toplevel top = Application.Top!;
-                                                Application.Top!.Add (w1, w2, w3);
+                                                Toplevel top = Application.Current!;
+                                                Application.Current!.Add (w1, w2, w3);
                                             })
                                             })
                                      .AssertTrue (v5.HasFocus)
                                      .AssertTrue (v5.HasFocus)
                                      .EnqueueKeyEvent (Key.F6)
                                      .EnqueueKeyEvent (Key.F6)

+ 16 - 16
Tests/IntegrationTests/FluentTests/PopverMenuTests.cs

@@ -26,10 +26,10 @@ public class PopoverMenuTests
                                      .Then (() =>
                                      .Then (() =>
                                             {
                                             {
                                                 PopoverMenu popoverMenu = new ();
                                                 PopoverMenu popoverMenu = new ();
-                                                Application.Top!.Add (popoverMenu);
+                                                Application.Current!.Add (popoverMenu);
 
 
                                                 // Call EnableForDesign
                                                 // Call EnableForDesign
-                                                Toplevel top = Application.Top;
+                                                Toplevel top = Application.Current;
                                                 bool result = popoverMenu.EnableForDesign (ref top);
                                                 bool result = popoverMenu.EnableForDesign (ref top);
 
 
                                                 // Should return true
                                                 // Should return true
@@ -60,7 +60,7 @@ public class PopoverMenuTests
                                                     PopoverMenu popoverMenu = new ();
                                                     PopoverMenu popoverMenu = new ();
 
 
                                                     // Call EnableForDesign
                                                     // Call EnableForDesign
-                                                    Toplevel top = Application.Top!;
+                                                    Toplevel top = Application.Current!;
                                                     popoverMenu.EnableForDesign (ref top);
                                                     popoverMenu.EnableForDesign (ref top);
 
 
                                                     var view = new View
                                                     var view = new View
@@ -71,7 +71,7 @@ public class PopoverMenuTests
                                                         Id = "focusableView",
                                                         Id = "focusableView",
                                                         Text = "View"
                                                         Text = "View"
                                                     };
                                                     };
-                                                    Application.Top!.Add (view);
+                                                    Application.Current!.Add (view);
 
 
                                                     // EnableForDesign sets to true; undo that
                                                     // EnableForDesign sets to true; undo that
                                                     popoverMenu.Visible = false;
                                                     popoverMenu.Visible = false;
@@ -100,7 +100,7 @@ public class PopoverMenuTests
                                                 PopoverMenu popoverMenu = new ();
                                                 PopoverMenu popoverMenu = new ();
 
 
                                                 // Call EnableForDesign
                                                 // Call EnableForDesign
-                                                Toplevel top = Application.Top!;
+                                                Toplevel top = Application.Current!;
                                                 bool result = popoverMenu.EnableForDesign (ref top);
                                                 bool result = popoverMenu.EnableForDesign (ref top);
 
 
                                                 var view = new View
                                                 var view = new View
@@ -111,7 +111,7 @@ public class PopoverMenuTests
                                                     Id = "focusableView",
                                                     Id = "focusableView",
                                                     Text = "View"
                                                     Text = "View"
                                                 };
                                                 };
-                                                Application.Top!.Add (view);
+                                                Application.Current!.Add (view);
 
 
                                                 // EnableForDesign sets to true; undo that
                                                 // EnableForDesign sets to true; undo that
                                                 popoverMenu.Visible = false;
                                                 popoverMenu.Visible = false;
@@ -129,7 +129,7 @@ public class PopoverMenuTests
                                      .ScreenShot ($"After {Application.QuitKey}", _out)
                                      .ScreenShot ($"After {Application.QuitKey}", _out)
                                      .AssertFalse (Application.Popover!.Popovers.Cast<PopoverMenu> ().FirstOrDefault ()!.Visible)
                                      .AssertFalse (Application.Popover!.Popovers.Cast<PopoverMenu> ().FirstOrDefault ()!.Visible)
                                      .AssertNull (Application.Popover!.GetActivePopover ())
                                      .AssertNull (Application.Popover!.GetActivePopover ())
-                                     .AssertTrue (Application.Top!.Running);
+                                     .AssertTrue (Application.Current!.Running);
     }
     }
 
 
     [Theory]
     [Theory]
@@ -142,7 +142,7 @@ public class PopoverMenuTests
                                                 PopoverMenu popoverMenu = new ();
                                                 PopoverMenu popoverMenu = new ();
 
 
                                                 // Call EnableForDesign
                                                 // Call EnableForDesign
-                                                Toplevel top = Application.Top!;
+                                                Toplevel top = Application.Current!;
                                                 bool result = popoverMenu.EnableForDesign (ref top);
                                                 bool result = popoverMenu.EnableForDesign (ref top);
 
 
                                                 var view = new View
                                                 var view = new View
@@ -153,7 +153,7 @@ public class PopoverMenuTests
                                                     Id = "focusableView",
                                                     Id = "focusableView",
                                                     Text = "View"
                                                     Text = "View"
                                                 };
                                                 };
-                                                Application.Top!.Add (view);
+                                                Application.Current!.Add (view);
 
 
                                                 // EnableForDesign sets to true; undo that
                                                 // EnableForDesign sets to true; undo that
                                                 popoverMenu.Visible = false;
                                                 popoverMenu.Visible = false;
@@ -185,7 +185,7 @@ public class PopoverMenuTests
                                                 PopoverMenu popoverMenu = new ();
                                                 PopoverMenu popoverMenu = new ();
 
 
                                                 // Call EnableForDesign
                                                 // Call EnableForDesign
-                                                Toplevel top = Application.Top!;
+                                                Toplevel top = Application.Current!;
                                                 bool result = popoverMenu.EnableForDesign (ref top);
                                                 bool result = popoverMenu.EnableForDesign (ref top);
 
 
                                                 var view = new View
                                                 var view = new View
@@ -196,7 +196,7 @@ public class PopoverMenuTests
                                                     Id = "focusableView",
                                                     Id = "focusableView",
                                                     Text = "View"
                                                     Text = "View"
                                                 };
                                                 };
-                                                Application.Top!.Add (view);
+                                                Application.Current!.Add (view);
 
 
                                                 // EnableForDesign sets to true; undo that
                                                 // EnableForDesign sets to true; undo that
                                                 popoverMenu.Visible = false;
                                                 popoverMenu.Visible = false;
@@ -210,11 +210,11 @@ public class PopoverMenuTests
                                      .Then (() => Application.Popover!.Show (Application.Popover.Popovers.First ()))
                                      .Then (() => Application.Popover!.Show (Application.Popover.Popovers.First ()))
                                      .ScreenShot ("PopoverMenu after Show", _out)
                                      .ScreenShot ("PopoverMenu after Show", _out)
                                      .AssertEqual ("Cu_t", Application.Navigation!.GetFocused ()!.Title)
                                      .AssertEqual ("Cu_t", Application.Navigation!.GetFocused ()!.Title)
-                                     .AssertTrue (Application.Top!.Running)
+                                     .AssertTrue (Application.Current!.Running)
                                      .EnqueueKeyEvent (Application.QuitKey)
                                      .EnqueueKeyEvent (Application.QuitKey)
                                      .ScreenShot ($"After {Application.QuitKey}", _out)
                                      .ScreenShot ($"After {Application.QuitKey}", _out)
                                      .AssertFalse (Application.Popover?.GetActivePopover () is PopoverMenu)
                                      .AssertFalse (Application.Popover?.GetActivePopover () is PopoverMenu)
-                                     .AssertTrue (Application.Top!.Running);
+                                     .AssertTrue (Application.Current!.Running);
     }
     }
 
 
     [Theory]
     [Theory]
@@ -241,7 +241,7 @@ public class PopoverMenuTests
                                      .Then (() =>
                                      .Then (() =>
                                             {
                                             {
                                                 PopoverMenu popoverMenu = new ();
                                                 PopoverMenu popoverMenu = new ();
-                                                Toplevel top = Application.Top!;
+                                                Toplevel top = Application.Current!;
                                                 popoverMenu.EnableForDesign (ref top);
                                                 popoverMenu.EnableForDesign (ref top);
                                                 Application.Popover!.Register (popoverMenu);
                                                 Application.Popover!.Register (popoverMenu);
                                             })
                                             })
@@ -275,7 +275,7 @@ public class PopoverMenuTests
                                      .Then (() =>
                                      .Then (() =>
                                             {
                                             {
                                                 PopoverMenu popoverMenu = new ();
                                                 PopoverMenu popoverMenu = new ();
-                                                Toplevel top = Application.Top!;
+                                                Toplevel top = Application.Current!;
                                                 popoverMenu.EnableForDesign (ref top);
                                                 popoverMenu.EnableForDesign (ref top);
                                                 Application.Popover!.Register (popoverMenu);
                                                 Application.Popover!.Register (popoverMenu);
                                             })
                                             })
@@ -309,7 +309,7 @@ public class PopoverMenuTests
                                      .Then (() =>
                                      .Then (() =>
                                             {
                                             {
                                                 PopoverMenu popoverMenu = new ();
                                                 PopoverMenu popoverMenu = new ();
-                                                Toplevel top = Application.Top!;
+                                                Toplevel top = Application.Current!;
                                                 popoverMenu.EnableForDesign (ref top);
                                                 popoverMenu.EnableForDesign (ref top);
                                                 Application.Popover!.Register (popoverMenu);
                                                 Application.Popover!.Register (popoverMenu);
                                             })
                                             })

+ 2 - 2
Tests/StressTests/ApplicationStressTests.cs

@@ -71,8 +71,8 @@ public class ApplicationStressTests
                 {
                 {
                     int tbNow = _tbCounter;
                     int tbNow = _tbCounter;
 
 
-                    // Wait for Application.Top to be running to ensure timed events can be processed
-                    while (Application.Top is null || Application.Top is { Running: false })
+                    // Wait for Application.Current to be running to ensure timed events can be processed
+                    while (Application.Current is null || Application.Current is { Running: false })
                     {
                     {
                         Thread.Sleep (1);
                         Thread.Sleep (1);
                     }
                     }

+ 2 - 2
Tests/StressTests/ScenariosStressTests.cs

@@ -126,7 +126,7 @@ public class ScenariosStressTests
 
 
         void OnApplicationSessionBegun (object? sender, SessionTokenEventArgs e)
         void OnApplicationSessionBegun (object? sender, SessionTokenEventArgs e)
         {
         {
-            // Get a list of all subviews under Application.Top (and their subviews, etc.)
+            // Get a list of all subviews under Application.Current (and their subviews, etc.)
             // and subscribe to their DrawComplete event
             // and subscribe to their DrawComplete event
             void SubscribeAllSubViews (View view)
             void SubscribeAllSubViews (View view)
             {
             {
@@ -140,7 +140,7 @@ public class ScenariosStressTests
                 }
                 }
             }
             }
 
 
-            SubscribeAllSubViews (Application.Top!);
+            SubscribeAllSubViews (Application.Current!);
         }
         }
 
 
         // If the scenario doesn't close within the abort time, this will force it to quit
         // If the scenario doesn't close within the abort time, this will force it to quit

+ 1 - 1
Tests/TerminalGuiFluentTesting/FakeDriver/FakeApplicationLifecycle.cs

@@ -14,7 +14,7 @@ internal class FakeApplicationLifecycle (IApplication origApp, CancellationToken
     {
     {
         hardStop.Cancel ();
         hardStop.Cancel ();
 
 
-        Application.Top?.Dispose ();
+        Application.Current?.Dispose ();
         Application.Shutdown ();
         Application.Shutdown ();
         ApplicationImpl.ChangeInstance (origApp);
         ApplicationImpl.ChangeInstance (origApp);
     }
     }

+ 2 - 2
Tests/TerminalGuiFluentTesting/GuiTestContext.Navigation.cs

@@ -40,13 +40,13 @@ public partial class GuiTestContext
     public GuiTestContext Focus<T> (Func<T, bool>? evaluator = null) where T : View
     public GuiTestContext Focus<T> (Func<T, bool>? evaluator = null) where T : View
     {
     {
         evaluator ??= _ => true;
         evaluator ??= _ => true;
-        Toplevel? t = Application.Top;
+        Toplevel? t = Application.Current;
 
 
         HashSet<View> seen = new ();
         HashSet<View> seen = new ();
 
 
         if (t == null)
         if (t == null)
         {
         {
-            Fail ("Application.Top was null when trying to set focus");
+            Fail ("Application.Current was null when trying to set focus");
 
 
             return this;
             return this;
         }
         }

+ 4 - 4
Tests/TerminalGuiFluentTesting/GuiTestContext.ViewBase.cs

@@ -14,7 +14,7 @@ public partial class GuiTestContext
     {
     {
         WaitIteration (() =>
         WaitIteration (() =>
                        {
                        {
-                           Toplevel top = Application.Top ?? throw new ("Top was null so could not add view");
+                           Toplevel top = Application.Current ?? throw new ("Top was null so could not add view");
                            top.Add (v);
                            top.Add (v);
                            top.Layout ();
                            top.Layout ();
                            _lastView = v;
                            _lastView = v;
@@ -28,15 +28,15 @@ public partial class GuiTestContext
     /// <summary>
     /// <summary>
     ///     The last view added (e.g. with <see cref="Add"/>) or the root/current top.
     ///     The last view added (e.g. with <see cref="Add"/>) or the root/current top.
     /// </summary>
     /// </summary>
-    public View LastView => _lastView ?? Application.Top ?? throw new ("Could not determine which view to add to");
+    public View LastView => _lastView ?? Application.Current ?? throw new ("Could not determine which view to add to");
 
 
     private T Find<T> (Func<T, bool> evaluator) where T : View
     private T Find<T> (Func<T, bool> evaluator) where T : View
     {
     {
-        Toplevel? t = Application.Top;
+        Toplevel? t = Application.Current;
 
 
         if (t == null)
         if (t == null)
         {
         {
-            Fail ("Application.Top was null when attempting to find view");
+            Fail ("Application.Current was null when attempting to find view");
         }
         }
 
 
         T? f = FindRecursive (t!, evaluator);
         T? f = FindRecursive (t!, evaluator);

+ 16 - 16
Tests/UnitTests/Application/Application.NavigationTests.cs

@@ -86,7 +86,7 @@ public class ApplicationNavigationTests (ITestOutputHelper output)
     {
     {
         Application.Navigation = new ();
         Application.Navigation = new ();
 
 
-        Application.Top = new ()
+        Application.Current = new ()
         {
         {
             Id = "top",
             Id = "top",
             CanFocus = true
             CanFocus = true
@@ -103,18 +103,18 @@ public class ApplicationNavigationTests (ITestOutputHelper output)
             Id = "subView2",
             Id = "subView2",
             CanFocus = true
             CanFocus = true
         };
         };
-        Application.Top.Add (subView1, subView2);
-        Assert.False (Application.Top.HasFocus);
+        Application.Current.Add (subView1, subView2);
+        Assert.False (Application.Current.HasFocus);
 
 
-        Application.Top.SetFocus ();
+        Application.Current.SetFocus ();
         Assert.True (subView1.HasFocus);
         Assert.True (subView1.HasFocus);
         Assert.Equal (subView1, Application.Navigation.GetFocused ());
         Assert.Equal (subView1, Application.Navigation.GetFocused ());
 
 
         Application.Navigation.AdvanceFocus (NavigationDirection.Forward, null);
         Application.Navigation.AdvanceFocus (NavigationDirection.Forward, null);
         Assert.Equal (subView2, Application.Navigation.GetFocused ());
         Assert.Equal (subView2, Application.Navigation.GetFocused ());
 
 
-        Application.Top.Dispose ();
-        Application.Top = null;
+        Application.Current.Dispose ();
+        Application.Current = null;
         Application.Navigation = null;
         Application.Navigation = null;
     }
     }
 
 
@@ -123,7 +123,7 @@ public class ApplicationNavigationTests (ITestOutputHelper output)
     {
     {
         Application.Navigation = new ();
         Application.Navigation = new ();
 
 
-        Application.Top = new ()
+        Application.Current = new ()
         {
         {
             Id = "top",
             Id = "top",
             CanFocus = true
             CanFocus = true
@@ -135,24 +135,24 @@ public class ApplicationNavigationTests (ITestOutputHelper output)
             CanFocus = true
             CanFocus = true
         };
         };
 
 
-        Application.Top.Add (subView1);
-        Assert.False (Application.Top.HasFocus);
+        Application.Current.Add (subView1);
+        Assert.False (Application.Current.HasFocus);
 
 
-        Application.Top.SetFocus ();
+        Application.Current.SetFocus ();
         Assert.True (subView1.HasFocus);
         Assert.True (subView1.HasFocus);
         Assert.Equal (subView1, Application.Navigation.GetFocused ());
         Assert.Equal (subView1, Application.Navigation.GetFocused ());
 
 
         subView1.HasFocus = false;
         subView1.HasFocus = false;
         Assert.False (subView1.HasFocus);
         Assert.False (subView1.HasFocus);
-        Assert.True (Application.Top.HasFocus);
-        Assert.Equal (Application.Top, Application.Navigation.GetFocused ());
+        Assert.True (Application.Current.HasFocus);
+        Assert.Equal (Application.Current, Application.Navigation.GetFocused ());
 
 
-        Application.Top.HasFocus = false;
-        Assert.False (Application.Top.HasFocus);
+        Application.Current.HasFocus = false;
+        Assert.False (Application.Current.HasFocus);
         Assert.Null (Application.Navigation.GetFocused ());
         Assert.Null (Application.Navigation.GetFocused ());
 
 
-        Application.Top.Dispose ();
-        Application.Top = null;
+        Application.Current.Dispose ();
+        Application.Current = null;
         Application.Navigation = null;
         Application.Navigation = null;
     }
     }
 }
 }

+ 29 - 29
Tests/UnitTests/Application/ApplicationImplTests.cs

@@ -194,7 +194,7 @@ public class ApplicationImplTests
                                              TimeSpan.FromMilliseconds (150),
                                              TimeSpan.FromMilliseconds (150),
                                              () =>
                                              () =>
                                              {
                                              {
-                                                 if (Application.Top != null)
+                                                 if (Application.Current != null)
                                                  {
                                                  {
                                                      Application.RequestStop ();
                                                      Application.RequestStop ();
 
 
@@ -204,7 +204,7 @@ public class ApplicationImplTests
                                                  return false;
                                                  return false;
                                              }
                                              }
                                             );
                                             );
-        Assert.Null (Application.Top);
+        Assert.Null (Application.Current);
 
 
         // Blocks until the timeout call is hit
         // Blocks until the timeout call is hit
 
 
@@ -213,10 +213,10 @@ public class ApplicationImplTests
         // We returned false above, so we should not have to remove the timeout
         // We returned false above, so we should not have to remove the timeout
         Assert.False (v2.RemoveTimeout (timeoutToken));
         Assert.False (v2.RemoveTimeout (timeoutToken));
 
 
-        Assert.NotNull (Application.Top);
-        Application.Top?.Dispose ();
+        Assert.NotNull (Application.Current);
+        Application.Current?.Dispose ();
         v2.Shutdown ();
         v2.Shutdown ();
-        Assert.Null (Application.Top);
+        Assert.Null (Application.Current);
 
 
         ApplicationImpl.ChangeInstance (orig);
         ApplicationImpl.ChangeInstance (orig);
     }
     }
@@ -242,7 +242,7 @@ public class ApplicationImplTests
                                              {
                                              {
                                                  Assert.True (top!.Running);
                                                  Assert.True (top!.Running);
 
 
-                                                 if (Application.Top != null)
+                                                 if (Application.Current != null)
                                                  {
                                                  {
                                                      Application.RequestStop ();
                                                      Application.RequestStop ();
 
 
@@ -264,8 +264,8 @@ public class ApplicationImplTests
         Assert.False (top!.Running);
         Assert.False (top!.Running);
 
 
         // BUGBUG: Shutdown sets Top to null, not End.
         // BUGBUG: Shutdown sets Top to null, not End.
-        //Assert.Null (Application.Top);
-        Application.Top?.Dispose ();
+        //Assert.Null (Application.Current);
+        Application.Current?.Dispose ();
         v2.Shutdown ();
         v2.Shutdown ();
 
 
         ApplicationImpl.ChangeInstance (orig);
         ApplicationImpl.ChangeInstance (orig);
@@ -280,7 +280,7 @@ public class ApplicationImplTests
         ApplicationImpl v2 = NewMockedApplicationImpl ();
         ApplicationImpl v2 = NewMockedApplicationImpl ();
         ApplicationImpl.ChangeInstance (v2);
         ApplicationImpl.ChangeInstance (v2);
 
 
-        Assert.Null (Application.Top);
+        Assert.Null (Application.Current);
         Assert.Null (Application.Driver);
         Assert.Null (Application.Driver);
 
 
         v2.Init (null, "fake");
         v2.Init (null, "fake");
@@ -315,7 +315,7 @@ public class ApplicationImplTests
         Assert.Equal (1, closedCount);
         Assert.Equal (1, closedCount);
         Assert.Equal (1, unloadedCount);
         Assert.Equal (1, unloadedCount);
 
 
-        Application.Top?.Dispose ();
+        Application.Current?.Dispose ();
         v2.Shutdown ();
         v2.Shutdown ();
         Assert.Equal (1, closedCount);
         Assert.Equal (1, closedCount);
         Assert.Equal (1, unloadedCount);
         Assert.Equal (1, unloadedCount);
@@ -332,7 +332,7 @@ public class ApplicationImplTests
         ApplicationImpl v2 = NewMockedApplicationImpl ();
         ApplicationImpl v2 = NewMockedApplicationImpl ();
         ApplicationImpl.ChangeInstance (v2);
         ApplicationImpl.ChangeInstance (v2);
 
 
-        Assert.Null (Application.Top);
+        Assert.Null (Application.Current);
         Assert.Null (Application.Driver);
         Assert.Null (Application.Driver);
 
 
         v2.Init (null, "fake");
         v2.Init (null, "fake");
@@ -356,7 +356,7 @@ public class ApplicationImplTests
                                              {
                                              {
                                                  Assert.True (top!.Running);
                                                  Assert.True (top!.Running);
 
 
-                                                 if (Application.Top != null)
+                                                 if (Application.Current != null)
                                                  {
                                                  {
                                                      Application.RequestStop ();
                                                      Application.RequestStop ();
 
 
@@ -379,7 +379,7 @@ public class ApplicationImplTests
         // We returned false above, so we should not have to remove the timeout
         // We returned false above, so we should not have to remove the timeout
         Assert.False (v2.RemoveTimeout (timeoutToken));
         Assert.False (v2.RemoveTimeout (timeoutToken));
 
 
-        Application.Top?.Dispose ();
+        Application.Current?.Dispose ();
         v2.Shutdown ();
         v2.Shutdown ();
         Assert.Equal (1, closedCount);
         Assert.Equal (1, closedCount);
         Assert.Equal (1, unloadedCount);
         Assert.Equal (1, unloadedCount);
@@ -408,7 +408,7 @@ public class ApplicationImplTests
                                              {
                                              {
                                                  Assert.True (top!.Running);
                                                  Assert.True (top!.Running);
 
 
-                                                 if (Application.Top != null)
+                                                 if (Application.Current != null)
                                                  {
                                                  {
                                                      Application.RaiseKeyDownEvent (Application.QuitKey);
                                                      Application.RaiseKeyDownEvent (Application.QuitKey);
                                                  }
                                                  }
@@ -427,10 +427,10 @@ public class ApplicationImplTests
 
 
         Assert.False (top!.Running);
         Assert.False (top!.Running);
 
 
-        Assert.NotNull (Application.Top);
+        Assert.NotNull (Application.Current);
         top.Dispose ();
         top.Dispose ();
         v2.Shutdown ();
         v2.Shutdown ();
-        Assert.Null (Application.Top);
+        Assert.Null (Application.Current);
 
 
         ApplicationImpl.ChangeInstance (orig);
         ApplicationImpl.ChangeInstance (orig);
     }
     }
@@ -446,16 +446,16 @@ public class ApplicationImplTests
         v2.Init (null, "fake");
         v2.Init (null, "fake");
 
 
         v2.AddTimeout (TimeSpan.Zero, IdleExit);
         v2.AddTimeout (TimeSpan.Zero, IdleExit);
-        Assert.Null (Application.Top);
+        Assert.Null (Application.Current);
 
 
         // Blocks until the timeout call is hit
         // Blocks until the timeout call is hit
 
 
         v2.Run<Window> ();
         v2.Run<Window> ();
 
 
-        Assert.NotNull (Application.Top);
-        Application.Top?.Dispose ();
+        Assert.NotNull (Application.Current);
+        Application.Current?.Dispose ();
         v2.Shutdown ();
         v2.Shutdown ();
-        Assert.Null (Application.Top);
+        Assert.Null (Application.Current);
 
 
         ApplicationImpl.ChangeInstance (orig);
         ApplicationImpl.ChangeInstance (orig);
     }
     }
@@ -500,7 +500,7 @@ public class ApplicationImplTests
 
 
         v2.Run (t);
         v2.Run (t);
 
 
-        Application.Top?.Dispose ();
+        Application.Current?.Dispose ();
         v2.Shutdown ();
         v2.Shutdown ();
 
 
         ApplicationImpl.ChangeInstance (orig);
         ApplicationImpl.ChangeInstance (orig);
@@ -511,7 +511,7 @@ public class ApplicationImplTests
 
 
     private bool IdleExit ()
     private bool IdleExit ()
     {
     {
-        if (Application.Top != null)
+        if (Application.Current != null)
         {
         {
             Application.RequestStop ();
             Application.RequestStop ();
 
 
@@ -583,7 +583,7 @@ public class ApplicationImplTests
                        () =>
                        () =>
                        {
                        {
                            // Run asynchronous logic inside Task.Run
                            // Run asynchronous logic inside Task.Run
-                           if (Application.Top != null)
+                           if (Application.Current != null)
                            {
                            {
                                b.NewKeyDownEvent (Key.Enter);
                                b.NewKeyDownEvent (Key.Enter);
                                b.NewKeyUpEvent (Key.Enter);
                                b.NewKeyUpEvent (Key.Enter);
@@ -592,7 +592,7 @@ public class ApplicationImplTests
                            return false;
                            return false;
                        });
                        });
 
 
-        Assert.Null (Application.Top);
+        Assert.Null (Application.Current);
 
 
         var w = new Window
         var w = new Window
         {
         {
@@ -603,10 +603,10 @@ public class ApplicationImplTests
         // Blocks until the timeout call is hit
         // Blocks until the timeout call is hit
         v2.Run (w);
         v2.Run (w);
 
 
-        Assert.NotNull (Application.Top);
-        Application.Top?.Dispose ();
+        Assert.NotNull (Application.Current);
+        Application.Current?.Dispose ();
         v2.Shutdown ();
         v2.Shutdown ();
-        Assert.Null (Application.Top);
+        Assert.Null (Application.Current);
 
 
         ApplicationImpl.ChangeInstance (orig);
         ApplicationImpl.ChangeInstance (orig);
 
 
@@ -645,8 +645,8 @@ public class ApplicationImplTests
         Assert.Equal (v2.Initialized, Application.Initialized);
         Assert.Equal (v2.Initialized, Application.Initialized);
         Assert.Equal (v2.Popover, Application.Popover);
         Assert.Equal (v2.Popover, Application.Popover);
         Assert.Equal (v2.Navigation, Application.Navigation);
         Assert.Equal (v2.Navigation, Application.Navigation);
-        Assert.Equal (v2.Top, Application.Top);
-        Assert.Same (v2.TopLevels, Application.TopLevels);
+        Assert.Equal (v2.Top, Application.Current);
+        Assert.Same (v2.TopLevels, Application.SessionStack);
 
 
         // Shutdown should clean up instance fields
         // Shutdown should clean up instance fields
         v2.Shutdown ();
         v2.Shutdown ();

+ 7 - 7
Tests/UnitTests/Application/ApplicationPopoverTests.cs

@@ -200,14 +200,14 @@ public class ApplicationPopoverTests
             // Arrange
             // Arrange
             Assert.Null (Application.Popover);
             Assert.Null (Application.Popover);
             Application.Init (null, "fake");
             Application.Init (null, "fake");
-            Application.Top = new Toplevel ();
+            Application.Current = new Toplevel ();
             PopoverTestClass? popover = new ();
             PopoverTestClass? popover = new ();
 
 
             // Act
             // Act
             Application.Popover?.Register (popover);
             Application.Popover?.Register (popover);
 
 
             // Assert
             // Assert
-            Assert.Equal (Application.Top, popover.Toplevel);
+            Assert.Equal (Application.Current, popover.Toplevel);
         }
         }
         finally
         finally
         {
         {
@@ -223,7 +223,7 @@ public class ApplicationPopoverTests
             // Arrange
             // Arrange
             Assert.Null (Application.Popover);
             Assert.Null (Application.Popover);
             Application.Init (null, "fake");
             Application.Init (null, "fake");
-            Application.Top = new Toplevel () { Id = "initialTop" };
+            Application.Current = new Toplevel () { Id = "initialTop" };
             PopoverTestClass? popover = new ();
             PopoverTestClass? popover = new ();
             int keyDownEvents = 0;
             int keyDownEvents = 0;
             popover.KeyDown += (s, e) =>
             popover.KeyDown += (s, e) =>
@@ -237,7 +237,7 @@ public class ApplicationPopoverTests
             // Act
             // Act
             Application.RaiseKeyDownEvent (Key.A); // Goes to initialTop
             Application.RaiseKeyDownEvent (Key.A); // Goes to initialTop
 
 
-            Application.Top = new Toplevel () { Id = "secondaryTop" };
+            Application.Current = new Toplevel () { Id = "secondaryTop" };
             Application.RaiseKeyDownEvent (Key.A); // Goes to secondaryTop
             Application.RaiseKeyDownEvent (Key.A); // Goes to secondaryTop
 
 
             // Test
             // Test
@@ -270,7 +270,7 @@ public class ApplicationPopoverTests
             // Arrange
             // Arrange
             Assert.Null (Application.Popover);
             Assert.Null (Application.Popover);
             Application.Init (null, "fake");
             Application.Init (null, "fake");
-            Application.Top = new ()
+            Application.Current = new ()
             {
             {
                 Frame = new (0, 0, 10, 10),
                 Frame = new (0, 0, 10, 10),
                 Id = "top"
                 Id = "top"
@@ -285,7 +285,7 @@ public class ApplicationPopoverTests
                 Height = 2,
                 Height = 2,
             };
             };
 
 
-            Application.Top.Add (view);
+            Application.Current.Add (view);
 
 
             popover = new ()
             popover = new ()
             {
             {
@@ -318,7 +318,7 @@ public class ApplicationPopoverTests
         finally
         finally
         {
         {
             popover?.Dispose ();
             popover?.Dispose ();
-            Application.Top?.Dispose ();
+            Application.Current?.Dispose ();
             Application.ResetState (true);
             Application.ResetState (true);
         }
         }
     }
     }

+ 5 - 5
Tests/UnitTests/Application/ApplicationScreenTests.cs

@@ -46,35 +46,35 @@ public class ApplicationScreenTests
         Assert.Equal (0, clearedContentsRaised);
         Assert.Equal (0, clearedContentsRaised);
 
 
         // Act
         // Act
-        Application.Top!.SetNeedsLayout ();
+        Application.Current!.SetNeedsLayout ();
         Application.LayoutAndDraw ();
         Application.LayoutAndDraw ();
 
 
         // Assert
         // Assert
         Assert.Equal (0, clearedContentsRaised);
         Assert.Equal (0, clearedContentsRaised);
 
 
         // Act
         // Act
-        Application.Top.X = 1;
+        Application.Current.X = 1;
         Application.LayoutAndDraw ();
         Application.LayoutAndDraw ();
 
 
         // Assert
         // Assert
         Assert.Equal (1, clearedContentsRaised);
         Assert.Equal (1, clearedContentsRaised);
 
 
         // Act
         // Act
-        Application.Top.Width = 10;
+        Application.Current.Width = 10;
         Application.LayoutAndDraw ();
         Application.LayoutAndDraw ();
 
 
         // Assert
         // Assert
         Assert.Equal (2, clearedContentsRaised);
         Assert.Equal (2, clearedContentsRaised);
 
 
         // Act
         // Act
-        Application.Top.Y = 1;
+        Application.Current.Y = 1;
         Application.LayoutAndDraw ();
         Application.LayoutAndDraw ();
 
 
         // Assert
         // Assert
         Assert.Equal (3, clearedContentsRaised);
         Assert.Equal (3, clearedContentsRaised);
 
 
         // Act
         // Act
-        Application.Top.Height = 10;
+        Application.Current.Height = 10;
         Application.LayoutAndDraw ();
         Application.LayoutAndDraw ();
 
 
         // Assert
         // Assert

+ 56 - 56
Tests/UnitTests/Application/ApplicationTests.cs

@@ -149,13 +149,13 @@ public class ApplicationTests
     [SetupFakeApplication]
     [SetupFakeApplication]
     public void Begin_Sets_Application_Top_To_Console_Size ()
     public void Begin_Sets_Application_Top_To_Console_Size ()
     {
     {
-        Assert.Null (Application.Top);
+        Assert.Null (Application.Current);
         Application.Driver!.SetScreenSize (80, 25);
         Application.Driver!.SetScreenSize (80, 25);
         Toplevel top = new ();
         Toplevel top = new ();
         Application.Begin (top);
         Application.Begin (top);
-        Assert.Equal (new (0, 0, 80, 25), Application.Top!.Frame);
+        Assert.Equal (new (0, 0, 80, 25), Application.Current!.Frame);
         Application.Driver!.SetScreenSize (5, 5);
         Application.Driver!.SetScreenSize (5, 5);
-        Assert.Equal (new (0, 0, 5, 5), Application.Top!.Frame);
+        Assert.Equal (new (0, 0, 5, 5), Application.Current!.Frame);
         top.Dispose ();
         top.Dispose ();
     }
     }
 
 
@@ -163,21 +163,21 @@ public class ApplicationTests
     [SetupFakeApplication]
     [SetupFakeApplication]
     public void End_And_Shutdown_Should_Not_Dispose_ApplicationTop ()
     public void End_And_Shutdown_Should_Not_Dispose_ApplicationTop ()
     {
     {
-        Assert.Null (Application.Top);
+        Assert.Null (Application.Current);
 
 
         SessionToken rs = Application.Begin (new ());
         SessionToken rs = Application.Begin (new ());
-        Application.Top!.Title = "End_And_Shutdown_Should_Not_Dispose_ApplicationTop";
-        Assert.Equal (rs.Toplevel, Application.Top);
+        Application.Current!.Title = "End_And_Shutdown_Should_Not_Dispose_ApplicationTop";
+        Assert.Equal (rs.Toplevel, Application.Current);
         Application.End (rs);
         Application.End (rs);
 
 
 #if DEBUG_IDISPOSABLE
 #if DEBUG_IDISPOSABLE
         Assert.True (rs.WasDisposed);
         Assert.True (rs.WasDisposed);
-        Assert.False (Application.Top!.WasDisposed); // Is true because the rs.Toplevel is the same as Application.Top
+        Assert.False (Application.Current!.WasDisposed); // Is true because the rs.Toplevel is the same as Application.Current
 #endif
 #endif
 
 
         Assert.Null (rs.Toplevel);
         Assert.Null (rs.Toplevel);
 
 
-        Toplevel top = Application.Top;
+        Toplevel top = Application.Current;
 
 
 #if DEBUG_IDISPOSABLE
 #if DEBUG_IDISPOSABLE
         Exception exception = Record.Exception (Application.Shutdown);
         Exception exception = Record.Exception (Application.Shutdown);
@@ -211,12 +211,12 @@ public class ApplicationTests
         Assert.NotNull (sessionToken);
         Assert.NotNull (sessionToken);
         Assert.Equal (rs, sessionToken);
         Assert.Equal (rs, sessionToken);
 
 
-        Assert.Equal (topLevel, Application.Top);
+        Assert.Equal (topLevel, Application.Current);
 
 
         Application.SessionBegun -= newSessionTokenFn;
         Application.SessionBegun -= newSessionTokenFn;
         Application.End (sessionToken);
         Application.End (sessionToken);
 
 
-        Assert.NotNull (Application.Top);
+        Assert.NotNull (Application.Current);
         Assert.NotNull (Application.Driver);
         Assert.NotNull (Application.Driver);
 
 
         topLevel.Dispose ();
         topLevel.Dispose ();
@@ -327,7 +327,7 @@ public class ApplicationTests
             // Check that all fields and properties are set to their default values
             // Check that all fields and properties are set to their default values
 
 
             // Public Properties
             // Public Properties
-            Assert.Null (Application.Top);
+            Assert.Null (Application.Current);
             Assert.Null (Application.Mouse.MouseGrabView);
             Assert.Null (Application.Mouse.MouseGrabView);
 
 
             // Don't check Application.ForceDriver
             // Don't check Application.ForceDriver
@@ -350,7 +350,7 @@ public class ApplicationTests
             Assert.Equal (Application.GetSupportedCultures (), Application.SupportedCultures);
             Assert.Equal (Application.GetSupportedCultures (), Application.SupportedCultures);
             Assert.Equal (Application.GetAvailableCulturesFromEmbeddedResources (), Application.SupportedCultures);
             Assert.Equal (Application.GetAvailableCulturesFromEmbeddedResources (), Application.SupportedCultures);
             Assert.Null (Application.MainThreadId);
             Assert.Null (Application.MainThreadId);
-            Assert.Empty (Application.TopLevels);
+            Assert.Empty (Application.SessionStack);
             Assert.Empty (Application.CachedViewsUnderMouse);
             Assert.Empty (Application.CachedViewsUnderMouse);
 
 
             // Mouse
             // Mouse
@@ -472,18 +472,18 @@ public class ApplicationTests
         Assert.NotNull (sessionToken);
         Assert.NotNull (sessionToken);
         Assert.Equal (rs, sessionToken);
         Assert.Equal (rs, sessionToken);
 
 
-        Assert.Equal (topLevel, Application.Top);
+        Assert.Equal (topLevel, Application.Current);
 
 
         Application.SessionBegun -= newSessionTokenFn;
         Application.SessionBegun -= newSessionTokenFn;
         Application.End (sessionToken);
         Application.End (sessionToken);
 
 
-        Assert.NotNull (Application.Top);
+        Assert.NotNull (Application.Current);
         Assert.NotNull (Application.Driver);
         Assert.NotNull (Application.Driver);
 
 
         topLevel.Dispose ();
         topLevel.Dispose ();
         Application.Shutdown ();
         Application.Shutdown ();
 
 
-        Assert.Null (Application.Top);
+        Assert.Null (Application.Current);
         Assert.Null (Application.Driver);
         Assert.Null (Application.Driver);
     }
     }
 
 
@@ -492,11 +492,11 @@ public class ApplicationTests
     public void Internal_Properties_Correct ()
     public void Internal_Properties_Correct ()
     {
     {
         Assert.True (Application.Initialized);
         Assert.True (Application.Initialized);
-        Assert.Null (Application.Top);
+        Assert.Null (Application.Current);
         SessionToken rs = Application.Begin (new ());
         SessionToken rs = Application.Begin (new ());
-        Assert.Equal (Application.Top, rs.Toplevel);
+        Assert.Equal (Application.Current, rs.Toplevel);
         Assert.Null (Application.Mouse.MouseGrabView); // public
         Assert.Null (Application.Mouse.MouseGrabView); // public
-        Application.Top!.Dispose ();
+        Application.Current!.Dispose ();
     }
     }
 
 
     // Invoke Tests
     // Invoke Tests
@@ -592,9 +592,9 @@ public class ApplicationTests
         // Run<Toplevel> when already initialized or not with a Driver will not throw (because Window is derived from Toplevel)
         // Run<Toplevel> when already initialized or not with a Driver will not throw (because Window is derived from Toplevel)
         // Using another type not derived from Toplevel will throws at compile time
         // Using another type not derived from Toplevel will throws at compile time
         Application.Run<Window> ();
         Application.Run<Window> ();
-        Assert.True (Application.Top is Window);
+        Assert.True (Application.Current is Window);
 
 
-        Application.Top!.Dispose ();
+        Application.Current!.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -605,15 +605,15 @@ public class ApplicationTests
         // Run<Toplevel> when already initialized or not with a Driver will not throw (because Window is derived from Toplevel)
         // Run<Toplevel> when already initialized or not with a Driver will not throw (because Window is derived from Toplevel)
         // Using another type not derived from Toplevel will throws at compile time
         // Using another type not derived from Toplevel will throws at compile time
         Application.Run<Window> (null, "fake");
         Application.Run<Window> (null, "fake");
-        Assert.True (Application.Top is Window);
+        Assert.True (Application.Current is Window);
 
 
-        Application.Top!.Dispose ();
+        Application.Current!.Dispose ();
 
 
         // Run<Toplevel> when already initialized or not with a Driver will not throw (because Dialog is derived from Toplevel)
         // Run<Toplevel> when already initialized or not with a Driver will not throw (because Dialog is derived from Toplevel)
         Application.Run<Dialog> (null, "fake");
         Application.Run<Dialog> (null, "fake");
-        Assert.True (Application.Top is Dialog);
+        Assert.True (Application.Current is Dialog);
 
 
-        Application.Top!.Dispose ();
+        Application.Current!.Dispose ();
         Application.Shutdown ();
         Application.Shutdown ();
     }
     }
 
 
@@ -621,7 +621,7 @@ public class ApplicationTests
     [SetupFakeApplication]
     [SetupFakeApplication]
     public void Run_T_After_Init_Does_Not_Disposes_Application_Top ()
     public void Run_T_After_Init_Does_Not_Disposes_Application_Top ()
     {
     {
-        // Init doesn't create a Toplevel and assigned it to Application.Top
+        // Init doesn't create a Toplevel and assigned it to Application.Current
         // but Begin does
         // but Begin does
         var initTop = new Toplevel ();
         var initTop = new Toplevel ();
 
 
@@ -635,13 +635,13 @@ public class ApplicationTests
         initTop.Dispose ();
         initTop.Dispose ();
         Assert.True (initTop.WasDisposed);
         Assert.True (initTop.WasDisposed);
 #endif
 #endif
-        Application.Top!.Dispose ();
+        Application.Current!.Dispose ();
 
 
         return;
         return;
 
 
         void OnApplicationOnIteration (object s, IterationEventArgs a)
         void OnApplicationOnIteration (object s, IterationEventArgs a)
         {
         {
-            Assert.NotEqual (initTop, Application.Top);
+            Assert.NotEqual (initTop, Application.Current);
 #if DEBUG_IDISPOSABLE
 #if DEBUG_IDISPOSABLE
             Assert.False (initTop.WasDisposed);
             Assert.False (initTop.WasDisposed);
 #endif
 #endif
@@ -658,7 +658,7 @@ public class ApplicationTests
         // Init has been called and we're passing no driver to Run<TestTopLevel>. This is ok.
         // Init has been called and we're passing no driver to Run<TestTopLevel>. This is ok.
         Application.Run<Toplevel> ();
         Application.Run<Toplevel> ();
 
 
-        Application.Top!.Dispose ();
+        Application.Current!.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -670,7 +670,7 @@ public class ApplicationTests
         // Init has been called, selecting FakeDriver; we're passing no driver to Run<TestTopLevel>. Should be fine.
         // Init has been called, selecting FakeDriver; we're passing no driver to Run<TestTopLevel>. Should be fine.
         Application.Run<Toplevel> ();
         Application.Run<Toplevel> ();
 
 
-        Application.Top!.Dispose ();
+        Application.Current!.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -701,7 +701,7 @@ public class ApplicationTests
         // Init has NOT been called and we're passing a valid driver to Run<TestTopLevel>. This is ok.
         // Init has NOT been called and we're passing a valid driver to Run<TestTopLevel>. This is ok.
         Application.Run<Toplevel> (null, "fake");
         Application.Run<Toplevel> (null, "fake");
 
 
-        Application.Top!.Dispose ();
+        Application.Current!.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -825,9 +825,9 @@ public class ApplicationTests
 
 
         Assert.NotNull (w);
         Assert.NotNull (w);
         Assert.Equal (string.Empty, w.Title); // Valid - w has not been disposed. The user may want to run it again
         Assert.Equal (string.Empty, w.Title); // Valid - w has not been disposed. The user may want to run it again
-        Assert.NotNull (Application.Top);
-        Assert.Equal (w, Application.Top);
-        Assert.NotEqual (top, Application.Top);
+        Assert.NotNull (Application.Current);
+        Assert.Equal (w, Application.Current);
+        Assert.NotEqual (top, Application.Current);
 
 
         Application.Run (w); // Valid - w has not been disposed.
         Application.Run (w); // Valid - w has not been disposed.
 
 
@@ -855,14 +855,14 @@ public class ApplicationTests
     [Fact]
     [Fact]
     public void Run_Creates_Top_Without_Init ()
     public void Run_Creates_Top_Without_Init ()
     {
     {
-        Assert.Null (Application.Top);
+        Assert.Null (Application.Current);
         Application.StopAfterFirstIteration = true;
         Application.StopAfterFirstIteration = true;
 
 
         Application.Iteration += OnApplicationOnIteration;
         Application.Iteration += OnApplicationOnIteration;
         Toplevel top = Application.Run (null, "fake");
         Toplevel top = Application.Run (null, "fake");
         Application.Iteration -= OnApplicationOnIteration;
         Application.Iteration -= OnApplicationOnIteration;
 #if DEBUG_IDISPOSABLE
 #if DEBUG_IDISPOSABLE
-        Assert.Equal (top, Application.Top);
+        Assert.Equal (top, Application.Current);
         Assert.False (top.WasDisposed);
         Assert.False (top.WasDisposed);
         Exception exception = Record.Exception (Application.Shutdown);
         Exception exception = Record.Exception (Application.Shutdown);
         Assert.NotNull (exception);
         Assert.NotNull (exception);
@@ -875,38 +875,38 @@ public class ApplicationTests
 #if DEBUG_IDISPOSABLE
 #if DEBUG_IDISPOSABLE
         Assert.True (top.WasDisposed);
         Assert.True (top.WasDisposed);
 #endif
 #endif
-        Assert.NotNull (Application.Top);
+        Assert.NotNull (Application.Current);
 
 
         Application.Shutdown ();
         Application.Shutdown ();
-        Assert.Null (Application.Top);
+        Assert.Null (Application.Current);
 
 
         return;
         return;
 
 
-        void OnApplicationOnIteration (object s, IterationEventArgs e) { Assert.NotNull (Application.Top); }
+        void OnApplicationOnIteration (object s, IterationEventArgs e) { Assert.NotNull (Application.Current); }
     }
     }
 
 
     [Fact]
     [Fact]
     public void Run_T_Creates_Top_Without_Init ()
     public void Run_T_Creates_Top_Without_Init ()
     {
     {
-        Assert.Null (Application.Top);
+        Assert.Null (Application.Current);
 
 
         Application.StopAfterFirstIteration = true;
         Application.StopAfterFirstIteration = true;
 
 
         Application.Run<Toplevel> (null, "fake");
         Application.Run<Toplevel> (null, "fake");
 #if DEBUG_IDISPOSABLE
 #if DEBUG_IDISPOSABLE
-        Assert.False (Application.Top!.WasDisposed);
+        Assert.False (Application.Current!.WasDisposed);
         Exception exception = Record.Exception (Application.Shutdown);
         Exception exception = Record.Exception (Application.Shutdown);
         Assert.NotNull (exception);
         Assert.NotNull (exception);
-        Assert.False (Application.Top!.WasDisposed);
+        Assert.False (Application.Current!.WasDisposed);
 
 
         // It's up to caller to dispose it
         // It's up to caller to dispose it
-        Application.Top!.Dispose ();
-        Assert.True (Application.Top!.WasDisposed);
+        Application.Current!.Dispose ();
+        Assert.True (Application.Current!.WasDisposed);
 #endif
 #endif
-        Assert.NotNull (Application.Top);
+        Assert.NotNull (Application.Current);
 
 
         Application.Shutdown ();
         Application.Shutdown ();
-        Assert.Null (Application.Top);
+        Assert.Null (Application.Current);
     }
     }
 
 
     [Fact]
     [Fact]
@@ -920,7 +920,7 @@ public class ApplicationTests
         // the new(Toplevel) may be a derived class that is possible using Application static
         // the new(Toplevel) may be a derived class that is possible using Application static
         // properties that is only available after the Application.Init was called
         // properties that is only available after the Application.Init was called
 
 
-        Assert.Null (Application.Top);
+        Assert.Null (Application.Current);
 
 
         Assert.Throws<NotInitializedException> (() => Application.Run (new Toplevel ()));
         Assert.Throws<NotInitializedException> (() => Application.Run (new Toplevel ()));
 
 
@@ -930,25 +930,25 @@ public class ApplicationTests
         Application.Run (new Toplevel ());
         Application.Run (new Toplevel ());
         Application.Iteration -= OnApplicationOnIteration;
         Application.Iteration -= OnApplicationOnIteration;
 #if DEBUG_IDISPOSABLE
 #if DEBUG_IDISPOSABLE
-        Assert.False (Application.Top!.WasDisposed);
+        Assert.False (Application.Current!.WasDisposed);
         Exception exception = Record.Exception (Application.Shutdown);
         Exception exception = Record.Exception (Application.Shutdown);
         Assert.NotNull (exception);
         Assert.NotNull (exception);
-        Assert.False (Application.Top!.WasDisposed);
+        Assert.False (Application.Current!.WasDisposed);
 
 
         // It's up to caller to dispose it
         // It's up to caller to dispose it
-        Application.Top!.Dispose ();
-        Assert.True (Application.Top!.WasDisposed);
+        Application.Current!.Dispose ();
+        Assert.True (Application.Current!.WasDisposed);
 #endif
 #endif
-        Assert.NotNull (Application.Top);
+        Assert.NotNull (Application.Current);
 
 
         Application.Shutdown ();
         Application.Shutdown ();
-        Assert.Null (Application.Top);
+        Assert.Null (Application.Current);
 
 
         return;
         return;
 
 
         void OnApplicationOnIteration (object s, IterationEventArgs e)
         void OnApplicationOnIteration (object s, IterationEventArgs e)
         {
         {
-            Assert.NotNull (Application.Top);
+            Assert.NotNull (Application.Current);
             Application.RequestStop ();
             Application.RequestStop ();
         }
         }
     }
     }
@@ -973,9 +973,9 @@ public class ApplicationTests
                            TaskScheduler.FromCurrentSynchronizationContext ());
                            TaskScheduler.FromCurrentSynchronizationContext ());
         Application.Run<TestToplevel> ();
         Application.Run<TestToplevel> ();
         Assert.NotNull (Application.Driver);
         Assert.NotNull (Application.Driver);
-        Assert.NotNull (Application.Top);
-        Assert.False (Application.Top!.Running);
-        Application.Top!.Dispose ();
+        Assert.NotNull (Application.Current);
+        Assert.False (Application.Current!.Running);
+        Application.Current!.Dispose ();
         Application.Shutdown ();
         Application.Shutdown ();
     }
     }
 
 

+ 20 - 20
Tests/UnitTests/Application/Mouse/ApplicationMouseEnterLeaveTests.cs

@@ -41,9 +41,9 @@ public class ApplicationMouseEnterLeaveTests
     public void RaiseMouseEnterLeaveEvents_MouseEntersView_CallsOnMouseEnter ()
     public void RaiseMouseEnterLeaveEvents_MouseEntersView_CallsOnMouseEnter ()
     {
     {
         // Arrange
         // Arrange
-        Application.Top = new () { Frame = new (0, 0, 10, 10) };
+        Application.Current = new () { Frame = new (0, 0, 10, 10) };
         var view = new TestView ();
         var view = new TestView ();
-        Application.Top.Add (view);
+        Application.Current.Add (view);
         var mousePosition = new Point (1, 1);
         var mousePosition = new Point (1, 1);
         List<View> currentViewsUnderMouse = new () { view };
         List<View> currentViewsUnderMouse = new () { view };
 
 
@@ -66,7 +66,7 @@ public class ApplicationMouseEnterLeaveTests
         finally
         finally
         {
         {
             // Cleanup
             // Cleanup
-            Application.Top?.Dispose ();
+            Application.Current?.Dispose ();
             Application.ResetState ();
             Application.ResetState ();
         }
         }
     }
     }
@@ -75,9 +75,9 @@ public class ApplicationMouseEnterLeaveTests
     public void RaiseMouseEnterLeaveEvents_MouseLeavesView_CallsOnMouseLeave ()
     public void RaiseMouseEnterLeaveEvents_MouseLeavesView_CallsOnMouseLeave ()
     {
     {
         // Arrange
         // Arrange
-        Application.Top = new () { Frame = new (0, 0, 10, 10) };
+        Application.Current = new () { Frame = new (0, 0, 10, 10) };
         var view = new TestView ();
         var view = new TestView ();
-        Application.Top.Add (view);
+        Application.Current.Add (view);
         var mousePosition = new Point (0, 0);
         var mousePosition = new Point (0, 0);
         List<View> currentViewsUnderMouse = new ();
         List<View> currentViewsUnderMouse = new ();
         var mouseEvent = new MouseEventArgs ();
         var mouseEvent = new MouseEventArgs ();
@@ -97,7 +97,7 @@ public class ApplicationMouseEnterLeaveTests
         finally
         finally
         {
         {
             // Cleanup
             // Cleanup
-            Application.Top?.Dispose ();
+            Application.Current?.Dispose ();
             Application.ResetState ();
             Application.ResetState ();
         }
         }
     }
     }
@@ -106,7 +106,7 @@ public class ApplicationMouseEnterLeaveTests
     public void RaiseMouseEnterLeaveEvents_MouseMovesBetweenAdjacentViews_CallsOnMouseEnterAndLeave ()
     public void RaiseMouseEnterLeaveEvents_MouseMovesBetweenAdjacentViews_CallsOnMouseEnterAndLeave ()
     {
     {
         // Arrange
         // Arrange
-        Application.Top = new () { Frame = new (0, 0, 10, 10) };
+        Application.Current = new () { Frame = new (0, 0, 10, 10) };
         var view1 = new TestView (); // at 1,1 to 2,2
         var view1 = new TestView (); // at 1,1 to 2,2
 
 
         var view2 = new TestView () // at 2,2 to 3,3
         var view2 = new TestView () // at 2,2 to 3,3
@@ -114,8 +114,8 @@ public class ApplicationMouseEnterLeaveTests
             X = 2,
             X = 2,
             Y = 2
             Y = 2
         };
         };
-        Application.Top.Add (view1);
-        Application.Top.Add (view2);
+        Application.Current.Add (view1);
+        Application.Current.Add (view2);
 
 
         Application.CachedViewsUnderMouse.Clear ();
         Application.CachedViewsUnderMouse.Clear ();
 
 
@@ -189,7 +189,7 @@ public class ApplicationMouseEnterLeaveTests
         finally
         finally
         {
         {
             // Cleanup
             // Cleanup
-            Application.Top?.Dispose ();
+            Application.Current?.Dispose ();
             Application.ResetState ();
             Application.ResetState ();
         }
         }
     }
     }
@@ -198,9 +198,9 @@ public class ApplicationMouseEnterLeaveTests
     public void RaiseMouseEnterLeaveEvents_NoViewsUnderMouse_DoesNotCallOnMouseEnterOrLeave ()
     public void RaiseMouseEnterLeaveEvents_NoViewsUnderMouse_DoesNotCallOnMouseEnterOrLeave ()
     {
     {
         // Arrange
         // Arrange
-        Application.Top = new () { Frame = new (0, 0, 10, 10) };
+        Application.Current = new () { Frame = new (0, 0, 10, 10) };
         var view = new TestView ();
         var view = new TestView ();
-        Application.Top.Add (view);
+        Application.Current.Add (view);
         var mousePosition = new Point (0, 0);
         var mousePosition = new Point (0, 0);
         List<View> currentViewsUnderMouse = new ();
         List<View> currentViewsUnderMouse = new ();
         var mouseEvent = new MouseEventArgs ();
         var mouseEvent = new MouseEventArgs ();
@@ -219,7 +219,7 @@ public class ApplicationMouseEnterLeaveTests
         finally
         finally
         {
         {
             // Cleanup
             // Cleanup
-            Application.Top?.Dispose ();
+            Application.Current?.Dispose ();
             Application.ResetState ();
             Application.ResetState ();
         }
         }
     }
     }
@@ -228,7 +228,7 @@ public class ApplicationMouseEnterLeaveTests
     public void RaiseMouseEnterLeaveEvents_MouseMovesBetweenOverlappingPeerViews_CallsOnMouseEnterAndLeave ()
     public void RaiseMouseEnterLeaveEvents_MouseMovesBetweenOverlappingPeerViews_CallsOnMouseEnterAndLeave ()
     {
     {
         // Arrange
         // Arrange
-        Application.Top = new () { Frame = new (0, 0, 10, 10) };
+        Application.Current = new () { Frame = new (0, 0, 10, 10) };
 
 
         var view1 = new TestView
         var view1 = new TestView
         {
         {
@@ -241,8 +241,8 @@ public class ApplicationMouseEnterLeaveTests
             X = 2,
             X = 2,
             Y = 2
             Y = 2
         };
         };
-        Application.Top.Add (view1);
-        Application.Top.Add (view2);
+        Application.Current.Add (view1);
+        Application.Current.Add (view2);
 
 
         Application.CachedViewsUnderMouse.Clear ();
         Application.CachedViewsUnderMouse.Clear ();
 
 
@@ -329,7 +329,7 @@ public class ApplicationMouseEnterLeaveTests
         finally
         finally
         {
         {
             // Cleanup
             // Cleanup
-            Application.Top?.Dispose ();
+            Application.Current?.Dispose ();
             Application.ResetState ();
             Application.ResetState ();
         }
         }
     }
     }
@@ -338,7 +338,7 @@ public class ApplicationMouseEnterLeaveTests
     public void RaiseMouseEnterLeaveEvents_MouseMovesBetweenOverlappingSubViews_CallsOnMouseEnterAndLeave ()
     public void RaiseMouseEnterLeaveEvents_MouseMovesBetweenOverlappingSubViews_CallsOnMouseEnterAndLeave ()
     {
     {
         // Arrange
         // Arrange
-        Application.Top = new () { Frame = new (0, 0, 10, 10) };
+        Application.Current = new () { Frame = new (0, 0, 10, 10) };
 
 
         var view1 = new TestView
         var view1 = new TestView
         {
         {
@@ -358,7 +358,7 @@ public class ApplicationMouseEnterLeaveTests
             Arrangement = ViewArrangement.Overlapped
             Arrangement = ViewArrangement.Overlapped
         }; // at 2,2 to 4,4 (screen)
         }; // at 2,2 to 4,4 (screen)
         view1.Add (subView);
         view1.Add (subView);
-        Application.Top.Add (view1);
+        Application.Current.Add (view1);
 
 
         Application.CachedViewsUnderMouse.Clear ();
         Application.CachedViewsUnderMouse.Clear ();
 
 
@@ -474,7 +474,7 @@ public class ApplicationMouseEnterLeaveTests
         finally
         finally
         {
         {
             // Cleanup
             // Cleanup
-            Application.Top?.Dispose ();
+            Application.Current?.Dispose ();
             Application.ResetState ();
             Application.ResetState ();
         }
         }
     }
     }

+ 8 - 8
Tests/UnitTests/Application/Mouse/ApplicationMouseTests.cs

@@ -202,15 +202,15 @@ public class ApplicationMouseTests
 
 
         var clicked = false;
         var clicked = false;
 
 
-        Application.Top = new Toplevel ()
+        Application.Current = new Toplevel ()
         {
         {
             Id = "top",
             Id = "top",
         };
         };
-        Application.Top.X = 0;
-        Application.Top.Y = 0;
-        Application.Top.Width = size.Width * 2;
-        Application.Top.Height = size.Height * 2;
-        Application.Top.BorderStyle = LineStyle.None;
+        Application.Current.X = 0;
+        Application.Current.Y = 0;
+        Application.Current.Width = size.Width * 2;
+        Application.Current.Height = size.Height * 2;
+        Application.Current.BorderStyle = LineStyle.None;
 
 
         var view = new View { Id = "view", X = pos.X, Y = pos.Y, Width = size.Width, Height = size.Height };
         var view = new View { Id = "view", X = pos.X, Y = pos.Y, Width = size.Width, Height = size.Height };
 
 
@@ -218,7 +218,7 @@ public class ApplicationMouseTests
         view.BorderStyle = LineStyle.Single;
         view.BorderStyle = LineStyle.Single;
         view.CanFocus = true;
         view.CanFocus = true;
 
 
-        Application.Top.Add (view);
+        Application.Current.Add (view);
 
 
         var mouseEvent = new MouseEventArgs { Position = new (clickX, clickY), ScreenPosition = new (clickX, clickY), Flags = MouseFlags.Button1Clicked };
         var mouseEvent = new MouseEventArgs { Position = new (clickX, clickY), ScreenPosition = new (clickX, clickY), Flags = MouseFlags.Button1Clicked };
 
 
@@ -231,7 +231,7 @@ public class ApplicationMouseTests
 
 
         Application.RaiseMouseEvent (mouseEvent);
         Application.RaiseMouseEvent (mouseEvent);
         Assert.Equal (expectedClicked, clicked);
         Assert.Equal (expectedClicked, clicked);
-        Application.Top.Dispose ();
+        Application.Current.Dispose ();
         Application.ResetState (ignoreDisposed: true);
         Application.ResetState (ignoreDisposed: true);
 
 
     }
     }

+ 1 - 1
Tests/UnitTests/Application/SessionTokenTests.cs

@@ -26,7 +26,7 @@ public class SessionTokenTests
         Assert.NotNull (rs);
         Assert.NotNull (rs);
         Application.End (rs);
         Application.End (rs);
 
 
-        Assert.NotNull (Application.Top);
+        Assert.NotNull (Application.Current);
 
 
         // v2 does not use main loop, it uses MainLoop<T> and its internal
         // v2 does not use main loop, it uses MainLoop<T> and its internal
         //Assert.NotNull (Application.MainLoop);
         //Assert.NotNull (Application.MainLoop);

+ 2 - 2
Tests/UnitTests/Application/SynchronizatonContextTests.cs

@@ -39,7 +39,7 @@ public class SyncrhonizationContextTests
 
 
             Task.Run (() =>
             Task.Run (() =>
                       {
                       {
-                          while (Application.Top is null || Application.Top is { Running: false })
+                          while (Application.Current is null || Application.Current is { Running: false })
                           {
                           {
                               Thread.Sleep (500);
                               Thread.Sleep (500);
                           }
                           }
@@ -56,7 +56,7 @@ public class SyncrhonizationContextTests
                                         null
                                         null
                                        );
                                        );
 
 
-                          if (Application.Top is { Running: true })
+                          if (Application.Current is { Running: true })
                           {
                           {
                               Assert.False (success);
                               Assert.False (success);
                           }
                           }

+ 15 - 15
Tests/UnitTests/Dialogs/DialogTests.cs

@@ -902,8 +902,8 @@ public class DialogTests (ITestOutputHelper output)
 
 
 #if DEBUG_IDISPOSABLE
 #if DEBUG_IDISPOSABLE
         Assert.False (dlg.WasDisposed);
         Assert.False (dlg.WasDisposed);
-        Assert.False (Application.Top!.WasDisposed);
-        Assert.Equal (dlg, Application.Top);
+        Assert.False (Application.Current!.WasDisposed);
+        Assert.Equal (dlg, Application.Current);
 #endif
 #endif
 
 
         Assert.True (dlg.Canceled);
         Assert.True (dlg.Canceled);
@@ -925,8 +925,8 @@ public class DialogTests (ITestOutputHelper output)
         Application.Run (dlg2);
         Application.Run (dlg2);
 
 
         Assert.True (dlg.WasDisposed);
         Assert.True (dlg.WasDisposed);
-        Assert.False (Application.Top.WasDisposed);
-        Assert.Equal (dlg2, Application.Top);
+        Assert.False (Application.Current.WasDisposed);
+        Assert.Equal (dlg2, Application.Current);
         Assert.False (dlg2.WasDisposed);
         Assert.False (dlg2.WasDisposed);
 
 
         dlg2.Dispose ();
         dlg2.Dispose ();
@@ -937,10 +937,10 @@ public class DialogTests (ITestOutputHelper output)
         //Assert.NotNull (exception);
         //Assert.NotNull (exception);
         //Assert.StartsWith ("Cannot access a disposed object.", exception.Message);
         //Assert.StartsWith ("Cannot access a disposed object.", exception.Message);
 
 
-        Assert.True (Application.Top.WasDisposed);
+        Assert.True (Application.Current.WasDisposed);
         Application.Shutdown ();
         Application.Shutdown ();
         Assert.True (dlg2.WasDisposed);
         Assert.True (dlg2.WasDisposed);
-        Assert.Null (Application.Top);
+        Assert.Null (Application.Current);
 #endif
 #endif
 
 
         return;
         return;
@@ -1174,8 +1174,8 @@ public class DialogTests (ITestOutputHelper output)
             switch (iterations)
             switch (iterations)
             {
             {
                 case 0:
                 case 0:
-                    Application.Top!.SetNeedsLayout ();
-                    Application.Top.SetNeedsDraw ();
+                    Application.Current!.SetNeedsLayout ();
+                    Application.Current.SetNeedsDraw ();
 
 
                     break;
                     break;
 
 
@@ -1216,7 +1216,7 @@ public class DialogTests (ITestOutputHelper output)
   └───────────────────────┘",
   └───────────────────────┘",
                                                                    output);
                                                                    output);
 
 
-                    Assert.False (Application.Top!.NewKeyDownEvent (Key.Enter));
+                    Assert.False (Application.Current!.NewKeyDownEvent (Key.Enter));
 
 
                     break;
                     break;
                 case 7:
                 case 7:
@@ -1410,9 +1410,9 @@ public class DialogTests (ITestOutputHelper output)
 
 
 #if DEBUG_IDISPOSABLE
 #if DEBUG_IDISPOSABLE
         Assert.False (dlg.WasDisposed);
         Assert.False (dlg.WasDisposed);
-        Assert.False (Application.Top!.WasDisposed);
-        Assert.NotEqual (top, Application.Top);
-        Assert.Equal (dlg, Application.Top);
+        Assert.False (Application.Current!.WasDisposed);
+        Assert.NotEqual (top, Application.Current);
+        Assert.Equal (dlg, Application.Current);
 #endif
 #endif
 
 
         // dlg wasn't disposed yet and it's possible to access to his properties
         // dlg wasn't disposed yet and it's possible to access to his properties
@@ -1426,11 +1426,11 @@ public class DialogTests (ITestOutputHelper output)
         top.Dispose ();
         top.Dispose ();
 #if DEBUG_IDISPOSABLE
 #if DEBUG_IDISPOSABLE
         Assert.True (dlg.WasDisposed);
         Assert.True (dlg.WasDisposed);
-        Assert.True (Application.Top.WasDisposed);
-        Assert.NotNull (Application.Top);
+        Assert.True (Application.Current.WasDisposed);
+        Assert.NotNull (Application.Current);
 #endif
 #endif
         Application.Shutdown ();
         Application.Shutdown ();
-        Assert.Null (Application.Top);
+        Assert.Null (Application.Current);
 
 
         return;
         return;
 
 

+ 7 - 7
Tests/UnitTests/Dialogs/MessageBoxTests.cs

@@ -193,7 +193,7 @@ public class MessageBoxTests (ITestOutputHelper output)
             }
             }
             else if (iterations == 1)
             else if (iterations == 1)
             {
             {
-                mbFrame = Application.Top!.Frame;
+                mbFrame = Application.Current!.Frame;
                 Application.RequestStop ();
                 Application.RequestStop ();
             }
             }
         }
         }
@@ -378,8 +378,8 @@ public class MessageBoxTests (ITestOutputHelper output)
                                      {
                                      {
                                          AutoInitShutdownAttribute.RunIteration ();
                                          AutoInitShutdownAttribute.RunIteration ();
 
 
-                                         Assert.IsType<Dialog> (Application.Top);
-                                         Assert.Equal (new (height, width), Application.Top.Frame.Size);
+                                         Assert.IsType<Dialog> (Application.Current);
+                                         Assert.Equal (new (height, width), Application.Current.Frame.Size);
 
 
                                          Application.RequestStop ();
                                          Application.RequestStop ();
                                      }
                                      }
@@ -415,8 +415,8 @@ public class MessageBoxTests (ITestOutputHelper output)
                                      {
                                      {
                                          AutoInitShutdownAttribute.RunIteration ();
                                          AutoInitShutdownAttribute.RunIteration ();
 
 
-                                         Assert.IsType<Dialog> (Application.Top);
-                                         Assert.Equal (new (height, width), Application.Top.Frame.Size);
+                                         Assert.IsType<Dialog> (Application.Current);
+                                         Assert.Equal (new (height, width), Application.Current.Frame.Size);
 
 
                                          Application.RequestStop ();
                                          Application.RequestStop ();
                                      }
                                      }
@@ -448,8 +448,8 @@ public class MessageBoxTests (ITestOutputHelper output)
                                      {
                                      {
                                          AutoInitShutdownAttribute.RunIteration ();
                                          AutoInitShutdownAttribute.RunIteration ();
 
 
-                                         Assert.IsType<Dialog> (Application.Top);
-                                         Assert.Equal (new (height, width), Application.Top.Frame.Size);
+                                         Assert.IsType<Dialog> (Application.Current);
+                                         Assert.Equal (new (height, width), Application.Current.Frame.Size);
 
 
                                          Application.RequestStop ();
                                          Application.RequestStop ();
                                      }
                                      }

+ 12 - 12
Tests/UnitTests/View/Adornment/AdornmentSubViewTests.cs

@@ -14,14 +14,14 @@ public class AdornmentSubViewTests (ITestOutputHelper output)
     [InlineData (2, 1, true)]
     [InlineData (2, 1, true)]
     public void Adornment_WithSubView_Finds (int viewMargin, int subViewMargin, bool expectedFound)
     public void Adornment_WithSubView_Finds (int viewMargin, int subViewMargin, bool expectedFound)
     {
     {
-        Application.Top = new Toplevel()
+        Application.Current = new Toplevel()
         {
         {
             Width = 10,
             Width = 10,
             Height = 10
             Height = 10
         };
         };
-        Application.Top.Margin!.Thickness = new Thickness (viewMargin);
+        Application.Current.Margin!.Thickness = new Thickness (viewMargin);
         // Turn of TransparentMouse for the test
         // Turn of TransparentMouse for the test
-        Application.Top.Margin!.ViewportSettings = ViewportSettingsFlags.None;
+        Application.Current.Margin!.ViewportSettings = ViewportSettingsFlags.None;
 
 
         var subView = new View ()
         var subView = new View ()
         {
         {
@@ -34,26 +34,26 @@ public class AdornmentSubViewTests (ITestOutputHelper output)
         // Turn of TransparentMouse for the test
         // Turn of TransparentMouse for the test
         subView.Margin!.ViewportSettings = ViewportSettingsFlags.None;
         subView.Margin!.ViewportSettings = ViewportSettingsFlags.None;
 
 
-        Application.Top.Margin!.Add (subView);
-        Application.Top.Layout ();
+        Application.Current.Margin!.Add (subView);
+        Application.Current.Layout ();
 
 
         var foundView = View.GetViewsUnderLocation (new Point(0, 0), ViewportSettingsFlags.None).LastOrDefault ();
         var foundView = View.GetViewsUnderLocation (new Point(0, 0), ViewportSettingsFlags.None).LastOrDefault ();
 
 
         bool found = foundView == subView || foundView == subView.Margin;
         bool found = foundView == subView || foundView == subView.Margin;
         Assert.Equal (expectedFound, found);
         Assert.Equal (expectedFound, found);
-        Application.Top.Dispose ();
+        Application.Current.Dispose ();
         Application.ResetState (ignoreDisposed: true);
         Application.ResetState (ignoreDisposed: true);
     }
     }
 
 
     [Fact]
     [Fact]
     public void Adornment_WithNonVisibleSubView_Finds_Adornment ()
     public void Adornment_WithNonVisibleSubView_Finds_Adornment ()
     {
     {
-        Application.Top = new Toplevel ()
+        Application.Current = new Toplevel ()
         {
         {
             Width = 10,
             Width = 10,
             Height = 10
             Height = 10
         };
         };
-        Application.Top.Padding.Thickness = new Thickness (1);
+        Application.Current.Padding.Thickness = new Thickness (1);
 
 
         var subView = new View ()
         var subView = new View ()
         {
         {
@@ -63,11 +63,11 @@ public class AdornmentSubViewTests (ITestOutputHelper output)
             Height = 1,
             Height = 1,
             Visible = false
             Visible = false
         };
         };
-        Application.Top.Padding.Add (subView);
-        Application.Top.Layout ();
+        Application.Current.Padding.Add (subView);
+        Application.Current.Layout ();
 
 
-        Assert.Equal (Application.Top.Padding, View.GetViewsUnderLocation (new Point(0, 0), ViewportSettingsFlags.None).LastOrDefault ());
-        Application.Top?.Dispose ();
+        Assert.Equal (Application.Current.Padding, View.GetViewsUnderLocation (new Point(0, 0), ViewportSettingsFlags.None).LastOrDefault ());
+        Application.Current?.Dispose ();
         Application.ResetState (ignoreDisposed: true);
         Application.ResetState (ignoreDisposed: true);
     }
     }
 }
 }

+ 16 - 16
Tests/UnitTests/View/Adornment/MarginTests.cs

@@ -15,27 +15,27 @@ public class MarginTests (ITestOutputHelper output)
         view.Margin!.Diagnostics = ViewDiagnosticFlags.Thickness;
         view.Margin!.Diagnostics = ViewDiagnosticFlags.Thickness;
         view.Margin.Thickness = new (1);
         view.Margin.Thickness = new (1);
 
 
-        Application.Top = new Toplevel ();
-        Application.TopLevels.Push (Application.Top);
+        Application.Current = new Toplevel ();
+        Application.SessionStack.Push (Application.Current);
 
 
-        Application.Top.SetScheme (new()
+        Application.Current.SetScheme (new()
         {
         {
             Normal = new (Color.Red, Color.Green), Focus = new (Color.Green, Color.Red)
             Normal = new (Color.Red, Color.Green), Focus = new (Color.Green, Color.Red)
         });
         });
 
 
-        Application.Top.Add (view);
+        Application.Current.Add (view);
         Assert.Equal (ColorName16.Red, view.Margin.GetAttributeForRole (VisualRole.Normal).Foreground.GetClosestNamedColor16 ());
         Assert.Equal (ColorName16.Red, view.Margin.GetAttributeForRole (VisualRole.Normal).Foreground.GetClosestNamedColor16 ());
-        Assert.Equal (ColorName16.Red, Application.Top.GetAttributeForRole (VisualRole.Normal).Foreground.GetClosestNamedColor16 ());
+        Assert.Equal (ColorName16.Red, Application.Current.GetAttributeForRole (VisualRole.Normal).Foreground.GetClosestNamedColor16 ());
 
 
-        Application.Top.BeginInit ();
-        Application.Top.EndInit ();
+        Application.Current.BeginInit ();
+        Application.Current.EndInit ();
         Application.LayoutAndDraw();
         Application.LayoutAndDraw();
 
 
         DriverAssert.AssertDriverContentsAre (
         DriverAssert.AssertDriverContentsAre (
                                              @"",
                                              @"",
                                              output
                                              output
                                             );
                                             );
-        DriverAssert.AssertDriverAttributesAre ("0", output, null, Application.Top.GetAttributeForRole (VisualRole.Normal));
+        DriverAssert.AssertDriverAttributesAre ("0", output, null, Application.Current.GetAttributeForRole (VisualRole.Normal));
 
 
         Application.ResetState (true);
         Application.ResetState (true);
     }
     }
@@ -51,20 +51,20 @@ public class MarginTests (ITestOutputHelper output)
         view.Margin.Thickness = new (1);
         view.Margin.Thickness = new (1);
         view.Margin.ViewportSettings = ViewportSettingsFlags.None;
         view.Margin.ViewportSettings = ViewportSettingsFlags.None;
 
 
-        Application.Top = new Toplevel ();
-        Application.TopLevels.Push (Application.Top);
+        Application.Current = new Toplevel ();
+        Application.SessionStack.Push (Application.Current);
 
 
-        Application.Top.SetScheme (new ()
+        Application.Current.SetScheme (new ()
         {
         {
             Normal = new (Color.Red, Color.Green), Focus = new (Color.Green, Color.Red)
             Normal = new (Color.Red, Color.Green), Focus = new (Color.Green, Color.Red)
         });
         });
 
 
-        Application.Top.Add (view);
+        Application.Current.Add (view);
         Assert.Equal (ColorName16.Red, view.Margin.GetAttributeForRole (VisualRole.Normal).Foreground.GetClosestNamedColor16 ());
         Assert.Equal (ColorName16.Red, view.Margin.GetAttributeForRole (VisualRole.Normal).Foreground.GetClosestNamedColor16 ());
-        Assert.Equal (ColorName16.Red, Application.Top.GetAttributeForRole (VisualRole.Normal).Foreground.GetClosestNamedColor16 ());
+        Assert.Equal (ColorName16.Red, Application.Current.GetAttributeForRole (VisualRole.Normal).Foreground.GetClosestNamedColor16 ());
 
 
-        Application.Top.BeginInit ();
-        Application.Top.EndInit ();
+        Application.Current.BeginInit ();
+        Application.Current.EndInit ();
         Application.LayoutAndDraw ();
         Application.LayoutAndDraw ();
 
 
         DriverAssert.AssertDriverContentsAre (
         DriverAssert.AssertDriverContentsAre (
@@ -74,7 +74,7 @@ M M
 MMM",
 MMM",
                                               output
                                               output
                                              );
                                              );
-        DriverAssert.AssertDriverAttributesAre ("0", output, null, Application.Top.GetAttributeForRole (VisualRole.Normal));
+        DriverAssert.AssertDriverAttributesAre ("0", output, null, Application.Current.GetAttributeForRole (VisualRole.Normal));
 
 
         Application.ResetState (true);
         Application.ResetState (true);
     }
     }

+ 2 - 2
Tests/UnitTests/View/Adornment/ShadowStyleTests.cs

@@ -65,7 +65,7 @@ public class ShadowStyleTests (ITestOutputHelper output)
         view.SetScheme (new (Attribute.Default));
         view.SetScheme (new (Attribute.Default));
 
 
         superView.Add (view);
         superView.Add (view);
-        Application.TopLevels.Push (superView);
+        Application.SessionStack.Push (superView);
         Application.LayoutAndDraw (true);
         Application.LayoutAndDraw (true);
         DriverAssert.AssertDriverAttributesAre (expectedAttrs, output, Application.Driver, attributes);
         DriverAssert.AssertDriverAttributesAre (expectedAttrs, output, Application.Driver, attributes);
         Application.ResetState (true);
         Application.ResetState (true);
@@ -118,7 +118,7 @@ public class ShadowStyleTests (ITestOutputHelper output)
         };
         };
         view.ShadowStyle = style;
         view.ShadowStyle = style;
         superView.Add (view);
         superView.Add (view);
-        Application.TopLevels.Push (superView);
+        Application.SessionStack.Push (superView);
         Application.LayoutAndDraw (true);
         Application.LayoutAndDraw (true);
 
 
         DriverAssert.AssertDriverContentsWithFrameAre (expected, output);
         DriverAssert.AssertDriverContentsWithFrameAre (expected, output);

+ 3 - 3
Tests/UnitTests/View/Keyboard/KeyBindingsTests.cs

@@ -160,14 +160,14 @@ public class KeyBindingsTests ()
         var hotKeyRaised = false;
         var hotKeyRaised = false;
         var acceptRaised = false;
         var acceptRaised = false;
         var selectRaised = false;
         var selectRaised = false;
-        Application.Top = new Toplevel ();
+        Application.Current = new Toplevel ();
         var view = new View
         var view = new View
         {
         {
             CanFocus = true,
             CanFocus = true,
             HotKeySpecifier = new Rune ('_'),
             HotKeySpecifier = new Rune ('_'),
             Title = "_Test"
             Title = "_Test"
         };
         };
-        Application.Top.Add (view);
+        Application.Current.Add (view);
         view.HandlingHotKey += (s, e) => hotKeyRaised = true;
         view.HandlingHotKey += (s, e) => hotKeyRaised = true;
         view.Accepting += (s, e) => acceptRaised = true;
         view.Accepting += (s, e) => acceptRaised = true;
         view.Selecting += (s, e) => selectRaised = true;
         view.Selecting += (s, e) => selectRaised = true;
@@ -191,7 +191,7 @@ public class KeyBindingsTests ()
         Assert.False (acceptRaised);
         Assert.False (acceptRaised);
         Assert.False (selectRaised);
         Assert.False (selectRaised);
 
 
-        Application.Top.Dispose ();
+        Application.Current.Dispose ();
         Application.ResetState (true);
         Application.ResetState (true);
     }
     }
     // tests that test KeyBindingScope.Focus and KeyBindingScope.HotKey (tests for KeyBindingScope.Application are in Application/KeyboardTests.cs)
     // tests that test KeyBindingScope.Focus and KeyBindingScope.HotKey (tests for KeyBindingScope.Application are in Application/KeyboardTests.cs)

+ 92 - 92
Tests/UnitTests/View/Layout/GetViewsUnderLocationTests.cs

@@ -70,17 +70,17 @@ public class GetViewsUnderLocationTests
     )
     )
     {
     {
         // Arrange
         // Arrange
-        Application.Top = new ()
+        Application.Current = new ()
         {
         {
             Id = "Top",
             Id = "Top",
             Frame = new (frameX, frameY, 10, 10)
             Frame = new (frameX, frameY, 10, 10)
         };
         };
-        Application.Top.Margin!.Thickness = new (marginThickness);
-        Application.Top.Margin!.Id = "Margin";
-        Application.Top.Border!.Thickness = new (borderThickness);
-        Application.Top.Border!.Id = "Border";
-        Application.Top.Padding!.Thickness = new (paddingThickness);
-        Application.Top.Padding.Id = "Padding";
+        Application.Current.Margin!.Thickness = new (marginThickness);
+        Application.Current.Margin!.Id = "Margin";
+        Application.Current.Border!.Thickness = new (borderThickness);
+        Application.Current.Border!.Id = "Border";
+        Application.Current.Padding!.Thickness = new (paddingThickness);
+        Application.Current.Padding.Id = "Padding";
 
 
         var location = new Point (testX, testY);
         var location = new Point (testX, testY);
 
 
@@ -98,7 +98,7 @@ public class GetViewsUnderLocationTests
             Assert.Equal (expectedViewsFound, foundIds);
             Assert.Equal (expectedViewsFound, foundIds);
         }
         }
 
 
-        Application.Top.Dispose ();
+        Application.Current.Dispose ();
         Application.ResetState (true);
         Application.ResetState (true);
     }
     }
 
 
@@ -109,7 +109,7 @@ public class GetViewsUnderLocationTests
     public void Returns_Top_If_No_SubViews (int testX, int testY)
     public void Returns_Top_If_No_SubViews (int testX, int testY)
     {
     {
         // Arrange
         // Arrange
-        Application.Top = new ()
+        Application.Current = new ()
         {
         {
             Frame = new (0, 0, 10, 10)
             Frame = new (0, 0, 10, 10)
         };
         };
@@ -120,8 +120,8 @@ public class GetViewsUnderLocationTests
         List<View?> viewsUnderMouse = View.GetViewsUnderLocation (location, ViewportSettingsFlags.TransparentMouse);
         List<View?> viewsUnderMouse = View.GetViewsUnderLocation (location, ViewportSettingsFlags.TransparentMouse);
 
 
         // Assert
         // Assert
-        Assert.Contains (viewsUnderMouse, v => v == Application.Top);
-        Application.Top.Dispose ();
+        Assert.Contains (viewsUnderMouse, v => v == Application.Current);
+        Application.Current.Dispose ();
         Application.ResetState (true);
         Application.ResetState (true);
     }
     }
 
 
@@ -134,13 +134,13 @@ public class GetViewsUnderLocationTests
     {
     {
         Application.ResetState (true);
         Application.ResetState (true);
 
 
-        Application.Top = new ()
+        Application.Current = new ()
         {
         {
             Width = 10, Height = 10
             Width = 10, Height = 10
         };
         };
 
 
-        Assert.Same (Application.Top, View.GetViewsUnderLocation (new (testX, testY), ViewportSettingsFlags.TransparentMouse).LastOrDefault ());
-        Application.Top.Dispose ();
+        Assert.Same (Application.Current, View.GetViewsUnderLocation (new (testX, testY), ViewportSettingsFlags.TransparentMouse).LastOrDefault ());
+        Application.Current.Dispose ();
         Application.ResetState (true);
         Application.ResetState (true);
     }
     }
 
 
@@ -155,7 +155,7 @@ public class GetViewsUnderLocationTests
     [InlineData (5, 6, true)]
     [InlineData (5, 6, true)]
     public void Returns_Correct_If_SubViews (int testX, int testY, bool expectedSubViewFound)
     public void Returns_Correct_If_SubViews (int testX, int testY, bool expectedSubViewFound)
     {
     {
-        Application.Top = new ()
+        Application.Current = new ()
         {
         {
             Width = 10, Height = 10
             Width = 10, Height = 10
         };
         };
@@ -165,12 +165,12 @@ public class GetViewsUnderLocationTests
             X = 1, Y = 2,
             X = 1, Y = 2,
             Width = 5, Height = 5
             Width = 5, Height = 5
         };
         };
-        Application.Top.Add (subview);
+        Application.Current.Add (subview);
 
 
         View? found = View.GetViewsUnderLocation (new (testX, testY), ViewportSettingsFlags.TransparentMouse).LastOrDefault ();
         View? found = View.GetViewsUnderLocation (new (testX, testY), ViewportSettingsFlags.TransparentMouse).LastOrDefault ();
 
 
         Assert.Equal (expectedSubViewFound, found == subview);
         Assert.Equal (expectedSubViewFound, found == subview);
-        Application.Top.Dispose ();
+        Application.Current.Dispose ();
         Application.ResetState (true);
         Application.ResetState (true);
     }
     }
 
 
@@ -184,7 +184,7 @@ public class GetViewsUnderLocationTests
     [InlineData (5, 6, false)]
     [InlineData (5, 6, false)]
     public void Returns_Null_If_SubView_NotVisible (int testX, int testY, bool expectedSubViewFound)
     public void Returns_Null_If_SubView_NotVisible (int testX, int testY, bool expectedSubViewFound)
     {
     {
-        Application.Top = new ()
+        Application.Current = new ()
         {
         {
             Width = 10, Height = 10
             Width = 10, Height = 10
         };
         };
@@ -195,12 +195,12 @@ public class GetViewsUnderLocationTests
             Width = 5, Height = 5,
             Width = 5, Height = 5,
             Visible = false
             Visible = false
         };
         };
-        Application.Top.Add (subview);
+        Application.Current.Add (subview);
 
 
         View? found = View.GetViewsUnderLocation (new (testX, testY), ViewportSettingsFlags.TransparentMouse).LastOrDefault ();
         View? found = View.GetViewsUnderLocation (new (testX, testY), ViewportSettingsFlags.TransparentMouse).LastOrDefault ();
 
 
         Assert.Equal (expectedSubViewFound, found == subview);
         Assert.Equal (expectedSubViewFound, found == subview);
-        Application.Top.Dispose ();
+        Application.Current.Dispose ();
         Application.ResetState (true);
         Application.ResetState (true);
     }
     }
 
 
@@ -214,7 +214,7 @@ public class GetViewsUnderLocationTests
     [InlineData (5, 6, false)]
     [InlineData (5, 6, false)]
     public void Returns_Null_If_Not_Visible_And_SubView_Visible (int testX, int testY, bool expectedSubViewFound)
     public void Returns_Null_If_Not_Visible_And_SubView_Visible (int testX, int testY, bool expectedSubViewFound)
     {
     {
-        Application.Top = new ()
+        Application.Current = new ()
         {
         {
             Width = 10, Height = 10,
             Width = 10, Height = 10,
             Visible = false
             Visible = false
@@ -225,14 +225,14 @@ public class GetViewsUnderLocationTests
             X = 1, Y = 2,
             X = 1, Y = 2,
             Width = 5, Height = 5
             Width = 5, Height = 5
         };
         };
-        Application.Top.Add (subview);
+        Application.Current.Add (subview);
         subview.Visible = true;
         subview.Visible = true;
         Assert.True (subview.Visible);
         Assert.True (subview.Visible);
-        Assert.False (Application.Top.Visible);
+        Assert.False (Application.Current.Visible);
         View? found = View.GetViewsUnderLocation (new (testX, testY), ViewportSettingsFlags.TransparentMouse).LastOrDefault ();
         View? found = View.GetViewsUnderLocation (new (testX, testY), ViewportSettingsFlags.TransparentMouse).LastOrDefault ();
 
 
         Assert.Equal (expectedSubViewFound, found == subview);
         Assert.Equal (expectedSubViewFound, found == subview);
-        Application.Top.Dispose ();
+        Application.Current.Dispose ();
         Application.ResetState (true);
         Application.ResetState (true);
     }
     }
 
 
@@ -249,23 +249,23 @@ public class GetViewsUnderLocationTests
     [InlineData (6, 7, true)]
     [InlineData (6, 7, true)]
     public void Returns_Correct_If_Start_Has_Adornments (int testX, int testY, bool expectedSubViewFound)
     public void Returns_Correct_If_Start_Has_Adornments (int testX, int testY, bool expectedSubViewFound)
     {
     {
-        Application.Top = new ()
+        Application.Current = new ()
         {
         {
             Width = 10, Height = 10
             Width = 10, Height = 10
         };
         };
-        Application.Top.Margin!.Thickness = new (1);
+        Application.Current.Margin!.Thickness = new (1);
 
 
         var subview = new View
         var subview = new View
         {
         {
             X = 1, Y = 2,
             X = 1, Y = 2,
             Width = 5, Height = 5
             Width = 5, Height = 5
         };
         };
-        Application.Top.Add (subview);
+        Application.Current.Add (subview);
 
 
         View? found = View.GetViewsUnderLocation (new (testX, testY), ViewportSettingsFlags.TransparentMouse).LastOrDefault ();
         View? found = View.GetViewsUnderLocation (new (testX, testY), ViewportSettingsFlags.TransparentMouse).LastOrDefault ();
 
 
         Assert.Equal (expectedSubViewFound, found == subview);
         Assert.Equal (expectedSubViewFound, found == subview);
-        Application.Top.Dispose ();
+        Application.Current.Dispose ();
         Application.ResetState (true);
         Application.ResetState (true);
     }
     }
 
 
@@ -280,24 +280,24 @@ public class GetViewsUnderLocationTests
     [InlineData (-1, 0, 0, false)]
     [InlineData (-1, 0, 0, false)]
     public void Returns_Correct_If_Start_Has_Offset_Viewport (int offset, int testX, int testY, bool expectedSubViewFound)
     public void Returns_Correct_If_Start_Has_Offset_Viewport (int offset, int testX, int testY, bool expectedSubViewFound)
     {
     {
-        Application.Top = new ()
+        Application.Current = new ()
         {
         {
             Width = 10, Height = 10,
             Width = 10, Height = 10,
             ViewportSettings = ViewportSettingsFlags.AllowNegativeLocation
             ViewportSettings = ViewportSettingsFlags.AllowNegativeLocation
         };
         };
-        Application.Top.Viewport = new (offset, offset, 10, 10);
+        Application.Current.Viewport = new (offset, offset, 10, 10);
 
 
         var subview = new View
         var subview = new View
         {
         {
             X = 1, Y = 1,
             X = 1, Y = 1,
             Width = 2, Height = 2
             Width = 2, Height = 2
         };
         };
-        Application.Top.Add (subview);
+        Application.Current.Add (subview);
 
 
         View? found = View.GetViewsUnderLocation (new (testX, testY), ViewportSettingsFlags.TransparentMouse).LastOrDefault ();
         View? found = View.GetViewsUnderLocation (new (testX, testY), ViewportSettingsFlags.TransparentMouse).LastOrDefault ();
 
 
         Assert.Equal (expectedSubViewFound, found == subview);
         Assert.Equal (expectedSubViewFound, found == subview);
-        Application.Top.Dispose ();
+        Application.Current.Dispose ();
         Application.ResetState (true);
         Application.ResetState (true);
     }
     }
 
 
@@ -313,25 +313,25 @@ public class GetViewsUnderLocationTests
     [InlineData (6, 7, false)]
     [InlineData (6, 7, false)]
     public void Returns_Correct_If_Start_Has_Adornment_WithSubView (int testX, int testY, bool expectedSubViewFound)
     public void Returns_Correct_If_Start_Has_Adornment_WithSubView (int testX, int testY, bool expectedSubViewFound)
     {
     {
-        Application.Top = new ()
+        Application.Current = new ()
         {
         {
             Width = 10, Height = 10
             Width = 10, Height = 10
         };
         };
-        Application.Top.Padding!.Thickness = new (1);
+        Application.Current.Padding!.Thickness = new (1);
 
 
         var subview = new View
         var subview = new View
         {
         {
             X = Pos.AnchorEnd (1), Y = Pos.AnchorEnd (1),
             X = Pos.AnchorEnd (1), Y = Pos.AnchorEnd (1),
             Width = 1, Height = 1
             Width = 1, Height = 1
         };
         };
-        Application.Top.Padding.Add (subview);
-        Application.Top.BeginInit ();
-        Application.Top.EndInit ();
+        Application.Current.Padding.Add (subview);
+        Application.Current.BeginInit ();
+        Application.Current.EndInit ();
 
 
         View? found = View.GetViewsUnderLocation (new (testX, testY), ViewportSettingsFlags.TransparentMouse).LastOrDefault ();
         View? found = View.GetViewsUnderLocation (new (testX, testY), ViewportSettingsFlags.TransparentMouse).LastOrDefault ();
 
 
         Assert.Equal (expectedSubViewFound, found == subview);
         Assert.Equal (expectedSubViewFound, found == subview);
-        Application.Top.Dispose ();
+        Application.Current.Dispose ();
         Application.ResetState (true);
         Application.ResetState (true);
     }
     }
 
 
@@ -347,17 +347,17 @@ public class GetViewsUnderLocationTests
     {
     {
         Application.ResetState (true);
         Application.ResetState (true);
 
 
-        Application.Top = new ()
+        Application.Current = new ()
         {
         {
             Id = "Top",
             Id = "Top",
             Width = 10, Height = 10
             Width = 10, Height = 10
         };
         };
-        Application.Top.Margin!.Thickness = new (1);
-        Application.Top.Margin!.Id = "Margin";
-        Application.Top.Border!.Thickness = new (1);
-        Application.Top.Border!.Id = "Border";
-        Application.Top.Padding!.Thickness = new (1);
-        Application.Top.Padding.Id = "Padding";
+        Application.Current.Margin!.Thickness = new (1);
+        Application.Current.Margin!.Id = "Margin";
+        Application.Current.Border!.Thickness = new (1);
+        Application.Current.Border!.Id = "Border";
+        Application.Current.Padding!.Thickness = new (1);
+        Application.Current.Padding.Id = "Padding";
 
 
         var subview = new View
         var subview = new View
         {
         {
@@ -365,13 +365,13 @@ public class GetViewsUnderLocationTests
             X = 1, Y = 1,
             X = 1, Y = 1,
             Width = 1, Height = 1
             Width = 1, Height = 1
         };
         };
-        Application.Top.Add (subview);
+        Application.Current.Add (subview);
 
 
         List<View?> viewsUnderMouse = View.GetViewsUnderLocation (new (testX, testY), ViewportSettingsFlags.TransparentMouse);
         List<View?> viewsUnderMouse = View.GetViewsUnderLocation (new (testX, testY), ViewportSettingsFlags.TransparentMouse);
         string [] foundIds = viewsUnderMouse.Select (v => v!.Id).ToArray ();
         string [] foundIds = viewsUnderMouse.Select (v => v!.Id).ToArray ();
 
 
         Assert.Equal (expectedViewsFound, foundIds);
         Assert.Equal (expectedViewsFound, foundIds);
-        Application.Top.Dispose ();
+        Application.Current.Dispose ();
         Application.ResetState (true);
         Application.ResetState (true);
     }
     }
 
 
@@ -388,7 +388,7 @@ public class GetViewsUnderLocationTests
     [InlineData (2, 3, new [] { "Top", "subview" })]
     [InlineData (2, 3, new [] { "Top", "subview" })]
     public void Returns_Correct_If_SubView_Has_Adornments (int testX, int testY, string [] expectedViewsFound)
     public void Returns_Correct_If_SubView_Has_Adornments (int testX, int testY, string [] expectedViewsFound)
     {
     {
-        Application.Top = new ()
+        Application.Current = new ()
         {
         {
             Id = "Top",
             Id = "Top",
             Width = 10, Height = 10
             Width = 10, Height = 10
@@ -402,13 +402,13 @@ public class GetViewsUnderLocationTests
         };
         };
         subview.Border!.Thickness = new (1);
         subview.Border!.Thickness = new (1);
         subview.Border!.Id = "border";
         subview.Border!.Id = "border";
-        Application.Top.Add (subview);
+        Application.Current.Add (subview);
 
 
         List<View?> viewsUnderMouse = View.GetViewsUnderLocation (new (testX, testY), ViewportSettingsFlags.TransparentMouse);
         List<View?> viewsUnderMouse = View.GetViewsUnderLocation (new (testX, testY), ViewportSettingsFlags.TransparentMouse);
         string [] foundIds = viewsUnderMouse.Select (v => v!.Id).ToArray ();
         string [] foundIds = viewsUnderMouse.Select (v => v!.Id).ToArray ();
 
 
         Assert.Equal (expectedViewsFound, foundIds);
         Assert.Equal (expectedViewsFound, foundIds);
-        Application.Top.Dispose ();
+        Application.Current.Dispose ();
         Application.ResetState (true);
         Application.ResetState (true);
     }
     }
 
 
@@ -425,7 +425,7 @@ public class GetViewsUnderLocationTests
     [InlineData (2, 3, new [] { "Top", "subview" })]
     [InlineData (2, 3, new [] { "Top", "subview" })]
     public void Returns_Correct_If_SubView_Has_Adornments_With_TransparentMouse (int testX, int testY, string [] expectedViewsFound)
     public void Returns_Correct_If_SubView_Has_Adornments_With_TransparentMouse (int testX, int testY, string [] expectedViewsFound)
     {
     {
-        Application.Top = new ()
+        Application.Current = new ()
         {
         {
             Id = "Top",
             Id = "Top",
             Width = 10, Height = 10
             Width = 10, Height = 10
@@ -440,13 +440,13 @@ public class GetViewsUnderLocationTests
         subview.Border!.Thickness = new (1);
         subview.Border!.Thickness = new (1);
         subview.Border!.ViewportSettings = ViewportSettingsFlags.TransparentMouse;
         subview.Border!.ViewportSettings = ViewportSettingsFlags.TransparentMouse;
         subview.Border!.Id = "border";
         subview.Border!.Id = "border";
-        Application.Top.Add (subview);
+        Application.Current.Add (subview);
 
 
         List<View?> viewsUnderMouse = View.GetViewsUnderLocation (new (testX, testY), ViewportSettingsFlags.TransparentMouse);
         List<View?> viewsUnderMouse = View.GetViewsUnderLocation (new (testX, testY), ViewportSettingsFlags.TransparentMouse);
         string [] foundIds = viewsUnderMouse.Select (v => v!.Id).ToArray ();
         string [] foundIds = viewsUnderMouse.Select (v => v!.Id).ToArray ();
 
 
         Assert.Equal (expectedViewsFound, foundIds);
         Assert.Equal (expectedViewsFound, foundIds);
-        Application.Top.Dispose ();
+        Application.Current.Dispose ();
         Application.ResetState (true);
         Application.ResetState (true);
     }
     }
 
 
@@ -463,7 +463,7 @@ public class GetViewsUnderLocationTests
     [InlineData (5, 5, true)]
     [InlineData (5, 5, true)]
     public void Returns_Correct_If_SubView_Has_Adornment_WithSubView (int testX, int testY, bool expectedSubViewFound)
     public void Returns_Correct_If_SubView_Has_Adornment_WithSubView (int testX, int testY, bool expectedSubViewFound)
     {
     {
-        Application.Top = new ()
+        Application.Current = new ()
         {
         {
             Width = 10, Height = 10
             Width = 10, Height = 10
         };
         };
@@ -486,14 +486,14 @@ public class GetViewsUnderLocationTests
             Height = 1
             Height = 1
         };
         };
         subview.Padding.Add (paddingSubView);
         subview.Padding.Add (paddingSubView);
-        Application.Top.Add (subview);
-        Application.Top.BeginInit ();
-        Application.Top.EndInit ();
+        Application.Current.Add (subview);
+        Application.Current.BeginInit ();
+        Application.Current.EndInit ();
 
 
         View? found = View.GetViewsUnderLocation (new (testX, testY), ViewportSettingsFlags.TransparentMouse).LastOrDefault ();
         View? found = View.GetViewsUnderLocation (new (testX, testY), ViewportSettingsFlags.TransparentMouse).LastOrDefault ();
 
 
         Assert.Equal (expectedSubViewFound, found == paddingSubView);
         Assert.Equal (expectedSubViewFound, found == paddingSubView);
-        Application.Top.Dispose ();
+        Application.Current.Dispose ();
         Application.ResetState (true);
         Application.ResetState (true);
     }
     }
 
 
@@ -510,7 +510,7 @@ public class GetViewsUnderLocationTests
     [InlineData (5, 5, true)]
     [InlineData (5, 5, true)]
     public void Returns_Correct_If_SubView_Is_Scrolled_And_Has_Adornment_WithSubView (int testX, int testY, bool expectedSubViewFound)
     public void Returns_Correct_If_SubView_Is_Scrolled_And_Has_Adornment_WithSubView (int testX, int testY, bool expectedSubViewFound)
     {
     {
-        Application.Top = new ()
+        Application.Current = new ()
         {
         {
             Width = 10, Height = 10
             Width = 10, Height = 10
         };
         };
@@ -537,14 +537,14 @@ public class GetViewsUnderLocationTests
             Height = 1
             Height = 1
         };
         };
         subview.Padding.Add (paddingSubView);
         subview.Padding.Add (paddingSubView);
-        Application.Top.Add (subview);
-        Application.Top.BeginInit ();
-        Application.Top.EndInit ();
+        Application.Current.Add (subview);
+        Application.Current.BeginInit ();
+        Application.Current.EndInit ();
 
 
         View? found = View.GetViewsUnderLocation (new (testX, testY), ViewportSettingsFlags.TransparentMouse).LastOrDefault ();
         View? found = View.GetViewsUnderLocation (new (testX, testY), ViewportSettingsFlags.TransparentMouse).LastOrDefault ();
 
 
         Assert.Equal (expectedSubViewFound, found == paddingSubView);
         Assert.Equal (expectedSubViewFound, found == paddingSubView);
-        Application.Top.Dispose ();
+        Application.Current.Dispose ();
         Application.ResetState (true);
         Application.ResetState (true);
     }
     }
 
 
@@ -560,7 +560,7 @@ public class GetViewsUnderLocationTests
     [InlineData (5, 5, 2)]
     [InlineData (5, 5, 2)]
     public void Returns_Correct_With_NestedSubViews (int testX, int testY, int expectedSubViewFound)
     public void Returns_Correct_With_NestedSubViews (int testX, int testY, int expectedSubViewFound)
     {
     {
-        Application.Top = new ()
+        Application.Current = new ()
         {
         {
             Width = 10, Height = 10
             Width = 10, Height = 10
         };
         };
@@ -583,11 +583,11 @@ public class GetViewsUnderLocationTests
             }
             }
         }
         }
 
 
-        Application.Top.Add (subviews [0]);
+        Application.Current.Add (subviews [0]);
 
 
         View? found = View.GetViewsUnderLocation (new (testX, testY), ViewportSettingsFlags.TransparentMouse).LastOrDefault ();
         View? found = View.GetViewsUnderLocation (new (testX, testY), ViewportSettingsFlags.TransparentMouse).LastOrDefault ();
         Assert.Equal (expectedSubViewFound, subviews.IndexOf (found!));
         Assert.Equal (expectedSubViewFound, subviews.IndexOf (found!));
-        Application.Top.Dispose ();
+        Application.Current.Dispose ();
         Application.ResetState (true);
         Application.ResetState (true);
     }
     }
 
 
@@ -604,7 +604,7 @@ public class GetViewsUnderLocationTests
     public void Tiled_SubViews (int mouseX, int mouseY, string [] viewIdStrings)
     public void Tiled_SubViews (int mouseX, int mouseY, string [] viewIdStrings)
     {
     {
         // Arrange
         // Arrange
-        Application.Top = new ()
+        Application.Current = new ()
         {
         {
             Frame = new (0, 0, 10, 10),
             Frame = new (0, 0, 10, 10),
             Id = "top"
             Id = "top"
@@ -630,7 +630,7 @@ public class GetViewsUnderLocationTests
             Arrangement = ViewArrangement.Overlapped
             Arrangement = ViewArrangement.Overlapped
         }; // at 2,2 to 4,3 (screen)
         }; // at 2,2 to 4,3 (screen)
         view.Add (subView);
         view.Add (subView);
-        Application.Top.Add (view);
+        Application.Current.Add (view);
 
 
         List<View?> found = View.GetViewsUnderLocation (new (mouseX, mouseY), ViewportSettingsFlags.TransparentMouse);
         List<View?> found = View.GetViewsUnderLocation (new (mouseX, mouseY), ViewportSettingsFlags.TransparentMouse);
 
 
@@ -638,7 +638,7 @@ public class GetViewsUnderLocationTests
 
 
         Assert.Equal (viewIdStrings, foundIds);
         Assert.Equal (viewIdStrings, foundIds);
 
 
-        Application.Top.Dispose ();
+        Application.Current.Dispose ();
         Application.ResetState (true);
         Application.ResetState (true);
     }
     }
 
 
@@ -656,7 +656,7 @@ public class GetViewsUnderLocationTests
     public void Popover (int mouseX, int mouseY, string [] viewIdStrings)
     public void Popover (int mouseX, int mouseY, string [] viewIdStrings)
     {
     {
         // Arrange
         // Arrange
-        Application.Top = new ()
+        Application.Current = new ()
         {
         {
             Frame = new (0, 0, 10, 10),
             Frame = new (0, 0, 10, 10),
             Id = "top"
             Id = "top"
@@ -683,7 +683,7 @@ public class GetViewsUnderLocationTests
         }; // at 2,2 to 4,3 (screen)
         }; // at 2,2 to 4,3 (screen)
 
 
         view.Add (popOver);
         view.Add (popOver);
-        Application.Top.Add (view);
+        Application.Current.Add (view);
 
 
         List<View?> found = View.GetViewsUnderLocation (new (mouseX, mouseY), ViewportSettingsFlags.TransparentMouse);
         List<View?> found = View.GetViewsUnderLocation (new (mouseX, mouseY), ViewportSettingsFlags.TransparentMouse);
 
 
@@ -691,7 +691,7 @@ public class GetViewsUnderLocationTests
 
 
         Assert.Equal (viewIdStrings, foundIds);
         Assert.Equal (viewIdStrings, foundIds);
 
 
-        Application.Top.Dispose ();
+        Application.Current.Dispose ();
         Application.ResetState (true);
         Application.ResetState (true);
     }
     }
 
 
@@ -714,10 +714,10 @@ public class GetViewsUnderLocationTests
         secondaryToplevel.Margin!.Thickness = new (1);
         secondaryToplevel.Margin!.Thickness = new (1);
         secondaryToplevel.Layout ();
         secondaryToplevel.Layout ();
 
 
-        Application.TopLevels.Clear ();
-        Application.TopLevels.Push (topToplevel);
-        Application.TopLevels.Push (secondaryToplevel);
-        Application.Top = secondaryToplevel;
+        Application.SessionStack.Clear ();
+        Application.SessionStack.Push (topToplevel);
+        Application.SessionStack.Push (secondaryToplevel);
+        Application.Current = secondaryToplevel;
 
 
         List<View?> found = View.GetViewsUnderLocation (new (2, 2), ViewportSettingsFlags.TransparentMouse);
         List<View?> found = View.GetViewsUnderLocation (new (2, 2), ViewportSettingsFlags.TransparentMouse);
         Assert.Contains (found, v => v?.Id == topToplevel.Id);
         Assert.Contains (found, v => v?.Id == topToplevel.Id);
@@ -725,7 +725,7 @@ public class GetViewsUnderLocationTests
 
 
         topToplevel.Dispose ();
         topToplevel.Dispose ();
         secondaryToplevel.Dispose ();
         secondaryToplevel.Dispose ();
-        Application.TopLevels.Clear ();
+        Application.SessionStack.Clear ();
         Application.ResetState (true);
         Application.ResetState (true);
     }
     }
 
 
@@ -748,10 +748,10 @@ public class GetViewsUnderLocationTests
         secondaryToplevel.Margin!.Thickness = new (1);
         secondaryToplevel.Margin!.Thickness = new (1);
         secondaryToplevel.Layout ();
         secondaryToplevel.Layout ();
 
 
-        Application.TopLevels.Clear ();
-        Application.TopLevels.Push (topToplevel);
-        Application.TopLevels.Push (secondaryToplevel);
-        Application.Top = secondaryToplevel;
+        Application.SessionStack.Clear ();
+        Application.SessionStack.Push (topToplevel);
+        Application.SessionStack.Push (secondaryToplevel);
+        Application.Current = secondaryToplevel;
 
 
         List<View?> found = View.GetViewsUnderLocation (new (7, 7), ViewportSettingsFlags.TransparentMouse);
         List<View?> found = View.GetViewsUnderLocation (new (7, 7), ViewportSettingsFlags.TransparentMouse);
         Assert.Contains (found, v => v?.Id == secondaryToplevel.Id);
         Assert.Contains (found, v => v?.Id == secondaryToplevel.Id);
@@ -759,7 +759,7 @@ public class GetViewsUnderLocationTests
 
 
         topToplevel.Dispose ();
         topToplevel.Dispose ();
         secondaryToplevel.Dispose ();
         secondaryToplevel.Dispose ();
-        Application.TopLevels.Clear ();
+        Application.SessionStack.Clear ();
         Application.ResetState (true);
         Application.ResetState (true);
     }
     }
 
 
@@ -781,10 +781,10 @@ public class GetViewsUnderLocationTests
         };
         };
         secondaryToplevel.Margin!.Thickness = new (1);
         secondaryToplevel.Margin!.Thickness = new (1);
 
 
-        Application.TopLevels.Clear ();
-        Application.TopLevels.Push (topToplevel);
-        Application.TopLevels.Push (secondaryToplevel);
-        Application.Top = secondaryToplevel;
+        Application.SessionStack.Clear ();
+        Application.SessionStack.Push (topToplevel);
+        Application.SessionStack.Push (secondaryToplevel);
+        Application.Current = secondaryToplevel;
 
 
         secondaryToplevel.Margin!.ViewportSettings = ViewportSettingsFlags.None;
         secondaryToplevel.Margin!.ViewportSettings = ViewportSettingsFlags.None;
 
 
@@ -801,7 +801,7 @@ public class GetViewsUnderLocationTests
 
 
         topToplevel.Dispose ();
         topToplevel.Dispose ();
         secondaryToplevel.Dispose ();
         secondaryToplevel.Dispose ();
-        Application.TopLevels.Clear ();
+        Application.SessionStack.Clear ();
         Application.ResetState (true);
         Application.ResetState (true);
     }
     }
 
 
@@ -824,17 +824,17 @@ public class GetViewsUnderLocationTests
         secondaryToplevel.Margin!.Thickness = new (1);
         secondaryToplevel.Margin!.Thickness = new (1);
         secondaryToplevel.Layout ();
         secondaryToplevel.Layout ();
 
 
-        Application.TopLevels.Clear ();
-        Application.TopLevels.Push (topToplevel);
-        Application.TopLevels.Push (secondaryToplevel);
-        Application.Top = secondaryToplevel;
+        Application.SessionStack.Clear ();
+        Application.SessionStack.Push (topToplevel);
+        Application.SessionStack.Push (secondaryToplevel);
+        Application.Current = secondaryToplevel;
 
 
         List<View?> found = View.GetViewsUnderLocation (new (20, 20), ViewportSettingsFlags.TransparentMouse);
         List<View?> found = View.GetViewsUnderLocation (new (20, 20), ViewportSettingsFlags.TransparentMouse);
         Assert.Empty (found);
         Assert.Empty (found);
 
 
         topToplevel.Dispose ();
         topToplevel.Dispose ();
         secondaryToplevel.Dispose ();
         secondaryToplevel.Dispose ();
-        Application.TopLevels.Clear ();
+        Application.SessionStack.Clear ();
         Application.ResetState (true);
         Application.ResetState (true);
     }
     }
 }
 }

+ 11 - 11
Tests/UnitTests/View/Layout/Pos.CombineTests.cs

@@ -40,7 +40,7 @@ public class PosCombineTests (ITestOutputHelper output)
     [SetupFakeApplication]
     [SetupFakeApplication]
     public void PosCombine_DimCombine_View_With_SubViews ()
     public void PosCombine_DimCombine_View_With_SubViews ()
     {
     {
-        Application.Top = new Toplevel () { Width = 80, Height = 25 };
+        Application.Current = new Toplevel () { Width = 80, Height = 25 };
         var win1 = new Window { Id = "win1", Width = 20, Height = 10 };
         var win1 = new Window { Id = "win1", Width = 20, Height = 10 };
         var view1 = new View
         var view1 = new View
         {
         {
@@ -59,10 +59,10 @@ public class PosCombineTests (ITestOutputHelper output)
         view2.Add (view3);
         view2.Add (view3);
         win2.Add (view2);
         win2.Add (view2);
         win1.Add (view1, win2);
         win1.Add (view1, win2);
-        Application.Top.Add (win1);
-        Application.Top.Layout ();
+        Application.Current.Add (win1);
+        Application.Current.Layout ();
 
 
-        Assert.Equal (new Rectangle (0, 0, 80, 25), Application.Top.Frame);
+        Assert.Equal (new Rectangle (0, 0, 80, 25), Application.Current.Frame);
         Assert.Equal (new Rectangle (0, 0, 5, 1), view1.Frame);
         Assert.Equal (new Rectangle (0, 0, 5, 1), view1.Frame);
         Assert.Equal (new Rectangle (0, 0, 20, 10), win1.Frame);
         Assert.Equal (new Rectangle (0, 0, 20, 10), win1.Frame);
         Assert.Equal (new Rectangle (0, 2, 10, 3), win2.Frame);
         Assert.Equal (new Rectangle (0, 2, 10, 3), win2.Frame);
@@ -70,7 +70,7 @@ public class PosCombineTests (ITestOutputHelper output)
         Assert.Equal (new Rectangle (0, 0, 7, 1), view3.Frame);
         Assert.Equal (new Rectangle (0, 0, 7, 1), view3.Frame);
         var foundView = View.GetViewsUnderLocation (new Point(9, 4), ViewportSettingsFlags.None).LastOrDefault ();
         var foundView = View.GetViewsUnderLocation (new Point(9, 4), ViewportSettingsFlags.None).LastOrDefault ();
         Assert.Equal (foundView, view2);
         Assert.Equal (foundView, view2);
-        Application.Top.Dispose ();
+        Application.Current.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -89,13 +89,13 @@ public class PosCombineTests (ITestOutputHelper output)
         top.Add (w);
         top.Add (w);
         Application.Begin (top);
         Application.Begin (top);
 
 
-        f.X = Pos.X (Application.Top) + Pos.X (v2) - Pos.X (v1);
-        f.Y = Pos.Y (Application.Top) + Pos.Y (v2) - Pos.Y (v1);
+        f.X = Pos.X (Application.Current) + Pos.X (v2) - Pos.X (v1);
+        f.Y = Pos.Y (Application.Current) + Pos.Y (v2) - Pos.Y (v1);
 
 
-        Application.Top.SubViewsLaidOut += (s, e) =>
+        Application.Current.SubViewsLaidOut += (s, e) =>
         {
         {
-            Assert.Equal (0, Application.Top.Frame.X);
-            Assert.Equal (0, Application.Top.Frame.Y);
+            Assert.Equal (0, Application.Current.Frame.X);
+            Assert.Equal (0, Application.Current.Frame.Y);
             Assert.Equal (2, w.Frame.X);
             Assert.Equal (2, w.Frame.X);
             Assert.Equal (2, w.Frame.Y);
             Assert.Equal (2, w.Frame.Y);
             Assert.Equal (2, f.Frame.X);
             Assert.Equal (2, f.Frame.X);
@@ -109,7 +109,7 @@ public class PosCombineTests (ITestOutputHelper output)
         Application.StopAfterFirstIteration = true;
         Application.StopAfterFirstIteration = true;
 
 
         Assert.Throws<LayoutException> (() => Application.Run ());
         Assert.Throws<LayoutException> (() => Application.Run ());
-        Application.Top.Dispose ();
+        Application.Current.Dispose ();
         top.Dispose ();
         top.Dispose ();
         Application.Shutdown ();
         Application.Shutdown ();
     }
     }

+ 8 - 8
Tests/UnitTests/View/Layout/SetLayoutTests.cs

@@ -12,7 +12,7 @@ public class SetLayoutTests (ITestOutputHelper output)
     [AutoInitShutdown]
     [AutoInitShutdown]
     public void Screen_Size_Change_Causes_Layout ()
     public void Screen_Size_Change_Causes_Layout ()
     {
     {
-        Application.Top = new ();
+        Application.Current = new ();
 
 
         var view = new View
         var view = new View
         {
         {
@@ -22,21 +22,21 @@ public class SetLayoutTests (ITestOutputHelper output)
             Height = 1,
             Height = 1,
             Text = "0123456789"
             Text = "0123456789"
         };
         };
-        Application.Top.Add (view);
+        Application.Current.Add (view);
 
 
-        var rs = Application.Begin (Application.Top);
+        var rs = Application.Begin (Application.Current);
         Application.Driver!.SetScreenSize (80, 25);
         Application.Driver!.SetScreenSize (80, 25);
 
 
         Assert.Equal (new (0, 0, 80, 25), new Rectangle (0, 0, Application.Screen.Width, Application.Screen.Height));
         Assert.Equal (new (0, 0, 80, 25), new Rectangle (0, 0, Application.Screen.Width, Application.Screen.Height));
-        Assert.Equal (new (0, 0, Application.Screen.Width, Application.Screen.Height), Application.Top.Frame);
-        Assert.Equal (new (0, 0, 80, 25), Application.Top.Frame);
+        Assert.Equal (new (0, 0, Application.Screen.Width, Application.Screen.Height), Application.Current.Frame);
+        Assert.Equal (new (0, 0, 80, 25), Application.Current.Frame);
 
 
         Application.Driver!.SetScreenSize (20, 10);
         Application.Driver!.SetScreenSize (20, 10);
-        Assert.Equal (new (0, 0, Application.Screen.Width, Application.Screen.Height), Application.Top.Frame);
+        Assert.Equal (new (0, 0, Application.Screen.Width, Application.Screen.Height), Application.Current.Frame);
 
 
-        Assert.Equal (new (0, 0, 20, 10), Application.Top.Frame);
+        Assert.Equal (new (0, 0, 20, 10), Application.Current.Frame);
 
 
         Application.End (rs);
         Application.End (rs);
-        Application.Top.Dispose ();
+        Application.Current.Dispose ();
     }
     }
 }
 }

+ 4 - 4
Tests/UnitTests/View/Navigation/CanFocusTests.cs

@@ -91,10 +91,10 @@ public class CanFocusTests
         Label label = new () { Text = "label" };
         Label label = new () { Text = "label" };
         View view = new () { Text = "view", CanFocus = true };
         View view = new () { Text = "view", CanFocus = true };
         Application.Navigation = new ();
         Application.Navigation = new ();
-        Application.Top = new ();
-        Application.Top.Add (label, view);
+        Application.Current = new ();
+        Application.Current.Add (label, view);
 
 
-        Application.Top.SetFocus ();
+        Application.Current.SetFocus ();
         Assert.Equal (view, Application.Navigation.GetFocused ());
         Assert.Equal (view, Application.Navigation.GetFocused ());
         Assert.False (label.CanFocus);
         Assert.False (label.CanFocus);
         Assert.False (label.HasFocus);
         Assert.False (label.HasFocus);
@@ -124,7 +124,7 @@ public class CanFocusTests
         Assert.True (label.HasFocus);
         Assert.True (label.HasFocus);
         Assert.False (view.HasFocus);
         Assert.False (view.HasFocus);
 
 
-        Application.Top.Dispose ();
+        Application.Current.Dispose ();
         Application.ResetState ();
         Application.ResetState ();
     }
     }
 }
 }

+ 5 - 5
Tests/UnitTests/View/Navigation/NavigationTests.cs

@@ -27,7 +27,7 @@ public class NavigationTests (ITestOutputHelper output) : TestsAllViews
         }
         }
 
 
         Toplevel top = new ();
         Toplevel top = new ();
-        Application.Top = top;
+        Application.Current = top;
         Application.Navigation = new ();
         Application.Navigation = new ();
 
 
         View otherView = new ()
         View otherView = new ()
@@ -118,7 +118,7 @@ public class NavigationTests (ITestOutputHelper output) : TestsAllViews
         }
         }
 
 
         Toplevel top = new ();
         Toplevel top = new ();
-        Application.Top = top;
+        Application.Current = top;
         Application.Navigation = new ();
         Application.Navigation = new ();
 
 
         View otherView = new ()
         View otherView = new ()
@@ -150,8 +150,8 @@ public class NavigationTests (ITestOutputHelper output) : TestsAllViews
         // Ensure the view is Visible
         // Ensure the view is Visible
         view.Visible = true;
         view.Visible = true;
 
 
-        Application.Top.SetFocus ();
-        Assert.True (Application.Top!.HasFocus);
+        Application.Current.SetFocus ();
+        Assert.True (Application.Current!.HasFocus);
         Assert.True (top.HasFocus);
         Assert.True (top.HasFocus);
 
 
         // Start with the focus on our test view
         // Start with the focus on our test view
@@ -282,7 +282,7 @@ public class NavigationTests (ITestOutputHelper output) : TestsAllViews
 
 
         Toplevel top = new ();
         Toplevel top = new ();
 
 
-        Application.Top = top;
+        Application.Current = top;
         Application.Navigation = new ();
         Application.Navigation = new ();
 
 
         View otherView = new ()
         View otherView = new ()

+ 1 - 1
Tests/UnitTests/View/TextTests.cs

@@ -394,7 +394,7 @@ Y
         Assert.Equal (new (1, 5), view.TextFormatter.ConstrainToSize);
         Assert.Equal (new (1, 5), view.TextFormatter.ConstrainToSize);
         Assert.Equal (new () { "Views" }, view.TextFormatter.GetLines ());
         Assert.Equal (new () { "Views" }, view.TextFormatter.GetLines ());
         Assert.Equal (new (0, 0, 4, 10), win.Frame);
         Assert.Equal (new (0, 0, 4, 10), win.Frame);
-        Assert.Equal (new (0, 0, 4, 10), Application.Top.Frame);
+        Assert.Equal (new (0, 0, 4, 10), Application.Current.Frame);
 
 
         var expected = @"
         var expected = @"
 ┌──┐
 ┌──┐

+ 6 - 6
Tests/UnitTests/View/ViewCommandTests.cs

@@ -46,9 +46,9 @@ public class ViewCommandTests
 
 
         w.LayoutSubViews ();
         w.LayoutSubViews ();
 
 
-        Application.Top = w;
-        Application.TopLevels.Push (w);
-        Assert.Same (Application.Top, w);
+        Application.Current = w;
+        Application.SessionStack.Push (w);
+        Assert.Same (Application.Current, w);
 
 
         // Click button 2
         // Click button 2
         Rectangle btn2Frame = btnB.FrameToScreen ();
         Rectangle btn2Frame = btnB.FrameToScreen ();
@@ -121,9 +121,9 @@ public class ViewCommandTests
 
 
         w.Add (btn);
         w.Add (btn);
 
 
-        Application.Top = w;
-        Application.TopLevels.Push (w);
-        Assert.Same (Application.Top, w);
+        Application.Current = w;
+        Application.SessionStack.Push (w);
+        Assert.Same (Application.Current, w);
 
 
         w.LayoutSubViews ();
         w.LayoutSubViews ();
 
 

+ 3 - 3
Tests/UnitTests/View/Viewport/ViewportSettings.TransparentMouseTests.cs

@@ -23,7 +23,7 @@ public class TransparentMouseTests
         {
         {
             Id = "top",
             Id = "top",
         };
         };
-        Application.Top = top;
+        Application.Current = top;
 
 
         var underlying = new MouseTrackingView { Id = "underlying", X = 0, Y = 0, Width = 10, Height = 10 };
         var underlying = new MouseTrackingView { Id = "underlying", X = 0, Y = 0, Width = 10, Height = 10 };
         var overlay = new MouseTrackingView { Id = "overlay", X = 0, Y = 0, Width = 10, Height = 10, ViewportSettings = ViewportSettingsFlags.TransparentMouse };
         var overlay = new MouseTrackingView { Id = "overlay", X = 0, Y = 0, Width = 10, Height = 10, ViewportSettings = ViewportSettingsFlags.TransparentMouse };
@@ -56,7 +56,7 @@ public class TransparentMouseTests
     {
     {
         // Arrange
         // Arrange
         var top = new Toplevel ();
         var top = new Toplevel ();
-        Application.Top = top;
+        Application.Current = top;
 
 
         var underlying = new MouseTrackingView { X = 0, Y = 0, Width = 10, Height = 10 };
         var underlying = new MouseTrackingView { X = 0, Y = 0, Width = 10, Height = 10 };
         var overlay = new MouseTrackingView { X = 0, Y = 0, Width = 10, Height = 10, ViewportSettings = ViewportSettingsFlags.None };
         var overlay = new MouseTrackingView { X = 0, Y = 0, Width = 10, Height = 10, ViewportSettings = ViewportSettingsFlags.None };
@@ -90,7 +90,7 @@ public class TransparentMouseTests
     {
     {
         // Arrange
         // Arrange
         var top = new Toplevel ();
         var top = new Toplevel ();
-        Application.Top = top;
+        Application.Current = top;
 
 
         var underlying = new MouseTrackingView { X = 0, Y = 0, Width = 10, Height = 10, ViewportSettings = ViewportSettingsFlags.TransparentMouse };
         var underlying = new MouseTrackingView { X = 0, Y = 0, Width = 10, Height = 10, ViewportSettings = ViewportSettingsFlags.TransparentMouse };
         var overlay = new MouseTrackingView { X = 0, Y = 0, Width = 10, Height = 10, ViewportSettings = ViewportSettingsFlags.TransparentMouse };
         var overlay = new MouseTrackingView { X = 0, Y = 0, Width = 10, Height = 10, ViewportSettings = ViewportSettingsFlags.TransparentMouse };

+ 12 - 12
Tests/UnitTests/Views/AppendAutocompleteTests.cs

@@ -30,12 +30,12 @@ public class AppendAutocompleteTests (ITestOutputHelper output)
         Assert.Equal ("f", tf.Text);
         Assert.Equal ("f", tf.Text);
 
 
         // Still has focus though
         // Still has focus though
-        Assert.Same (tf, Application.Top.Focused);
+        Assert.Same (tf, Application.Current.Focused);
 
 
         // But can tab away
         // But can tab away
         Application.RaiseKeyDownEvent ('\t');
         Application.RaiseKeyDownEvent ('\t');
-        Assert.NotSame (tf, Application.Top.Focused);
-        Application.Top.Dispose ();
+        Assert.NotSame (tf, Application.Current.Focused);
+        Application.Current.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -69,7 +69,7 @@ public class AppendAutocompleteTests (ITestOutputHelper output)
         tf.PositionCursor ();
         tf.PositionCursor ();
         DriverAssert.AssertDriverContentsAre ("fish", output);
         DriverAssert.AssertDriverContentsAre ("fish", output);
         Assert.Equal ("fi", tf.Text);
         Assert.Equal ("fi", tf.Text);
-        Application.Top.Dispose ();
+        Application.Current.Dispose ();
     }
     }
 
 
     [Theory]
     [Theory]
@@ -107,7 +107,7 @@ public class AppendAutocompleteTests (ITestOutputHelper output)
         tf.PositionCursor ();
         tf.PositionCursor ();
         DriverAssert.AssertDriverContentsAre ("fish", output);
         DriverAssert.AssertDriverContentsAre ("fish", output);
         Assert.Equal ("f", tf.Text);
         Assert.Equal ("f", tf.Text);
-        Application.Top.Dispose ();
+        Application.Current.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -133,7 +133,7 @@ public class AppendAutocompleteTests (ITestOutputHelper output)
         tf.Draw ();
         tf.Draw ();
         DriverAssert.AssertDriverContentsAre ("f", output);
         DriverAssert.AssertDriverContentsAre ("f", output);
         Assert.Equal ("f ", tf.Text);
         Assert.Equal ("f ", tf.Text);
-        Application.Top.Dispose ();
+        Application.Current.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -157,7 +157,7 @@ public class AppendAutocompleteTests (ITestOutputHelper output)
         tf.Draw ();
         tf.Draw ();
         DriverAssert.AssertDriverContentsAre ("fx", output);
         DriverAssert.AssertDriverContentsAre ("fx", output);
         Assert.Equal ("fx", tf.Text);
         Assert.Equal ("fx", tf.Text);
-        Application.Top.Dispose ();
+        Application.Current.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -195,7 +195,7 @@ public class AppendAutocompleteTests (ITestOutputHelper output)
         tf.Draw ();
         tf.Draw ();
         DriverAssert.AssertDriverContentsAre ("my FISH", output);
         DriverAssert.AssertDriverContentsAre ("my FISH", output);
         Assert.Equal ("my FISH", tf.Text);
         Assert.Equal ("my FISH", tf.Text);
-        Application.Top.Dispose ();
+        Application.Current.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -231,12 +231,12 @@ public class AppendAutocompleteTests (ITestOutputHelper output)
         Assert.Equal ("fish", tf.Text);
         Assert.Equal ("fish", tf.Text);
 
 
         // Tab should autcomplete but not move focus
         // Tab should autcomplete but not move focus
-        Assert.Same (tf, Application.Top.Focused);
+        Assert.Same (tf, Application.Current.Focused);
 
 
         // Second tab should move focus (nothing to autocomplete)
         // Second tab should move focus (nothing to autocomplete)
         Application.RaiseKeyDownEvent ('\t');
         Application.RaiseKeyDownEvent ('\t');
-        Assert.NotSame (tf, Application.Top.Focused);
-        Application.Top.Dispose ();
+        Assert.NotSame (tf, Application.Current.Focused);
+        Application.Current.Dispose ();
     }
     }
 
 
     [Theory]
     [Theory]
@@ -256,7 +256,7 @@ public class AppendAutocompleteTests (ITestOutputHelper output)
         tf.PositionCursor ();
         tf.PositionCursor ();
         DriverAssert.AssertDriverContentsAre (expectRender, output);
         DriverAssert.AssertDriverContentsAre (expectRender, output);
         Assert.Equal ("f", tf.Text);
         Assert.Equal ("f", tf.Text);
-        Application.Top.Dispose ();
+        Application.Current.Dispose ();
     }
     }
 
 
     private TextField GetTextFieldsInView ()
     private TextField GetTextFieldsInView ()

+ 1 - 1
Tests/UnitTests/Views/ButtonTests.cs

@@ -204,7 +204,7 @@ public class ButtonTests (ITestOutputHelper output)
         clicked = false;
         clicked = false;
 
 
         // Toplevel does not handle Enter, so it should get passed on to button
         // Toplevel does not handle Enter, so it should get passed on to button
-        Assert.False (Application.Top.NewKeyDownEvent (Key.Enter));
+        Assert.False (Application.Current.NewKeyDownEvent (Key.Enter));
         Assert.True (clicked);
         Assert.True (clicked);
         clicked = false;
         clicked = false;
 
 

+ 4 - 4
Tests/UnitTests/Views/CheckBoxTests.cs

@@ -16,11 +16,11 @@ public class CheckBoxTests (ITestOutputHelper output)
     public void Commands_Select ()
     public void Commands_Select ()
     {
     {
         Application.Navigation = new ();
         Application.Navigation = new ();
-        Application.Top = new ();
+        Application.Current = new ();
         View otherView = new () { CanFocus = true };
         View otherView = new () { CanFocus = true };
         var ckb = new CheckBox ();
         var ckb = new CheckBox ();
-        Application.Top.Add (ckb, otherView);
-        Application.Top.SetFocus ();
+        Application.Current.Add (ckb, otherView);
+        Application.Current.SetFocus ();
         Assert.True (ckb.HasFocus);
         Assert.True (ckb.HasFocus);
 
 
         var checkedStateChangingCount = 0;
         var checkedStateChangingCount = 0;
@@ -64,7 +64,7 @@ public class CheckBoxTests (ITestOutputHelper output)
         Assert.Equal (3, selectCount);
         Assert.Equal (3, selectCount);
         Assert.Equal (1, acceptCount);
         Assert.Equal (1, acceptCount);
 
 
-        Application.Top.Dispose ();
+        Application.Current.Dispose ();
         Application.ResetState ();
         Application.ResetState ();
     }
     }
 
 

+ 5 - 5
Tests/UnitTests/Views/ColorPickerTests.cs

@@ -12,7 +12,7 @@ public class ColorPickerTests
 
 
         var otherView = new View { CanFocus = true };
         var otherView = new View { CanFocus = true };
 
 
-        Application.Top?.Add (otherView); // thi sets focus to otherView
+        Application.Current?.Add (otherView); // thi sets focus to otherView
         Assert.True (otherView.HasFocus);
         Assert.True (otherView.HasFocus);
 
 
         cp.SetFocus ();
         cp.SetFocus ();
@@ -774,11 +774,11 @@ public class ColorPickerTests
 
 
         Application.Navigation = new ();
         Application.Navigation = new ();
 
 
-        Application.Top = new () { Width = 20, Height = 5 };
-        Application.Top.Add (cp);
+        Application.Current = new () { Width = 20, Height = 5 };
+        Application.Current.Add (cp);
 
 
-        Application.Top.LayoutSubViews ();
-        Application.Top.SetFocus ();
+        Application.Current.LayoutSubViews ();
+        Application.Current.SetFocus ();
 
 
         return cp;
         return cp;
     }
     }

+ 2 - 2
Tests/UnitTests/Views/ComboBoxTests.cs

@@ -1016,7 +1016,7 @@ Three
         Application.Navigation = new ();
         Application.Navigation = new ();
         var cb = new ComboBox ();
         var cb = new ComboBox ();
         var top = new Toplevel ();
         var top = new Toplevel ();
-        Application.Top = top;
+        Application.Current = top;
 
 
         top.Add (cb);
         top.Add (cb);
         top.FocusDeepest (NavigationDirection.Forward, null);
         top.FocusDeepest (NavigationDirection.Forward, null);
@@ -1055,7 +1055,7 @@ Three
         Assert.Equal (-1, cb.SelectedItem);
         Assert.Equal (-1, cb.SelectedItem);
         Assert.Equal ("", cb.Text);
         Assert.Equal ("", cb.Text);
 
 
-        Application.Top.Dispose ();
+        Application.Current.Dispose ();
         Application.ResetState (true);
         Application.ResetState (true);
     }
     }
 }
 }

+ 29 - 29
Tests/UnitTests/Views/HexViewTests.cs

@@ -33,9 +33,9 @@ public class HexViewTests
     {
     {
         var hv = new HexView (LoadStream (null, out _, true)) { Width = 20, Height = 20 };
         var hv = new HexView (LoadStream (null, out _, true)) { Width = 20, Height = 20 };
         Application.Navigation = new ApplicationNavigation ();
         Application.Navigation = new ApplicationNavigation ();
-        Application.Top = new Toplevel ();
-        Application.Top.Add (hv);
-        Application.Top.SetFocus ();
+        Application.Current = new Toplevel ();
+        Application.Current.Add (hv);
+        Application.Current.SetFocus ();
 
 
         // Needed because HexView relies on LayoutComplete to calc sizes
         // Needed because HexView relies on LayoutComplete to calc sizes
         hv.LayoutSubViews ();
         hv.LayoutSubViews ();
@@ -70,7 +70,7 @@ public class HexViewTests
         Assert.Empty (hv.Edits);
         Assert.Empty (hv.Edits);
         Assert.Equal (127, hv.Source.Length);
         Assert.Equal (127, hv.Source.Length);
 
 
-        Application.Top.Dispose ();
+        Application.Current.Dispose ();
         Application.ResetState (true);
         Application.ResetState (true);
 
 
     }
     }
@@ -79,7 +79,7 @@ public class HexViewTests
     public void ApplyEdits_With_Argument ()
     public void ApplyEdits_With_Argument ()
     {
     {
         Application.Navigation = new ApplicationNavigation ();
         Application.Navigation = new ApplicationNavigation ();
-        Application.Top = new Toplevel ();
+        Application.Current = new Toplevel ();
 
 
         byte [] buffer = Encoding.Default.GetBytes ("Fest");
         byte [] buffer = Encoding.Default.GetBytes ("Fest");
         var original = new MemoryStream ();
         var original = new MemoryStream ();
@@ -90,8 +90,8 @@ public class HexViewTests
         original.CopyTo (copy);
         original.CopyTo (copy);
         copy.Flush ();
         copy.Flush ();
         var hv = new HexView (copy) { Width = Dim.Fill (), Height = Dim.Fill () };
         var hv = new HexView (copy) { Width = Dim.Fill (), Height = Dim.Fill () };
-        Application.Top.Add (hv);
-        Application.Top.SetFocus ();
+        Application.Current.Add (hv);
+        Application.Current.SetFocus ();
 
 
         // Needed because HexView relies on LayoutComplete to calc sizes
         // Needed because HexView relies on LayoutComplete to calc sizes
         hv.LayoutSubViews ();
         hv.LayoutSubViews ();
@@ -122,7 +122,7 @@ public class HexViewTests
         Assert.Equal ("Zest", Encoding.Default.GetString (readBuffer));
         Assert.Equal ("Zest", Encoding.Default.GetString (readBuffer));
         Assert.Equal (Encoding.Default.GetString (buffer), Encoding.Default.GetString (readBuffer));
         Assert.Equal (Encoding.Default.GetString (buffer), Encoding.Default.GetString (readBuffer));
 
 
-        Application.Top.Dispose ();
+        Application.Current.Dispose ();
         Application.ResetState (true);
         Application.ResetState (true);
     }
     }
 
 
@@ -148,10 +148,10 @@ public class HexViewTests
         Application.Navigation = new ApplicationNavigation ();
         Application.Navigation = new ApplicationNavigation ();
 
 
         var hv = new HexView (LoadStream (null, out _)) { Width = 100, Height = 100 };
         var hv = new HexView (LoadStream (null, out _)) { Width = 100, Height = 100 };
-        Application.Top = new Toplevel ();
-        Application.Top.Add (hv);
+        Application.Current = new Toplevel ();
+        Application.Current.Add (hv);
 
 
-        Application.Top.LayoutSubViews ();
+        Application.Current.LayoutSubViews ();
 
 
         Assert.Equal (63, hv.Source!.Length);
         Assert.Equal (63, hv.Source!.Length);
         Assert.Equal (20, hv.BytesPerLine);
         Assert.Equal (20, hv.BytesPerLine);
@@ -176,7 +176,7 @@ public class HexViewTests
         Assert.Equal (new (3, 3), hv.GetPosition (hv.Address));
         Assert.Equal (new (3, 3), hv.GetPosition (hv.Address));
 
 
         Assert.Equal (hv.Source!.Length, hv.Address);
         Assert.Equal (hv.Source!.Length, hv.Address);
-        Application.Top.Dispose ();
+        Application.Current.Dispose ();
         Application.ResetState (true);
         Application.ResetState (true);
     }
     }
 
 
@@ -186,8 +186,8 @@ public class HexViewTests
         Application.Navigation = new ApplicationNavigation ();
         Application.Navigation = new ApplicationNavigation ();
 
 
         var hv = new HexView (LoadStream (null, out _, unicode: true)) { Width = 100, Height = 100 };
         var hv = new HexView (LoadStream (null, out _, unicode: true)) { Width = 100, Height = 100 };
-        Application.Top = new Toplevel ();
-        Application.Top.Add (hv);
+        Application.Current = new Toplevel ();
+        Application.Current.Add (hv);
 
 
         hv.LayoutSubViews ();
         hv.LayoutSubViews ();
 
 
@@ -213,7 +213,7 @@ public class HexViewTests
         Assert.Equal (new (6, 6), hv.GetPosition (hv.Address));
         Assert.Equal (new (6, 6), hv.GetPosition (hv.Address));
 
 
         Assert.Equal (hv.Source!.Length, hv.Address);
         Assert.Equal (hv.Source!.Length, hv.Address);
-        Application.Top.Dispose ();
+        Application.Current.Dispose ();
         Application.ResetState (true);
         Application.ResetState (true);
     }
     }
 
 
@@ -266,9 +266,9 @@ public class HexViewTests
     public void KeyBindings_Test_Movement_LeftSide ()
     public void KeyBindings_Test_Movement_LeftSide ()
     {
     {
         Application.Navigation = new ApplicationNavigation ();
         Application.Navigation = new ApplicationNavigation ();
-        Application.Top = new Toplevel ();
+        Application.Current = new Toplevel ();
         var hv = new HexView (LoadStream (null, out _)) { Width = 20, Height = 10 };
         var hv = new HexView (LoadStream (null, out _)) { Width = 20, Height = 10 };
-        Application.Top.Add (hv);
+        Application.Current.Add (hv);
 
 
         hv.LayoutSubViews ();
         hv.LayoutSubViews ();
 
 
@@ -314,7 +314,7 @@ public class HexViewTests
 
 
         Assert.True (Application.RaiseKeyDownEvent (Key.CursorUp.WithCtrl));
         Assert.True (Application.RaiseKeyDownEvent (Key.CursorUp.WithCtrl));
         Assert.Equal (0, hv.Address);
         Assert.Equal (0, hv.Address);
-        Application.Top.Dispose ();
+        Application.Current.Dispose ();
         Application.ResetState (true);
         Application.ResetState (true);
     }
     }
 
 
@@ -322,10 +322,10 @@ public class HexViewTests
     public void PositionChanged_Event ()
     public void PositionChanged_Event ()
     {
     {
         var hv = new HexView (LoadStream (null, out _)) { Width = 20, Height = 10 };
         var hv = new HexView (LoadStream (null, out _)) { Width = 20, Height = 10 };
-        Application.Top = new Toplevel ();
-        Application.Top.Add (hv);
+        Application.Current = new Toplevel ();
+        Application.Current.Add (hv);
 
 
-        Application.Top.LayoutSubViews ();
+        Application.Current.LayoutSubViews ();
 
 
         HexViewEventArgs hexViewEventArgs = null!;
         HexViewEventArgs hexViewEventArgs = null!;
         hv.PositionChanged += (s, e) => hexViewEventArgs = e;
         hv.PositionChanged += (s, e) => hexViewEventArgs = e;
@@ -339,7 +339,7 @@ public class HexViewTests
         Assert.Equal (4, hexViewEventArgs.BytesPerLine);
         Assert.Equal (4, hexViewEventArgs.BytesPerLine);
         Assert.Equal (new (1, 1), hexViewEventArgs.Position);
         Assert.Equal (new (1, 1), hexViewEventArgs.Position);
         Assert.Equal (5, hexViewEventArgs.Address);
         Assert.Equal (5, hexViewEventArgs.Address);
-        Application.Top.Dispose ();
+        Application.Current.Dispose ();
         Application.ResetState (true);
         Application.ResetState (true);
     }
     }
 
 
@@ -347,32 +347,32 @@ public class HexViewTests
     public void Source_Sets_Address_To_Zero_If_Greater_Than_Source_Length ()
     public void Source_Sets_Address_To_Zero_If_Greater_Than_Source_Length ()
     {
     {
         var hv = new HexView (LoadStream (null, out _)) { Width = 10, Height = 5 };
         var hv = new HexView (LoadStream (null, out _)) { Width = 10, Height = 5 };
-        Application.Top = new Toplevel ();
-        Application.Top.Add (hv);
+        Application.Current = new Toplevel ();
+        Application.Current.Add (hv);
 
 
-        Application.Top.Layout ();
+        Application.Current.Layout ();
 
 
         Assert.True (hv.NewKeyDownEvent (Key.End));
         Assert.True (hv.NewKeyDownEvent (Key.End));
         Assert.Equal (MEM_STRING_LENGTH, hv.Address);
         Assert.Equal (MEM_STRING_LENGTH, hv.Address);
 
 
         hv.Source = new MemoryStream ();
         hv.Source = new MemoryStream ();
-        Application.Top.Layout ();
+        Application.Current.Layout ();
         Assert.Equal (0, hv.Address);
         Assert.Equal (0, hv.Address);
 
 
         hv.Source = LoadStream (null, out _);
         hv.Source = LoadStream (null, out _);
         hv.Width = Dim.Fill ();
         hv.Width = Dim.Fill ();
         hv.Height = Dim.Fill ();
         hv.Height = Dim.Fill ();
-        Application.Top.Layout ();
+        Application.Current.Layout ();
         Assert.Equal (0, hv.Address);
         Assert.Equal (0, hv.Address);
 
 
         Assert.True (hv.NewKeyDownEvent (Key.End));
         Assert.True (hv.NewKeyDownEvent (Key.End));
         Assert.Equal (MEM_STRING_LENGTH, hv.Address);
         Assert.Equal (MEM_STRING_LENGTH, hv.Address);
 
 
         hv.Source = new MemoryStream ();
         hv.Source = new MemoryStream ();
-        Application.Top.Layout ();
+        Application.Current.Layout ();
         Assert.Equal (0, hv.Address);
         Assert.Equal (0, hv.Address);
 
 
-        Application.Top.Dispose ();
+        Application.Current.Dispose ();
         Application.ResetState (true);
         Application.ResetState (true);
     }
     }
 
 

+ 19 - 19
Tests/UnitTests/Views/LabelTests.cs

@@ -1071,7 +1071,7 @@ e
         Assert.Equal (new (5, 1), label.TextFormatter.ConstrainToSize);
         Assert.Equal (new (5, 1), label.TextFormatter.ConstrainToSize);
         Assert.Equal (["Label"], label.TextFormatter.GetLines ());
         Assert.Equal (["Label"], label.TextFormatter.GetLines ());
         Assert.Equal (new (0, 0, 10, 4), win.Frame);
         Assert.Equal (new (0, 0, 10, 4), win.Frame);
-        Assert.Equal (new (0, 0, 10, 4), Application.Top.Frame);
+        Assert.Equal (new (0, 0, 10, 4), Application.Current.Frame);
 
 
         var expected = @"
         var expected = @"
 ┌────────┐
 ┌────────┐
@@ -1130,7 +1130,7 @@ e
         Assert.Equal (new (5, 1), label.TextFormatter.ConstrainToSize);
         Assert.Equal (new (5, 1), label.TextFormatter.ConstrainToSize);
         Assert.Equal (["Label"], label.TextFormatter.GetLines ());
         Assert.Equal (["Label"], label.TextFormatter.GetLines ());
         Assert.Equal (new (0, 0, 10, 4), win.Frame);
         Assert.Equal (new (0, 0, 10, 4), win.Frame);
-        Assert.Equal (new (0, 0, 10, 4), Application.Top.Frame);
+        Assert.Equal (new (0, 0, 10, 4), Application.Current.Frame);
 
 
         var expected = @"
         var expected = @"
 ┌────────┐
 ┌────────┐
@@ -1203,10 +1203,10 @@ e
             CanFocus = true
             CanFocus = true
         };
         };
         Application.Navigation = new ();
         Application.Navigation = new ();
-        Application.Top = new ();
-        Application.Top.Add (otherView, label, nextView);
+        Application.Current = new ();
+        Application.Current.Add (otherView, label, nextView);
 
 
-        Application.Top.SetFocus ();
+        Application.Current.SetFocus ();
         Assert.True (otherView.HasFocus);
         Assert.True (otherView.HasFocus);
 
 
         Assert.True (Application.RaiseKeyDownEvent (label.HotKey));
         Assert.True (Application.RaiseKeyDownEvent (label.HotKey));
@@ -1214,7 +1214,7 @@ e
         Assert.False (label.HasFocus);
         Assert.False (label.HasFocus);
         Assert.True (nextView.HasFocus);
         Assert.True (nextView.HasFocus);
 
 
-        Application.Top.Dispose ();
+        Application.Current.Dispose ();
         Application.ResetState ();
         Application.ResetState ();
     }
     }
 
 
@@ -1225,18 +1225,18 @@ e
         Label label = new () { X = 0, Y = 1, Text = "_label" };
         Label label = new () { X = 0, Y = 1, Text = "_label" };
         View nextView = new () { X = Pos.Right (label), Y = Pos.Top (label), Width = 1, Height = 1, Id = "nextView", CanFocus = true };
         View nextView = new () { X = Pos.Right (label), Y = Pos.Top (label), Width = 1, Height = 1, Id = "nextView", CanFocus = true };
         Application.Navigation = new ();
         Application.Navigation = new ();
-        Application.Top = new ();
-        Application.Top.Add (otherView, label, nextView);
-        Application.Top.Layout ();
+        Application.Current = new ();
+        Application.Current.Add (otherView, label, nextView);
+        Application.Current.Layout ();
 
 
-        Application.Top.SetFocus ();
+        Application.Current.SetFocus ();
 
 
         // click on label
         // click on label
         Application.RaiseMouseEvent (new () { ScreenPosition = label.Frame.Location, Flags = MouseFlags.Button1Clicked });
         Application.RaiseMouseEvent (new () { ScreenPosition = label.Frame.Location, Flags = MouseFlags.Button1Clicked });
         Assert.False (label.HasFocus);
         Assert.False (label.HasFocus);
         Assert.True (nextView.HasFocus);
         Assert.True (nextView.HasFocus);
 
 
-        Application.Top.Dispose ();
+        Application.Current.Dispose ();
         Application.ResetState ();
         Application.ResetState ();
     }
     }
 
 
@@ -1255,8 +1255,8 @@ e
             CanFocus = true
             CanFocus = true
         };
         };
         Application.Navigation = new ();
         Application.Navigation = new ();
-        Application.Top = new ();
-        Application.Top.Add (label, view);
+        Application.Current = new ();
+        Application.Current.Add (label, view);
 
 
         view.SetFocus ();
         view.SetFocus ();
         Assert.True (label.CanFocus);
         Assert.True (label.CanFocus);
@@ -1269,7 +1269,7 @@ e
         Assert.True (label.HasFocus);
         Assert.True (label.HasFocus);
         Assert.False (view.HasFocus);
         Assert.False (view.HasFocus);
 
 
-        Application.Top.Dispose ();
+        Application.Current.Dispose ();
         Application.ResetState ();
         Application.ResetState ();
     }
     }
 
 
@@ -1296,14 +1296,14 @@ e
             CanFocus = true
             CanFocus = true
         };
         };
 
 
-        Application.Top = new ()
+        Application.Current = new ()
         {
         {
             Width = 10,
             Width = 10,
             Height = 10
             Height = 10
         };
         };
-        Application.Top.Add (label, otherView);
-        Application.Top.SetFocus ();
-        Application.Top.Layout ();
+        Application.Current.Add (label, otherView);
+        Application.Current.SetFocus ();
+        Application.Current.Layout ();
 
 
         Assert.True (label.CanFocus);
         Assert.True (label.CanFocus);
         Assert.True (label.HasFocus);
         Assert.True (label.HasFocus);
@@ -1323,7 +1323,7 @@ e
         Assert.False (label.HasFocus);
         Assert.False (label.HasFocus);
         Assert.True (otherView.HasFocus);
         Assert.True (otherView.HasFocus);
 
 
-        Application.Top.Dispose ();
+        Application.Current.Dispose ();
         Application.ResetState ();
         Application.ResetState ();
     }
     }
 
 

+ 27 - 27
Tests/UnitTests/Views/Menuv1/MenuBarv1Tests.cs

@@ -1100,11 +1100,11 @@ wo
         Assert.False (copyAction);
         Assert.False (copyAction);
 
 
 #if SUPPORT_ALT_TO_ACTIVATE_MENU
 #if SUPPORT_ALT_TO_ACTIVATE_MENU
-        Assert.False (Application.Top.ProcessKeyDown (new KeyEventArgs (Key.AltMask)));
-        Assert.False (Application.Top.ProcessKeyDown (new KeyEventArgs (Key.AltMask)));
-        Assert.True (Application.Top.ProcessKeyUp (new KeyEventArgs (Key.AltMask)));
+        Assert.False (Application.Current.ProcessKeyDown (new KeyEventArgs (Key.AltMask)));
+        Assert.False (Application.Current.ProcessKeyDown (new KeyEventArgs (Key.AltMask)));
+        Assert.True (Application.Current.ProcessKeyUp (new KeyEventArgs (Key.AltMask)));
         Assert.True (menu.IsMenuOpen);
         Assert.True (menu.IsMenuOpen);
-        Application.Top.Draw ();
+        Application.Current.Draw ();
 
 
         string expected = @"
         string expected = @"
  File  Edit
  File  Edit
@@ -1113,26 +1113,26 @@ wo
         var pos = DriverAsserts.AssertDriverContentsWithFrameAre (expected, output);
         var pos = DriverAsserts.AssertDriverContentsWithFrameAre (expected, output);
         Assert.Equal (new (1, 0, 11, 1), pos);
         Assert.Equal (new (1, 0, 11, 1), pos);
 
 
-        Assert.True (Application.Top.ProcessKeyDown (new KeyEventArgs (Key.N)));
+        Assert.True (Application.Current.ProcessKeyDown (new KeyEventArgs (Key.N)));
         AutoInitShutdownAttribute.RunIteration ();
         AutoInitShutdownAttribute.RunIteration ();
         Assert.False (newAction); // not yet, hot keys don't work if the item is not visible
         Assert.False (newAction); // not yet, hot keys don't work if the item is not visible
 
 
-        Assert.True (Application.Top.ProcessKeyDown (new KeyEventArgs (Key.F)));
+        Assert.True (Application.Current.ProcessKeyDown (new KeyEventArgs (Key.F)));
         AutoInitShutdownAttribute.RunIteration ();
         AutoInitShutdownAttribute.RunIteration ();
-        Assert.True (Application.Top.ProcessKeyDown (new KeyEventArgs (Key.N)));
+        Assert.True (Application.Current.ProcessKeyDown (new KeyEventArgs (Key.N)));
         AutoInitShutdownAttribute.RunIteration ();
         AutoInitShutdownAttribute.RunIteration ();
         Assert.True (newAction);
         Assert.True (newAction);
-        Application.Top.Draw ();
+        Application.Current.Draw ();
 
 
         expected = @"
         expected = @"
  File  Edit
  File  Edit
 ";
 ";
 
 
-        Assert.False (Application.Top.ProcessKeyDown (new KeyEventArgs (Key.AltMask)));
-        Assert.True (Application.Top.ProcessKeyUp (new KeyEventArgs (Key.AltMask)));
-        Assert.True (Application.Top.ProcessKeyUp (new KeyEventArgs (Key.AltMask)));
+        Assert.False (Application.Current.ProcessKeyDown (new KeyEventArgs (Key.AltMask)));
+        Assert.True (Application.Current.ProcessKeyUp (new KeyEventArgs (Key.AltMask)));
+        Assert.True (Application.Current.ProcessKeyUp (new KeyEventArgs (Key.AltMask)));
         Assert.True (menu.IsMenuOpen);
         Assert.True (menu.IsMenuOpen);
-        Application.Top.Draw ();
+        Application.Current.Draw ();
 
 
         expected = @"
         expected = @"
  File  Edit
  File  Edit
@@ -1141,8 +1141,8 @@ wo
         pos = DriverAsserts.AssertDriverContentsWithFrameAre (expected, output);
         pos = DriverAsserts.AssertDriverContentsWithFrameAre (expected, output);
         Assert.Equal (new (1, 0, 11, 1), pos);
         Assert.Equal (new (1, 0, 11, 1), pos);
 
 
-        Assert.True (Application.Top.ProcessKeyDown (new KeyEventArgs (Key.CursorRight)));
-        Assert.True (Application.Top.ProcessKeyDown (new KeyEventArgs (Key.C)));
+        Assert.True (Application.Current.ProcessKeyDown (new KeyEventArgs (Key.CursorRight)));
+        Assert.True (Application.Current.ProcessKeyDown (new KeyEventArgs (Key.C)));
         AutoInitShutdownAttribute.RunIteration ();
         AutoInitShutdownAttribute.RunIteration ();
         Assert.True (copyAction);
         Assert.True (copyAction);
 #endif
 #endif
@@ -1211,19 +1211,19 @@ wo
 
 
         Assert.True (menu.NewKeyDownEvent (Key.F.WithAlt));
         Assert.True (menu.NewKeyDownEvent (Key.F.WithAlt));
         Assert.True (menu.IsMenuOpen);
         Assert.True (menu.IsMenuOpen);
-        Application.Top.Draw ();
+        Application.Current.Draw ();
         DriverAssert.AssertDriverContentsAre (expectedMenu.ExpectedSubMenuOpen (0), output);
         DriverAssert.AssertDriverContentsAre (expectedMenu.ExpectedSubMenuOpen (0), output);
 
 
-        Assert.True (Application.Top.SubViews.ElementAt (1).NewKeyDownEvent (Key.N));
+        Assert.True (Application.Current.SubViews.ElementAt (1).NewKeyDownEvent (Key.N));
         AutoInitShutdownAttribute.RunIteration ();
         AutoInitShutdownAttribute.RunIteration ();
         Assert.True (newAction);
         Assert.True (newAction);
 
 
         Assert.True (menu.NewKeyDownEvent (Key.E.WithAlt));
         Assert.True (menu.NewKeyDownEvent (Key.E.WithAlt));
         Assert.True (menu.IsMenuOpen);
         Assert.True (menu.IsMenuOpen);
-        Application.Top.Draw ();
+        Application.Current.Draw ();
         DriverAssert.AssertDriverContentsAre (expectedMenu.ExpectedSubMenuOpen (1), output);
         DriverAssert.AssertDriverContentsAre (expectedMenu.ExpectedSubMenuOpen (1), output);
 
 
-        Assert.True (Application.Top.SubViews.ElementAt (1).NewKeyDownEvent (Key.C));
+        Assert.True (Application.Current.SubViews.ElementAt (1).NewKeyDownEvent (Key.C));
         AutoInitShutdownAttribute.RunIteration ();
         AutoInitShutdownAttribute.RunIteration ();
         Assert.True (copyAction);
         Assert.True (copyAction);
         top.Dispose ();
         top.Dispose ();
@@ -1945,7 +1945,7 @@ wo
 
 
         Application.AddTimeout (TimeSpan.Zero, () =>
         Application.AddTimeout (TimeSpan.Zero, () =>
                                                        {
                                                        {
-                                                           Toplevel top = Application.Top;
+                                                           Toplevel top = Application.Current;
 
 
                                                            AutoInitShutdownAttribute.RunIteration ();
                                                            AutoInitShutdownAttribute.RunIteration ();
 
 
@@ -2090,7 +2090,7 @@ wo
         DriverAssert.AssertDriverContentsAre (expectedMenu.ExpectedSubMenuOpen (0), output);
         DriverAssert.AssertDriverContentsAre (expectedMenu.ExpectedSubMenuOpen (0), output);
 
 
         // Open second
         // Open second
-        Assert.True (Application.Top.SubViews.ElementAt (1).NewKeyDownEvent (Key.CursorRight));
+        Assert.True (Application.Current.SubViews.ElementAt (1).NewKeyDownEvent (Key.CursorRight));
         Assert.True (menu.IsMenuOpen);
         Assert.True (menu.IsMenuOpen);
         View.SetClipToScreen ();
         View.SetClipToScreen ();
         top.Draw ();
         top.Draw ();
@@ -2141,7 +2141,7 @@ wo
         Assert.True (top.SubViews.ElementAt (1).NewKeyDownEvent (Key.CursorRight));
         Assert.True (top.SubViews.ElementAt (1).NewKeyDownEvent (Key.CursorRight));
         Assert.True (menu.IsMenuOpen);
         Assert.True (menu.IsMenuOpen);
         View.SetClipToScreen ();
         View.SetClipToScreen ();
-        Application.Top.Draw ();
+        Application.Current.Draw ();
         DriverAssert.AssertDriverContentsAre (expectedMenu.ExpectedSubMenuOpen (1), output);
         DriverAssert.AssertDriverContentsAre (expectedMenu.ExpectedSubMenuOpen (1), output);
 
 
         // Close menu
         // Close menu
@@ -3075,7 +3075,7 @@ Edit
 
 
         pos = DriverAssert.AssertDriverContentsWithFrameAre (expected, output);
         pos = DriverAssert.AssertDriverContentsWithFrameAre (expected, output);
 
 
-        Assert.True (Application.Top.SubViews.ElementAt (1).NewKeyDownEvent (Key.CursorDown));
+        Assert.True (Application.Current.SubViews.ElementAt (1).NewKeyDownEvent (Key.CursorDown));
         top.Draw ();
         top.Draw ();
 
 
         expected = @"
         expected = @"
@@ -3090,7 +3090,7 @@ Edit
 
 
         pos = DriverAssert.AssertDriverContentsWithFrameAre (expected, output);
         pos = DriverAssert.AssertDriverContentsWithFrameAre (expected, output);
 
 
-        Assert.True (Application.Top.SubViews.ElementAt (2).NewKeyDownEvent (Key.CursorLeft));
+        Assert.True (Application.Current.SubViews.ElementAt (2).NewKeyDownEvent (Key.CursorLeft));
         top.Draw ();
         top.Draw ();
 
 
         expected = @"
         expected = @"
@@ -3104,7 +3104,7 @@ Edit
 
 
         pos = DriverAssert.AssertDriverContentsWithFrameAre (expected, output);
         pos = DriverAssert.AssertDriverContentsWithFrameAre (expected, output);
 
 
-        Assert.True (Application.Top.SubViews.ElementAt (1).NewKeyDownEvent (Key.Esc));
+        Assert.True (Application.Current.SubViews.ElementAt (1).NewKeyDownEvent (Key.Esc));
         top.Draw ();
         top.Draw ();
 
 
         expected = @"
         expected = @"
@@ -3186,7 +3186,7 @@ Edit
         menu.NewMouseEvent (
         menu.NewMouseEvent (
                             new ()
                             new ()
                             {
                             {
-                                Position = new (1, 2), Flags = MouseFlags.ReportMousePosition, View = Application.Top.SubViews.ElementAt (1)
+                                Position = new (1, 2), Flags = MouseFlags.ReportMousePosition, View = Application.Current.SubViews.ElementAt (1)
                             }
                             }
                            );
                            );
         top.Draw ();
         top.Draw ();
@@ -3208,7 +3208,7 @@ Edit
                       menu.NewMouseEvent (
                       menu.NewMouseEvent (
                                           new ()
                                           new ()
                                           {
                                           {
-                                              Position = new (1, 1), Flags = MouseFlags.ReportMousePosition, View = Application.Top.SubViews.ElementAt (1)
+                                              Position = new (1, 1), Flags = MouseFlags.ReportMousePosition, View = Application.Current.SubViews.ElementAt (1)
                                           }
                                           }
                                          )
                                          )
                      );
                      );
@@ -3227,7 +3227,7 @@ Edit
         Assert.Equal (new (1, 0, 10, 6), pos);
         Assert.Equal (new (1, 0, 10, 6), pos);
 
 
         menu.NewMouseEvent (
         menu.NewMouseEvent (
-                            new () { Position = new (70, 2), Flags = MouseFlags.Button1Clicked, View = Application.Top }
+                            new () { Position = new (70, 2), Flags = MouseFlags.Button1Clicked, View = Application.Current }
                            );
                            );
         top.Draw ();
         top.Draw ();
 
 

+ 36 - 36
Tests/UnitTests/Views/ShortcutTests.cs

@@ -23,7 +23,7 @@ public class ShortcutTests
     [InlineData (9, 0)]
     [InlineData (9, 0)]
     public void MouseClick_Raises_Accepted (int x, int expectedAccepted)
     public void MouseClick_Raises_Accepted (int x, int expectedAccepted)
     {
     {
-        Application.Top = new ();
+        Application.Current = new ();
 
 
         var shortcut = new Shortcut
         var shortcut = new Shortcut
         {
         {
@@ -31,8 +31,8 @@ public class ShortcutTests
             Text = "0",
             Text = "0",
             Title = "C"
             Title = "C"
         };
         };
-        Application.Top.Add (shortcut);
-        Application.Top.Layout ();
+        Application.Current.Add (shortcut);
+        Application.Current.Layout ();
 
 
         var accepted = 0;
         var accepted = 0;
         shortcut.Accepting += (s, e) => accepted++;
         shortcut.Accepting += (s, e) => accepted++;
@@ -46,7 +46,7 @@ public class ShortcutTests
 
 
         Assert.Equal (expectedAccepted, accepted);
         Assert.Equal (expectedAccepted, accepted);
 
 
-        Application.Top.Dispose ();
+        Application.Current.Dispose ();
         Application.ResetState (true);
         Application.ResetState (true);
     }
     }
 
 
@@ -74,7 +74,7 @@ public class ShortcutTests
         int expectedShortcutSelected
         int expectedShortcutSelected
     )
     )
     {
     {
-        Application.Top = new ();
+        Application.Current = new ();
 
 
         var shortcut = new Shortcut
         var shortcut = new Shortcut
         {
         {
@@ -93,9 +93,9 @@ public class ShortcutTests
         var shortcutSelectCount = 0;
         var shortcutSelectCount = 0;
         shortcut.Selecting += (s, e) => { shortcutSelectCount++; };
         shortcut.Selecting += (s, e) => { shortcutSelectCount++; };
 
 
-        Application.Top.Add (shortcut);
-        Application.Top.SetRelativeLayout (new (100, 100));
-        Application.Top.LayoutSubViews ();
+        Application.Current.Add (shortcut);
+        Application.Current.SetRelativeLayout (new (100, 100));
+        Application.Current.LayoutSubViews ();
 
 
         Application.RaiseMouseEvent (
         Application.RaiseMouseEvent (
                                   new ()
                                   new ()
@@ -109,7 +109,7 @@ public class ShortcutTests
         Assert.Equal (expectedCommandViewAccepted, commandViewAcceptCount);
         Assert.Equal (expectedCommandViewAccepted, commandViewAcceptCount);
         Assert.Equal (expectedCommandViewSelected, commandViewSelectCount);
         Assert.Equal (expectedCommandViewSelected, commandViewSelectCount);
 
 
-        Application.Top.Dispose ();
+        Application.Current.Dispose ();
         Application.ResetState (true);
         Application.ResetState (true);
     }
     }
 
 
@@ -130,7 +130,7 @@ public class ShortcutTests
     [InlineData (9, 0, 0)]
     [InlineData (9, 0, 0)]
     public void MouseClick_Button_CommandView_Raises_Shortcut_Accepted (int mouseX, int expectedAccept, int expectedButtonAccept)
     public void MouseClick_Button_CommandView_Raises_Shortcut_Accepted (int mouseX, int expectedAccept, int expectedButtonAccept)
     {
     {
-        Application.Top = new ();
+        Application.Current = new ();
 
 
         var shortcut = new Shortcut
         var shortcut = new Shortcut
         {
         {
@@ -147,9 +147,9 @@ public class ShortcutTests
         };
         };
         var buttonAccepted = 0;
         var buttonAccepted = 0;
         shortcut.CommandView.Accepting += (s, e) => { buttonAccepted++; };
         shortcut.CommandView.Accepting += (s, e) => { buttonAccepted++; };
-        Application.Top.Add (shortcut);
-        Application.Top.SetRelativeLayout (new (100, 100));
-        Application.Top.LayoutSubViews ();
+        Application.Current.Add (shortcut);
+        Application.Current.SetRelativeLayout (new (100, 100));
+        Application.Current.LayoutSubViews ();
 
 
         var accepted = 0;
         var accepted = 0;
         shortcut.Accepting += (s, e) => { accepted++; };
         shortcut.Accepting += (s, e) => { accepted++; };
@@ -164,7 +164,7 @@ public class ShortcutTests
         Assert.Equal (expectedAccept, accepted);
         Assert.Equal (expectedAccept, accepted);
         Assert.Equal (expectedButtonAccept, buttonAccepted);
         Assert.Equal (expectedButtonAccept, buttonAccepted);
 
 
-        Application.Top.Dispose ();
+        Application.Current.Dispose ();
         Application.ResetState (true);
         Application.ResetState (true);
     }
     }
 
 
@@ -186,7 +186,7 @@ public class ShortcutTests
     [InlineData (10, 1, 0)]
     [InlineData (10, 1, 0)]
     public void MouseClick_CheckBox_CommandView_Raises_Shortcut_Accepted_Selected_Correctly (int mouseX, int expectedAccepted, int expectedCheckboxAccepted)
     public void MouseClick_CheckBox_CommandView_Raises_Shortcut_Accepted_Selected_Correctly (int mouseX, int expectedAccepted, int expectedCheckboxAccepted)
     {
     {
-        Application.Top = new ();
+        Application.Current = new ();
 
 
         var shortcut = new Shortcut
         var shortcut = new Shortcut
         {
         {
@@ -212,9 +212,9 @@ public class ShortcutTests
                                              checkboxSelected++;
                                              checkboxSelected++;
                                          };
                                          };
 
 
-        Application.Top.Add (shortcut);
-        Application.Top.SetRelativeLayout (new (100, 100));
-        Application.Top.LayoutSubViews ();
+        Application.Current.Add (shortcut);
+        Application.Current.SetRelativeLayout (new (100, 100));
+        Application.Current.LayoutSubViews ();
 
 
         var selected = 0;
         var selected = 0;
         shortcut.Selecting += (s, e) =>
         shortcut.Selecting += (s, e) =>
@@ -241,7 +241,7 @@ public class ShortcutTests
         Assert.Equal (expectedCheckboxAccepted, checkboxAccepted);
         Assert.Equal (expectedCheckboxAccepted, checkboxAccepted);
         Assert.Equal (expectedCheckboxAccepted, checkboxSelected);
         Assert.Equal (expectedCheckboxAccepted, checkboxSelected);
 
 
-        Application.Top.Dispose ();
+        Application.Current.Dispose ();
         Application.ResetState (true);
         Application.ResetState (true);
     }
     }
 
 
@@ -260,7 +260,7 @@ public class ShortcutTests
     [InlineData (false, KeyCode.F1, 0, 0)]
     [InlineData (false, KeyCode.F1, 0, 0)]
     public void KeyDown_Raises_Accepted_Selected (bool canFocus, KeyCode key, int expectedAccept, int expectedSelect)
     public void KeyDown_Raises_Accepted_Selected (bool canFocus, KeyCode key, int expectedAccept, int expectedSelect)
     {
     {
-        Application.Top = new ();
+        Application.Current = new ();
 
 
         var shortcut = new Shortcut
         var shortcut = new Shortcut
         {
         {
@@ -269,7 +269,7 @@ public class ShortcutTests
             Title = "_C",
             Title = "_C",
             CanFocus = canFocus
             CanFocus = canFocus
         };
         };
-        Application.Top.Add (shortcut);
+        Application.Current.Add (shortcut);
         shortcut.SetFocus ();
         shortcut.SetFocus ();
 
 
         Assert.Equal (canFocus, shortcut.HasFocus);
         Assert.Equal (canFocus, shortcut.HasFocus);
@@ -285,7 +285,7 @@ public class ShortcutTests
         Assert.Equal (expectedAccept, accepted);
         Assert.Equal (expectedAccept, accepted);
         Assert.Equal (expectedSelect, selected);
         Assert.Equal (expectedSelect, selected);
 
 
-        Application.Top.Dispose ();
+        Application.Current.Dispose ();
         Application.ResetState (true);
         Application.ResetState (true);
     }
     }
 
 
@@ -305,7 +305,7 @@ public class ShortcutTests
     [InlineData (false, KeyCode.F1, 0, 0)]
     [InlineData (false, KeyCode.F1, 0, 0)]
     public void KeyDown_CheckBox_Raises_Accepted_Selected (bool canFocus, KeyCode key, int expectedAccept, int expectedSelect)
     public void KeyDown_CheckBox_Raises_Accepted_Selected (bool canFocus, KeyCode key, int expectedAccept, int expectedSelect)
     {
     {
-        Application.Top = new ();
+        Application.Current = new ();
 
 
         var shortcut = new Shortcut
         var shortcut = new Shortcut
         {
         {
@@ -317,7 +317,7 @@ public class ShortcutTests
             },
             },
             CanFocus = canFocus
             CanFocus = canFocus
         };
         };
-        Application.Top.Add (shortcut);
+        Application.Current.Add (shortcut);
         shortcut.SetFocus ();
         shortcut.SetFocus ();
 
 
         Assert.Equal (canFocus, shortcut.HasFocus);
         Assert.Equal (canFocus, shortcut.HasFocus);
@@ -337,7 +337,7 @@ public class ShortcutTests
         Assert.Equal (expectedAccept, accepted);
         Assert.Equal (expectedAccept, accepted);
         Assert.Equal (expectedSelect, selected);
         Assert.Equal (expectedSelect, selected);
 
 
-        Application.Top.Dispose ();
+        Application.Current.Dispose ();
         Application.ResetState (true);
         Application.ResetState (true);
     }
     }
     [Theory]
     [Theory]
@@ -349,7 +349,7 @@ public class ShortcutTests
     [InlineData (KeyCode.F1, 0)]
     [InlineData (KeyCode.F1, 0)]
     public void KeyDown_App_Scope_Invokes_Accept (KeyCode key, int expectedAccept)
     public void KeyDown_App_Scope_Invokes_Accept (KeyCode key, int expectedAccept)
     {
     {
-        Application.Top = new ();
+        Application.Current = new ();
 
 
         var shortcut = new Shortcut
         var shortcut = new Shortcut
         {
         {
@@ -358,8 +358,8 @@ public class ShortcutTests
             Text = "0",
             Text = "0",
             Title = "_C"
             Title = "_C"
         };
         };
-        Application.Top.Add (shortcut);
-        Application.Top.SetFocus ();
+        Application.Current.Add (shortcut);
+        Application.Current.SetFocus ();
 
 
         var accepted = 0;
         var accepted = 0;
         shortcut.Accepting += (s, e) => accepted++;
         shortcut.Accepting += (s, e) => accepted++;
@@ -368,7 +368,7 @@ public class ShortcutTests
 
 
         Assert.Equal (expectedAccept, accepted);
         Assert.Equal (expectedAccept, accepted);
 
 
-        Application.Top.Dispose ();
+        Application.Current.Dispose ();
         Application.ResetState (true);
         Application.ResetState (true);
     }
     }
 
 
@@ -427,7 +427,7 @@ public class ShortcutTests
     [InlineData (false, KeyCode.F1, 0)]
     [InlineData (false, KeyCode.F1, 0)]
     public void KeyDown_App_Scope_Invokes_Action (bool canFocus, KeyCode key, int expectedAction)
     public void KeyDown_App_Scope_Invokes_Action (bool canFocus, KeyCode key, int expectedAction)
     {
     {
-        Application.Top = new ();
+        Application.Current = new ();
 
 
         var shortcut = new Shortcut
         var shortcut = new Shortcut
         {
         {
@@ -438,8 +438,8 @@ public class ShortcutTests
             CanFocus = canFocus
             CanFocus = canFocus
         };
         };
 
 
-        Application.Top.Add (shortcut);
-        Application.Top.SetFocus ();
+        Application.Current.Add (shortcut);
+        Application.Current.SetFocus ();
 
 
         var action = 0;
         var action = 0;
         shortcut.Action += () => action++;
         shortcut.Action += () => action++;
@@ -448,7 +448,7 @@ public class ShortcutTests
 
 
         Assert.Equal (expectedAction, action);
         Assert.Equal (expectedAction, action);
 
 
-        Application.Top.Dispose ();
+        Application.Current.Dispose ();
         Application.ResetState (true);
         Application.ResetState (true);
     }
     }
 
 
@@ -456,11 +456,11 @@ public class ShortcutTests
     [Fact]
     [Fact]
     public void Scheme_SetScheme_Does_Not_Fault_3664 ()
     public void Scheme_SetScheme_Does_Not_Fault_3664 ()
     {
     {
-        Application.Top = new ();
+        Application.Current = new ();
         Application.Navigation = new ();
         Application.Navigation = new ();
         var shortcut = new Shortcut ();
         var shortcut = new Shortcut ();
 
 
-        Application.Top.SetScheme (null);
+        Application.Current.SetScheme (null);
 
 
         Assert.False (shortcut.HasScheme);
         Assert.False (shortcut.HasScheme);
         Assert.NotNull (shortcut.GetScheme ());
         Assert.NotNull (shortcut.GetScheme ());
@@ -470,7 +470,7 @@ public class ShortcutTests
         Assert.False (shortcut.HasScheme);
         Assert.False (shortcut.HasScheme);
         Assert.NotNull (shortcut.GetScheme ());
         Assert.NotNull (shortcut.GetScheme ());
 
 
-        Application.Top.Dispose ();
+        Application.Current.Dispose ();
         Application.ResetState ();
         Application.ResetState ();
     }
     }
 }
 }

+ 3 - 3
Tests/UnitTests/Views/SpinnerViewTests.cs

@@ -40,7 +40,7 @@ public class SpinnerViewTests (ITestOutputHelper output)
         // Dispose clears timeout
         // Dispose clears timeout
         view.Dispose ();
         view.Dispose ();
         Assert.Empty (Application.TimedEvents.Timeouts);
         Assert.Empty (Application.TimedEvents.Timeouts);
-        Application.Top.Dispose ();
+        Application.Current.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -62,7 +62,7 @@ public class SpinnerViewTests (ITestOutputHelper output)
 
 
         expected = "/";
         expected = "/";
         DriverAssert.AssertDriverContentsWithFrameAre (expected, output);
         DriverAssert.AssertDriverContentsWithFrameAre (expected, output);
-        Application.Top.Dispose ();
+        Application.Current.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -95,7 +95,7 @@ public class SpinnerViewTests (ITestOutputHelper output)
 
 
         //expected = "|";
         //expected = "|";
         //DriverAsserts.AssertDriverContentsWithFrameAre (expected, output);
         //DriverAsserts.AssertDriverContentsWithFrameAre (expected, output);
-        Application.Top.Dispose ();
+        Application.Current.Dispose ();
     }
     }
 
 
     private SpinnerView GetSpinnerView ()
     private SpinnerView GetSpinnerView ()

+ 26 - 26
Tests/UnitTests/Views/TableViewTests.cs

@@ -3234,19 +3234,19 @@ A B C
 
 
         // Pressing left should move us to the first column without changing focus
         // Pressing left should move us to the first column without changing focus
         Application.RaiseKeyDownEvent (Key.CursorLeft);
         Application.RaiseKeyDownEvent (Key.CursorLeft);
-        Assert.Same (tableView, Application.Top!.MostFocused);
+        Assert.Same (tableView, Application.Current!.MostFocused);
         Assert.True (tableView.HasFocus);
         Assert.True (tableView.HasFocus);
 
 
         // Because we are now on the leftmost cell a further left press should move focus
         // Because we are now on the leftmost cell a further left press should move focus
         Application.RaiseKeyDownEvent (Key.CursorLeft);
         Application.RaiseKeyDownEvent (Key.CursorLeft);
 
 
-        Assert.NotSame (tableView, Application.Top.MostFocused);
+        Assert.NotSame (tableView, Application.Current.MostFocused);
         Assert.False (tableView.HasFocus);
         Assert.False (tableView.HasFocus);
 
 
-        Assert.Same (tf1, Application.Top.MostFocused);
+        Assert.Same (tf1, Application.Current.MostFocused);
         Assert.True (tf1.HasFocus);
         Assert.True (tf1.HasFocus);
 
 
-        Application.Top.Dispose ();
+        Application.Current.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -3259,19 +3259,19 @@ A B C
 
 
         // First press should move us up
         // First press should move us up
         Application.RaiseKeyDownEvent (Key.CursorUp);
         Application.RaiseKeyDownEvent (Key.CursorUp);
-        Assert.Same (tableView, Application.Top!.MostFocused);
+        Assert.Same (tableView, Application.Current!.MostFocused);
         Assert.True (tableView.HasFocus);
         Assert.True (tableView.HasFocus);
 
 
         // Because we are now on the top row a further press should move focus
         // Because we are now on the top row a further press should move focus
         Application.RaiseKeyDownEvent (Key.CursorUp);
         Application.RaiseKeyDownEvent (Key.CursorUp);
 
 
-        Assert.NotSame (tableView, Application.Top.MostFocused);
+        Assert.NotSame (tableView, Application.Current.MostFocused);
         Assert.False (tableView.HasFocus);
         Assert.False (tableView.HasFocus);
 
 
-        Assert.Same (tf1, Application.Top.MostFocused);
+        Assert.Same (tf1, Application.Current.MostFocused);
         Assert.True (tf1.HasFocus);
         Assert.True (tf1.HasFocus);
 
 
-        Application.Top.Dispose ();
+        Application.Current.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -3284,19 +3284,19 @@ A B C
 
 
         // First press should move us to the rightmost column without changing focus
         // First press should move us to the rightmost column without changing focus
         Application.RaiseKeyDownEvent (Key.CursorRight);
         Application.RaiseKeyDownEvent (Key.CursorRight);
-        Assert.Same (tableView, Application.Top!.MostFocused);
+        Assert.Same (tableView, Application.Current!.MostFocused);
         Assert.True (tableView.HasFocus);
         Assert.True (tableView.HasFocus);
 
 
         // Because we are now on the rightmost cell, a further right press should move focus
         // Because we are now on the rightmost cell, a further right press should move focus
         Application.RaiseKeyDownEvent (Key.CursorRight);
         Application.RaiseKeyDownEvent (Key.CursorRight);
 
 
-        Assert.NotSame (tableView, Application.Top.MostFocused);
+        Assert.NotSame (tableView, Application.Current.MostFocused);
         Assert.False (tableView.HasFocus);
         Assert.False (tableView.HasFocus);
 
 
-        Assert.Same (tf2, Application.Top.MostFocused);
+        Assert.Same (tf2, Application.Current.MostFocused);
         Assert.True (tf2.HasFocus);
         Assert.True (tf2.HasFocus);
 
 
-        Application.Top.Dispose ();
+        Application.Current.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -3309,19 +3309,19 @@ A B C
 
 
         // First press should move us to the bottommost row without changing focus
         // First press should move us to the bottommost row without changing focus
         Application.RaiseKeyDownEvent (Key.CursorDown);
         Application.RaiseKeyDownEvent (Key.CursorDown);
-        Assert.Same (tableView, Application.Top!.MostFocused);
+        Assert.Same (tableView, Application.Current!.MostFocused);
         Assert.True (tableView.HasFocus);
         Assert.True (tableView.HasFocus);
 
 
         // Because we are now on the bottommost cell, a further down press should move focus
         // Because we are now on the bottommost cell, a further down press should move focus
         Application.RaiseKeyDownEvent (Key.CursorDown);
         Application.RaiseKeyDownEvent (Key.CursorDown);
 
 
-        Assert.NotSame (tableView, Application.Top.MostFocused);
+        Assert.NotSame (tableView, Application.Current.MostFocused);
         Assert.False (tableView.HasFocus);
         Assert.False (tableView.HasFocus);
 
 
-        Assert.Same (tf2, Application.Top.MostFocused);
+        Assert.Same (tf2, Application.Current.MostFocused);
         Assert.True (tf2.HasFocus);
         Assert.True (tf2.HasFocus);
 
 
-        Application.Top.Dispose ();
+        Application.Current.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -3334,7 +3334,7 @@ A B C
 
 
         // Pressing shift-left should give us a multi selection
         // Pressing shift-left should give us a multi selection
         Application.RaiseKeyDownEvent (Key.CursorLeft.WithShift);
         Application.RaiseKeyDownEvent (Key.CursorLeft.WithShift);
-        Assert.Same (tableView, Application.Top!.MostFocused);
+        Assert.Same (tableView, Application.Current!.MostFocused);
         Assert.True (tableView.HasFocus);
         Assert.True (tableView.HasFocus);
         Assert.Equal (2, tableView.GetAllSelectedCells ().Count ());
         Assert.Equal (2, tableView.GetAllSelectedCells ().Count ());
 
 
@@ -3345,19 +3345,19 @@ A B C
 
 
         // Selection 'clears' just to the single cell and we remain focused
         // Selection 'clears' just to the single cell and we remain focused
         Assert.Single (tableView.GetAllSelectedCells ());
         Assert.Single (tableView.GetAllSelectedCells ());
-        Assert.Same (tableView, Application.Top.MostFocused);
+        Assert.Same (tableView, Application.Current.MostFocused);
         Assert.True (tableView.HasFocus);
         Assert.True (tableView.HasFocus);
 
 
         // A further left will switch focus
         // A further left will switch focus
         Application.RaiseKeyDownEvent (Key.CursorLeft);
         Application.RaiseKeyDownEvent (Key.CursorLeft);
 
 
-        Assert.NotSame (tableView, Application.Top.MostFocused);
+        Assert.NotSame (tableView, Application.Current.MostFocused);
         Assert.False (tableView.HasFocus);
         Assert.False (tableView.HasFocus);
 
 
-        Assert.Same (tf1, Application.Top.MostFocused);
+        Assert.Same (tf1, Application.Current.MostFocused);
         Assert.True (tf1.HasFocus);
         Assert.True (tf1.HasFocus);
 
 
-        Application.Top.Dispose ();
+        Application.Current.Dispose ();
     }
     }
 
 
     [Theory]
     [Theory]
@@ -3398,16 +3398,16 @@ A B C
         tableView.EndInit ();
         tableView.EndInit ();
 
 
         Application.Navigation = new ();
         Application.Navigation = new ();
-        Application.Top = new ();
+        Application.Current = new ();
         tf1 = new ();
         tf1 = new ();
         tf2 = new ();
         tf2 = new ();
-        Application.Top.Add (tf1);
-        Application.Top.Add (tableView);
-        Application.Top.Add (tf2);
+        Application.Current.Add (tf1);
+        Application.Current.Add (tableView);
+        Application.Current.Add (tf2);
 
 
         tableView.SetFocus ();
         tableView.SetFocus ();
 
 
-        Assert.Same (tableView, Application.Top.MostFocused);
+        Assert.Same (tableView, Application.Current.MostFocused);
         Assert.True (tableView.HasFocus);
         Assert.True (tableView.HasFocus);
 
 
         // Set big table
         // Set big table

+ 8 - 8
Tests/UnitTests/Views/TextFieldTests.cs

@@ -84,7 +84,7 @@ public class TextFieldTests (ITestOutputHelper output)
 
 
         tf.Draw ();
         tf.Draw ();
         DriverAssert.AssertDriverContentsAre (expectedRender, output);
         DriverAssert.AssertDriverContentsAre (expectedRender, output);
-        Application.Top.Dispose ();
+        Application.Current.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -104,7 +104,7 @@ public class TextFieldTests (ITestOutputHelper output)
 
 
         tf.Draw ();
         tf.Draw ();
         DriverAssert.AssertDriverContentsAre ("Misérables", output);
         DriverAssert.AssertDriverContentsAre ("Misérables", output);
-        Application.Top.Dispose ();
+        Application.Current.Dispose ();
     }
     }
 
 
     [Theory (Skip = "Broke with ContextMenuv2")]
     [Theory (Skip = "Broke with ContextMenuv2")]
@@ -132,7 +132,7 @@ public class TextFieldTests (ITestOutputHelper output)
         View.SetClipToScreen ();
         View.SetClipToScreen ();
         tf.Draw ();
         tf.Draw ();
         DriverAssert.AssertDriverContentsAre (content, output);
         DriverAssert.AssertDriverContentsAre (content, output);
-        Application.Top.Dispose ();
+        Application.Current.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -157,7 +157,7 @@ public class TextFieldTests (ITestOutputHelper output)
         View.SetClipToScreen ();
         View.SetClipToScreen ();
         tf.Draw ();
         tf.Draw ();
         DriverAssert.AssertDriverContentsAre ("Enter txt", output);
         DriverAssert.AssertDriverContentsAre ("Enter txt", output);
-        Application.Top.Dispose ();
+        Application.Current.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -187,7 +187,7 @@ public class TextFieldTests (ITestOutputHelper output)
         // All characters in "Enter text" should have the caption attribute
         // All characters in "Enter text" should have the caption attribute
         DriverAssert.AssertDriverAttributesAre ("0000000000", output, Application.Driver, captionAttr);
         DriverAssert.AssertDriverAttributesAre ("0000000000", output, Application.Driver, captionAttr);
 
 
-        Application.Top.Dispose ();
+        Application.Current.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -221,7 +221,7 @@ public class TextFieldTests (ITestOutputHelper output)
         // F is underlined (index 1), remaining characters use normal caption attribute (index 0)
         // F is underlined (index 1), remaining characters use normal caption attribute (index 0)
         DriverAssert.AssertDriverAttributesAre ("1000", output, Application.Driver, captionAttr, hotkeyAttr);
         DriverAssert.AssertDriverAttributesAre ("1000", output, Application.Driver, captionAttr, hotkeyAttr);
 
 
-        Application.Top.Dispose ();
+        Application.Current.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -255,7 +255,7 @@ public class TextFieldTests (ITestOutputHelper output)
         // "Enter " (6 chars) + "T" (underlined) + "ext" (3 chars)
         // "Enter " (6 chars) + "T" (underlined) + "ext" (3 chars)
         DriverAssert.AssertDriverAttributesAre ("0000001000", output, Application.Driver, captionAttr, hotkeyAttr);
         DriverAssert.AssertDriverAttributesAre ("0000001000", output, Application.Driver, captionAttr, hotkeyAttr);
 
 
-        Application.Top.Dispose ();
+        Application.Current.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -1686,7 +1686,7 @@ Les Miśerables",
         {
         {
             base.Before (methodUnderTest);
             base.Before (methodUnderTest);
 
 
-            //Application.Top.Scheme = Colors.Schemes ["Base"];
+            //Application.Current.Scheme = Colors.Schemes ["Base"];
             _textField = new ()
             _textField = new ()
             {
             {
                 //                1         2         3 
                 //                1         2         3 

+ 1 - 1
Tests/UnitTests/Views/TextViewTests.cs

@@ -109,7 +109,7 @@ public class TextViewTests
                 Assert.Equal (leftCol, _textView.LeftColumn);
                 Assert.Equal (leftCol, _textView.LeftColumn);
             }
             }
 
 
-            Application.Top.Remove (_textView);
+            Application.Current.Remove (_textView);
             Application.RequestStop ();
             Application.RequestStop ();
         }
         }
     }
     }

+ 34 - 34
Tests/UnitTests/Views/ToplevelTests.cs

@@ -69,11 +69,11 @@ public class ToplevelTests
 #endif
 #endif
 
 
         Application.Begin (top);
         Application.Begin (top);
-        Assert.Equal (top, Application.Top);
+        Assert.Equal (top, Application.Current);
 
 
-        // Application.Top without menu and status bar.
+        // Application.Current without menu and status bar.
         View supView = View.GetLocationEnsuringFullVisibility (top, 2, 2, out int nx, out int ny /*, out StatusBar sb*/);
         View supView = View.GetLocationEnsuringFullVisibility (top, 2, 2, out int nx, out int ny /*, out StatusBar sb*/);
-        Assert.Equal (Application.Top, supView);
+        Assert.Equal (Application.Current, supView);
         Assert.Equal (0, nx);
         Assert.Equal (0, nx);
         Assert.Equal (0, ny);
         Assert.Equal (0, ny);
 
 
@@ -82,7 +82,7 @@ public class ToplevelTests
         top.Add (new MenuBar ());
         top.Add (new MenuBar ());
         Assert.NotNull (top.MenuBar);
         Assert.NotNull (top.MenuBar);
 
 
-        // Application.Top with a menu and without status bar.
+        // Application.Current with a menu and without status bar.
         View.GetLocationEnsuringFullVisibility (top, 2, 2, out nx, out ny /*, out sb*/);
         View.GetLocationEnsuringFullVisibility (top, 2, 2, out nx, out ny /*, out sb*/);
         Assert.Equal (0, nx);
         Assert.Equal (0, nx);
         Assert.Equal (1, ny);
         Assert.Equal (1, ny);
@@ -92,11 +92,11 @@ public class ToplevelTests
         //top.Add (new StatusBar ());
         //top.Add (new StatusBar ());
         //Assert.NotNull (top.StatusBar);
         //Assert.NotNull (top.StatusBar);
 
 
-        // Application.Top with a menu and status bar.
+        // Application.Current with a menu and status bar.
         View.GetLocationEnsuringFullVisibility (top, 2, 2, out nx, out ny /*, out sb*/);
         View.GetLocationEnsuringFullVisibility (top, 2, 2, out nx, out ny /*, out sb*/);
         Assert.Equal (0, nx);
         Assert.Equal (0, nx);
 
 
-        // The available height is lower than the Application.Top height minus
+        // The available height is lower than the Application.Current height minus
         // the menu bar and status bar, then the top can go beyond the bottom
         // the menu bar and status bar, then the top can go beyond the bottom
         //        Assert.Equal (2, ny);
         //        Assert.Equal (2, ny);
         //Assert.NotNull (sb);
         //Assert.NotNull (sb);
@@ -106,11 +106,11 @@ public class ToplevelTests
         Assert.Null (top.MenuBar);
         Assert.Null (top.MenuBar);
         Assert.NotNull (menuBar);
         Assert.NotNull (menuBar);
 
 
-        // Application.Top without a menu and with a status bar.
+        // Application.Current without a menu and with a status bar.
         View.GetLocationEnsuringFullVisibility (top, 2, 2, out nx, out ny /*, out sb*/);
         View.GetLocationEnsuringFullVisibility (top, 2, 2, out nx, out ny /*, out sb*/);
         Assert.Equal (0, nx);
         Assert.Equal (0, nx);
 
 
-        // The available height is lower than the Application.Top height minus
+        // The available height is lower than the Application.Current height minus
         // the status bar, then the top can go beyond the bottom
         // the status bar, then the top can go beyond the bottom
         //        Assert.Equal (2, ny);
         //        Assert.Equal (2, ny);
         //Assert.NotNull (sb);
         //Assert.NotNull (sb);
@@ -127,11 +127,11 @@ public class ToplevelTests
 
 
         // The SuperView is always the same regardless of the caller.
         // The SuperView is always the same regardless of the caller.
         supView = View.GetLocationEnsuringFullVisibility (win, 0, 0, out nx, out ny /*, out sb*/);
         supView = View.GetLocationEnsuringFullVisibility (win, 0, 0, out nx, out ny /*, out sb*/);
-        Assert.Equal (Application.Top, supView);
+        Assert.Equal (Application.Current, supView);
         supView = View.GetLocationEnsuringFullVisibility (win, 0, 0, out nx, out ny /*, out sb*/);
         supView = View.GetLocationEnsuringFullVisibility (win, 0, 0, out nx, out ny /*, out sb*/);
-        Assert.Equal (Application.Top, supView);
+        Assert.Equal (Application.Current, supView);
 
 
-        // Application.Top without menu and status bar.
+        // Application.Current without menu and status bar.
         View.GetLocationEnsuringFullVisibility (win, 0, 0, out nx, out ny /*, out sb*/);
         View.GetLocationEnsuringFullVisibility (win, 0, 0, out nx, out ny /*, out sb*/);
         Assert.Equal (0, nx);
         Assert.Equal (0, nx);
         Assert.Equal (0, ny);
         Assert.Equal (0, ny);
@@ -141,7 +141,7 @@ public class ToplevelTests
         top.Add (new MenuBar ());
         top.Add (new MenuBar ());
         Assert.NotNull (top.MenuBar);
         Assert.NotNull (top.MenuBar);
 
 
-        // Application.Top with a menu and without status bar.
+        // Application.Current with a menu and without status bar.
         View.GetLocationEnsuringFullVisibility (win, 2, 2, out nx, out ny /*, out sb*/);
         View.GetLocationEnsuringFullVisibility (win, 2, 2, out nx, out ny /*, out sb*/);
         Assert.Equal (0, nx);
         Assert.Equal (0, nx);
         Assert.Equal (1, ny);
         Assert.Equal (1, ny);
@@ -152,11 +152,11 @@ public class ToplevelTests
 
 
         //Assert.NotNull (top.StatusBar);
         //Assert.NotNull (top.StatusBar);
 
 
-        // Application.Top with a menu and status bar.
+        // Application.Current with a menu and status bar.
         View.GetLocationEnsuringFullVisibility (win, 30, 20, out nx, out ny /*, out sb*/);
         View.GetLocationEnsuringFullVisibility (win, 30, 20, out nx, out ny /*, out sb*/);
         Assert.Equal (0, nx);
         Assert.Equal (0, nx);
 
 
-        // The available height is lower than the Application.Top height minus
+        // The available height is lower than the Application.Current height minus
         // the menu bar and status bar, then the top can go beyond the bottom
         // the menu bar and status bar, then the top can go beyond the bottom
         //Assert.Equal (20, ny);
         //Assert.Equal (20, ny);
         //Assert.NotNull (sb);
         //Assert.NotNull (sb);
@@ -177,7 +177,7 @@ public class ToplevelTests
         win = new () { Width = 60, Height = 15 };
         win = new () { Width = 60, Height = 15 };
         top.Add (win);
         top.Add (win);
 
 
-        // Application.Top without menu and status bar.
+        // Application.Current without menu and status bar.
         View.GetLocationEnsuringFullVisibility (win, 0, 0, out nx, out ny /*, out sb*/);
         View.GetLocationEnsuringFullVisibility (win, 0, 0, out nx, out ny /*, out sb*/);
         Assert.Equal (0, nx);
         Assert.Equal (0, nx);
         Assert.Equal (0, ny);
         Assert.Equal (0, ny);
@@ -187,7 +187,7 @@ public class ToplevelTests
         top.Add (new MenuBar ());
         top.Add (new MenuBar ());
         Assert.NotNull (top.MenuBar);
         Assert.NotNull (top.MenuBar);
 
 
-        // Application.Top with a menu and without status bar.
+        // Application.Current with a menu and without status bar.
         View.GetLocationEnsuringFullVisibility (win, 2, 2, out nx, out ny /*, out sb*/);
         View.GetLocationEnsuringFullVisibility (win, 2, 2, out nx, out ny /*, out sb*/);
         Assert.Equal (2, nx);
         Assert.Equal (2, nx);
         Assert.Equal (2, ny);
         Assert.Equal (2, ny);
@@ -198,7 +198,7 @@ public class ToplevelTests
 
 
         //Assert.NotNull (top.StatusBar);
         //Assert.NotNull (top.StatusBar);
 
 
-        // Application.Top with a menu and status bar.
+        // Application.Current with a menu and status bar.
         View.GetLocationEnsuringFullVisibility (win, 30, 20, out nx, out ny /*, out sb*/);
         View.GetLocationEnsuringFullVisibility (win, 30, 20, out nx, out ny /*, out sb*/);
         Assert.Equal (20, nx); // 20+60=80
         Assert.Equal (20, nx); // 20+60=80
 
 
@@ -307,7 +307,7 @@ public class ToplevelTests
             }
             }
             else if (iterations == 1)
             else if (iterations == 1)
             {
             {
-                Assert.Equal (new (2, 2), Application.Top!.Frame.Location);
+                Assert.Equal (new (2, 2), Application.Current!.Frame.Location);
             }
             }
             else if (iterations == 2)
             else if (iterations == 2)
             {
             {
@@ -316,12 +316,12 @@ public class ToplevelTests
                 // Grab the mouse
                 // Grab the mouse
                 Application.RaiseMouseEvent (new () { ScreenPosition = new (3, 2), Flags = MouseFlags.Button1Pressed });
                 Application.RaiseMouseEvent (new () { ScreenPosition = new (3, 2), Flags = MouseFlags.Button1Pressed });
 
 
-                Assert.Equal (Application.Top!.Border, Application.Mouse.MouseGrabView);
-                Assert.Equal (new (2, 2, 10, 3), Application.Top.Frame);
+                Assert.Equal (Application.Current!.Border, Application.Mouse.MouseGrabView);
+                Assert.Equal (new (2, 2, 10, 3), Application.Current.Frame);
             }
             }
             else if (iterations == 3)
             else if (iterations == 3)
             {
             {
-                Assert.Equal (Application.Top!.Border, Application.Mouse.MouseGrabView);
+                Assert.Equal (Application.Current!.Border, Application.Mouse.MouseGrabView);
 
 
                 // Drag to left
                 // Drag to left
                 Application.RaiseMouseEvent (
                 Application.RaiseMouseEvent (
@@ -333,38 +333,38 @@ public class ToplevelTests
                                              });
                                              });
                 AutoInitShutdownAttribute.RunIteration ();
                 AutoInitShutdownAttribute.RunIteration ();
 
 
-                Assert.Equal (Application.Top.Border, Application.Mouse.MouseGrabView);
-                Assert.Equal (new (1, 2, 10, 3), Application.Top.Frame);
+                Assert.Equal (Application.Current.Border, Application.Mouse.MouseGrabView);
+                Assert.Equal (new (1, 2, 10, 3), Application.Current.Frame);
             }
             }
             else if (iterations == 4)
             else if (iterations == 4)
             {
             {
-                Assert.Equal (Application.Top!.Border, Application.Mouse.MouseGrabView);
-                Assert.Equal (new (1, 2), Application.Top.Frame.Location);
+                Assert.Equal (Application.Current!.Border, Application.Mouse.MouseGrabView);
+                Assert.Equal (new (1, 2), Application.Current.Frame.Location);
 
 
-                Assert.Equal (Application.Top.Border, Application.Mouse.MouseGrabView);
+                Assert.Equal (Application.Current.Border, Application.Mouse.MouseGrabView);
             }
             }
             else if (iterations == 5)
             else if (iterations == 5)
             {
             {
-                Assert.Equal (Application.Top!.Border, Application.Mouse.MouseGrabView);
+                Assert.Equal (Application.Current!.Border, Application.Mouse.MouseGrabView);
 
 
                 // Drag up
                 // Drag up
                 Application.RaiseMouseEvent (new () { ScreenPosition = new (2, 1), Flags = MouseFlags.Button1Pressed | MouseFlags.ReportMousePosition });
                 Application.RaiseMouseEvent (new () { ScreenPosition = new (2, 1), Flags = MouseFlags.Button1Pressed | MouseFlags.ReportMousePosition });
                 AutoInitShutdownAttribute.RunIteration ();
                 AutoInitShutdownAttribute.RunIteration ();
 
 
-                Assert.Equal (Application.Top!.Border, Application.Mouse.MouseGrabView);
-                Assert.Equal (new (1, 1, 10, 3), Application.Top.Frame);
+                Assert.Equal (Application.Current!.Border, Application.Mouse.MouseGrabView);
+                Assert.Equal (new (1, 1, 10, 3), Application.Current.Frame);
             }
             }
             else if (iterations == 6)
             else if (iterations == 6)
             {
             {
-                Assert.Equal (Application.Top!.Border, Application.Mouse.MouseGrabView);
-                Assert.Equal (new (1, 1), Application.Top.Frame.Location);
+                Assert.Equal (Application.Current!.Border, Application.Mouse.MouseGrabView);
+                Assert.Equal (new (1, 1), Application.Current.Frame.Location);
 
 
-                Assert.Equal (Application.Top.Border, Application.Mouse.MouseGrabView);
-                Assert.Equal (new (1, 1, 10, 3), Application.Top.Frame);
+                Assert.Equal (Application.Current.Border, Application.Mouse.MouseGrabView);
+                Assert.Equal (new (1, 1, 10, 3), Application.Current.Frame);
             }
             }
             else if (iterations == 7)
             else if (iterations == 7)
             {
             {
-                Assert.Equal (Application.Top!.Border, Application.Mouse.MouseGrabView);
+                Assert.Equal (Application.Current!.Border, Application.Mouse.MouseGrabView);
 
 
                 // Ungrab the mouse
                 // Ungrab the mouse
                 Application.RaiseMouseEvent (new () { ScreenPosition = new (2, 1), Flags = MouseFlags.Button1Released });
                 Application.RaiseMouseEvent (new () { ScreenPosition = new (2, 1), Flags = MouseFlags.Button1Released });

+ 2 - 2
Tests/UnitTestsParallelizable/TestSetup.cs

@@ -39,7 +39,7 @@ public class GlobalTestSetup : IDisposable
         // Check that all Application fields and properties are set to their default values
         // Check that all Application fields and properties are set to their default values
 
 
         // Public Properties
         // Public Properties
-        Assert.Null (Application.Top);
+        Assert.Null (Application.Current);
         Assert.Null (Application.Mouse.MouseGrabView);
         Assert.Null (Application.Mouse.MouseGrabView);
 
 
         // Don't check Application.ForceDriver
         // Don't check Application.ForceDriver
@@ -59,7 +59,7 @@ public class GlobalTestSetup : IDisposable
         Assert.Equal (Application.GetSupportedCultures (), Application.SupportedCultures);
         Assert.Equal (Application.GetSupportedCultures (), Application.SupportedCultures);
         Assert.Equal (Application.GetAvailableCulturesFromEmbeddedResources (), Application.SupportedCultures);
         Assert.Equal (Application.GetAvailableCulturesFromEmbeddedResources (), Application.SupportedCultures);
         Assert.Null (Application.MainThreadId);
         Assert.Null (Application.MainThreadId);
-        Assert.Empty (Application.TopLevels);
+        Assert.Empty (Application.SessionStack);
         Assert.Empty (Application.CachedViewsUnderMouse);
         Assert.Empty (Application.CachedViewsUnderMouse);
 
 
         // Mouse
         // Mouse