mirror of
https://github.com/Ryujinx/Opentk.git
synced 2024-12-27 06:05:56 +00:00
223c742648
Update X11 stack to use System.Windows.Forms.XPlatUI for its Display, Screen and RootWindow. Fixed mode setting for X11GLControl. Fixed X11 shutdown (was generating X11 errors). Added DeviceContext getter to WinWindowInfo. Made IWindowInfo disposable. Added documentation to many public methods. Worked around a Mono 1.2.4 bug with Handle creation on Windows.Forms.Control. Updated GL.BuildExtensionList to correctly parse GL_VERSION when in indirect rendering mode. Fixed crash errors in X11GLContext.CreateContext and X11GraphicsMode. Added a ref overload to Glx.ChooseVisual() IGraphicsContext.MakeCurrent now takes an IWindowInfo parameter. This allows the user to change to window is context is bound to (untested). Renamed XyzWindowInfo.Handle to XyzWindowInfo.WindowHandle.
125 lines
3.5 KiB
C#
125 lines
3.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
|
|
namespace OpenTK.Platform.Windows
|
|
{
|
|
/// <internal />
|
|
/// <summary>Describes a win32 window.</summary>
|
|
internal sealed class WinWindowInfo : IWindowInfo
|
|
{
|
|
IntPtr handle, dc;
|
|
WinWindowInfo parent;
|
|
bool disposed;
|
|
|
|
#region --- Constructors ---
|
|
|
|
internal WinWindowInfo()
|
|
{
|
|
}
|
|
|
|
internal WinWindowInfo(IntPtr handle, WinWindowInfo parent)
|
|
{
|
|
this.handle = handle;
|
|
this.parent = parent;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region --- Public Methods ---
|
|
|
|
public IntPtr WindowHandle { get { return handle; } set { handle = value; } }
|
|
public WinWindowInfo Parent { get { return parent; } set { parent = value; } }
|
|
public IntPtr DeviceContext
|
|
{
|
|
get
|
|
{
|
|
if (dc == IntPtr.Zero)
|
|
dc = Functions.GetDC(this.WindowHandle);
|
|
return dc;
|
|
}
|
|
//set { dc = value; }
|
|
}
|
|
|
|
#region public override string ToString()
|
|
|
|
/// <summary>Returns a System.String that represents the current window.</summary>
|
|
/// <returns>A System.String that represents the current window.</returns>
|
|
public override string ToString()
|
|
{
|
|
return String.Format("Windows.WindowInfo: Handle {0}, Parent ({1})",
|
|
this.WindowHandle, this.Parent != null ? this.Parent.ToString() : "null");
|
|
}
|
|
|
|
/// <summary>Checks if <c>this</c> and <c>obj</c> reference the same win32 window.</summary>
|
|
/// <param name="obj">The object to check against.</param>
|
|
/// <returns>True if <c>this</c> and <c>obj</c> reference the same win32 window; false otherwise.</returns>
|
|
public override bool Equals(object obj)
|
|
{
|
|
if (obj == null) return false;
|
|
if (this.GetType() != obj.GetType()) return false;
|
|
WinWindowInfo info = (WinWindowInfo)obj;
|
|
|
|
if (info == null) return false;
|
|
// TODO: Assumes windows will always have unique handles.
|
|
return handle.Equals(info.handle);
|
|
}
|
|
|
|
/// <summary>Returns the hash code for this instance.</summary>
|
|
/// <returns>A hash code for the current <c>WinWindowInfo</c>.</returns>
|
|
public override int GetHashCode()
|
|
{
|
|
return handle.GetHashCode();
|
|
}
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
#region --- IDisposable ---
|
|
|
|
#region public void Dispose()
|
|
|
|
/// <summary>Releases the unmanaged resources consumed by this instance.</summary>
|
|
public void Dispose()
|
|
{
|
|
this.Dispose(true);
|
|
GC.SuppressFinalize(this);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region void Dispose(bool manual)
|
|
|
|
void Dispose(bool manual)
|
|
{
|
|
if (!disposed)
|
|
{
|
|
if (this.dc != IntPtr.Zero)
|
|
Functions.ReleaseDC(this.handle, this.dc);
|
|
|
|
if (manual)
|
|
{
|
|
if (parent != null)
|
|
parent.Dispose();
|
|
}
|
|
|
|
disposed = true;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region ~WinWindowInfo()
|
|
|
|
~WinWindowInfo()
|
|
{
|
|
this.Dispose(false);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
}
|
|
}
|