Do not hook ProcessExit event if an X server is not available. Should fix issue [#1364]: 1.0 beta-1 throws TypeInitializationException in OpenTK.Platform.X11.API when running on windows.

Cleaned up stale comments and code.
This commit is contained in:
the_fiddler 2009-11-12 15:41:41 +00:00
parent 01bb1971e4
commit fe01e67d39

View file

@ -74,24 +74,15 @@ namespace OpenTK.Platform.X11
{
Debug.Print("Initializing threaded X11: {0}.", Functions.XInitThreads().ToString());
AppDomain.CurrentDomain.ProcessExit += new EventHandler(CurrentDomain_ProcessExit);
// Bad idea - Windows.Forms will steal our events!
//Type xplatui = Type.GetType("System.Windows.Forms.XplatUIX11, System.Windows.Forms");
//defaultDisplay = (IntPtr)xplatui.GetField("DisplayHandle", System.Reflection.BindingFlags.Static |
// System.Reflection.BindingFlags.NonPublic).GetValue(null);
defaultDisplay = Functions.XOpenDisplay(IntPtr.Zero);
if (defaultDisplay == IntPtr.Zero)
throw new PlatformException("Could not establish connection to the X-Server.");
//defaultScreen = Functions.XDefaultScreen(DefaultDisplay);
//rootWindow = Functions.XRootWindow(DefaultDisplay, DefaultScreen);
screenCount = Functions.XScreenCount(DefaultDisplay);
//Debug.Print("Default Display: {0}, Default Screen: {1}, Default Root Window: {2}, Screen Count: {3}",
// DefaultDisplay, DefaultScreen, RootWindow, ScreenCount);
Debug.Print("Display connection: {0}, Screen count: {1}", DefaultDisplay, ScreenCount);
AppDomain.CurrentDomain.ProcessExit += new EventHandler(CurrentDomain_ProcessExit);
}
static void CurrentDomain_ProcessExit(object sender, EventArgs e)