summaryrefslogtreecommitdiff
path: root/hw/xwin
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2010-05-18 11:12:49 +1000
committerKeith Packard <keithp@keithp.com>2010-05-18 15:43:51 -0700
commitd88ba7721d2d3b58cdc664fd4c23a3c5e2a5f909 (patch)
tree80b64d2ed0c450d093156b1be4ca626228eeb78c /hw/xwin
parent673eb707ce6737284c4886265ba149c5587a74e2 (diff)
xfree86: Add option parsing for percent options.
In some cases, an option of "50%" would be preferable over fixed value configuration - especially if the actual values are autoprobed. Add a new set of functions to parse percent values from configurations. The percent value parsing differs slightly - if the option is not to marked as used (e.g. xf86CheckPercentOption()), no warning is emitted to the log file if the value is not a percent value. This allows double-options (either as % or as absolute number) without warnings. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Dan Nicholson <dbn.lists@gmail.com> Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'hw/xwin')
-rw-r--r--hw/xwin/winconfig.c37
-rw-r--r--hw/xwin/winconfig.h2
2 files changed, 39 insertions, 0 deletions
diff --git a/hw/xwin/winconfig.c b/hw/xwin/winconfig.c
index 971d381a3..c2dd05693 100644
--- a/hw/xwin/winconfig.c
+++ b/hw/xwin/winconfig.c
@@ -673,6 +673,18 @@ winSetRealOption (pointer optlist, const char *name, double deflt)
deflt = o.value.realnum;
return deflt;
}
+
+double
+winSetPercentOption (pointer optlist, const char *name, double deflt)
+{
+ OptionInfoRec o;
+
+ o.name = name;
+ o.type = OPTV_PERCENT;
+ if (ParseOptionValue (-1, optlist, &o))
+ deflt = o.value.realnum;
+ return deflt;
+}
#endif
@@ -851,6 +863,31 @@ ParseOptionValue (int scrnIndex, pointer options, OptionInfoPtr p)
p->found = FALSE;
}
break;
+ case OPTV_PERCENT:
+ if (*s == '\0')
+ {
+ winDrvMsg (scrnIndex, X_WARNING,
+ "Option \"%s\" requires a percent value\n",
+ p->name);
+ p->found = FALSE;
+ }
+ else
+ {
+ double percent = strtod (s, &end);
+
+ if (end != s && winNameCompare (end, "%"))
+ {
+ p->found = TRUE;
+ p->value.realnum = percent;
+ }
+ else
+ {
+ winDrvMsg (scrnIndex, X_WARNING,
+ "Option \"%s\" requires a frequency value\n",
+ p->name);
+ p->found = FALSE;
+ }
+ }
case OPTV_FREQ:
if (*s == '\0')
{
diff --git a/hw/xwin/winconfig.h b/hw/xwin/winconfig.h
index 058884abc..4699ca8ef 100644
--- a/hw/xwin/winconfig.h
+++ b/hw/xwin/winconfig.h
@@ -256,6 +256,7 @@ typedef enum
OPTV_ANYSTR, /* Any string, including an empty one */
OPTV_REAL,
OPTV_BOOLEAN,
+ OPTV_PERCENT,
OPTV_FREQ
}
OptionValueType;
@@ -289,6 +290,7 @@ char *winSetStrOption (pointer optlist, const char *name, char *deflt);
int winSetBoolOption (pointer optlist, const char *name, int deflt);
int winSetIntOption (pointer optlist, const char *name, int deflt);
double winSetRealOption (pointer optlist, const char *name, double deflt);
+double winSetPercentOption (pointer optlist, const char *name, double deflt);
#ifdef XWIN_XF86CONFIG
XF86OptionPtr winFindOption (XF86OptionPtr list, const char *name);
char *winFindOptionValue (XF86OptionPtr list, const char *name);