diff --git a/Terminal.Gui/App/ApplicationImpl.Lifecycle.cs b/Terminal.Gui/App/ApplicationImpl.Lifecycle.cs
index acdd2a0cf..ed548ebca 100644
--- a/Terminal.Gui/App/ApplicationImpl.Lifecycle.cs
+++ b/Terminal.Gui/App/ApplicationImpl.Lifecycle.cs
@@ -87,7 +87,7 @@ internal partial class ApplicationImpl
_keyboard.PrevTabGroupKey = existingPrevTabGroupKey;
CreateDriver (_driverName);
- Screen = Driver!.Screen;
+ //Screen = Driver!.Screen;
Initialized = true;
RaiseInitializedChanged (this, new (true));
@@ -273,10 +273,6 @@ internal partial class ApplicationImpl
Driver = null;
}
- // Reset screen
- ResetScreen ();
- _screen = null;
-
// === 5. Clear run state ===
Iteration = null;
SessionBegun = null;
diff --git a/Terminal.Gui/App/ApplicationImpl.Screen.cs b/Terminal.Gui/App/ApplicationImpl.Screen.cs
index 2605156dc..bbd43cf70 100644
--- a/Terminal.Gui/App/ApplicationImpl.Screen.cs
+++ b/Terminal.Gui/App/ApplicationImpl.Screen.cs
@@ -5,24 +5,10 @@ internal partial class ApplicationImpl
///
public event EventHandler>? ScreenChanged;
- private readonly object _lockScreen = new ();
- private Rectangle? _screen;
-
///
public Rectangle Screen
{
- get
- {
- lock (_lockScreen)
- {
- if (_screen == null)
- {
- _screen = Driver?.Screen ?? new (new (0, 0), new (2048, 2048));
- }
-
- return _screen.Value;
- }
- }
+ get => Driver?.Screen ?? new (new (0, 0), new (2048, 2048));
set
{
if (value is { } && (value.X != 0 || value.Y != 0))
@@ -30,12 +16,7 @@ internal partial class ApplicationImpl
throw new NotImplementedException ("Screen locations other than 0, 0 are not yet supported");
}
- // TODO: Enable this to actually change the Driver.
-
- lock (_lockScreen)
- {
- _screen = value;
- }
+ Driver?.SetScreenSize (value.Size.Width, value.Size.Height);
}
}
@@ -115,16 +96,6 @@ internal partial class ApplicationImpl
return false;
}
- ///
- /// INTERNAL: Resets the Screen rectangle to null so it will be recalculated on next access.
- ///
- private void ResetScreen ()
- {
- lock (_lockScreen)
- {
- _screen = null;
- }
- }
///
/// INTERNAL: Called when the application's screen has changed.
@@ -133,7 +104,7 @@ internal partial class ApplicationImpl
/// The new screen size and position.
private void RaiseScreenChangedEvent (Rectangle screen)
{
- Screen = new (Point.Empty, screen.Size);
+ //Screen = new (Point.Empty, screen.Size);
ScreenChanged?.Invoke (this, new (screen));
@@ -185,7 +156,7 @@ internal partial class ApplicationImpl
// Only force a complete redraw if needed (needsLayout or forceRedraw).
// Otherwise, just redraw views that need it.
- View.Draw (views: views.ToArray ().Cast ()!, neededLayout || forceRedraw);
+ View.Draw (views: views.ToArray ().Cast (), neededLayout || forceRedraw);
Driver.Clip = new (Screen);
diff --git a/Terminal.Gui/App/IApplication.cs b/Terminal.Gui/App/IApplication.cs
index 4d0959a2f..9933ab178 100644
--- a/Terminal.Gui/App/IApplication.cs
+++ b/Terminal.Gui/App/IApplication.cs
@@ -463,8 +463,9 @@ public interface IApplication : IDisposable
string ForceDriver { get; set; }
///
- /// Gets or sets the size of the screen. By default, this is the size of the screen as reported by the
- /// .
+ /// Gets or location and size of the application in the terminal. By default, the location is (0, 0) and the size
+ /// is the size of the terminal as reported by the .
+ /// Setting the location to anything but (0, 0) is not supported and will throw .
///
///
///
diff --git a/Tests/UnitTestsParallelizable/Application/IApplicationScreenChangedTests.cs b/Tests/UnitTestsParallelizable/Application/IApplicationScreenChangedTests.cs
index 112860cd0..55557266b 100644
--- a/Tests/UnitTestsParallelizable/Application/IApplicationScreenChangedTests.cs
+++ b/Tests/UnitTestsParallelizable/Application/IApplicationScreenChangedTests.cs
@@ -383,7 +383,7 @@ public class IApplicationScreenChangedTests (ITestOutputHelper output)
}
[Fact]
- public void Screen_Property_Setting_Does_Not_Fire_ScreenChanged_Event ()
+ public void Screen_Property_Setting_Raises_ScreenChanged_Event ()
{
// Arrange
using IApplication app = Application.Create ();
@@ -397,11 +397,10 @@ public class IApplicationScreenChangedTests (ITestOutputHelper output)
try
{
- // Act - Manually set Screen property (not via driver resize)
+ // Act - Manually set Screen property
app.Screen = new (0, 0, 100, 50);
- // Assert - Event should not fire for manual property setting
- Assert.False (eventFired);
+ Assert.True (eventFired);
Assert.Equal (new (0, 0, 100, 50), app.Screen);
}
finally