Added IWindowInfo.cs, X11/WindowInfo.cs and Windows/WindowInfo.cs, which hold information regarding a platform specific window object.
Updated everything to not use raw window handles, but rather WindowInfo objects. Added code that (hopefully) creates an invisible input window for X11.
This commit is contained in:
parent
0172ff101c
commit
b630d84add
19 changed files with 405 additions and 155 deletions
|
@ -23,6 +23,18 @@ namespace Examples
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[STAThread]
|
[STAThread]
|
||||||
static void Main()
|
static void Main()
|
||||||
|
{
|
||||||
|
StreamWriter sw = new StreamWriter(Path.Combine(System.Environment.CurrentDirectory, "debug.log"));
|
||||||
|
System.Diagnostics.Debug.Listeners.Clear();
|
||||||
|
System.Diagnostics.Debug.Listeners.Add(new TextWriterTraceListener(sw));
|
||||||
|
System.Diagnostics.Debug.AutoFlush = true;
|
||||||
|
Debug.AutoFlush = true;
|
||||||
|
System.Diagnostics.Trace.Listeners.Clear();
|
||||||
|
System.Diagnostics.Trace.Listeners.Add(new TextWriterTraceListener(Console.Out));
|
||||||
|
System.Diagnostics.Trace.AutoFlush = true;
|
||||||
|
Trace.AutoFlush = true;
|
||||||
|
|
||||||
|
try
|
||||||
{
|
{
|
||||||
using (Form exampleLauncher = new ExampleLauncher())
|
using (Form exampleLauncher = new ExampleLauncher())
|
||||||
{
|
{
|
||||||
|
@ -30,23 +42,20 @@ namespace Examples
|
||||||
Application.Run(exampleLauncher);
|
Application.Run(exampleLauncher);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
StreamWriter sw = new StreamWriter(Path.Combine(System.Environment.CurrentDirectory, "keymap.log"));
|
finally
|
||||||
|
{
|
||||||
|
Debug.Flush();
|
||||||
|
Debug.Close();
|
||||||
|
Trace.Flush();
|
||||||
|
Trace.Close();
|
||||||
|
sw.Flush();
|
||||||
|
sw.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public ExampleLauncher()
|
public ExampleLauncher()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
System.Diagnostics.Debug.Listeners.Clear();
|
|
||||||
System.Diagnostics.Debug.Listeners.Add(new TextWriterTraceListener(sw));
|
|
||||||
System.Diagnostics.Debug.AutoFlush = true;
|
|
||||||
System.Diagnostics.Trace.Listeners.Clear();
|
|
||||||
System.Diagnostics.Trace.Listeners.Add(new TextWriterTraceListener(Console.Out));
|
|
||||||
System.Diagnostics.Trace.AutoFlush = true;
|
|
||||||
Trace.AutoFlush = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
~ExampleLauncher()
|
|
||||||
{
|
|
||||||
sw.Flush();
|
|
||||||
sw.Close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void listBox1_DoubleClick(object sender, EventArgs e)
|
private void listBox1_DoubleClick(object sender, EventArgs e)
|
||||||
|
@ -100,27 +109,7 @@ namespace Examples
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Debug.WriteLine(e.ToString());
|
Debug.WriteLine(e.ToString());
|
||||||
//throw;
|
|
||||||
}
|
}
|
||||||
//(example as Type).InvokeMember("Launch", BindingFlags.InvokeMethod, null, example, null);
|
|
||||||
/*
|
|
||||||
AppDomain app = AppDomain.CreateDomain((example as Type).Name);
|
|
||||||
|
|
||||||
Type exType = example as Type;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
IExample ex = app.CreateInstanceAndUnwrap(
|
|
||||||
exType.Assembly.GetName().Name,
|
|
||||||
"Examples.Tests.Shim") as IExample;
|
|
||||||
ex.Launch();
|
|
||||||
//ex.InvokeMember("Launch", BindingFlags.InvokeMethod, null, null, null);
|
|
||||||
//
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
AppDomain.Unload(app);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ExampleLauncher_Load(object sender, EventArgs e)
|
public void ExampleLauncher_Load(object sender, EventArgs e)
|
||||||
|
|
|
@ -35,7 +35,7 @@ namespace Examples.WinForms
|
||||||
{
|
{
|
||||||
base.OnHandleCreated(e);
|
base.OnHandleCreated(e);
|
||||||
|
|
||||||
input = new OpenTK.InputDriver(this.Handle);
|
input = new OpenTK.InputDriver(OpenTK.Platform.Utilities.GetWindowInfo(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void redButton_Click(object sender, EventArgs e)
|
private void redButton_Click(object sender, EventArgs e)
|
||||||
|
|
|
@ -29,7 +29,6 @@ namespace OpenTK
|
||||||
{
|
{
|
||||||
#region --- Private Fields ---
|
#region --- Private Fields ---
|
||||||
|
|
||||||
private bool fullscreen;
|
|
||||||
private IGLControl glControl;
|
private IGLControl glControl;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -85,7 +84,7 @@ namespace OpenTK
|
||||||
if (height > 0)
|
if (height > 0)
|
||||||
this.Height = height;
|
this.Height = height;
|
||||||
*/
|
*/
|
||||||
if (fullscreen)
|
if (mode.Fullscreen)
|
||||||
this.Fullscreen = true;
|
this.Fullscreen = true;
|
||||||
|
|
||||||
this.SetStyle(ControlStyles.UserPaint, true);
|
this.SetStyle(ControlStyles.UserPaint, true);
|
||||||
|
@ -136,17 +135,11 @@ namespace OpenTK
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return fullscreen;
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (!fullscreen && value)
|
throw new NotImplementedException();
|
||||||
{
|
|
||||||
//fullscreen = this.SetFullscreenResolution(this.Width, this.Height);
|
|
||||||
}
|
|
||||||
else if (fullscreen && !value)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,21 +15,15 @@ namespace OpenTK
|
||||||
{
|
{
|
||||||
public class GameWindow : OpenTK.Platform.IGameWindow
|
public class GameWindow : OpenTK.Platform.IGameWindow
|
||||||
{
|
{
|
||||||
private INativeWindow glWindow;
|
#region --- Fields ---
|
||||||
|
|
||||||
|
private INativeGLWindow glWindow;
|
||||||
private ResizeEventArgs resizeEventArgs = new ResizeEventArgs();
|
private ResizeEventArgs resizeEventArgs = new ResizeEventArgs();
|
||||||
private DisplayMode mode;
|
private DisplayMode mode;
|
||||||
|
|
||||||
private InputDriver inputDevices;
|
private InputDriver driver;
|
||||||
public IList<Input.Keyboard> Keyboard { get { return Input.Keyboard; } }
|
|
||||||
public InputDriver Input
|
#endregion
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (inputDevices == null)
|
|
||||||
inputDevices = new InputDriver(this.Handle);
|
|
||||||
return inputDevices;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#region --- Contructors ---
|
#region --- Contructors ---
|
||||||
|
|
||||||
|
@ -41,19 +35,16 @@ namespace OpenTK
|
||||||
if (Environment.OSVersion.Platform == PlatformID.Win32NT ||
|
if (Environment.OSVersion.Platform == PlatformID.Win32NT ||
|
||||||
Environment.OSVersion.Platform == PlatformID.Win32Windows)
|
Environment.OSVersion.Platform == PlatformID.Win32Windows)
|
||||||
{
|
{
|
||||||
// Create a new Windows native window. We want to be notified when it's ready,
|
|
||||||
// in order to do some preparatory work.
|
|
||||||
glWindow = new OpenTK.Platform.Windows.WinGLNative();
|
glWindow = new OpenTK.Platform.Windows.WinGLNative();
|
||||||
}
|
}
|
||||||
else if (Environment.OSVersion.Platform == PlatformID.Unix ||
|
else if (Environment.OSVersion.Platform == PlatformID.Unix)
|
||||||
Environment.OSVersion.Platform == (PlatformID)128) // some older versions of Mono reported 128.
|
|
||||||
{
|
{
|
||||||
glWindow = new OpenTK.Platform.X11.X11GLNative();
|
glWindow = new OpenTK.Platform.X11.X11GLNative();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new PlatformNotSupportedException(
|
throw new PlatformNotSupportedException(
|
||||||
"Your operating system is not currently supported. We are sorry for the inconvenience."
|
"Your platform is not currently supported. Refer to http://opentk.sourceforge.net for more information."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,7 +55,7 @@ namespace OpenTK
|
||||||
void glWindow_Create(object sender, EventArgs e)
|
void glWindow_Create(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
//glWindow.Context.MakeCurrent();
|
//glWindow.Context.MakeCurrent();
|
||||||
inputDevices = new InputDriver(this.Handle);
|
driver = new InputDriver(this.WindowInfo);
|
||||||
|
|
||||||
this.OnCreate(e);
|
this.OnCreate(e);
|
||||||
}
|
}
|
||||||
|
@ -76,7 +67,51 @@ namespace OpenTK
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region --- INativeWindow Members ---
|
#region --- Public Properties ---
|
||||||
|
|
||||||
|
#region public IList<Input.Keyboard> Keyboard
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the list of available Keyboard devices.
|
||||||
|
/// </summary>
|
||||||
|
public IList<Input.Keyboard> Keyboard
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (driver == null)
|
||||||
|
{
|
||||||
|
Debug.WriteLine("WARNING: Requested the list of Keyboard devices, without creating an InputDriver first. Continuing by creating an input driver, but this may indicate a prorgamming error.");
|
||||||
|
driver = new InputDriver(this.WindowInfo);
|
||||||
|
}
|
||||||
|
return driver.Keyboard;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region public IList<OpenTK.Input.IInputDevice> Input
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the list of available InputDevices.
|
||||||
|
/// </summary>
|
||||||
|
public IList<OpenTK.Input.IInputDevice> Input
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (driver == null)
|
||||||
|
{
|
||||||
|
Debug.WriteLine("WARNING: Requested available InputDevices, without creating an InputDriver first. Continuing by creating an input driver, but this may indicate a prorgamming error.");
|
||||||
|
driver = new InputDriver(this.WindowInfo);
|
||||||
|
}
|
||||||
|
return driver.InputDevices;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region --- INativeGLWindow Members ---
|
||||||
|
|
||||||
#region public void CreateWindow(DisplayMode mode)
|
#region public void CreateWindow(DisplayMode mode)
|
||||||
|
|
||||||
|
@ -99,18 +134,6 @@ namespace OpenTK
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region public IntPtr Handle
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the handle of the current GameWindow.
|
|
||||||
/// </summary>
|
|
||||||
public IntPtr Handle
|
|
||||||
{
|
|
||||||
get { return glWindow.Handle; }
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region public void Exit()
|
#region public void Exit()
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -197,6 +220,15 @@ namespace OpenTK
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region public IWindowInfo WindowInfo
|
||||||
|
|
||||||
|
public IWindowInfo WindowInfo
|
||||||
|
{
|
||||||
|
get { return glWindow.WindowInfo; }
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region --- IGameWindow Members ---
|
#region --- IGameWindow Members ---
|
||||||
|
|
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
using OpenTK.Input;
|
using OpenTK.Input;
|
||||||
|
using OpenTK.Platform;
|
||||||
|
|
||||||
namespace OpenTK
|
namespace OpenTK
|
||||||
{
|
{
|
||||||
|
@ -10,16 +11,17 @@ namespace OpenTK
|
||||||
{
|
{
|
||||||
IInputDriver inputDriver;
|
IInputDriver inputDriver;
|
||||||
|
|
||||||
public InputDriver(IntPtr parentHandle)
|
public InputDriver(IWindowInfo parent)
|
||||||
{
|
{
|
||||||
if (Environment.OSVersion.Version.Major > 5 ||
|
if (Environment.OSVersion.Version.Major > 5 ||
|
||||||
(Environment.OSVersion.Version.Major == 5 && Environment.OSVersion.Version.Minor >= 1))
|
(Environment.OSVersion.Version.Major == 5 && Environment.OSVersion.Version.Minor >= 1))
|
||||||
{
|
{
|
||||||
inputDriver = new OpenTK.Platform.Windows.WinRawInput(parentHandle);
|
inputDriver = new OpenTK.Platform.Windows.WinRawInput(parent.Handle);
|
||||||
}
|
}
|
||||||
else if (Environment.OSVersion.Platform == PlatformID.Unix)
|
else if (Environment.OSVersion.Platform == PlatformID.Unix)
|
||||||
{
|
{
|
||||||
inputDriver = new OpenTK.Platform.X11.X11Input(parentHandle);
|
inputDriver =
|
||||||
|
new OpenTK.Platform.X11.X11Input(parent as OpenTK.Platform.X11.WindowInfo);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,7 +5,7 @@ using System.Text;
|
||||||
|
|
||||||
namespace OpenTK.Platform
|
namespace OpenTK.Platform
|
||||||
{
|
{
|
||||||
interface IGameWindow : INativeWindow
|
interface IGameWindow : INativeGLWindow
|
||||||
{
|
{
|
||||||
void Run();
|
void Run();
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,10 @@ using System.Text;
|
||||||
|
|
||||||
namespace OpenTK.Platform
|
namespace OpenTK.Platform
|
||||||
{
|
{
|
||||||
interface INativeWindow : IGLControl, IResizable
|
/// <summary>
|
||||||
|
/// This interface supports OpenTK, and is not intended for use by OpenTK programs.
|
||||||
|
/// </summary>
|
||||||
|
interface INativeGLWindow : IGLControl, IResizable
|
||||||
{
|
{
|
||||||
void CreateWindow(DisplayMode mode);
|
void CreateWindow(DisplayMode mode);
|
||||||
void ProcessEvents();
|
void ProcessEvents();
|
||||||
|
@ -12,6 +15,6 @@ namespace OpenTK.Platform
|
||||||
|
|
||||||
bool Created { get; }
|
bool Created { get; }
|
||||||
bool Quit { get; }
|
bool Quit { get; }
|
||||||
IntPtr Handle { get; }
|
IWindowInfo WindowInfo { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -4,7 +4,12 @@ using System.Text;
|
||||||
|
|
||||||
namespace OpenTK.Platform
|
namespace OpenTK.Platform
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This interface supports OpenTK, and is not intended for use by OpenTK programs.
|
||||||
|
/// </summary>
|
||||||
public interface IWindowInfo
|
public interface IWindowInfo
|
||||||
{
|
{
|
||||||
|
IntPtr Handle { get; }
|
||||||
|
IWindowInfo Parent { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
18
Source/OpenTK/Platform/Utilities.cs
Normal file
18
Source/OpenTK/Platform/Utilities.cs
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace OpenTK.Platform
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Provides cross-platform utilities to help interact with the underlying platform.
|
||||||
|
/// </summary>
|
||||||
|
public static class Utilities
|
||||||
|
{
|
||||||
|
public static IWindowInfo GetWindowInfo(Form form)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -17,16 +17,22 @@ using System.Diagnostics;
|
||||||
|
|
||||||
namespace OpenTK.Platform.Windows
|
namespace OpenTK.Platform.Windows
|
||||||
{
|
{
|
||||||
sealed class WinGLNative : NativeWindow, OpenTK.Platform.INativeWindow, IDisposable
|
/// <summary>
|
||||||
|
/// Drives GameWindow on Windows.
|
||||||
|
/// This class supports OpenTK, and is not intended for use by OpenTK programs.
|
||||||
|
/// </summary>
|
||||||
|
sealed class WinGLNative : NativeWindow, OpenTK.Platform.INativeGLWindow, IDisposable
|
||||||
{
|
{
|
||||||
#region --- Fields ---
|
#region --- Fields ---
|
||||||
|
|
||||||
private WinGLContext glContext;
|
private WinGLContext glContext;
|
||||||
private DisplayMode mode = new DisplayMode();
|
private DisplayMode mode = new DisplayMode();
|
||||||
|
|
||||||
|
private bool fullscreen = false;
|
||||||
private bool disposed;
|
private bool disposed;
|
||||||
private bool quit;
|
private bool quit;
|
||||||
private bool created;
|
private bool created;
|
||||||
|
private WindowInfo info;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
@ -38,6 +44,7 @@ namespace OpenTK.Platform.Windows
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public WinGLNative()
|
public WinGLNative()
|
||||||
{
|
{
|
||||||
|
Debug.Print("Native window driver: {0}", this.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -79,6 +86,12 @@ namespace OpenTK.Platform.Windows
|
||||||
mode.Width = Marshal.ReadInt32(m.LParam, (int)Marshal.OffsetOf(typeof(API.CreateStruct), "cx"));
|
mode.Width = Marshal.ReadInt32(m.LParam, (int)Marshal.OffsetOf(typeof(API.CreateStruct), "cx"));
|
||||||
mode.Height = Marshal.ReadInt32(m.LParam, (int)Marshal.OffsetOf(typeof(API.CreateStruct), "cy"));
|
mode.Height = Marshal.ReadInt32(m.LParam, (int)Marshal.OffsetOf(typeof(API.CreateStruct), "cy"));
|
||||||
|
|
||||||
|
info = new WindowInfo();
|
||||||
|
info.Handle = this.Handle;
|
||||||
|
info.Parent = null;
|
||||||
|
|
||||||
|
Debug.Print("Window handle: {0}", this.Handle);
|
||||||
|
|
||||||
// Raise the Create event
|
// Raise the Create event
|
||||||
this.OnCreate(EventArgs.Empty);
|
this.OnCreate(EventArgs.Empty);
|
||||||
|
|
||||||
|
@ -92,20 +105,23 @@ namespace OpenTK.Platform.Windows
|
||||||
//case API.Constants.WM_KEYUP:
|
//case API.Constants.WM_KEYUP:
|
||||||
// break;
|
// break;
|
||||||
|
|
||||||
//case API.Constants.WM_INPUT: // Raw input
|
|
||||||
// WinRawInput.ProcessEvent(ref msg, key);
|
|
||||||
// break;
|
|
||||||
|
|
||||||
case API.Constants.WM_CLOSE:
|
case API.Constants.WM_CLOSE:
|
||||||
|
//this.Exit();
|
||||||
|
//return;
|
||||||
|
break;
|
||||||
|
|
||||||
case API.Constants.WM_DESTROY:
|
case API.Constants.WM_DESTROY:
|
||||||
|
if (this.Handle != IntPtr.Zero)
|
||||||
|
{
|
||||||
Debug.Print("Window handle {0} destroyed.", this.Handle);
|
Debug.Print("Window handle {0} destroyed.", this.Handle);
|
||||||
this.DestroyHandle();
|
this.DestroyHandle();
|
||||||
|
}
|
||||||
API.PostQuitMessage(0);
|
API.PostQuitMessage(0);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case API.Constants.WM_QUIT:
|
case API.Constants.WM_QUIT:
|
||||||
quit = true;
|
quit = true;
|
||||||
Debug.WriteLine("Window quit.");
|
Debug.WriteLine("Application quit.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,12 +131,15 @@ namespace OpenTK.Platform.Windows
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region --- INativeWindow Members ---
|
#region --- INativeGLWindow Members ---
|
||||||
|
|
||||||
#region private void CreateWindow(DisplayMode mode)
|
#region private void CreateWindow(DisplayMode mode)
|
||||||
|
|
||||||
public void CreateWindow(DisplayMode mode)
|
public void CreateWindow(DisplayMode mode)
|
||||||
{
|
{
|
||||||
|
Debug.Print("Creating native window with mode: {0}", mode.ToString());
|
||||||
|
Debug.Indent();
|
||||||
|
|
||||||
CreateParams cp = new CreateParams();
|
CreateParams cp = new CreateParams();
|
||||||
cp.ClassStyle =
|
cp.ClassStyle =
|
||||||
(int)API.WindowClassStyle.OwnDC |
|
(int)API.WindowClassStyle.OwnDC |
|
||||||
|
@ -134,7 +153,10 @@ namespace OpenTK.Platform.Windows
|
||||||
cp.Width = mode.Width;
|
cp.Width = mode.Width;
|
||||||
cp.Height = mode.Height;
|
cp.Height = mode.Height;
|
||||||
cp.Caption = "OpenTK Game Window";
|
cp.Caption = "OpenTK Game Window";
|
||||||
base.CreateHandle(cp);
|
|
||||||
|
// Keep in mind that some construction code runs in WM_CREATE,
|
||||||
|
// which is raised CreateHandle()
|
||||||
|
CreateHandle(cp);
|
||||||
|
|
||||||
glContext = new WinGLContext(
|
glContext = new WinGLContext(
|
||||||
this.Handle,
|
this.Handle,
|
||||||
|
@ -151,6 +173,7 @@ namespace OpenTK.Platform.Windows
|
||||||
|
|
||||||
if (this.Handle != IntPtr.Zero && glContext != null)
|
if (this.Handle != IntPtr.Zero && glContext != null)
|
||||||
{
|
{
|
||||||
|
Debug.WriteLine("Window creation was succesful.");
|
||||||
created = true;
|
created = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -159,6 +182,8 @@ namespace OpenTK.Platform.Windows
|
||||||
"Could not create native window and/or context. Handle: {0}, Context {1}",
|
"Could not create native window and/or context. Handle: {0}, Context {1}",
|
||||||
this.Handle, this.Context.ToString()));
|
this.Handle, this.Context.ToString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Debug.Unindent();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -288,7 +313,6 @@ namespace OpenTK.Platform.Windows
|
||||||
|
|
||||||
#region public bool Fullscreen
|
#region public bool Fullscreen
|
||||||
|
|
||||||
bool fullscreen;
|
|
||||||
public bool Fullscreen
|
public bool Fullscreen
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
@ -317,6 +341,15 @@ namespace OpenTK.Platform.Windows
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region public IWindowInfo WindowInfo
|
||||||
|
|
||||||
|
public IWindowInfo WindowInfo
|
||||||
|
{
|
||||||
|
get { return info; }
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region --- IDisposable Members ---
|
#region --- IDisposable Members ---
|
||||||
|
|
|
@ -24,17 +24,19 @@ namespace OpenTK.Platform.Windows
|
||||||
/// Input event data.
|
/// Input event data.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private API.RawInput data = new API.RawInput();
|
private API.RawInput data = new API.RawInput();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The list of keyboards connected to this system.
|
/// The total number of input devices connected to this system.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
//internal List<WinRawKeyboard> keyboards = new List<WinRawKeyboard>();
|
private static int deviceCount;
|
||||||
|
|
||||||
|
|
||||||
private WinRawKeyboard keyboardDriver;
|
private WinRawKeyboard keyboardDriver;
|
||||||
|
|
||||||
|
#region --- Constructors ---
|
||||||
|
|
||||||
internal WinRawInput(IntPtr parentHandle)
|
internal WinRawInput(IntPtr parentHandle)
|
||||||
{
|
{
|
||||||
Debug.WriteLine("Initalizing raw input driver.");
|
Debug.WriteLine("Initalizing windows raw input driver.");
|
||||||
Debug.Indent();
|
Debug.Indent();
|
||||||
|
|
||||||
AssignHandle(parentHandle);
|
AssignHandle(parentHandle);
|
||||||
|
@ -44,7 +46,7 @@ namespace OpenTK.Platform.Windows
|
||||||
Debug.Unindent();
|
Debug.Unindent();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int deviceCount;
|
#endregion
|
||||||
|
|
||||||
internal static int DeviceCount
|
internal static int DeviceCount
|
||||||
{
|
{
|
||||||
|
@ -54,6 +56,7 @@ namespace OpenTK.Platform.Windows
|
||||||
return deviceCount;
|
return deviceCount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a value indicating whether the Device list has changed, for example
|
/// Gets a value indicating whether the Device list has changed, for example
|
||||||
|
|
32
Source/OpenTK/Platform/Windows/WindowInfo.cs
Normal file
32
Source/OpenTK/Platform/Windows/WindowInfo.cs
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace OpenTK.Platform.Windows
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Describes a Windows window.
|
||||||
|
/// This class supports OpenTK, and is not intended for use by OpenTK programs.
|
||||||
|
/// </summary>
|
||||||
|
internal class WindowInfo : IWindowInfo
|
||||||
|
{
|
||||||
|
private IntPtr handle;
|
||||||
|
private WindowInfo parent;
|
||||||
|
|
||||||
|
#region --- IWindowInfo Members ---
|
||||||
|
|
||||||
|
public IntPtr Handle
|
||||||
|
{
|
||||||
|
get { return handle; }
|
||||||
|
internal set { handle = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public IWindowInfo Parent
|
||||||
|
{
|
||||||
|
get { return parent; }
|
||||||
|
internal set { parent = value as WindowInfo; }
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
|
@ -159,9 +159,33 @@ namespace OpenTK.Platform.X11
|
||||||
ref Event event_send
|
ref Event event_send
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The XSelectInput() function requests that the X server report the events associated
|
||||||
|
/// with the specified event mask.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="display">Specifies the connection to the X server.</param>
|
||||||
|
/// <param name="w">Specifies the window whose events you are interested in.</param>
|
||||||
|
/// <param name="event_mask">Specifies the event mask.</param>
|
||||||
|
/// <remarks>
|
||||||
|
/// Initially, X will not report any of these events.
|
||||||
|
/// Events are reported relative to a window.
|
||||||
|
/// If a window is not interested in a device event,
|
||||||
|
/// it usually propagates to the closest ancestor that is interested,
|
||||||
|
/// unless the do_not_propagate mask prohibits it.
|
||||||
|
/// Setting the event-mask attribute of a window overrides any previous call for the same window but not for other clients. Multiple clients can select for the same events on the same window with the following restrictions:
|
||||||
|
/// <para>Multiple clients can select events on the same window because their event masks are disjoint. When the X server generates an event, it reports it to all interested clients. </para>
|
||||||
|
/// <para>Only one client at a time can select CirculateRequest, ConfigureRequest, or MapRequest events, which are associated with the event mask SubstructureRedirectMask. </para>
|
||||||
|
/// <para>Only one client at a time can select a ResizeRequest event, which is associated with the event mask ResizeRedirectMask. </para>
|
||||||
|
/// <para>Only one client at a time can select a ButtonPress event, which is associated with the event mask ButtonPressMask. </para>
|
||||||
|
/// <para>The server reports the event to all interested clients. </para>
|
||||||
|
/// <para>XSelectInput() can generate a BadWindow error.</para>
|
||||||
|
/// </remarks>
|
||||||
|
[DllImport(_dll_name, EntryPoint = "XSelectInput")]
|
||||||
|
internal static extern void SelectInput(Display display, Window w, EventMask event_mask);
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Thing grabbin'
|
#region Pointer and Keyboard grabbing
|
||||||
|
|
||||||
[DllImport(_dll_name, EntryPoint = "XGrabPointer")]
|
[DllImport(_dll_name, EntryPoint = "XGrabPointer")]
|
||||||
extern internal static ErrorCodes XGrabPointer(
|
extern internal static ErrorCodes XGrabPointer(
|
||||||
|
@ -873,11 +897,11 @@ XF86VidModeGetGammaRampSize(
|
||||||
}
|
}
|
||||||
|
|
||||||
[Flags]
|
[Flags]
|
||||||
internal enum EventMask : ulong
|
internal enum EventMask : long //: ulong
|
||||||
{
|
{
|
||||||
NoEventMask = 0,
|
NoEventMask = 0,
|
||||||
KeyPressMask = (1L<<0),
|
KeyPressMask = (1L<<0),
|
||||||
KeyReeaseMask = (1L<<1),
|
KeyReleaseMask = (1L<<1),
|
||||||
Button3MotionMask = (1L<<10),
|
Button3MotionMask = (1L<<10),
|
||||||
Button4MotionMask = (1L<<11),
|
Button4MotionMask = (1L<<11),
|
||||||
Button5MotionMask = (1L<<12),
|
Button5MotionMask = (1L<<12),
|
||||||
|
|
35
Source/OpenTK/Platform/X11/WindowInfo.cs
Normal file
35
Source/OpenTK/Platform/X11/WindowInfo.cs
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace OpenTK.Platform.X11
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Describes an X11 window.
|
||||||
|
/// This class supports OpenTK, and is not intended for use by OpenTK programs.
|
||||||
|
/// </summary>
|
||||||
|
internal class WindowInfo : IWindowInfo
|
||||||
|
{
|
||||||
|
internal WindowInfo() { }
|
||||||
|
internal WindowInfo(WindowInfo parent)
|
||||||
|
{
|
||||||
|
this.TopLevelWindow = parent.TopLevelWindow;
|
||||||
|
this.Screen = parent.Screen;
|
||||||
|
this.Display = parent.Display;
|
||||||
|
this.RootWindow = parent.RootWindow;
|
||||||
|
this.Handle = parent.Handle;
|
||||||
|
}
|
||||||
|
|
||||||
|
private IntPtr rootWindow, handle, topLevelWindow, display;
|
||||||
|
private int screen;
|
||||||
|
private WindowInfo parent;
|
||||||
|
|
||||||
|
internal IntPtr RootWindow { get { return rootWindow; } set { rootWindow = value; } }
|
||||||
|
internal IntPtr TopLevelWindow { get { return topLevelWindow; } set { topLevelWindow = value; } }
|
||||||
|
internal IntPtr Display { get { return display; } set { display = value; } }
|
||||||
|
internal int Screen { get { return screen; } set { screen = value; } }
|
||||||
|
|
||||||
|
public IntPtr Handle { get { return handle; } internal set { handle = value; } }
|
||||||
|
public IWindowInfo Parent { get { return parent; } internal set { parent = value as WindowInfo; } }
|
||||||
|
}
|
||||||
|
}
|
|
@ -14,14 +14,17 @@ using OpenTK.OpenGL;
|
||||||
|
|
||||||
namespace OpenTK.Platform.X11
|
namespace OpenTK.Platform.X11
|
||||||
{
|
{
|
||||||
public class X11GLContext : OpenTK.Platform.IGLContext
|
/// <summary>
|
||||||
|
/// Provides methods to create and control an opengl context on X11.
|
||||||
|
/// </summary>
|
||||||
|
public sealed class X11GLContext : OpenTK.Platform.IGLContext
|
||||||
{
|
{
|
||||||
private IntPtr x11context;
|
private IntPtr x11context;
|
||||||
private IntPtr display;
|
private IntPtr display;
|
||||||
private int screenNo;
|
private int screenNo;
|
||||||
|
|
||||||
private DisplayMode mode;// = new DisplayMode();
|
private DisplayMode mode;// = new DisplayMode();
|
||||||
internal X11WindowInfo windowInfo = new X11WindowInfo();
|
internal WindowInfo windowInfo = new WindowInfo();
|
||||||
private VisualInfo visualInfo;
|
private VisualInfo visualInfo;
|
||||||
|
|
||||||
//private IntPtr desktopResolution = IntPtr.Zero;
|
//private IntPtr desktopResolution = IntPtr.Zero;
|
||||||
|
@ -42,14 +45,13 @@ namespace OpenTK.Platform.X11
|
||||||
this.mode = new DisplayMode();
|
this.mode = new DisplayMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
internal X11GLContext(IWindowInfo info, DisplayMode mode)
|
internal X11GLContext(WindowInfo info, DisplayMode mode)
|
||||||
{
|
{
|
||||||
X11WindowInfo xInfo = info as X11WindowInfo;
|
this.windowInfo.Handle = info.Handle;
|
||||||
this.windowInfo.Window = xInfo.Window;
|
this.windowInfo.RootWindow = info.RootWindow;
|
||||||
this.windowInfo.RootWindow = xInfo.RootWindow;
|
this.windowInfo.TopLevelWindow = info.TopLevelWindow;
|
||||||
this.windowInfo.TopLevelWindow = xInfo.TopLevelWindow;
|
this.windowInfo.Display = info.Display;
|
||||||
this.windowInfo.Display = xInfo.Display;
|
this.windowInfo.Screen = info.Screen;
|
||||||
this.windowInfo.Screen = xInfo.Screen;
|
|
||||||
|
|
||||||
this.mode = mode;
|
this.mode = mode;
|
||||||
}
|
}
|
||||||
|
@ -62,7 +64,7 @@ namespace OpenTK.Platform.X11
|
||||||
|
|
||||||
public void SwapBuffers()
|
public void SwapBuffers()
|
||||||
{
|
{
|
||||||
Glx.SwapBuffers(windowInfo.Display, windowInfo.Window);
|
Glx.SwapBuffers(windowInfo.Display, windowInfo.Handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -77,10 +79,10 @@ namespace OpenTK.Platform.X11
|
||||||
x11context,
|
x11context,
|
||||||
System.Threading.Thread.CurrentThread.ManagedThreadId,
|
System.Threading.Thread.CurrentThread.ManagedThreadId,
|
||||||
windowInfo.Display,
|
windowInfo.Display,
|
||||||
windowInfo.Window
|
windowInfo.Handle
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
bool result = Glx.MakeCurrent(windowInfo.Display, windowInfo.Window, x11context);
|
bool result = Glx.MakeCurrent(windowInfo.Display, windowInfo.Handle, x11context);
|
||||||
|
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
|
@ -246,30 +248,30 @@ namespace OpenTK.Platform.X11
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public IntPtr XVisual
|
internal IntPtr XVisual
|
||||||
{
|
{
|
||||||
get { return this.visual; }
|
get { return this.visual; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public VisualInfo XVisualInfo
|
internal VisualInfo XVisualInfo
|
||||||
{
|
{
|
||||||
get { return this.visualInfo; }
|
get { return this.visualInfo; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public IntPtr XColormap
|
internal IntPtr XColormap
|
||||||
{
|
{
|
||||||
get { return colormap; }
|
get { return colormap; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public IntPtr Handle
|
internal IntPtr Handle
|
||||||
{
|
{
|
||||||
get { return this.x11context; }
|
get { return this.x11context; }
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
public IntPtr ContainingWindow
|
public IntPtr ContainingWindow
|
||||||
{
|
{
|
||||||
get { return windowInfo.Window; }
|
get { return info.Window; }
|
||||||
internal set { windowInfo.Window = value; }
|
internal set { info.Window = value; }
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ namespace OpenTK.Platform.X11
|
||||||
{
|
{
|
||||||
sealed class X11GLControl : IGLControl
|
sealed class X11GLControl : IGLControl
|
||||||
{
|
{
|
||||||
X11WindowInfo info = new X11WindowInfo();
|
WindowInfo info = new WindowInfo();
|
||||||
private Type xplatui;
|
private Type xplatui;
|
||||||
X11GLContext glContext;
|
X11GLContext glContext;
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ namespace OpenTK.Platform.X11
|
||||||
throw new Exception("Attempted to bind to non-existent control.");
|
throw new Exception("Attempted to bind to non-existent control.");
|
||||||
}
|
}
|
||||||
|
|
||||||
info.Window = c.Handle;
|
info.Handle = c.Handle;
|
||||||
Trace.WriteLine(
|
Trace.WriteLine(
|
||||||
String.Format(
|
String.Format(
|
||||||
"Binding to control: {0}",
|
"Binding to control: {0}",
|
||||||
|
@ -70,7 +70,7 @@ namespace OpenTK.Platform.X11
|
||||||
info.Screen,
|
info.Screen,
|
||||||
info.Display,
|
info.Display,
|
||||||
info.RootWindow,
|
info.RootWindow,
|
||||||
info.Window
|
info.Handle
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -14,12 +14,16 @@ using System.Diagnostics;
|
||||||
|
|
||||||
namespace OpenTK.Platform.X11
|
namespace OpenTK.Platform.X11
|
||||||
{
|
{
|
||||||
sealed class X11GLNative : OpenTK.Platform.INativeWindow, IDisposable
|
/// <summary>
|
||||||
|
/// Drives GameWindow on X11.
|
||||||
|
/// This class supports OpenTK, and is not intended for use by OpenTK programs.
|
||||||
|
/// </summary>
|
||||||
|
internal sealed class X11GLNative : INativeGLWindow, IDisposable
|
||||||
{
|
{
|
||||||
#region --- Private Fields ---
|
#region --- Fields ---
|
||||||
|
|
||||||
private X11GLContext glContext;
|
private X11GLContext glContext;
|
||||||
private X11WindowInfo windowInfo = new X11WindowInfo();
|
private WindowInfo info = new WindowInfo();
|
||||||
private IntPtr display;
|
private IntPtr display;
|
||||||
private int screen;
|
private int screen;
|
||||||
private IntPtr rootWindow;
|
private IntPtr rootWindow;
|
||||||
|
@ -59,11 +63,12 @@ namespace OpenTK.Platform.X11
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public X11GLNative()
|
public X11GLNative()
|
||||||
{
|
{
|
||||||
|
Debug.Print("Native window driver: {0}", this.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region --- INativeWindow Members ---
|
#region --- INativeGLWindow Members ---
|
||||||
|
|
||||||
#region public void CreateWindow(DisplayMode mode)
|
#region public void CreateWindow(DisplayMode mode)
|
||||||
|
|
||||||
|
@ -80,27 +85,25 @@ namespace OpenTK.Platform.X11
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public void CreateWindow(DisplayMode mode)
|
public void CreateWindow(DisplayMode mode)
|
||||||
{
|
{
|
||||||
Debug.WriteLine("Creating GameWindow (X11GLNative driver)");
|
Debug.Print("Creating native window with mode: {0}", mode.ToString());
|
||||||
Debug.Indent();
|
Debug.Indent();
|
||||||
|
|
||||||
Debug.WriteLine(String.Format("Display mode: {0}", mode));
|
info.Display = display = API.OpenDisplay(null); // null == default display
|
||||||
|
|
||||||
windowInfo.Display = display = API.OpenDisplay(null); // null == default display
|
|
||||||
if (display == IntPtr.Zero)
|
if (display == IntPtr.Zero)
|
||||||
{
|
{
|
||||||
throw new Exception("Could not open connection to X");
|
throw new Exception("Could not open connection to X");
|
||||||
}
|
}
|
||||||
windowInfo.Screen = screen = API.DefaultScreen(display);
|
info.Screen = screen = API.DefaultScreen(display);
|
||||||
windowInfo.RootWindow = rootWindow = API.RootWindow(display, screen);
|
info.RootWindow = rootWindow = API.RootWindow(display, screen);
|
||||||
|
|
||||||
Debug.Print(
|
Debug.Print(
|
||||||
"Display: {0}, Screen {1}, Root window: {2}",
|
"Display: {0}, Screen {1}, Root window: {2}",
|
||||||
windowInfo.Display,
|
info.Display,
|
||||||
windowInfo.Screen,
|
info.Screen,
|
||||||
windowInfo.RootWindow
|
info.RootWindow
|
||||||
);
|
);
|
||||||
|
|
||||||
glContext = new X11GLContext(windowInfo, mode);
|
glContext = new X11GLContext(info, mode);
|
||||||
glContext.CreateVisual();
|
glContext.CreateVisual();
|
||||||
|
|
||||||
// Create a window on this display using the visual above
|
// Create a window on this display using the visual above
|
||||||
|
@ -113,8 +116,7 @@ namespace OpenTK.Platform.X11
|
||||||
//API.CreateColormap(display, rootWindow, glxVisualInfo.visual, 0/*AllocNone*/);
|
//API.CreateColormap(display, rootWindow, glxVisualInfo.visual, 0/*AllocNone*/);
|
||||||
wnd_attributes.event_mask =
|
wnd_attributes.event_mask =
|
||||||
EventMask.StructureNotifyMask |
|
EventMask.StructureNotifyMask |
|
||||||
EventMask.ExposureMask |
|
EventMask.ExposureMask;
|
||||||
EventMask.KeyPressMask;
|
|
||||||
|
|
||||||
CreateWindowMask cw_mask =
|
CreateWindowMask cw_mask =
|
||||||
CreateWindowMask.CWBackPixel |
|
CreateWindowMask.CWBackPixel |
|
||||||
|
@ -123,8 +125,8 @@ namespace OpenTK.Platform.X11
|
||||||
CreateWindowMask.CWEventMask;
|
CreateWindowMask.CWEventMask;
|
||||||
|
|
||||||
window = API.CreateWindow(
|
window = API.CreateWindow(
|
||||||
windowInfo.Display,
|
info.Display,
|
||||||
windowInfo.RootWindow,
|
info.RootWindow,
|
||||||
0, 0,
|
0, 0,
|
||||||
640, 480,
|
640, 480,
|
||||||
0,
|
0,
|
||||||
|
@ -165,10 +167,10 @@ namespace OpenTK.Platform.X11
|
||||||
);
|
);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//glContext.ContainingWindow = windowInfo.Window;
|
//glContext.ContainingWindow = info.Window;
|
||||||
|
|
||||||
|
|
||||||
glContext.windowInfo.Window = window;
|
glContext.windowInfo.Handle = window;
|
||||||
glContext.CreateContext(null, true);
|
glContext.CreateContext(null, true);
|
||||||
|
|
||||||
API.MapRaised(display, window);
|
API.MapRaised(display, window);
|
||||||
|
@ -363,6 +365,15 @@ namespace OpenTK.Platform.X11
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region public IWindowInfo WindowInfo
|
||||||
|
|
||||||
|
public IWindowInfo WindowInfo
|
||||||
|
{
|
||||||
|
get { return info; }
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region --- IResizable Members ---
|
#region --- IResizable Members ---
|
||||||
|
@ -456,7 +467,9 @@ namespace OpenTK.Platform.X11
|
||||||
if (!disposed)
|
if (!disposed)
|
||||||
{
|
{
|
||||||
API.DestroyWindow(display, window);
|
API.DestroyWindow(display, window);
|
||||||
API.CloseDisplay(display);
|
// Kills connection to the X-Server. We don't want that,
|
||||||
|
// 'cause it kills the ExampleLauncher too.
|
||||||
|
//API.CloseDisplay(display);
|
||||||
|
|
||||||
if (manuallyCalled)
|
if (manuallyCalled)
|
||||||
{
|
{
|
||||||
|
|
|
@ -3,15 +3,73 @@ using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
using OpenTK.Input;
|
using OpenTK.Input;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
namespace OpenTK.Platform.X11
|
namespace OpenTK.Platform.X11
|
||||||
{
|
{
|
||||||
public class X11Input : IInputDriver
|
/// <summary>
|
||||||
|
/// Drives the InputDriver on X11.
|
||||||
|
/// This class supports OpenTK, and is not intended for users of OpenTK.
|
||||||
|
/// </summary>
|
||||||
|
internal sealed class X11Input : IInputDriver
|
||||||
{
|
{
|
||||||
public X11Input(IntPtr windowHandle)
|
private X11Keyboard keyboardDriver;
|
||||||
|
|
||||||
|
#region --- Constructors ---
|
||||||
|
|
||||||
|
public X11Input(WindowInfo parent)
|
||||||
{
|
{
|
||||||
|
Debug.WriteLine("Initalizing X11 input driver.");
|
||||||
|
Debug.Indent();
|
||||||
|
|
||||||
|
Debug.WriteLine("Creating hidden input window.");
|
||||||
|
|
||||||
|
SetWindowAttributes wnd_attributes = new SetWindowAttributes();
|
||||||
|
wnd_attributes.background_pixel = 0;
|
||||||
|
wnd_attributes.border_pixel = 0;
|
||||||
|
wnd_attributes.colormap = IntPtr.Zero;
|
||||||
|
wnd_attributes.event_mask = EventMask.KeyPressMask | EventMask.KeyReleaseMask;
|
||||||
|
|
||||||
|
CreateWindowMask cw_mask =
|
||||||
|
CreateWindowMask.CWEventMask;
|
||||||
|
|
||||||
|
WindowInfo window = new WindowInfo(parent);
|
||||||
|
|
||||||
|
window.Handle = API.CreateWindow(
|
||||||
|
window.Display,
|
||||||
|
window.RootWindow,
|
||||||
|
0, 0,
|
||||||
|
1, 1,
|
||||||
|
0,
|
||||||
|
//glxVisualInfo.depth,
|
||||||
|
//glContext.XVisualInfo.depth,
|
||||||
|
0,
|
||||||
|
Constants.InputOutput,
|
||||||
|
//glxVisualInfo.visual,
|
||||||
|
//glContext.XVisualInfo.visual,
|
||||||
|
IntPtr.Zero,
|
||||||
|
cw_mask,
|
||||||
|
wnd_attributes
|
||||||
|
);
|
||||||
|
|
||||||
|
if (window.Handle == IntPtr.Zero)
|
||||||
|
{
|
||||||
|
throw new Exception("Could not create input window.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Debug.WriteLine("done! (id: " + window + ")");
|
||||||
|
|
||||||
|
// Select input events to be reported here.
|
||||||
|
API.SelectInput(window.Display, window.Handle,
|
||||||
|
EventMask.KeyReleaseMask | EventMask.KeyPressMask);
|
||||||
|
|
||||||
|
keyboardDriver = new X11Keyboard(window);
|
||||||
|
|
||||||
|
Debug.Unindent();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region --- IInputDriver Members ---
|
#region --- IInputDriver Members ---
|
||||||
|
|
||||||
#region public IList<IInputDevice> InputDevices
|
#region public IList<IInputDevice> InputDevices
|
||||||
|
|
|
@ -6,8 +6,16 @@ using OpenTK.Input;
|
||||||
|
|
||||||
namespace OpenTK.Platform.X11
|
namespace OpenTK.Platform.X11
|
||||||
{
|
{
|
||||||
public class X11Keyboard : IKeyboardDriver
|
/// <summary>
|
||||||
|
/// Drives the Keyboard devices on X11.
|
||||||
|
/// This class supports OpenTK, and is not intended for use by OpenTK programs.
|
||||||
|
/// </summary>
|
||||||
|
internal class X11Keyboard : IKeyboardDriver
|
||||||
{
|
{
|
||||||
|
internal X11Keyboard(WindowInfo windowHandle)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
#region --- IKeyboardDriver Members ---
|
#region --- IKeyboardDriver Members ---
|
||||||
|
|
||||||
public IList<Keyboard> Keyboard
|
public IList<Keyboard> Keyboard
|
||||||
|
|
Loading…
Reference in a new issue