[X2Go-Commits] [nx-libs] 42/51: Extensions.c: Cleanup nxagentRandRInitSizes()

git-admin at x2go.org git-admin at x2go.org
Fri Feb 8 05:40:14 CET 2019


This is an automated email from the git hooks/post-receive script.

x2go pushed a commit to branch master
in repository nx-libs.

commit c4c39bc949549795c39ecbb24967256119c1f342
Author: Ulrich Sibiller <uli42 at gmx.de>
Date:   Fri Jan 11 22:39:34 2019 +0100

    Extensions.c: Cleanup nxagentRandRInitSizes()
---
 nx-X11/programs/Xserver/hw/nxagent/Extensions.c | 77 +++++++++++--------------
 1 file changed, 33 insertions(+), 44 deletions(-)

diff --git a/nx-X11/programs/Xserver/hw/nxagent/Extensions.c b/nx-X11/programs/Xserver/hw/nxagent/Extensions.c
index 3639922..785724c 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Extensions.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Extensions.c
@@ -269,40 +269,30 @@ int nxagentRandRGetInfo(ScreenPtr pScreen, Rotation *pRotations)
 
 static int nxagentRandRInitSizes(ScreenPtr pScreen)
 {
-  RRScreenSizePtr pSize;
+  const int refresh_rate = 60;
+  RRScreenSizePtr pSize = NULL;
 
-  int width;
-  int height;
-
-  int maxWidth;
-  int maxHeight;
+  /*
+    Index[0]: default size
+    Index[nsizes-1]: current size
+    Index[nsizes-2]: max size
+  */
 
-/*
+  /*
   int w[] = {0, 160, 320, 640, 800, 1024, 1152, 1280, 1280, 1280, 1280, 1280,
                  1280, 1360, 1440, 1600, 1600, 1680, 1920, 1920, 0, 0};
   int h[] = {0, 120, 240, 480, 600,  768,  864,  600,  720,  800,  854,  960,
                  1024,  768,  900,  900, 1200, 1050, 1080, 1200, 0, 0};
-*/
+  */
   int w[] = {0, 320, 640, 640, 800, 800, 1024, 1024, 1152, 1280, 1280, 1280, 1360,
                  1440, 1600, 1600, 1680, 1920, 1920, 0, 0};
   int h[] = {0, 240, 360, 480, 480, 600,  600,  768,  864,  720,  800, 1024,  768,
                   900,  900, 1200, 1050, 1080, 1200, 0, 0};
 
-  int i;
-  int nSizes;
-
-  int mmWidth;
-  int mmHeight;
-
-  /*
-   * Register all the supported sizes. The third
-   * parameter is the refresh rate.
-   */
-
-  maxWidth  = WidthOfScreen(DefaultScreenOfDisplay(nxagentDisplay));
-  maxHeight = HeightOfScreen(DefaultScreenOfDisplay(nxagentDisplay));
+  int maxWidth  = WidthOfScreen(DefaultScreenOfDisplay(nxagentDisplay));
+  int maxHeight = HeightOfScreen(DefaultScreenOfDisplay(nxagentDisplay));
 
-  nSizes = sizeof w / sizeof(int);
+  int nSizes = sizeof w / sizeof(int);
 
   /*
    * Add current and max sizes.
@@ -321,7 +311,7 @@ static int nxagentRandRInitSizes(ScreenPtr pScreen)
   w[0] = w[1];
   h[0] = h[1];
 
-  for (i = 2; i < nSizes - 1; i++)
+  for (int i = 2; i < nSizes - 1; i++)
   {
     if ((w[i] <= maxWidth * 3 / 4) && 
             (h[i] <= maxHeight * 3 / 4) &&
@@ -333,47 +323,46 @@ static int nxagentRandRInitSizes(ScreenPtr pScreen)
     }
   }
 
-  for (i = 0; i < nSizes; i++)
+  /*
+   * Register all the supported sizes at a fixed refresh rate.
+   */
+
+  for (int i = 0; i < nSizes; i++)
   {
-    width = w[i];
-    height = h[i];
+    int mmWidth, mmHeight;
 
     if (monitorResolution < 0)
     {
-      mmWidth  = width * DisplayWidthMM(nxagentDisplay, DefaultScreen(nxagentDisplay)) /
+      mmWidth  = w[i] * DisplayWidthMM(nxagentDisplay, DefaultScreen(nxagentDisplay)) /
                      DisplayWidth(nxagentDisplay, DefaultScreen(nxagentDisplay));
 
-      mmHeight = height * DisplayHeightMM(nxagentDisplay, DefaultScreen(nxagentDisplay)) /
+      mmHeight = h[i] * DisplayHeightMM(nxagentDisplay, DefaultScreen(nxagentDisplay)) /
                      DisplayHeight(nxagentDisplay, DefaultScreen(nxagentDisplay));
     }
     else
     {
-      mmWidth  = (width * 254 + monitorResolution * 5) / (monitorResolution * 10);
-      mmHeight = (height * 254 + monitorResolution * 5) / (monitorResolution * 10);
-
-    }
-
-    if (mmWidth < 1)
-    {
-      mmWidth = 1;
-    }
-
-    if (mmHeight < 1)
-    {
-      mmHeight = 1;
+      mmWidth  = (w[i] * 254 + monitorResolution * 5) / (monitorResolution * 10);
+      mmHeight = (h[i] * 254 + monitorResolution * 5) / (monitorResolution * 10);
     }
 
-    pSize = RRRegisterSize(pScreen, width, height, mmWidth, mmHeight);
+    pSize = RRRegisterSize(pScreen, w[i], h[i], mmWidth < 1 ? 1 : mmWidth, mmHeight < 1 ? 1 : mmHeight);
 
     if (pSize == NULL)
     {
       return 0;
     }
 
-    RRRegisterRate (pScreen, pSize, 60);
+    RRRegisterRate (pScreen, pSize, refresh_rate);
   }
 
-  RRSetCurrentConfig(pScreen, RR_Rotate_0, 60, pSize);
+  /*
+   * the last registered size should be the current size
+   */
+
+  if (pSize)
+  {
+    RRSetCurrentConfig(pScreen, RR_Rotate_0, refresh_rate, pSize);
+  }
 
   return 1;
 }

--
Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/nx-libs.git


More information about the x2go-commits mailing list