From 181b3b8a9a1e699dbb56a42b0d5bbd0ec85ddd27 Mon Sep 17 00:00:00 2001 From: Terry MacDonald Date: Wed, 28 Dec 2022 20:16:05 +1300 Subject: [PATCH] Added AMD display rotation awareness Fixes #153. AMD display profiles with rotated displays will now show that rotation properly in the display layout. Last commit included NVIDIA and Windows, and this now means all supported video cards now have this feature so the issue can be closed. --- DisplayMagician/Properties/AssemblyInfo.cs | 4 +-- DisplayMagicianShared/ProfileItem.cs | 41 +++++++++++++++++++--- 2 files changed, 38 insertions(+), 7 deletions(-) diff --git a/DisplayMagician/Properties/AssemblyInfo.cs b/DisplayMagician/Properties/AssemblyInfo.cs index e647264..2d6950d 100644 --- a/DisplayMagician/Properties/AssemblyInfo.cs +++ b/DisplayMagician/Properties/AssemblyInfo.cs @@ -26,8 +26,8 @@ using System.Resources; [assembly: Guid("e4ceaf5e-ad01-4695-b179-31168eb74c48")] // Version information -[assembly: AssemblyVersion("2.5.0.336")] -[assembly: AssemblyFileVersion("2.5.0.336")] +[assembly: AssemblyVersion("2.5.0.337")] +[assembly: AssemblyFileVersion("2.5.0.337")] [assembly: NeutralResourcesLanguageAttribute( "en" )] [assembly: CLSCompliant(true)] diff --git a/DisplayMagicianShared/ProfileItem.cs b/DisplayMagicianShared/ProfileItem.cs index fddeb33..9076446 100644 --- a/DisplayMagicianShared/ProfileItem.cs +++ b/DisplayMagicianShared/ProfileItem.cs @@ -1358,9 +1358,8 @@ namespace DisplayMagicianShared //screen.DisplayConnector = displayMode.DisplayConnector; screen.ScreenX = _amdDisplayConfig.DisplayMaps[i].DisplayMode.XPos; screen.ScreenY = _amdDisplayConfig.DisplayMaps[i].DisplayMode.YPos; - screen.ScreenWidth = _amdDisplayConfig.DisplayMaps[i].DisplayMode.XRes; - screen.ScreenHeight = _amdDisplayConfig.DisplayMaps[i].DisplayMode.YRes; - + screen.Rotation = ScreenRotation.ROTATE_0; + // If we're at the 0,0 coordinate then we're the primary monitor if (screen.ScreenX == 0 && screen.ScreenY == 0) { @@ -1439,8 +1438,40 @@ namespace DisplayMagicianShared //screen.DisplayConnector = displayMode.DisplayConnector; screen.ScreenX = displayMode.SourceMode.Position.X; screen.ScreenY = displayMode.SourceMode.Position.Y; - screen.ScreenWidth = (int)displayMode.SourceMode.Width; - screen.ScreenHeight = (int)displayMode.SourceMode.Height; + //screen.ScreenWidth = (int)displayMode.SourceMode.Width; + //screen.ScreenHeight = (int)displayMode.SourceMode.Height; + + if (path.TargetInfo.Rotation == DISPLAYCONFIG_ROTATION.DISPLAYCONFIG_ROTATION_IDENTITY) + { + screen.ScreenWidth = (int)displayMode.SourceMode.Width; + screen.ScreenHeight = (int)displayMode.SourceMode.Height; + screen.Rotation = ScreenRotation.ROTATE_0; + } + else if (path.TargetInfo.Rotation == DISPLAYCONFIG_ROTATION.DISPLAYCONFIG_ROTATION_ROTATE90) + { + // Portrait screen so need to change width and height + screen.ScreenWidth = (int)displayMode.SourceMode.Height; + screen.ScreenHeight = (int)displayMode.SourceMode.Width; + screen.Rotation = ScreenRotation.ROTATE_90; + } + else if (path.TargetInfo.Rotation == DISPLAYCONFIG_ROTATION.DISPLAYCONFIG_ROTATION_ROTATE180) + { + screen.ScreenWidth = (int)displayMode.SourceMode.Width; + screen.ScreenHeight = (int)displayMode.SourceMode.Height; + screen.Rotation = ScreenRotation.ROTATE_180; + } + else if (path.TargetInfo.Rotation == DISPLAYCONFIG_ROTATION.DISPLAYCONFIG_ROTATION_ROTATE270) + { + screen.ScreenWidth = (int)displayMode.SourceMode.Width; + screen.ScreenHeight = (int)displayMode.SourceMode.Height; + screen.Rotation = ScreenRotation.ROTATE_270; + } + else + { + screen.ScreenWidth = (int)displayMode.SourceMode.Width; + screen.ScreenHeight = (int)displayMode.SourceMode.Height; + screen.Rotation = ScreenRotation.ROTATE_0; + } // If we're at the 0,0 coordinate then we're the primary monitor if (screen.ScreenX == 0 && screen.ScreenY == 0)