aboutsummaryrefslogtreecommitdiff
path: root/xbmc-xrandr.c
diff options
context:
space:
mode:
authorh.udo <hudokkow@gmail.com>2018-06-08 12:51:16 +0100
committerh.udo <hudokkow@gmail.com>2018-06-12 14:46:37 +0100
commitdef12edfd52ccd75a73d7337db1bede711b3d8b2 (patch)
tree66355f82f30a9e615117b29c17a9b74246abc223 /xbmc-xrandr.c
parentb075db195f4542ecf8b6e72b21f583aaf83bca90 (diff)
[root] nuke whitespace
Diffstat (limited to 'xbmc-xrandr.c')
-rw-r--r--xbmc-xrandr.c210
1 files changed, 105 insertions, 105 deletions
diff --git a/xbmc-xrandr.c b/xbmc-xrandr.c
index 14b35ad491..a065ed0f27 100644
--- a/xbmc-xrandr.c
+++ b/xbmc-xrandr.c
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright © 2001 Keith Packard, member of The XFree86 Project, Inc.
* Copyright © 2002 Hewlett Packard Company, Inc.
* Copyright © 2006 Intel Corporation
@@ -58,16 +58,16 @@ static Bool grab_server = True;
static Bool no_primary = False;
static char *direction[5] = {
- "normal",
- "left",
- "inverted",
+ "normal",
+ "left",
+ "inverted",
"right",
"\n"};
static char *reflections[5] = {
- "normal",
- "x",
- "y",
+ "normal",
+ "x",
+ "y",
"xy",
"\n"};
@@ -161,7 +161,7 @@ static void _X_NORETURN
fatal (const char *format, ...)
{
va_list ap;
-
+
va_start (ap, format);
fprintf (stderr, "%s: ", program_name);
vfprintf (stderr, format, ap);
@@ -174,7 +174,7 @@ static void
warning (const char *format, ...)
{
va_list ap;
-
+
va_start (ap, format);
fprintf (stderr, "%s: ", program_name);
vfprintf (stderr, format, ap);
@@ -305,22 +305,22 @@ struct _output_prop {
struct _output {
struct _output *next;
-
+
changes_t changes;
-
+
output_prop_t *props;
name_t output;
XRROutputInfo *output_info;
-
+
name_t crtc;
crtc_t *crtc_info;
crtc_t *current_crtc_info;
-
+
name_t mode;
double refresh;
XRRModeInfo *mode_info;
-
+
name_t addmode;
relation_t relation;
@@ -355,7 +355,7 @@ typedef enum _umode_action {
struct _umode {
struct _umode *next;
-
+
umode_action_t action;
XRRModeInfo mode;
name_t output;
@@ -515,7 +515,7 @@ static double
mode_refresh (XRRModeInfo *mode_info)
{
double rate;
-
+
if (mode_info->hTotal && mode_info->vTotal)
rate = ((double) mode_info->dotClock /
((double) mode_info->hTotal * (double) mode_info->vTotal));
@@ -529,7 +529,7 @@ static double
mode_hsync (XRRModeInfo *mode_info)
{
double rate;
-
+
if (mode_info->hTotal)
rate = (double) mode_info->dotClock / (double) mode_info->hTotal;
else
@@ -669,7 +669,7 @@ find_output (name_t *name)
for (output = outputs; output; output = output->next)
{
name_kind_t common = name->kind & output->output.kind;
-
+
if ((common & name_xid) && name->xid == output->output.xid)
break;
if ((common & name_string) && !strcmp (name->string, output->output.string))
@@ -709,10 +709,10 @@ find_crtc (name_t *name)
for (c = 0; c < num_crtcs; c++)
{
name_kind_t common;
-
+
crtc = &crtcs[c];
common = name->kind & crtc->crtc.kind;
-
+
if ((common & name_xid) && name->xid == crtc->crtc.xid)
break;
if ((common & name_string) && !strcmp (name->string, crtc->crtc.string))
@@ -752,7 +752,7 @@ find_mode (name_t *name, double refresh)
if ((name->kind & name_string) && !strcmp (name->string, mode->name))
{
double dist;
-
+
if (refresh)
dist = fabs (mode_refresh (mode) - refresh);
else
@@ -837,14 +837,14 @@ preferred_mode (output_t *output)
int m;
XRRModeInfo *best;
int bestDist;
-
+
best = NULL;
bestDist = 0;
for (m = 0; m < output_info->nmode; m++)
{
XRRModeInfo *mode_info = find_mode_by_xid (output_info->modes[m]);
int dist;
-
+
if (m < output_info->npreferred)
dist = 0;
else if (output_info->mm_height)
@@ -920,7 +920,7 @@ output_rotations (output_t *output)
Rotation rotation = RR_Rotate_0;
XRROutputInfo *output_info = output->output_info;
int c;
-
+
for (c = 0; c < output_info->ncrtc; c++)
{
crtc_t *crtc = find_crtc_by_xid (output_info->crtcs[c]);
@@ -944,7 +944,7 @@ output_can_use_rotation (output_t *output, Rotation rotation)
int c;
/* make sure all of the crtcs can use this rotation.
- * yes, this is not strictly necessary, but it is
+ * yes, this is not strictly necessary, but it is
* simpler,and we expect most drivers to either
* support rotation everywhere or nowhere
*/
@@ -1062,18 +1062,18 @@ set_output_info (output_t *output, RROutput xid, XRROutputInfo *output_info)
if (output_info->connection != RR_Disconnected && !output_info->nmode)
warning ("Output %s is not disconnected but has no modes\n",
output_info->name);
-
+
/* set output name and info */
if (!(output->output.kind & name_xid))
set_name_xid (&output->output, xid);
if (!(output->output.kind & name_string))
set_name_string (&output->output, output_info->name);
output->output_info = output_info;
-
+
/* set crtc name and info */
if (!(output->changes & changes_crtc))
set_name_xid (&output->crtc, output_info->crtc);
-
+
if (output->crtc.kind == name_xid && output->crtc.xid == None)
output->crtc_info = NULL;
else
@@ -1095,7 +1095,7 @@ set_output_info (output_t *output, RROutput xid, XRROutputInfo *output_info)
if (!(output->changes & changes_mode))
{
crtc_t *crtc = NULL;
-
+
if (output_info->crtc)
crtc = find_crtc_by_xid(output_info->crtc);
if (crtc && crtc->crtc_info)
@@ -1214,16 +1214,16 @@ set_output_info (output_t *output, RROutput xid, XRROutputInfo *output_info)
if (!(output->changes & changes_primary))
output->primary = output_is_primary(output);
}
-
+
static void
get_screen (Bool current)
{
if (!has_1_2)
fatal ("Server RandR version before 1.2\n");
-
+
XRRGetScreenSizeRange (dpy, root, &minWidth, &minHeight,
&maxWidth, &maxHeight);
-
+
if (current)
res = XRRGetScreenResourcesCurrent (dpy, root);
else
@@ -1239,7 +1239,7 @@ get_crtcs (void)
num_crtcs = res->ncrtc;
crtcs = calloc (num_crtcs, sizeof (crtc_t));
if (!crtcs) fatal ("out of memory\n");
-
+
for (c = 0; c < res->ncrtc; c++)
{
XRRCrtcInfo *crtc_info = XRRGetCrtcInfo (dpy, res, res->crtcs[c]);
@@ -1420,7 +1420,7 @@ crtc_disable (crtc_t *crtc)
{
if (verbose)
printf ("crtc %d: disable\n", crtc->crtc.index);
-
+
if (dryrun)
return RRSetConfigSuccess;
return XRRSetCrtcConfig (dpy, res, crtc->crtc.xid, CurrentTime,
@@ -1445,10 +1445,10 @@ static Status
crtc_revert (crtc_t *crtc)
{
XRRCrtcInfo *crtc_info = crtc->crtc_info;
-
+
if (verbose)
printf ("crtc %d: revert\n", crtc->crtc.index);
-
+
if (dryrun)
return RRSetConfigSuccess;
@@ -1485,7 +1485,7 @@ crtc_apply (crtc_t *crtc)
printf (" \"%s\"", crtc->outputs[o]->output.string);
printf ("\n");
}
-
+
if (dryrun)
s = RRSetConfigSuccess;
else
@@ -1565,7 +1565,7 @@ panic (Status s, crtc_t *crtc)
{
int c = crtc->crtc.index;
char *message;
-
+
switch (s) {
case RRSetConfigSuccess: message = "succeeded"; break;
case BadAlloc: message = "out of memory"; break;
@@ -1574,7 +1574,7 @@ panic (Status s, crtc_t *crtc)
case RRSetConfigInvalidTime: message = "invalid time"; break;
default: message = "unknown failure"; break;
}
-
+
fprintf (stderr, "%s: Configure crtc %d %s\n", program_name, c, message);
revert ();
exit (1);
@@ -1585,7 +1585,7 @@ apply (void)
{
Status s;
int c;
-
+
/*
* Hold the server grabbed while messing with
* the screen so that apps which notice the resize
@@ -1594,7 +1594,7 @@ apply (void)
*/
if (grab_server)
XGrabServer (dpy);
-
+
/*
* Turn off any crtcs which are to be disabled or which are
* larger than the target size
@@ -1605,22 +1605,22 @@ apply (void)
XRRCrtcInfo *crtc_info = crtc->crtc_info;
/* if this crtc is already disabled, skip it */
- if (crtc_info->mode == None)
+ if (crtc_info->mode == None)
continue;
-
- /*
+
+ /*
* If this crtc is to be left enabled, make
* sure the old size fits then new screen
*/
- if (crtc->mode_info)
+ if (crtc->mode_info)
{
XRRModeInfo *old_mode = find_mode_by_xid (crtc_info->mode);
int x, y, w, h;
box_t bounds;
- if (!old_mode)
+ if (!old_mode)
panic (RRSetConfigFailed, crtc);
-
+
/* old position and size information */
mode_geometry (old_mode, crtc_info->rotation,
&crtc->current_transform.transform,
@@ -1632,7 +1632,7 @@ apply (void)
h = bounds.y2 - bounds.y1;
/* if it fits, skip it */
- if (x + w <= fb_width && y + h <= fb_height)
+ if (x + w <= fb_width && y + h <= fb_height)
continue;
crtc->changing = True;
}
@@ -1645,7 +1645,7 @@ apply (void)
* Set the screen size
*/
screen_apply ();
-
+
/*
* Set crtcs
*/
@@ -1653,7 +1653,7 @@ apply (void)
for (c = 0; c < res->ncrtc; c++)
{
crtc_t *crtc = &crtcs[c];
-
+
s = crtc_apply (crtc);
if (s != RRSetConfigSuccess)
panic (s, crtc);
@@ -1677,7 +1677,7 @@ get_outputs (void)
{
int o;
output_t *q;
-
+
for (o = 0; o < res->noutput; o++)
{
XRROutputInfo *output_info = XRRGetOutputInfo (dpy, res, res->outputs[o]);
@@ -1795,7 +1795,7 @@ check_crtc_for_output (crtc_t *crtc, output_t *output)
int c;
int l;
output_t *other;
-
+
for (c = 0; c < output->output_info->ncrtc; c++)
if (output->output_info->crtcs[c] == crtc->crtc.xid)
break;
@@ -1817,7 +1817,7 @@ check_crtc_for_output (crtc_t *crtc, output_t *output)
if (output->output_info->clones[l] == other->output.xid)
break;
/* not on the list, can't clone */
- if (l == output->output_info->nclone)
+ if (l == output->output_info->nclone)
return False;
}
@@ -1888,15 +1888,15 @@ set_positions (void)
name_t relation_name;
if (!(output->changes & changes_relation)) continue;
-
+
if (output->mode_info == NULL) continue;
init_name (&relation_name);
set_name_string (&relation_name, output->relative_to);
relation = find_output (&relation_name);
if (!relation) fatal ("cannot find output \"%s\"\n", output->relative_to);
-
- if (relation->mode_info == NULL)
+
+ if (relation->mode_info == NULL)
{
output->x = 0;
output->y = 0;
@@ -1907,13 +1907,13 @@ set_positions (void)
/*
* Make sure the dependent object has been set in place
*/
- if ((relation->changes & changes_relation) &&
+ if ((relation->changes & changes_relation) &&
!(relation->changes & changes_position))
{
keep_going = True;
continue;
}
-
+
switch (output->relation) {
case relation_left_of:
output->y = relation->y;
@@ -1952,7 +1952,7 @@ set_positions (void)
for (output = outputs; output; output = output->next)
{
if (output->mode_info == NULL) continue;
-
+
if (output->x < min_x) min_x = output->x;
if (output->y < min_y) min_y = output->y;
}
@@ -1975,15 +1975,15 @@ set_screen_size (void)
{
output_t *output;
Bool fb_specified = fb_width != 0 && fb_height != 0;
-
+
for (output = outputs; output; output = output->next)
{
XRRModeInfo *mode_info = output->mode_info;
int x, y, w, h;
box_t bounds;
-
+
if (!mode_info) continue;
-
+
mode_geometry (mode_info, output->rotation,
&output->transform.transform,
&bounds);
@@ -2015,7 +2015,7 @@ set_screen_size (void)
if (pan && pan->top + pan->height > fb_height)
fb_height = pan->top + pan->height;
}
- }
+ }
if (fb_width > maxWidth || fb_height > maxHeight)
fatal ("screen cannot be larger than %dx%d (desired size %dx%d)\n",
@@ -2031,7 +2031,7 @@ set_screen_size (void)
if (fb_height < minHeight) fb_height = minHeight;
}
}
-
+
static void
disable_outputs (output_t *outputs)
@@ -2055,10 +2055,10 @@ pick_crtcs_score (output_t *outputs)
int score;
crtc_t *best_crtc;
int c;
-
+
if (!outputs)
return 0;
-
+
output = outputs;
outputs = outputs->next;
/*
@@ -2070,7 +2070,7 @@ pick_crtcs_score (output_t *outputs)
return best_score;
best_crtc = NULL;
- /*
+ /*
* Now score with this output any valid crtc
*/
for (c = 0; c < output->output_info->ncrtc; c++)
@@ -2080,12 +2080,12 @@ pick_crtcs_score (output_t *outputs)
crtc = find_crtc_by_xid (output->output_info->crtcs[c]);
if (!crtc)
fatal ("cannot find crtc 0x%x\n", output->output_info->crtcs[c]);
-
+
/* reset crtc allocation for following outputs */
disable_outputs (outputs);
if (!check_crtc_for_output (crtc, output))
continue;
-
+
my_score = 1000;
/* slight preference for existing connections */
if (crtc == output->current_crtc_info)
@@ -2191,7 +2191,7 @@ main (int argc, char **argv)
int action_requested = False;
Rotation rotation, current_rotation, rotations;
XRRScreenChangeNotifyEvent event;
- XRRScreenChangeNotifyEvent *sce;
+ XRRScreenChangeNotifyEvent *sce;
char *display_name = NULL;
int i, j;
SizeID current_size;
@@ -2336,7 +2336,7 @@ main (int argc, char **argv)
output = add_output ();
set_name (&output->output, argv[i], name_string|name_xid);
}
-
+
setit_1_2 = True;
action_requested = True;
continue;
@@ -2469,7 +2469,7 @@ main (int argc, char **argv)
if (!strcmp ("--gamma", argv[i])) {
if (!output) usage();
if (++i>=argc) usage ();
- if (sscanf(argv[i], "%f:%f:%f", &output->gamma.red,
+ if (sscanf(argv[i], "%f:%f:%f", &output->gamma.red,
&output->gamma.green, &output->gamma.blue) != 3)
usage ();
output->changes |= changes_gamma;
@@ -2636,7 +2636,7 @@ main (int argc, char **argv)
{
umode_t *m = malloc (sizeof (umode_t));
double clock;
-
+
++i;
if (i + 9 >= argc) usage ();
m->mode.name = argv[i];
@@ -2656,11 +2656,11 @@ main (int argc, char **argv)
m->mode.modeFlags = 0;
while (i < argc) {
int f;
-
+
for (f = 0; mode_flags[f].string; f++)
if (!strcasecmp (mode_flags[f].string, argv[i]))
break;
-
+
if (!mode_flags[f].string)
break;
m->mode.modeFlags |= mode_flags[f].flag;
@@ -2720,7 +2720,7 @@ main (int argc, char **argv)
}
if (!action_requested)
query = True;
- if (verbose)
+ if (verbose)
{
query = True;
if (setit && !setit_1_2)
@@ -2758,7 +2758,7 @@ main (int argc, char **argv)
has_1_2 = True;
if (major > 1 || (major == 1 && minor >= 3))
has_1_3 = True;
-
+
if (has_1_2 && modeit)
{
umode_t *m;
@@ -2766,12 +2766,12 @@ main (int argc, char **argv)
get_screen (current);
get_crtcs();
get_outputs();
-
+
for (m = umodes; m; m = m->next)
{
XRRModeInfo *e;
output_t *o;
-
+
switch (m->action) {
case umode_create:
XRRCreateMode (dpy, root, &m->mode);
@@ -2810,11 +2810,11 @@ main (int argc, char **argv)
}
if (has_1_2 && propit)
{
-
+
get_screen (current);
get_crtcs();
get_outputs();
-
+
for (output = outputs; output; output = output->next)
{
output_prop_t *prop;
@@ -2835,7 +2835,7 @@ main (int argc, char **argv)
XRRPropertyInfo *propinfo;
type = AnyPropertyType;
-
+
if (XRRGetOutputProperty (dpy, output->output.xid, name,
0, 100, False, False,
AnyPropertyType,
@@ -2848,7 +2848,7 @@ main (int argc, char **argv)
type = actual_type;
format = actual_format;
}
-
+
if ((type == XA_INTEGER || type == AnyPropertyType) &&
(sscanf (prop->value, "%d", &int_value) == 1 ||
sscanf (prop->value, "0x%x", &int_value) == 1))
@@ -2899,7 +2899,7 @@ main (int argc, char **argv)
* Assign outputs to crtcs
*/
set_crtcs ();
-
+
/*
* Mark changing crtcs
*/
@@ -2956,13 +2956,13 @@ main (int argc, char **argv)
fb_height_mm = DisplayHeightMM (dpy, screen);
}
}
-
+
/*
* Set panning
*/
set_panning ();
- /*
+ /*
* Set gamma on crtc's that belong to the outputs.
*/
set_gamma ();
@@ -2971,16 +2971,16 @@ main (int argc, char **argv)
* Now apply all of the changes
*/
apply ();
-
+
XSync (dpy, False);
exit (0);
}
if (query_1_2 || (query && has_1_2 && !query_1))
{
output_t *output;
-
+
#define ModeShown 0x80000000
-
+
get_screen (current);
get_crtcs ();
get_outputs ();
@@ -3016,7 +3016,7 @@ main (int argc, char **argv)
printf (" id=\"%lx\"", mode->id);
if (output->rotation != RR_Rotate_0 || verbose)
{
- printf (" rotation=\"%s\"",
+ printf (" rotation=\"%s\"",
rotation_name (output->rotation));
if (output->rotation & (RR_Reflect_X|RR_Reflect_Y))
printf (" reflection=\"%s\"", reflection_name (output->rotation));
@@ -3142,7 +3142,7 @@ main (int argc, char **argv)
unsigned long nitems, bytes_after;
Atom actual_type;
XRRPropertyInfo *propinfo;
-
+
XRRGetOutputProperty (dpy, output->output.xid, props[j],
0, 100, False, False,
AnyPropertyType,
@@ -3154,7 +3154,7 @@ main (int argc, char **argv)
if (actual_type == XA_INTEGER && actual_format == 8) {
int k;
-
+
printf("\t%s:\n", XGetAtomName (dpy, props[j]));
for (k = 0; k < nitems; k++) {
if (k % 16 == 0)
@@ -3221,14 +3221,14 @@ main (int argc, char **argv)
free(propinfo);
}
}
-
+
if (verbose)
{
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.1fMHz",
mode->name, (int)mode->id,
(double)mode->dotClock / 1000000.0);
@@ -3256,9 +3256,9 @@ main (int argc, char **argv)
for (j = 0; j < output_info->nmode; j++)
{
XRRModeInfo *jmode, *kmode;
-
+
if (mode_shown[j]) continue;
-
+
jmode = find_mode_by_xid (output_info->modes[j]);
for (k = j; k < output_info->nmode; k++)
{
@@ -3283,7 +3283,7 @@ main (int argc, char **argv)
}
printf(" </output>\n");
}
-
+
/*
for (m = 0; m < res->nmode; m++)
{
@@ -3306,10 +3306,10 @@ main (int argc, char **argv)
printf("</screen>\n");
exit (0);
}
-
+
sc = XRRGetScreenInfo (dpy, root);
- if (sc == NULL)
+ if (sc == NULL)
exit (1);
current_size = XRRConfigCurrentConfiguration (sc, &current_rotation);
@@ -3368,7 +3368,7 @@ main (int argc, char **argv)
if (version) {
int major_version, minor_version;
XRRQueryVersion (dpy, &major_version, &minor_version);
- printf("Server reports RandR version %d.%d\n",
+ printf("Server reports RandR version %d.%d\n",
major_version, minor_version);
}
@@ -3416,7 +3416,7 @@ main (int argc, char **argv)
printf ("\n");
}
- if (verbose) {
+ if (verbose) {
printf("Setting size to %d, rotation to %s\n", size, direction[rot]);
printf ("Setting reflection on ");
@@ -3467,8 +3467,8 @@ main (int argc, char **argv)
sce = (XRRScreenChangeNotifyEvent *) &event;
printf("Got a screen change notify event!\n");
- printf(" window = %d\n root = %d\n size_index = %d\n rotation %d\n",
- (int) sce->window, (int) sce->root,
+ printf(" window = %d\n root = %d\n size_index = %d\n rotation %d\n",
+ (int) sce->window, (int) sce->root,
sce->size_index, sce->rotation);
printf(" timestamp = %ld, config_timestamp = %ld\n",
sce->timestamp, sce->config_timestamp);
@@ -3477,7 +3477,7 @@ main (int argc, char **argv)
sce->width, sce->height, sce->mwidth, sce->mheight);
printf("Display width %d, height %d\n",
DisplayWidth(dpy, screen), DisplayHeight(dpy, screen));
- printf("Display widthmm %d, heightmm %d\n",
+ printf("Display widthmm %d, heightmm %d\n",
DisplayWidthMM(dpy, screen), DisplayHeightMM(dpy, screen));
spo = sce->subpixel_order;
if ((spo < 0) || (spo > 5))
@@ -3486,7 +3486,7 @@ main (int argc, char **argv)
seen_screen = True;
break;
default:
- if (event.type != ConfigureNotify)
+ if (event.type != ConfigureNotify)
printf("unknown event received, type = %d!\n", event.type);
}
}