Zhiyi Zhang : winex11.drv: Sort display modes with orientation considered.

Alexandre Julliard julliard at winehq.org
Tue Sep 22 15:46:40 CDT 2020


Module: wine
Branch: master
Commit: ec245c7e300f7cb779cf404079872f68c812585e
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=ec245c7e300f7cb779cf404079872f68c812585e

Author: Zhiyi Zhang <zzhang at codeweavers.com>
Date:   Tue Sep 22 15:01:44 2020 +0800

winex11.drv: Sort display modes with orientation considered.

Signed-off-by: Zhiyi Zhang <zzhang at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/winex11.drv/settings.c | 42 +++++++++++++++++++++++++++++++++++++-----
 1 file changed, 37 insertions(+), 5 deletions(-)

diff --git a/dlls/winex11.drv/settings.c b/dlls/winex11.drv/settings.c
index 902f1ec15d..5bbba453b9 100644
--- a/dlls/winex11.drv/settings.c
+++ b/dlls/winex11.drv/settings.c
@@ -359,18 +359,50 @@ BOOL get_primary_adapter(WCHAR *name)
 
 static int mode_compare(const void *p1, const void *p2)
 {
+    DWORD a_width, a_height, b_width, b_height;
     const DEVMODEW *a = p1, *b = p2;
 
+    /* Use the width and height in landscape mode for comparison */
+    if (a->u1.s2.dmDisplayOrientation == DMDO_DEFAULT || a->u1.s2.dmDisplayOrientation == DMDO_180)
+    {
+        a_width = a->dmPelsWidth;
+        a_height = a->dmPelsHeight;
+    }
+    else
+    {
+        a_width = a->dmPelsHeight;
+        a_height = a->dmPelsWidth;
+    }
+
+    if (b->u1.s2.dmDisplayOrientation == DMDO_DEFAULT || b->u1.s2.dmDisplayOrientation == DMDO_180)
+    {
+        b_width = b->dmPelsWidth;
+        b_height = b->dmPelsHeight;
+    }
+    else
+    {
+        b_width = b->dmPelsHeight;
+        b_height = b->dmPelsWidth;
+    }
+
+    /* Depth in descending order */
     if (a->dmBitsPerPel != b->dmBitsPerPel)
         return b->dmBitsPerPel - a->dmBitsPerPel;
 
-    if (a->dmPelsWidth != b->dmPelsWidth)
-        return a->dmPelsWidth - b->dmPelsWidth;
+    /* Width in ascending order */
+    if (a_width != b_width)
+        return a_width - b_width;
+
+    /* Height in ascending order */
+    if (a_height != b_height)
+        return a_height - b_height;
 
-    if (a->dmPelsHeight != b->dmPelsHeight)
-        return a->dmPelsHeight - b->dmPelsHeight;
+    /* Frequency in descending order */
+    if (a->dmDisplayFrequency != b->dmDisplayFrequency)
+        return b->dmDisplayFrequency - a->dmDisplayFrequency;
 
-    return b->dmDisplayFrequency - a->dmDisplayFrequency;
+    /* Orientation in ascending order */
+    return a->u1.s2.dmDisplayOrientation - b->u1.s2.dmDisplayOrientation;
 }
 
 /***********************************************************************




More information about the wine-cvs mailing list