Skip to content

Commit

Permalink
Merge remote-tracking branch 'cwassall/develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
thefiddler committed Jan 26, 2014
2 parents b942600 + 7b59196 commit c73e478
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
20 changes: 19 additions & 1 deletion Source/OpenTK/DisplayDevice.cs
Expand Up @@ -47,7 +47,8 @@ public class DisplayDevice

bool primary;
Rectangle bounds;
DisplayResolution current_resolution = new DisplayResolution(), original_resolution;
DisplayResolution current_resolution = new DisplayResolution();
DisplayResolution original_resolution;
List<DisplayResolution> available_resolutions = new List<DisplayResolution>();
IList<DisplayResolution> available_resolutions_readonly;

Expand Down Expand Up @@ -335,6 +336,23 @@ public static DisplayDevice GetDisplay(DisplayIndex index)

#endregion

#region --- Internal Methods ---

#region internal DisplayResolution OriginalResolution

/// <summary>
/// Gets the original resolution of this instance.
/// </summary>
internal DisplayResolution OriginalResolution
{
get { return original_resolution; }
set { original_resolution = value; }
}

#endregion

#endregion

#region --- Private Methods ---

#region DisplayResolution FindResolution(int width, int height, int bitsPerPixel, float refreshRate)
Expand Down
9 changes: 9 additions & 0 deletions Source/OpenTK/Platform/Windows/WinDisplayDevice.cs
Expand Up @@ -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
Expand Down Expand Up @@ -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.OriginalResolution = existingDevice.OriginalResolution;

AvailableDevices.Add(opentk_dev);

if (opentk_dev_primary)
Expand Down

0 comments on commit c73e478

Please sign in to comment.