summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Plattner <aplattner@nvidia.com>2014-01-03 05:14:35 -0800
committerAaron Plattner <aplattner@nvidia.com>2014-01-07 10:23:42 -0800
commita29728ca9599fd08da1243e9b422ac26a24cc05b (patch)
tree7eac55bfc5467091b2d5a75d4b7e795da1b1cc3c
parentc5334bb4137d6ea7b8c8b10d51131b9450d1106b (diff)
Split output property printing into a helper function
Move the body of the code that prints the actual output property values into a helper function. This will make it easier for this function to select special-case property printers for properties that need special formatting. Signed-off-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
-rw-r--r--xrandr.c66
1 files changed, 39 insertions, 27 deletions
diff --git a/xrandr.c b/xrandr.c
index 63be486..c82632f 100644
--- a/xrandr.c
+++ b/xrandr.c
@@ -2415,6 +2415,42 @@ print_output_property_value(Bool is_edid,
}
static void
+print_output_property(const char *atom_name,
+ int value_format,
+ Atom value_type,
+ int nitems,
+ const unsigned char *prop)
+{
+ int bytes_per_item = value_format / 8;
+ Bool is_edid = strcmp (atom_name, "EDID") == 0;
+ int k;
+
+ if (is_edid)
+ {
+ printf ("\n\t\t");
+ }
+
+ for (k = 0; k < nitems; k++)
+ {
+ if (k != 0)
+ {
+ if ((k % 16) == 0)
+ {
+ printf ("\n\t\t");
+ }
+ }
+ print_output_property_value (is_edid, value_format, value_type,
+ prop + (k * bytes_per_item));
+ if (!is_edid)
+ {
+ printf (" ");
+ }
+ }
+
+ printf ("\n");
+}
+
+static void
get_providers (void)
{
XRRProviderResources *pr;
@@ -3510,8 +3546,7 @@ main (int argc, char **argv)
Atom actual_type;
XRRPropertyInfo *propinfo;
char *atom_name = XGetAtomName (dpy, props[j]);
- Bool is_edid = strcmp (atom_name, "EDID") == 0;
- int bytes_per_item, k;
+ int k;
XRRGetOutputProperty (dpy, output->output.xid, props[j],
0, 100, False, False,
@@ -3522,33 +3557,10 @@ main (int argc, char **argv)
propinfo = XRRQueryOutputProperty(dpy, output->output.xid,
props[j]);
- bytes_per_item = actual_format / 8;
-
printf ("\t%s: ", atom_name);
- if (is_edid)
- {
- printf ("\n\t\t");
- }
-
- for (k = 0; k < nitems; k++)
- {
- if (k != 0)
- {
- if ((k % 16) == 0)
- {
- printf ("\n\t\t");
- }
- }
- print_output_property_value (is_edid, actual_format,
- actual_type,
- prop + (k * bytes_per_item));
- if (!is_edid)
- {
- printf (" ");
- }
- }
- printf ("\n");
+ print_output_property(atom_name, actual_format,
+ actual_type, nitems, prop);
if (propinfo->range && propinfo->num_values > 0)
{