[PATCH] xrandr: Remove test against RANDR_MAJOR/RANDR_MINOR, already done by configure script

View: New views
3 Messages — Rating Filter:   Alert me  

[PATCH] xrandr: Remove test against RANDR_MAJOR/RANDR_MINOR, already done by configure script

by Yann Droneaud :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

xrandr.c uses structures defined in <X11/extensions/Xrandr.h>
provided by 'libXrandr' package but tests structures availability
through RANDR_MAJOR/RANDR_MINOR defined in <X11/extensions/randr.h>
provided by 'randrproto' package.

Sometimes they are not in sync so it's safer to rely on checks made
by configure script through pkg-config.

In my test case, XRRPanning structure is not defined in Xrandr.h,
RANDR_MAJOR is 1 and RANDR_MINOR 2 but xrandr.c try to use it anyway.
(for the record, XRRPanning was added in libXrandr-1.2.91).

---
 xrandr.c |   20 --------------------
 1 files changed, 0 insertions(+), 20 deletions(-)

diff --git a/xrandr.c b/xrandr.c
index f7eba11..8118ac3 100644
--- a/xrandr.c
+++ b/xrandr.c
@@ -39,10 +39,6 @@
 
 #include "config.h"
 
-#if RANDR_MAJOR > 1 || (RANDR_MAJOR == 1 && RANDR_MINOR >= 2)
-#define HAS_RANDR_1_2 1
-#endif
-
 static char *program_name;
 static Display *dpy;
 static Window root;
@@ -111,7 +107,6 @@ usage(void)
     fprintf(stderr, "  --verbose\n");
     fprintf(stderr, "  --dryrun\n");
     fprintf(stderr, "  --nograb\n");
-#if HAS_RANDR_1_2
     fprintf(stderr, "  --prop or --properties\n");
     fprintf(stderr, "  --fb <width>x<height>\n");
     fprintf(stderr, "  --fbmm <width>x<height>\n");
@@ -149,7 +144,6 @@ usage(void)
     fprintf(stderr, "  --rmmode <name>\n");
     fprintf(stderr, "  --addmode <output> <name>\n");
     fprintf(stderr, "  --delmode <output> <name>\n");
-#endif
 
     exit(1);
     /*NOTREACHED*/
@@ -209,7 +203,6 @@ reflection_name (Rotation rotation)
     return "invalid reflection";
 }
 
-#if HAS_RANDR_1_2
 typedef enum _policy {
     clone, extend
 } policy_t;
@@ -1099,9 +1092,7 @@ get_crtcs (void)
     for (c = 0; c < res->ncrtc; c++)
     {
  XRRCrtcInfo *crtc_info = XRRGetCrtcInfo (dpy, res, res->crtcs[c]);
-#if RANDR_MAJOR > 1 || RANDR_MINOR >= 3
  XRRCrtcTransformAttributes  *attr;
-#endif
  XRRPanning  *panning_info = NULL;
 
  if (has_1_3) {
@@ -1127,7 +1118,6 @@ get_crtcs (void)
     crtcs[c].y = 0;
     crtcs[c].rotation = RR_Rotate_0;
  }
-#if RANDR_MAJOR > 1 || RANDR_MINOR >= 3
  if (XRRGetCrtcTransform (dpy, res->crtcs[c], &attr) && attr) {
     set_transform (&crtcs[c].current_transform,
    &attr->currentTransform,
@@ -1137,7 +1127,6 @@ get_crtcs (void)
     XFree (attr);
  }
  else
-#endif
  {
     init_transform (&crtcs[c].current_transform);
  }
@@ -1886,7 +1875,6 @@ set_screen_size (void)
     }
 }
     
-#endif
 
 static void
 disable_outputs (output_t *outputs)
@@ -2060,7 +2048,6 @@ main (int argc, char **argv)
     int width = 0, height = 0;
     Bool     have_pixel_size = False;
     int ret = 0;
-#if HAS_RANDR_1_2
     output_t *output = NULL;
     policy_t policy = clone;
     Bool     setit_1_2 = False;
@@ -2070,7 +2057,6 @@ main (int argc, char **argv)
     Bool query_1 = False;
     int major, minor;
     Bool current = False;
-#endif
 
     program_name = argv[0];
     if (argc == 1) query = True;
@@ -2123,14 +2109,12 @@ main (int argc, char **argv)
     if (++i>=argc) usage ();
     rate = check_strtod(argv[i]);
     setit = True;
-#if HAS_RANDR_1_2
     if (output)
     {
  output->refresh = rate;
  output->changes |= changes_refresh;
  setit_1_2 = True;
     }
-#endif
     continue;
  }
 
@@ -2173,7 +2157,6 @@ main (int argc, char **argv)
     setit = True;
     continue;
  }
-#if HAS_RANDR_1_2
  if (!strcmp ("--prop", argv[i]) ||
     !strcmp ("--props", argv[i]) ||
     !strcmp ("--madprops", argv[i]) ||
@@ -2547,7 +2530,6 @@ main (int argc, char **argv)
     modeit = True;
     continue;
  }
-#endif
  usage();
     }
     if (verbose)
@@ -2575,7 +2557,6 @@ main (int argc, char **argv)
 
     root = RootWindow (dpy, screen);
 
-#if HAS_RANDR_1_2
     if (!XRRQueryVersion (dpy, &major, &minor))
     {
  fprintf (stderr, "RandR extension missing\n");
@@ -3127,7 +3108,6 @@ main (int argc, char **argv)
  }
  exit (0);
     }
-#endif
     
     sc = XRRGetScreenInfo (dpy, root);
 
--
1.6.0.2



_______________________________________________
xorg mailing list
xorg@...
http://lists.freedesktop.org/mailman/listinfo/xorg

Re: [PATCH] xrandr: Remove test against RANDR_MAJOR/RANDR_MINOR, already done by configure script

by Rémi Cardona-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Le 04/11/2009 14:28, Yann Droneaud a écrit :

> xrandr.c uses structures defined in<X11/extensions/Xrandr.h>
> provided by 'libXrandr' package but tests structures availability
> through RANDR_MAJOR/RANDR_MINOR defined in<X11/extensions/randr.h>
> provided by 'randrproto' package.
>
> Sometimes they are not in sync so it's safer to rely on checks made
> by configure script through pkg-config.
>
> In my test case, XRRPanning structure is not defined in Xrandr.h,
> RANDR_MAJOR is 1 and RANDR_MINOR 2 but xrandr.c try to use it anyway.
> (for the record, XRRPanning was added in libXrandr-1.2.91).

configure.ac deps on "xrandr >= 1.3".

Reviewed-by: Rémi Cardona <remi@...>

I'll push it to master in a few days if no-one objects.

Cheers,

Rémi
_______________________________________________
xorg mailing list
xorg@...
http://lists.freedesktop.org/mailman/listinfo/xorg

Re: [PATCH] xrandr: Remove test against RANDR_MAJOR/RANDR_MINOR, already done by configure script

by Rémi Cardona-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Le 04/11/2009 14:28, Yann Droneaud a écrit :

> xrandr.c uses structures defined in<X11/extensions/Xrandr.h>
> provided by 'libXrandr' package but tests structures availability
> through RANDR_MAJOR/RANDR_MINOR defined in<X11/extensions/randr.h>
> provided by 'randrproto' package.
>
> Sometimes they are not in sync so it's safer to rely on checks made
> by configure script through pkg-config.
>
> In my test case, XRRPanning structure is not defined in Xrandr.h,
> RANDR_MAJOR is 1 and RANDR_MINOR 2 but xrandr.c try to use it anyway.
> (for the record, XRRPanning was added in libXrandr-1.2.91).

Pushed to master. Don't forget to sign-off your patches next time :)

Cheers,

Rémi

_______________________________________________
xorg mailing list
xorg@...
http://lists.freedesktop.org/mailman/listinfo/xorg