Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WindowState.FullScreen support #1519

Draft
wants to merge 3 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/Eto.Gtk/Forms/GtkWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -700,12 +700,12 @@ public WindowState WindowState
if (gdkWindow == null)
return state;

if (gdkWindow.State.HasFlag(Gdk.WindowState.Fullscreen))
return WindowState.FullScreen;
if (gdkWindow.State.HasFlag(Gdk.WindowState.Iconified))
return WindowState.Minimized;
if (gdkWindow.State.HasFlag(Gdk.WindowState.Maximized))
return WindowState.Maximized;
if (gdkWindow.State.HasFlag(Gdk.WindowState.Fullscreen))
return WindowState.Maximized;
return WindowState.Normal;
}
set
Expand All @@ -716,6 +716,14 @@ public WindowState WindowState
var gdkWindow = Control.GetWindow();
switch (value)
{
case WindowState.FullScreen:
if (gdkWindow != null)
{
if (gdkWindow.State.HasFlag(Gdk.WindowState.Iconified))
Control.Deiconify();
}
Control.Fullscreen();
break;
case WindowState.Maximized:
if (gdkWindow != null)
{
Expand Down
21 changes: 21 additions & 0 deletions src/Eto.Mac/Forms/MacWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,8 @@ public override void AttachEvent(string id)
case Window.WindowStateChangedEvent:
Control.DidMiniaturize += HandleWindowStateChanged;
Control.DidDeminiaturize += HandleWindowStateChanged;
Control.DidEnterFullScreen += HandleWindowStateChanged;
Control.DidExitFullScreen += HandleWindowStateChanged;
break;
case Eto.Forms.Control.ShownEvent:
// handled when shown
Expand Down Expand Up @@ -1021,6 +1023,8 @@ public WindowState WindowState
{
if (initialState != null)
return initialState.Value;
if (Control.StyleMask.HasFlag(NSWindowStyle.FullScreenWindow))
return WindowState.FullScreen;
if (Control.IsMiniaturized)
return WindowState.Minimized;
if (Control.IsZoomed)
Expand All @@ -1032,21 +1036,38 @@ public WindowState WindowState
if (!Widget.Loaded)
{
initialState = value;
Callback.OnWindowStateChanged(Widget, EventArgs.Empty);
return;
}
switch (value)
{
case WindowState.FullScreen:
if (!Control.StyleMask.HasFlag(NSWindowStyle.FullScreenWindow))
Control.ToggleFullScreen(Control);
break;
case WindowState.Maximized:
if (Control.StyleMask.HasFlag(NSWindowStyle.FullScreenWindow))
{
Control.ToggleFullScreen(Control);
Application.Instance.AsyncInvoke(() => Control.OrderFront(Control));
}
if (Control.IsMiniaturized)
Control.Deminiaturize(Control);
if (!Control.IsZoomed)
Control.PerformZoom(Control);
break;
case WindowState.Minimized:
if (Control.StyleMask.HasFlag(NSWindowStyle.FullScreenWindow))
Control.ToggleFullScreen(Control);
if (!Control.IsMiniaturized)
Control.Miniaturize(Control);
break;
case WindowState.Normal:
if (Control.StyleMask.HasFlag(NSWindowStyle.FullScreenWindow))
{
Control.ToggleFullScreen(Control);
Application.Instance.AsyncInvoke(() => Control.OrderFront(Control));
}
if (Control.IsZoomed)
Control.Zoom(Control);
if (Control.IsMiniaturized)
Expand Down
6 changes: 5 additions & 1 deletion src/Eto/Forms/Window.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ public enum WindowState
/// <summary>
/// Window is minimized to the dock/taskbar/etc.
/// </summary>
Minimized
Minimized,
/// <summary>
/// Window is in full screen mode
/// </summary>
FullScreen
}

/// <summary>
Expand Down
3 changes: 2 additions & 1 deletion test/Eto.Test/Sections/Behaviors/WindowsSection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -605,9 +605,10 @@ static void child_OwnerChanged(object sender, EventArgs e)
Log.Write(child, "OwnerChanged: {0}", child.Owner);
}

static void child_WindowStateChanged(object sender, EventArgs e)
void child_WindowStateChanged(object sender, EventArgs e)
{
var child = (Window)sender;
stateCombo.SelectedValue = child.WindowState;
Log.Write(child, "StateChanged: {0}", child.WindowState);
}

Expand Down
Loading