Browse Source

Merge pull request #9119 from DrWenz/feat/drm-init-size

Implement DrmOutputOptions.VideoMode
Max Katz 3 years ago
parent
commit
6fb5de4085

+ 6 - 0
src/Linux/Avalonia.LinuxFramebuffer/DrmOutputOptions.cs

@@ -23,5 +23,11 @@ namespace Avalonia.LinuxFramebuffer
         /// Default: R0 G0 B0 A0
         /// </summary>
         public Color InitialBufferSwappingColor { get; set; } = new Color(0, 0, 0, 0);
+
+        /// <summary>
+        /// specific the video mode with which the DrmOutput should be created, if it is not found it will fallback to the preferred mode.
+        /// If NULL preferred mode will be used.
+        /// </summary>
+        public PixelSize? VideoMode { get; set; }
     }
 }

+ 10 - 1
src/Linux/Avalonia.LinuxFramebuffer/Output/DrmOutput.cs

@@ -51,7 +51,16 @@ namespace Avalonia.LinuxFramebuffer.Output
             if(connector == null)
                 throw new InvalidOperationException("Unable to find connected DRM connector");
 
-            var mode = connector.Modes.OrderByDescending(x => x.IsPreferred)
+            DrmModeInfo? mode = null;
+
+            if (options?.VideoMode != null)
+            {
+                mode = connector.Modes
+                    .FirstOrDefault(x => x.Resolution.Width == options.VideoMode.Value.Width &&
+                                         x.Resolution.Height == options.VideoMode.Value.Height);
+            }
+            
+            mode ??= connector.Modes.OrderByDescending(x => x.IsPreferred)
                 .ThenByDescending(x => x.Resolution.Width * x.Resolution.Height)
                 //.OrderByDescending(x => x.Resolution.Width * x.Resolution.Height)
                 .FirstOrDefault();