2008-01-25 10:02:05 +00:00
|
|
|
|
#region --- License ---
|
|
|
|
|
/* Licensed under the MIT/X11 license.
|
|
|
|
|
* Copyright (c) 2006-2008 the OpenTK team.
|
|
|
|
|
* This notice may not be removed.
|
|
|
|
|
* See license.txt for licensing detailed licensing details.
|
|
|
|
|
*/
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
|
|
using OpenTK.Graphics;
|
2008-01-25 13:13:05 +00:00
|
|
|
|
using System.Diagnostics;
|
2008-01-25 10:02:05 +00:00
|
|
|
|
|
|
|
|
|
namespace OpenTK.Platform.X11
|
|
|
|
|
{
|
|
|
|
|
internal class X11XrandrDisplayDevice : IDisplayDeviceDriver
|
|
|
|
|
{
|
2008-01-25 13:13:05 +00:00
|
|
|
|
static object display_lock = new object();
|
|
|
|
|
|
2008-01-25 10:02:05 +00:00
|
|
|
|
#region --- Constructors ---
|
|
|
|
|
|
|
|
|
|
static X11XrandrDisplayDevice()
|
|
|
|
|
{
|
2008-01-25 14:32:51 +00:00
|
|
|
|
// Get available resolutions. Then, for each resolution get all
|
|
|
|
|
// available rates.
|
|
|
|
|
// TODO: Find a way to get all available depths, too.
|
|
|
|
|
|
|
|
|
|
//lock (display_lock) // TODO: Global X11 lock.
|
2008-01-25 13:13:05 +00:00
|
|
|
|
{
|
2008-01-25 14:32:51 +00:00
|
|
|
|
for (int screen = 0; screen < API.ScreenCount; screen++)
|
2008-01-25 13:13:05 +00:00
|
|
|
|
{
|
2008-01-25 13:56:52 +00:00
|
|
|
|
List<DisplayResolution> resolutions = new List<DisplayResolution>();
|
2008-01-25 13:13:05 +00:00
|
|
|
|
unsafe
|
|
|
|
|
{
|
2008-01-25 14:32:51 +00:00
|
|
|
|
XRRScreenSize[] array = Functions.XRRSizes(API.DefaultDisplay, screen);
|
|
|
|
|
if (array == null)
|
|
|
|
|
throw new NotSupportedException("XRandR extensions not available.");
|
|
|
|
|
|
|
|
|
|
int resolution = 0;
|
|
|
|
|
foreach (XRRScreenSize size in array)
|
2008-01-25 13:56:52 +00:00
|
|
|
|
{
|
2008-01-25 14:32:51 +00:00
|
|
|
|
short[] rates = Functions.XRRRates(API.DefaultDisplay, screen, resolution);
|
|
|
|
|
foreach (short rate in rates)
|
|
|
|
|
resolutions.Add(new DisplayResolution(size.Width, size.Height, 24, (float)rate));
|
|
|
|
|
++resolution;
|
2008-01-25 13:56:52 +00:00
|
|
|
|
}
|
2008-01-25 13:13:05 +00:00
|
|
|
|
}
|
2008-01-25 13:56:52 +00:00
|
|
|
|
|
|
|
|
|
// Construct a default device for testing purposes.
|
2008-01-25 14:32:51 +00:00
|
|
|
|
new DisplayDevice(resolutions[0], screen == API.DefaultScreen, resolutions);
|
2008-01-25 13:13:05 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2008-01-25 10:02:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public X11XrandrDisplayDevice()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region --- IDisplayDeviceDriver Members ---
|
|
|
|
|
|
|
|
|
|
public bool TryChangeResolution(DisplayDevice device, DisplayResolution resolution)
|
|
|
|
|
{
|
2008-01-25 10:03:13 +00:00
|
|
|
|
return false;
|
2008-01-25 10:02:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void RestoreResolution(DisplayDevice device)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|