From a90a6c6e3d31b7172c11a1fcccaaeb4927a45f0f Mon Sep 17 00:00:00 2001 From: the_fiddler Date: Sun, 13 Apr 2008 21:32:04 +0000 Subject: [PATCH] Added stub for WindowState. --- Source/OpenTK/GameWindow.cs | 14 ++- Source/OpenTK/Platform/INativeGLWindow.cs | 1 + Source/OpenTK/Platform/Windows/WinGLNative.cs | 16 ++++ Source/OpenTK/Platform/X11/X11GLNative.cs | 92 +++++++++++-------- Source/OpenTK/WindowState.cs | 37 ++++++++ 5 files changed, 121 insertions(+), 39 deletions(-) create mode 100644 Source/OpenTK/WindowState.cs diff --git a/Source/OpenTK/GameWindow.cs b/Source/OpenTK/GameWindow.cs index 89dfea46..75936b5d 100644 --- a/Source/OpenTK/GameWindow.cs +++ b/Source/OpenTK/GameWindow.cs @@ -262,7 +262,7 @@ namespace OpenTK #endregion - #region --- Public Methods --- + #region --- Public Members --- #region public virtual void Exit() @@ -925,6 +925,18 @@ namespace OpenTK #endregion + internal WindowState WindowState + { + get + { + return glWindow.WindowState; + } + set + { + glWindow.WindowState = value; + } + } + #endregion #region --- GameWindow Timing --- diff --git a/Source/OpenTK/Platform/INativeGLWindow.cs b/Source/OpenTK/Platform/INativeGLWindow.cs index f1036ea3..9f93d61b 100644 --- a/Source/OpenTK/Platform/INativeGLWindow.cs +++ b/Source/OpenTK/Platform/INativeGLWindow.cs @@ -35,6 +35,7 @@ namespace OpenTK.Platform //IGraphicsContext Context { get; } IInputDriver InputDriver { get; } bool Fullscreen { get; set; } + WindowState WindowState { get; set; } event CreateEvent Create; event DestroyEvent Destroy; diff --git a/Source/OpenTK/Platform/Windows/WinGLNative.cs b/Source/OpenTK/Platform/Windows/WinGLNative.cs index 7162299e..abdec494 100644 --- a/Source/OpenTK/Platform/Windows/WinGLNative.cs +++ b/Source/OpenTK/Platform/Windows/WinGLNative.cs @@ -455,6 +455,22 @@ namespace OpenTK.Platform.Windows #endregion + #region public OpenTK.WindowState WindowState + + public OpenTK.WindowState WindowState + { + get + { + throw new NotImplementedException(); + } + set + { + throw new NotImplementedException(); + } + } + + #endregion + #endregion #region --- IResizable Members --- diff --git a/Source/OpenTK/Platform/X11/X11GLNative.cs b/Source/OpenTK/Platform/X11/X11GLNative.cs index 6e5628e8..80620cef 100644 --- a/Source/OpenTK/Platform/X11/X11GLNative.cs +++ b/Source/OpenTK/Platform/X11/X11GLNative.cs @@ -94,22 +94,22 @@ namespace OpenTK.Platform.X11 //window.Screen = (int)xplatui.GetField("ScreenNo", // System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic).GetValue(null); - // Open a display connection to the X server, and obtain the screen and root window. - window.Display = API.DefaultDisplay;//Functions.XOpenDisplay(IntPtr.Zero); // IntPtr.Zero == default display + // Open a display connection to the X server, and obtain the screen and root window. + window.Display = API.DefaultDisplay;//Functions.XOpenDisplay(IntPtr.Zero); // IntPtr.Zero == default display if (window.Display == IntPtr.Zero) throw new Exception("Could not open connection to X"); - - try - { - Functions.XLockDisplay(window.Display); + + try + { + Functions.XLockDisplay(window.Display); window.Screen = Functions.XDefaultScreen(window.Display); //API.DefaultScreen; - window.RootWindow = Functions.XRootWindow(window.Display, window.Screen); // API.RootWindow; - } - finally - { - Functions.XUnlockDisplay(window.Display); + window.RootWindow = Functions.XRootWindow(window.Display, window.Screen); // API.RootWindow; } - + finally + { + Functions.XUnlockDisplay(window.Display); + } + Debug.Print("Display: {0}, Screen {1}, Root window: {2}", window.Display, window.Screen, window.RootWindow); RegisterAtoms(window); @@ -154,12 +154,12 @@ namespace OpenTK.Platform.X11 if (width <= 0) throw new ArgumentOutOfRangeException("width", "Must be higher than zero."); if (height <= 0) throw new ArgumentOutOfRangeException("height", "Must be higher than zero."); if (exists) throw new InvalidOperationException("A render window already exists."); - - XVisualInfo info = new XVisualInfo(); - Debug.Indent(); - - lock (API.Lock) + XVisualInfo info = new XVisualInfo(); + + Debug.Indent(); + + lock (API.Lock) { info.visualid = mode.Index; int dummy; @@ -193,15 +193,15 @@ namespace OpenTK.Platform.X11 //Glx.CreateContext(window.Display, ref vis, IntPtr.Zero, true); } context = new GraphicsContext(mode, window); - + // Set the window hints XSizeHints hints = new XSizeHints(); hints.x = 0; hints.y = 0; hints.width = width; hints.height = height; - hints.flags = (IntPtr)(XSizeHintsFlags.USSize | XSizeHintsFlags.USPosition); - lock (API.Lock) + hints.flags = (IntPtr)(XSizeHintsFlags.USSize | XSizeHintsFlags.USPosition); + lock (API.Lock) { Functions.XSetWMNormalHints(window.Display, window.WindowHandle, ref hints); @@ -220,10 +220,10 @@ namespace OpenTK.Platform.X11 //Functions.XSetWMProperties(display, window, name, name, 0, /*None*/ null, 0, hints); Debug.Print("done! (id: {0})", window.WindowHandle); - - lock (API.Lock) + + lock (API.Lock) { - API.MapRaised(window.Display, window.WindowHandle); + API.MapRaised(window.Display, window.WindowHandle); } mapped = true; @@ -243,10 +243,10 @@ namespace OpenTK.Platform.X11 public void ProcessEvents() { // Process all pending events - //while (true) - while (Functions.XCheckWindowEvent(window.Display, window.WindowHandle, window.EventMask, ref e) || + //while (true) + while (Functions.XCheckWindowEvent(window.Display, window.WindowHandle, window.EventMask, ref e) || Functions.XCheckTypedWindowEvent(window.Display, window.WindowHandle, XEventName.ClientMessage, ref e)) - { + { //pending = Functions.XPending(window.Display); //pending = API.Pending(window.Display); @@ -563,6 +563,22 @@ namespace OpenTK.Platform.X11 #endregion + #region public OpenTK.WindowState WindowState + + public OpenTK.WindowState WindowState + { + get + { + throw new NotImplementedException(); + } + set + { + throw new NotImplementedException(); + } + } + + #endregion + #endregion #region --- IResizable Members --- @@ -678,24 +694,24 @@ namespace OpenTK.Platform.X11 private void Dispose(bool manuallyCalled) { if (!disposed) - { + { if (window != null && window.WindowHandle != IntPtr.Zero) { - try - { - Functions.XLockDisplay(window.Display); - Functions.XDestroyWindow(window.Display, window.WindowHandle); - } - finally - { - Functions.XUnlockDisplay(window.Display); - } + try + { + Functions.XLockDisplay(window.Display); + Functions.XDestroyWindow(window.Display, window.WindowHandle); + } + finally + { + Functions.XUnlockDisplay(window.Display); + } window = null; } - + if (manuallyCalled) - { + { } disposed = true; } diff --git a/Source/OpenTK/WindowState.cs b/Source/OpenTK/WindowState.cs new file mode 100644 index 00000000..9d2604f6 --- /dev/null +++ b/Source/OpenTK/WindowState.cs @@ -0,0 +1,37 @@ +#region --- License --- +/* Licensed under the MIT/X11 license. + * Copyright (c) 2006-2008 the OpenTK Team. + * This notice may not be removed from any source distribution. + * See license.txt for licensing details. + */ +#endregion + +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenTK +{ + /// + /// Defines the available states for the GameWindow. + /// + public enum WindowState + { + /// + /// The GameWindow is minimized to the taskbar (also known as 'iconified'). + /// + Minimized, + /// + /// The GameWindow is in its normal state. + /// + Normal, + /// + /// The GameWindow covers the whole working area, which includes the desktop but not the taskbar and/or panels. + /// + Maximized, + /// + /// The GameWindow covers the whole screen, including all taskbars and/or panels. + /// + Fullscreen + } +}