Module Name: xsrc
Committed By: mrg
Date: Sun Nov 8 11:40:23 UTC 2009
Modified Files:
xsrc/external/mit/xrandr/dist: xrandr.c
Log Message:
merge xrandr 1.3.2
To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 xsrc/external/mit/xrandr/dist/xrandr.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: xsrc/external/mit/xrandr/dist/xrandr.c
diff -u xsrc/external/mit/xrandr/dist/xrandr.c:1.2 xsrc/external/mit/xrandr/dist/xrandr.c:1.3
--- xsrc/external/mit/xrandr/dist/xrandr.c:1.2 Sat Aug 22 01:04:32 2009
+++ xsrc/external/mit/xrandr/dist/xrandr.c Sun Nov 8 11:40:22 2009
@@ -313,7 +313,7 @@
crtc_t *current_crtc_info;
name_t mode;
- float refresh;
+ double refresh;
XRRModeInfo *mode_info;
name_t addmode;
@@ -336,6 +336,8 @@
} gamma;
Bool primary;
+
+ Bool found;
};
typedef enum _umode_action {
@@ -378,7 +380,7 @@
static XRRScreenResources *res;
static int fb_width = 0, fb_height = 0;
static int fb_width_mm = 0, fb_height_mm = 0;
-static float dpi = 0;
+static double dpi = 0;
static char *dpi_output = NULL;
static Bool dryrun = False;
static int minWidth, maxWidth, minHeight, maxHeight;
@@ -491,27 +493,27 @@
}
/* v refresh frequency in Hz */
-static float
+static double
mode_refresh (XRRModeInfo *mode_info)
{
- float rate;
+ double rate;
if (mode_info->hTotal && mode_info->vTotal)
- rate = ((float) mode_info->dotClock /
- ((float) mode_info->hTotal * (float) mode_info->vTotal));
+ rate = ((double) mode_info->dotClock /
+ ((double) mode_info->hTotal * (double) mode_info->vTotal));
else
rate = 0;
return rate;
}
/* h sync frequency in Hz */
-static float
+static double
mode_hsync (XRRModeInfo *mode_info)
{
- float rate;
+ double rate;
if (mode_info->hTotal)
- rate = (float) mode_info->dotClock / (float) mode_info->hTotal;
+ rate = (double) mode_info->dotClock / (double) mode_info->hTotal;
else
rate = 0;
return rate;
@@ -634,6 +636,7 @@
if (!output)
fatal ("out of memory\n");
output->next = NULL;
+ output->found = False;
*outputs_tail = output;
outputs_tail = &output->next;
return output;
@@ -713,11 +716,11 @@
}
static XRRModeInfo *
-find_mode (name_t *name, float refresh)
+find_mode (name_t *name, double refresh)
{
int m;
XRRModeInfo *best = NULL;
- float bestDist = 0;
+ double bestDist = 0;
for (m = 0; m < res->nmode; m++)
{
@@ -729,7 +732,7 @@
}
if ((name->kind & name_string) && !strcmp (name->string, mode->name))
{
- float dist;
+ double dist;
if (refresh)
dist = fabs (mode_refresh (mode) - refresh);
@@ -774,7 +777,7 @@
XRROutputInfo *output_info = output->output_info;
int m;
XRRModeInfo *best = NULL;
- float bestDist = 0;
+ double bestDist = 0;
for (m = 0; m < output_info->nmode; m++)
{
@@ -789,7 +792,7 @@
}
if ((name->kind & name_string) && !strcmp (name->string, mode->name))
{
- float dist;
+ double dist;
/* Stay away from doublescan modes unless refresh rate is specified. */
if (!output->refresh && (mode->modeFlags & RR_DoubleScan))
@@ -1529,6 +1532,7 @@
get_outputs (void)
{
int o;
+ output_t *q;
for (o = 0; o < res->noutput; o++)
{
@@ -1567,6 +1571,7 @@
}
}
}
+ output->found = True;
/*
* Automatic mode -- track connection state and enable/disable outputs
@@ -1597,6 +1602,14 @@
set_output_info (output, res->outputs[o], output_info);
}
+ for (q = outputs; q; q = q->next)
+ {
+ if (!q->found)
+ {
+ fprintf(stderr, "warning: output %s not found; ignoring\n",
+ q->output.string);
+ }
+ }
}
static void
@@ -2001,6 +2014,26 @@
}
}
+static int
+check_strtol(char *s)
+{
+ char *endptr;
+ int result = strtol(s, &endptr, 10);
+ if (s == endptr)
+ usage();
+ return result;
+}
+
+static int
+check_strtod(char *s)
+{
+ char *endptr;
+ double result = strtod(s, &endptr);
+ if (s == endptr)
+ usage();
+ return result;
+}
+
int
main (int argc, char **argv)
{
@@ -2019,7 +2052,7 @@
int i, j;
SizeID current_size;
short current_rate;
- float rate = -1;
+ double rate = -1;
int size = -1;
int dirind = 0;
Bool setit = False;
@@ -2075,12 +2108,12 @@
if (!strcmp ("-s", argv[i]) || !strcmp ("--size", argv[i])) {
if (++i>=argc) usage ();
- if (sscanf (argv[i], "%dx%d", &width, &height) == 2)
+ if (sscanf (argv[i], "%dx%d", &width, &height) == 2) {
have_pixel_size = True;
- else {
- size = atoi (argv[i]);
- if (size < 0) usage();
- }
+ } else {
+ size = check_strtol(argv[i]);
+ if (size < 0) usage();
+ }
setit = True;
continue;
}
@@ -2090,8 +2123,7 @@
!strcmp ("--refresh", argv[i]))
{
if (++i>=argc) usage ();
- if (sscanf (argv[i], "%f", &rate) != 1)
- usage ();
+ rate = check_strtod(argv[i]);
setit = True;
#if HAS_RANDR_1_2
if (output)
@@ -2121,7 +2153,7 @@
}
if (!strcmp ("--screen", argv[i])) {
if (++i>=argc) usage ();
- screen = atoi (argv[i]);
+ screen = check_strtol(argv[i]);
if (screen < 0) usage();
continue;
}
@@ -2132,8 +2164,8 @@
if (!strcmp ("-o", argv[i]) || !strcmp ("--orientation", argv[i])) {
char *endptr;
if (++i>=argc) usage ();
- dirind = strtol(argv[i], &endptr, 0);
- if (*endptr != '\0') {
+ dirind = strtol(argv[i], &endptr, 10);
+ if (argv[i] == endptr) {
for (dirind = 0; dirind < 4; dirind++) {
if (strcmp (direction[dirind], argv[i]) == 0) break;
}
@@ -2395,8 +2427,10 @@
continue;
}
if (!strcmp ("--dpi", argv[i])) {
+ char *strtod_error;
if (++i>=argc) usage ();
- if (sscanf (argv[i], "%f", &dpi) != 1)
+ dpi = strtod(argv[i], &strtod_error);
+ if (argv[i] == strtod_error)
{
dpi = 0.0;
dpi_output = argv[i];
@@ -2438,25 +2472,24 @@
if (!strcmp ("--newmode", argv[i]))
{
umode_t *m = malloc (sizeof (umode_t));
- float clock;
+ double clock;
++i;
if (i + 9 >= argc) usage ();
m->mode.name = argv[i];
m->mode.nameLength = strlen (argv[i]);
i++;
- if (sscanf (argv[i++], "%f", &clock) != 1)
- usage ();
+ clock = check_strtod(argv[i++]);
m->mode.dotClock = clock * 1e6;
- if (sscanf (argv[i++], "%d", &m->mode.width) != 1) usage();
- if (sscanf (argv[i++], "%d", &m->mode.hSyncStart) != 1) usage();
- if (sscanf (argv[i++], "%d", &m->mode.hSyncEnd) != 1) usage();
- if (sscanf (argv[i++], "%d", &m->mode.hTotal) != 1) usage();
- if (sscanf (argv[i++], "%d", &m->mode.height) != 1) usage();
- if (sscanf (argv[i++], "%d", &m->mode.vSyncStart) != 1) usage();
- if (sscanf (argv[i++], "%d", &m->mode.vSyncEnd) != 1) usage();
- if (sscanf (argv[i++], "%d", &m->mode.vTotal) != 1) usage();
+ m->mode.width = check_strtol(argv[i++]);
+ m->mode.hSyncStart = check_strtol(argv[i++]);
+ m->mode.hSyncEnd = check_strtol(argv[i++]);
+ m->mode.hTotal = check_strtol(argv[i++]);
+ m->mode.height = check_strtol(argv[i++]);
+ m->mode.vSyncStart = check_strtol(argv[i++]);
+ m->mode.vSyncEnd = check_strtol(argv[i++]);
+ m->mode.vTotal = check_strtol(argv[i++]);
m->mode.modeFlags = 0;
while (i < argc) {
int f;
@@ -3024,7 +3057,7 @@
printf (" %s (0x%x) %6.1fMHz",
mode->name, (int)mode->id,
- (float)mode->dotClock / 1000000.0);
+ (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);
@@ -3085,7 +3118,7 @@
{
printf (" %s (0x%x) %6.1fMHz\n",
mode->name, (int)mode->id,
- (float)mode->dotClock / 1000000.0);
+ (double)mode->dotClock / 1000000.0);
printf (" h: width %4d start %4d end %4d total %4d skew %4d clock %6.1fKHz\n",
mode->width, mode->hSyncStart, mode->hSyncEnd,
mode->hTotal, mode->hSkew, mode_hsync (mode) / 1000);