Skip to content
Browse files

Remember DisplayDevice original resolutions

When refreshing the AvailableDevices list, it is important to set the
original resolution on any DisplayDevices that were previously available
to allow the RestoreResolution() method to work correctly.
  • Loading branch information...
1 parent c2e3328 commit 5f6c8e654c583b377dd67f8d61f4e157f835f1d4 @cwassall cwassall committed Jan 19, 2014
Showing with 11 additions and 1 deletion.
  1. +2 −1 Source/OpenTK/DisplayDevice.cs
  2. +9 −0 Source/OpenTK/Platform/Windows/WinDisplayDevice.cs
View
3 Source/OpenTK/DisplayDevice.cs
@@ -47,7 +47,8 @@ public class DisplayDevice
bool primary;
Rectangle bounds;
- DisplayResolution current_resolution = new DisplayResolution(), original_resolution;
+ DisplayResolution current_resolution = new DisplayResolution();
+ internal DisplayResolution original_resolution;
List<DisplayResolution> available_resolutions = new List<DisplayResolution>();
IList<DisplayResolution> available_resolutions_readonly;
View
9 Source/OpenTK/Platform/Windows/WinDisplayDevice.cs
@@ -96,6 +96,10 @@ public void RefreshDisplayDevices()
{
lock (display_lock)
{
+ // Store an array of the current available DisplayDevice objects.
+ // This is needed to preserve the original_resolution.
+ DisplayDevice[] previousDevices = AvailableDevices.ToArray();
+
AvailableDevices.Clear();
// We save all necessary parameters in temporary variables
@@ -159,6 +163,11 @@ public void RefreshDisplayDevices()
opentk_dev_current_res.Bounds,
dev1.DeviceName);
+ // Set the original_resolution if the DisplayDevice was previously available.
+ foreach (DisplayDevice existingDevice in previousDevices)
+ if ((string)existingDevice.Id == (string)opentk_dev.Id)
+ opentk_dev.original_resolution = existingDevice.original_resolution;
+
AvailableDevices.Add(opentk_dev);
if (opentk_dev_primary)

0 comments on commit 5f6c8e6

Please sign in to comment.
Something went wrong with that request. Please try again.