From 6977937b3bd64027d20a5e16ea36c5c60cc3d948 Mon Sep 17 00:00:00 2001 From: the_fiddler Date: Fri, 25 Jan 2008 14:32:51 +0000 Subject: [PATCH] Added code to obtain refresh rates. --- .../Platform/X11/X11XrandrDisplayDevice.cs | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/Source/OpenTK/Platform/X11/X11XrandrDisplayDevice.cs b/Source/OpenTK/Platform/X11/X11XrandrDisplayDevice.cs index 1bad4b0a..22346fc3 100644 --- a/Source/OpenTK/Platform/X11/X11XrandrDisplayDevice.cs +++ b/Source/OpenTK/Platform/X11/X11XrandrDisplayDevice.cs @@ -23,26 +23,33 @@ namespace OpenTK.Platform.X11 static X11XrandrDisplayDevice() { - //lock (display_lock) + // 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. { - for (int i = 0; i < API.ScreenCount; i++) + for (int screen = 0; screen < API.ScreenCount; screen++) { List resolutions = new List(); unsafe { - XRRScreenSize[] array = Functions.XRRSizes(API.DefaultDisplay, i); - Debug.Print("{0} resolutions.", array.Length); - Debug.Indent(); - for (int count = 0; count < array.Length; count++) + 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) { - resolutions.Add(new DisplayResolution(array[count].Width, array[count].Height, 24, 0)); - Debug.Print(resolutions[count].ToString()); + 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; } - Debug.Unindent(); } // Construct a default device for testing purposes. - new DisplayDevice(resolutions[0], i == API.DefaultScreen, resolutions); + new DisplayDevice(resolutions[0], screen == API.DefaultScreen, resolutions); } } }