Combine the two forms of verbose mode printing into a single function.  Pass the
'current' and 'preferred' flags as arguments.  This fixes the code that prints
unassociated modes to print the flags as well.

Signed-off-by: Aaron Plattner <aplatt...@nvidia.com>
---
 xrandr.c | 62 ++++++++++++++++++++++++++++++--------------------------------
 1 file changed, 30 insertions(+), 32 deletions(-)

diff --git a/xrandr.c b/xrandr.c
index 8a345427a226..5be2167d724f 100644
--- a/xrandr.c
+++ b/xrandr.c
@@ -566,7 +566,7 @@ mode_geometry (XRRModeInfo *mode_info, Rotation rotation,
 
 /* v refresh frequency in Hz */
 static double
-mode_refresh (XRRModeInfo *mode_info)
+mode_refresh (const XRRModeInfo *mode_info)
 {
     double rate;
     double vTotal = mode_info->vTotal;
@@ -592,7 +592,7 @@ mode_refresh (XRRModeInfo *mode_info)
 
 /* h sync frequency in Hz */
 static double
-mode_hsync (XRRModeInfo *mode_info)
+mode_hsync (const XRRModeInfo *mode_info)
 {
     double rate;
     
@@ -603,6 +603,30 @@ mode_hsync (XRRModeInfo *mode_info)
     return rate;
 }
 
+static void print_verbose_mode (const XRRModeInfo *mode, Bool current,
+                               Bool preferred)
+{
+    int f;
+
+    printf ("  %s (0x%x) %6.3fMHz",
+           mode->name, (int)mode->id,
+           (double)mode->dotClock / 1000000.0);
+    for (f = 0; mode_flags[f].flag; f++)
+       if (mode->modeFlags & mode_flags[f].flag)
+           printf (" %s", mode_flags[f].string);
+    if (current)
+       printf (" *current");
+    if (preferred)
+       printf (" +preferred");
+    printf ("\n");
+    printf ("        h: width  %4d start %4d end %4d total %4d skew %4d clock 
%6.2fKHz\n",
+           mode->width, mode->hSyncStart, mode->hSyncEnd,
+           mode->hTotal, mode->hSkew, mode_hsync (mode) / 1000);
+    printf ("        v: height %4d start %4d end %4d total %4d           clock 
%6.2fHz\n",
+           mode->height, mode->vSyncStart, mode->vSyncEnd, mode->vTotal,
+           mode_refresh (mode));
+}
+
 static void
 init_name (name_t *name)
 {
@@ -3836,25 +3860,9 @@ main (int argc, char **argv)
                for (j = 0; j < output_info->nmode; j++)
                {
                    XRRModeInfo *mode = find_mode_by_xid 
(output_info->modes[j]);
-                   int         f;
-                   
-                   printf ("  %s (0x%x) %6.3fMHz",
-                           mode->name, (int)mode->id,
-                           (double)mode->dotClock / 1000000.0);
-                   for (f = 0; mode_flags[f].flag; f++)
-                       if (mode->modeFlags & mode_flags[f].flag)
-                           printf (" %s", mode_flags[f].string);
-                   if (mode == output->mode_info)
-                       printf (" *current");
-                   if (j < output_info->npreferred)
-                       printf (" +preferred");
-                   printf ("\n");
-                   printf ("        h: width  %4d start %4d end %4d total %4d 
skew %4d clock %6.2fKHz\n",
-                           mode->width, mode->hSyncStart, mode->hSyncEnd,
-                           mode->hTotal, mode->hSkew, mode_hsync (mode) / 
1000);
-                   printf ("        v: height %4d start %4d end %4d total %4d  
         clock %6.2fHz\n",
-                           mode->height, mode->vSyncStart, mode->vSyncEnd, 
mode->vTotal,
-                           mode_refresh (mode));
+
+                   print_verbose_mode (mode, mode == output->mode_info,
+                                       j < output_info->npreferred);
                    mode->modeFlags |= ModeShown;
                }
            }
@@ -3899,17 +3907,7 @@ main (int argc, char **argv)
            XRRModeInfo *mode = &res->modes[m];
 
            if (!(mode->modeFlags & ModeShown))
-           {
-               printf ("  %s (0x%x) %6.3fMHz\n",
-                       mode->name, (int)mode->id,
-                       (double)mode->dotClock / 1000000.0);
-               printf ("        h: width  %4d start %4d end %4d total %4d skew 
%4d clock %6.2fKHz\n",
-                       mode->width, mode->hSyncStart, mode->hSyncEnd,
-                       mode->hTotal, mode->hSkew, mode_hsync (mode) / 1000);
-               printf ("        v: height %4d start %4d end %4d total %4d      
     clock %6.2fHz\n",
-                       mode->height, mode->vSyncStart, mode->vSyncEnd, 
mode->vTotal,
-                       mode_refresh (mode));
-           }
+               print_verbose_mode(mode, False, False);
        }
        exit (0);
     }
-- 
2.3.5

_______________________________________________
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Reply via email to