Zhiyi Zhang : winex11.drv: Add xrandr_get_screen_resources() helper.

Alexandre Julliard julliard at winehq.org
Wed Aug 21 14:39:33 CDT 2019


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

Author: Zhiyi Zhang <zzhang at codeweavers.com>
Date:   Wed Aug 14 16:22:01 2019 +0800

winex11.drv: Add xrandr_get_screen_resources() helper.

Getting screen resources will be used in multiple places.
So put it in a function.

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

---

 dlls/winex11.drv/xrandr.c | 29 +++++++++++++++--------------
 1 file changed, 15 insertions(+), 14 deletions(-)

diff --git a/dlls/winex11.drv/xrandr.c b/dlls/winex11.drv/xrandr.c
index 9f63310..288b83f 100644
--- a/dlls/winex11.drv/xrandr.c
+++ b/dlls/winex11.drv/xrandr.c
@@ -274,6 +274,20 @@ static void xrandr10_init_modes(void)
 
 #ifdef HAVE_XRRGETSCREENRESOURCES
 
+static XRRScreenResources *xrandr_get_screen_resources(void)
+{
+    XRRScreenResources *resources = pXRRGetScreenResourcesCurrent( gdi_display, root_window );
+    if (resources && !resources->ncrtc)
+    {
+        pXRRFreeScreenResources( resources );
+        resources = pXRRGetScreenResources( gdi_display, root_window );
+    }
+
+    if (!resources)
+        ERR("Failed to get screen resources.\n");
+    return resources;
+}
+
 static int xrandr12_get_current_mode(void)
 {
     XRRScreenResources *resources;
@@ -448,21 +462,8 @@ static int xrandr12_init_modes(void)
     int ret = -1;
     int i, j;
 
-    if (!(resources = pXRRGetScreenResourcesCurrent( gdi_display, root_window )))
-    {
-        ERR("Failed to get screen resources.\n");
+    if (!(resources = xrandr_get_screen_resources()))
         return ret;
-    }
-
-    if (!resources->ncrtc)
-    {
-        pXRRFreeScreenResources( resources );
-        if (!(resources = pXRRGetScreenResources( gdi_display, root_window )))
-        {
-            ERR("Failed to get screen resources.\n");
-            return ret;
-        }
-    }
 
     if (!(crtc_info = xrandr12_get_primary_crtc_info( resources, &primary_crtc )))
     {




More information about the wine-cvs mailing list