* X11GraphicsMode.cs: Protect the mode queries with XLockDisplay()/XUnlockDisplay().

This commit is contained in:
the_fiddler 2009-09-25 08:28:51 +00:00
parent 59f9746665
commit c559de1956

View file

@ -17,7 +17,8 @@ using OpenTK.Graphics;
namespace OpenTK.Platform.X11
{
class X11GraphicsMode : IGraphicsMode
{ // Todo: Add custom visual selection algorithm, instead of ChooseFBConfig/ChooseVisual.
{
// Todo: Add custom visual selection algorithm, instead of ChooseFBConfig/ChooseVisual.
// It seems the Choose* methods do not take multisampling into account (at least on some
// drivers).
@ -159,13 +160,14 @@ namespace OpenTK.Platform.X11
// Select a visual that matches the parameters set by the user.
IntPtr display = API.DefaultDisplay;
int screen = Functions.XDefaultScreen(display);
IntPtr root = Functions.XRootWindow(display, screen);
Debug.Print("Display: {0}, Screen: {1}, RootWindow: {2}", display, screen, root);
try
{
Functions.XLockDisplay(display);
int screen = Functions.XDefaultScreen(display);
IntPtr root = Functions.XRootWindow(display, screen);
Debug.Print("Display: {0}, Screen: {1}, RootWindow: {2}", display, screen, root);
unsafe
{
Debug.Print("Getting FB config.");
@ -185,6 +187,10 @@ namespace OpenTK.Platform.X11
Debug.Print("Function glXChooseFBConfig not supported.");
return IntPtr.Zero;
}
finally
{
Functions.XUnlockDisplay(display);
}
return visual;
}
@ -255,7 +261,15 @@ namespace OpenTK.Platform.X11
Debug.Print("Falling back to glXChooseVisual.");
IntPtr display = API.DefaultDisplay;
return Glx.ChooseVisual(display, Functions.XDefaultScreen(display), visualAttributes.ToArray());
try
{
Functions.XLockDisplay(display);
return Glx.ChooseVisual(display, Functions.XDefaultScreen(display), visualAttributes.ToArray());
}
finally
{
Functions.XUnlockDisplay(display);
}
}
#endregion