From 4414886832a6574f03997cdd9a4e76dcd2aa7416 Mon Sep 17 00:00:00 2001 From: Goz3rr Date: Thu, 15 May 2014 00:38:06 +0200 Subject: [PATCH 1/3] Added GameWindowFlags.FixedWindow to allow for fixed border SDL Windows --- Source/OpenTK/GameWindowFlags.cs | 5 +++++ Source/OpenTK/Platform/SDL2/Sdl2NativeWindow.cs | 9 +++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Source/OpenTK/GameWindowFlags.cs b/Source/OpenTK/GameWindowFlags.cs index 91bfca18..dfb6fbda 100644 --- a/Source/OpenTK/GameWindowFlags.cs +++ b/Source/OpenTK/GameWindowFlags.cs @@ -44,5 +44,10 @@ namespace OpenTK /// Indicates that the GameWindow should cover the whole screen. /// Fullscreen = 1, + + /// + /// Indicates that the GameWindow should be a fixed window. + /// + FixedWindow = 2, } } \ No newline at end of file diff --git a/Source/OpenTK/Platform/SDL2/Sdl2NativeWindow.cs b/Source/OpenTK/Platform/SDL2/Sdl2NativeWindow.cs index 036fb5c7..3700aef3 100644 --- a/Source/OpenTK/Platform/SDL2/Sdl2NativeWindow.cs +++ b/Source/OpenTK/Platform/SDL2/Sdl2NativeWindow.cs @@ -77,7 +77,6 @@ namespace OpenTK.Platform.SDL2 var bounds = device.Bounds; var flags = TranslateFlags(options); flags |= WindowFlags.OPENGL; - flags |= WindowFlags.RESIZABLE; flags |= WindowFlags.HIDDEN; if (Toolkit.Options.EnableHighResolution) { @@ -88,6 +87,9 @@ namespace OpenTK.Platform.SDL2 (flags & WindowFlags.FULLSCREEN) != 0) window_state = WindowState.Fullscreen; + if ((flags & WindowFlags.RESIZABLE) == 0) + window_border = WindowBorder.Fixed; + IntPtr handle; lock (SDL.Sync) { @@ -114,8 +116,11 @@ namespace OpenTK.Platform.SDL2 else return WindowFlags.FULLSCREEN; - default: + case GameWindowFlags.FixedWindow: return WindowFlags.Default; + + default: + return WindowFlags.Default | WindowFlags.RESIZABLE; } } From 399e08ee33febfe5c5fb677f56f3cace968d5d7b Mon Sep 17 00:00:00 2001 From: Goz3rr Date: Thu, 15 May 2014 11:52:55 +0200 Subject: [PATCH 2/3] Changed TranslateFlags to actually translate flags instead of using switch --- .../OpenTK/Platform/SDL2/Sdl2NativeWindow.cs | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Source/OpenTK/Platform/SDL2/Sdl2NativeWindow.cs b/Source/OpenTK/Platform/SDL2/Sdl2NativeWindow.cs index 3700aef3..0e576e90 100644 --- a/Source/OpenTK/Platform/SDL2/Sdl2NativeWindow.cs +++ b/Source/OpenTK/Platform/SDL2/Sdl2NativeWindow.cs @@ -108,20 +108,20 @@ namespace OpenTK.Platform.SDL2 static WindowFlags TranslateFlags(GameWindowFlags flags) { - switch (flags) + WindowFlags windowFlags = WindowFlags.Default; + + if ((flags & GameWindowFlags.Fullscreen) != 0) { - case GameWindowFlags.Fullscreen: - if (Sdl2Factory.UseFullscreenDesktop) - return WindowFlags.FULLSCREEN_DESKTOP; - else - return WindowFlags.FULLSCREEN; - - case GameWindowFlags.FixedWindow: - return WindowFlags.Default; - - default: - return WindowFlags.Default | WindowFlags.RESIZABLE; + if (Sdl2Factory.UseFullscreenDesktop) + windowFlags |= WindowFlags.FULLSCREEN_DESKTOP; + else + windowFlags |= WindowFlags.FULLSCREEN; } + + if ((flags & GameWindowFlags.FixedWindow) == 0) + windowFlags |= WindowFlags.RESIZABLE; + + return windowFlags; } static Key TranslateKey(Scancode scan) From 0c348d24296f8ed34a337ed917c5c381447b3c48 Mon Sep 17 00:00:00 2001 From: Goz3rr Date: Sat, 17 May 2014 00:27:38 +0200 Subject: [PATCH 3/3] Made NativeWindow set WindowBorder to Fixed when created with FixedWindow flag like SDL windows --- Source/OpenTK/NativeWindow.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Source/OpenTK/NativeWindow.cs b/Source/OpenTK/NativeWindow.cs index 96812c98..9b731f53 100644 --- a/Source/OpenTK/NativeWindow.cs +++ b/Source/OpenTK/NativeWindow.cs @@ -112,6 +112,11 @@ namespace OpenTK } WindowState = WindowState.Fullscreen; } + + if ((options & GameWindowFlags.FixedWindow) != 0) + { + WindowBorder = WindowBorder.Fixed; + } } #endregion