Skip to content

Commit 8bb8851

Browse files
fix: fullscreen state bug
1 parent f41020f commit 8bb8851

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

src/BlazorDesktop/Wpf/BlazorDesktopWindow.cs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,13 @@ public partial class BlazorDesktopWindow : Window
3636
/// <summary>
3737
/// If the window is fullscreen.
3838
/// </summary>
39-
public bool IsFullscreen => _fullscreen && WindowState == WindowState.Normal;
39+
public bool IsFullscreen { get; private set; }
4040

4141
/// <summary>
4242
/// Occurs when <see cref="IsFullscreen"/> changes.
4343
/// </summary>
4444
public event EventHandler<bool>? OnFullscreenChanged;
4545

46-
private bool _fullscreen;
4746
private WindowState _fullscreenStoredState = WindowState.Normal;
4847
private readonly IServiceProvider _services;
4948
private readonly IConfiguration _config;
@@ -95,10 +94,10 @@ public void ToggleFullScreen()
9594
{
9695
if (WindowStyle == WindowStyle.SingleBorderWindow)
9796
{
98-
_fullscreen = true;
97+
IsFullscreen = true;
9998
_fullscreenStoredState = WindowState;
10099

101-
UseFrame(_config.GetValue<bool?>(WindowDefaults.Frame) ?? true, _fullscreen);
100+
UseFrame(_config.GetValue<bool?>(WindowDefaults.Frame) ?? true);
102101
WindowStyle = WindowStyle.None;
103102

104103
if (WindowState == WindowState.Maximized)
@@ -112,9 +111,9 @@ public void ToggleFullScreen()
112111
}
113112
else
114113
{
115-
_fullscreen = false;
114+
IsFullscreen = false;
116115

117-
UseFrame(_config.GetValue<bool?>(WindowDefaults.Frame) ?? true, _fullscreen);
116+
UseFrame(_config.GetValue<bool?>(WindowDefaults.Frame) ?? true);
118117
WindowStyle = WindowStyle.SingleBorderWindow;
119118
WindowState = _fullscreenStoredState;
120119

@@ -240,7 +239,7 @@ private void InitializeWindow()
240239
MinWidth = minWidth;
241240
MaxHeight = maxHeight;
242241
MaxWidth = maxWidth;
243-
UseFrame(useFrame, _fullscreen);
242+
UseFrame(useFrame);
244243
ResizeMode = (_config.GetValue<bool?>(WindowDefaults.Resizable) ?? true) ? ResizeMode.CanResize : ResizeMode.NoResize;
245244
UseIcon(_config.GetValue<string?>(WindowDefaults.Icon) ?? string.Empty);
246245
Content = WebViewBorder;
@@ -312,7 +311,7 @@ private void UpdateWebViewBorderThickness()
312311

313312
if (WindowState == WindowState.Maximized && !useFrame)
314313
{
315-
if (_fullscreen)
314+
if (IsFullscreen)
316315
{
317316
WebViewBorder.BorderThickness = new Thickness(7, 7, 7, 7);
318317
}
@@ -345,11 +344,11 @@ private void UpdateTheme()
345344
}
346345
}
347346

348-
private void UseFrame(bool frame, bool fullscreen)
347+
private void UseFrame(bool frame)
349348
{
350349
if (!frame)
351350
{
352-
if (fullscreen)
351+
if (IsFullscreen)
353352
{
354353
WindowChrome.SetWindowChrome(this, new() { NonClientFrameEdges = NonClientFrameEdges.None });
355354
}

0 commit comments

Comments
 (0)