diff --git a/src/OpenTK.Windowing.Desktop/NativeWindow.cs b/src/OpenTK.Windowing.Desktop/NativeWindow.cs index 1bf06a7208..b6c289eb5d 100644 --- a/src/OpenTK.Windowing.Desktop/NativeWindow.cs +++ b/src/OpenTK.Windowing.Desktop/NativeWindow.cs @@ -483,8 +483,8 @@ public unsafe Vector2i ClientLocation } } - private Vector2i? _minimumSize; - private Vector2i? _maximumSize; + private Vector2i? _minimumClientSize; + private Vector2i? _maximumClientize; /// /// Gets or sets a structure that contains the external size of this window. @@ -537,11 +537,11 @@ public unsafe Vector2i ClientSize /// public unsafe Vector2i? MinimumSize { - get => _minimumSize; + get => _minimumClientSize; set { - _minimumSize = value; - GLFW.SetWindowSizeLimits(WindowPtr, value?.X ?? GLFW.DontCare, value?.Y ?? GLFW.DontCare, _maximumSize?.X ?? GLFW.DontCare, _maximumSize?.Y ?? GLFW.DontCare); + _minimumClientSize = value; + GLFW.SetWindowSizeLimits(WindowPtr, value?.X ?? GLFW.DontCare, value?.Y ?? GLFW.DontCare, _maximumClientize?.X ?? GLFW.DontCare, _maximumClientize?.Y ?? GLFW.DontCare); } } @@ -554,11 +554,11 @@ public unsafe Vector2i? MinimumSize /// public unsafe Vector2i? MaximumSize { - get => _maximumSize; + get => _maximumClientize; set { - _maximumSize = value; - GLFW.SetWindowSizeLimits(WindowPtr, _minimumSize?.X ?? GLFW.DontCare, _minimumSize?.Y ?? GLFW.DontCare, value?.X ?? GLFW.DontCare, value?.Y ?? GLFW.DontCare); + _maximumClientize = value; + GLFW.SetWindowSizeLimits(WindowPtr, _minimumClientSize?.X ?? GLFW.DontCare, _minimumClientSize?.Y ?? GLFW.DontCare, value?.X ?? GLFW.DontCare, value?.Y ?? GLFW.DontCare); } } @@ -846,7 +846,7 @@ public unsafe NativeWindow(NativeWindowSettings settings) GLFW.WindowHint(WindowHintInt.RefreshRate, modePtr->RefreshRate); _cachedWindowLocation = settings.Location ?? new Vector2i(32, 32); // Better than nothing. - _cachedWindowClientSize = settings.Size; + _cachedWindowClientSize = settings.ClientSize; if (settings.WindowState == WindowState.Fullscreen && _isVisible) { @@ -855,7 +855,7 @@ public unsafe NativeWindow(NativeWindowSettings settings) } else { - WindowPtr = GLFW.CreateWindow(settings.Size.X, settings.Size.Y, _title, null, (Window*)(settings.SharedContext?.WindowPtr ?? IntPtr.Zero)); + WindowPtr = GLFW.CreateWindow(settings.ClientSize.X, settings.ClientSize.Y, _title, null, (Window*)(settings.SharedContext?.WindowPtr ?? IntPtr.Zero)); if (settings.StartVisible) { @@ -916,10 +916,10 @@ public unsafe NativeWindow(NativeWindowSettings settings) GLFW.GetWindowSize(WindowPtr, out var width, out var height); AspectRatio = settings.AspectRatio; - _minimumSize = settings.MinimumSize; - _maximumSize = settings.MaximumSize; + _minimumClientSize = settings.MinimumClientSize; + _maximumClientize = settings.MaximumClientSize; - GLFW.SetWindowSizeLimits(WindowPtr, _minimumSize?.X ?? GLFW.DontCare, _minimumSize?.Y ?? GLFW.DontCare, _maximumSize?.X ?? GLFW.DontCare, _maximumSize?.Y ?? GLFW.DontCare); + GLFW.SetWindowSizeLimits(WindowPtr, _minimumClientSize?.X ?? GLFW.DontCare, _minimumClientSize?.Y ?? GLFW.DontCare, _maximumClientize?.X ?? GLFW.DontCare, _maximumClientize?.Y ?? GLFW.DontCare); GLFW.GetWindowPos(WindowPtr, out var x, out var y); diff --git a/src/OpenTK.Windowing.Desktop/NativeWindowSettings.cs b/src/OpenTK.Windowing.Desktop/NativeWindowSettings.cs index 59b6a3e4f9..8e9183c641 100644 --- a/src/OpenTK.Windowing.Desktop/NativeWindowSettings.cs +++ b/src/OpenTK.Windowing.Desktop/NativeWindowSettings.cs @@ -157,7 +157,7 @@ public NativeWindowSettings() /// /// Gets or sets the initial size of the contents of the window. /// - public Vector2i Size { get; set; } = new Vector2i(640, 360); + public Vector2i ClientSize { get; set; } = new Vector2i(640, 360); /// /// Gets or sets the minimum size of the contents of the window. @@ -166,7 +166,7 @@ public NativeWindowSettings() /// Set to null to remove the minimum size constraint. /// If you set size limits and an aspect ratio that conflict, the results are undefined. /// - public Vector2i? MinimumSize { get; set; } = null; + public Vector2i? MinimumClientSize { get; set; } = null; /// /// Gets or sets the maximum size of the contents of the window. @@ -175,6 +175,19 @@ public NativeWindowSettings() /// Set to null to remove the minimum size constraint. /// If you set size limits and an aspect ratio that conflict, the results are undefined. /// + public Vector2i? MaximumClientSize { get; set; } = null; + + [Obsolete("Use the ClientSize property to get or set the initial size of the contents of the window.")] + public Vector2i Size + { + get => ClientSize; + set { ClientSize = value; } + } + + [Obsolete("Use the MinimumClientSize property to get or set the minimum size of the contents of the window.")] + public Vector2i? MinimumSize { get; set; } = null; + + [Obsolete("Use the MaximumClientSize property to get or set the minimum size of the contents of the window.")] public Vector2i? MaximumSize { get; set; } = null; /// diff --git a/tests/LocalTest/Program.cs b/tests/LocalTest/Program.cs index cd2bfbf0b8..ea86ca741c 100644 --- a/tests/LocalTest/Program.cs +++ b/tests/LocalTest/Program.cs @@ -2,11 +2,8 @@ using OpenTK.Mathematics; using OpenTK.Windowing.Common; using OpenTK.Windowing.Desktop; -using OpenTK.Windowing.GraphicsLibraryFramework; using System; -using System.Diagnostics; -using System.Runtime.InteropServices; -using System.Threading; +using System.Linq; namespace LocalTest { @@ -17,7 +14,7 @@ static void Main(string[] args) GameWindowSettings gwSettings = new GameWindowSettings() { UpdateFrequency = 250, - //RenderFrequency = 10, + //RenderFrequency = 10, Obsolete as of 4.8.1 }; NativeWindowSettings nwSettings = new NativeWindowSettings() @@ -28,7 +25,8 @@ static void Main(string[] args) Flags = ContextFlags.Debug | ContextFlags.ForwardCompatible, IsEventDriven = false, Profile = ContextProfile.Core, - Size = (800, 600), + ClientSize = (800, 600), + //Size = (800, 600), Obsolete as of 4.8.2 StartFocused = true, StartVisible = true, Title = "Local OpenTK Test", @@ -36,14 +34,27 @@ static void Main(string[] args) WindowState = WindowState.Normal, }; - using (Window window = new Window(gwSettings, nwSettings)) - { - window.Run(); - } + using Window window = new Window(gwSettings, nwSettings); + window.Run(); } public Window(GameWindowSettings gwSettings, NativeWindowSettings nwSettings) : base(gwSettings, nwSettings) { + Console.WriteLine("\nGameWindowSettings:"); + DumpProperties(gwSettings); + Console.WriteLine("\nNativeWindowSettings:"); + DumpProperties(nwSettings); + + void DumpProperties(object o) + { + var properties = o.GetType().GetProperties().OrderBy(p => p.Name).ToList(); + foreach(var prop in properties) + { + var attribs = prop.GetCustomAttributes(typeof(ObsoleteAttribute), true); + if(attribs.Length == 0) // ignore obsolete properties, including inherited ones + Console.WriteLine($" {prop.Name} = {prop.GetValue(o)}"); + } + } } protected override void OnLoad()