input: switch InputOption to use XF86OptionRec storage.
Use the same struct for both InputOption and XF86OptionRec so we don't need to convert to and fro the two in the config backends. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Dan Nicholson <dbn.lists@gmail.com> Reviewed-by: Daniel Stone <daniel@fooishbar.org>
This commit is contained in:
parent
16ac78a53c
commit
c39c8d3428
|
@ -38,6 +38,7 @@
|
||||||
#include "inpututils.h"
|
#include "inpututils.h"
|
||||||
#include "eventstr.h"
|
#include "eventstr.h"
|
||||||
#include "scrnintstr.h"
|
#include "scrnintstr.h"
|
||||||
|
#include "optionstr.h"
|
||||||
|
|
||||||
/* Check if a button map change is okay with the device.
|
/* Check if a button map change is okay with the device.
|
||||||
* Returns -1 for BadValue, as it collides with MappingBusy. */
|
* Returns -1 for BadValue, as it collides with MappingBusy. */
|
||||||
|
@ -670,8 +671,9 @@ point_on_screen(ScreenPtr pScreen, int x, int y)
|
||||||
static void
|
static void
|
||||||
input_option_free(InputOption *o)
|
input_option_free(InputOption *o)
|
||||||
{
|
{
|
||||||
free(o->key);
|
free(o->opt_name);
|
||||||
free(o->value);
|
free(o->opt_val);
|
||||||
|
free(o->opt_comment);
|
||||||
free(o);
|
free(o);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -701,7 +703,7 @@ input_option_new(InputOption* list, const char *key, const char *value)
|
||||||
|
|
||||||
if (list)
|
if (list)
|
||||||
{
|
{
|
||||||
nt_list_for_each_entry(opt, list, next)
|
nt_list_for_each_entry(opt, list, list.next)
|
||||||
{
|
{
|
||||||
if (strcmp(input_option_get_key(opt), key) == 0)
|
if (strcmp(input_option_get_key(opt), key) == 0)
|
||||||
{
|
{
|
||||||
|
@ -715,13 +717,13 @@ input_option_new(InputOption* list, const char *key, const char *value)
|
||||||
if (!opt)
|
if (!opt)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
nt_list_init(opt, next);
|
nt_list_init(opt, list.next);
|
||||||
input_option_set_key(opt, key);
|
input_option_set_key(opt, key);
|
||||||
input_option_set_value(opt, value);
|
input_option_set_value(opt, value);
|
||||||
|
|
||||||
if (list)
|
if (list)
|
||||||
{
|
{
|
||||||
nt_list_append(opt, list, InputOption, next);
|
nt_list_append(opt, list, InputOption, list.next);
|
||||||
return list;
|
return list;
|
||||||
} else
|
} else
|
||||||
return opt;
|
return opt;
|
||||||
|
@ -732,9 +734,9 @@ input_option_free_element(InputOption *list, const char *key)
|
||||||
{
|
{
|
||||||
InputOption *element;
|
InputOption *element;
|
||||||
|
|
||||||
nt_list_for_each_entry(element, list, next) {
|
nt_list_for_each_entry(element, list, list.next) {
|
||||||
if (strcmp(input_option_get_key(element), key) == 0) {
|
if (strcmp(input_option_get_key(element), key) == 0) {
|
||||||
nt_list_del(element, list, InputOption, next);
|
nt_list_del(element, list, InputOption, list.next);
|
||||||
input_option_free(element);
|
input_option_free(element);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -750,8 +752,8 @@ input_option_free_list(InputOption **opt)
|
||||||
{
|
{
|
||||||
InputOption *element, *tmp;
|
InputOption *element, *tmp;
|
||||||
|
|
||||||
nt_list_for_each_entry_safe(element, tmp, *opt, next) {
|
nt_list_for_each_entry_safe(element, tmp, *opt, list.next) {
|
||||||
nt_list_del(element, *opt, InputOption, next);
|
nt_list_del(element, *opt, InputOption, list.next);
|
||||||
input_option_free(element);
|
input_option_free(element);
|
||||||
}
|
}
|
||||||
*opt = NULL;
|
*opt = NULL;
|
||||||
|
@ -768,7 +770,7 @@ input_option_find(InputOption *list, const char *key)
|
||||||
{
|
{
|
||||||
InputOption *element;
|
InputOption *element;
|
||||||
|
|
||||||
nt_list_for_each_entry(element, list, next) {
|
nt_list_for_each_entry(element, list, list.next) {
|
||||||
if (strcmp(input_option_get_key(element), key) == 0)
|
if (strcmp(input_option_get_key(element), key) == 0)
|
||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
|
@ -779,29 +781,29 @@ input_option_find(InputOption *list, const char *key)
|
||||||
const char*
|
const char*
|
||||||
input_option_get_key(const InputOption *opt)
|
input_option_get_key(const InputOption *opt)
|
||||||
{
|
{
|
||||||
return opt->key;
|
return opt->opt_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char*
|
const char*
|
||||||
input_option_get_value(const InputOption *opt)
|
input_option_get_value(const InputOption *opt)
|
||||||
{
|
{
|
||||||
return opt->value;
|
return opt->opt_val;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
input_option_set_key(InputOption *opt, const char *key)
|
input_option_set_key(InputOption *opt, const char *key)
|
||||||
{
|
{
|
||||||
free(opt->key);
|
free(opt->opt_name);
|
||||||
if (key)
|
if (key)
|
||||||
opt->key = strdup(key);
|
opt->opt_name = strdup(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
input_option_set_value(InputOption *opt, const char *value)
|
input_option_set_value(InputOption *opt, const char *value)
|
||||||
{
|
{
|
||||||
free(opt->value);
|
free(opt->opt_val);
|
||||||
if (value)
|
if (value)
|
||||||
opt->value = strdup(value);
|
opt->opt_val = strdup(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,7 @@
|
||||||
#include "eventstr.h"
|
#include "eventstr.h"
|
||||||
#include "xserver-properties.h"
|
#include "xserver-properties.h"
|
||||||
#include "inpututils.h"
|
#include "inpututils.h"
|
||||||
|
#include "optionstr.h"
|
||||||
|
|
||||||
#define AtomFromName(x) MakeAtom(x, strlen(x), 1)
|
#define AtomFromName(x) MakeAtom(x, strlen(x), 1)
|
||||||
|
|
||||||
|
@ -1074,7 +1075,7 @@ KdParseKbdOptions (KdKeyboardInfo *ki)
|
||||||
{
|
{
|
||||||
InputOption *option = NULL;
|
InputOption *option = NULL;
|
||||||
|
|
||||||
nt_list_for_each_entry(option, ki->options, next)
|
nt_list_for_each_entry(option, ki->options, list.next)
|
||||||
{
|
{
|
||||||
const char *key = input_option_get_key(option);
|
const char *key = input_option_get_key(option);
|
||||||
const char *value = input_option_get_value(option);
|
const char *value = input_option_get_value(option);
|
||||||
|
@ -1174,7 +1175,7 @@ KdParsePointerOptions (KdPointerInfo *pi)
|
||||||
{
|
{
|
||||||
InputOption *option = NULL;
|
InputOption *option = NULL;
|
||||||
|
|
||||||
nt_list_for_each_entry(option, pi->options, next)
|
nt_list_for_each_entry(option, pi->options, list.next)
|
||||||
{
|
{
|
||||||
const char *key = input_option_get_key(option);
|
const char *key = input_option_get_key(option);
|
||||||
const char *value = input_option_get_value(option);
|
const char *value = input_option_get_value(option);
|
||||||
|
@ -2222,7 +2223,7 @@ NewInputDeviceRequest(InputOption *options, InputAttributes *attrs,
|
||||||
KdPointerInfo *pi = NULL;
|
KdPointerInfo *pi = NULL;
|
||||||
KdKeyboardInfo *ki = NULL;
|
KdKeyboardInfo *ki = NULL;
|
||||||
|
|
||||||
nt_list_for_each_entry(option, options, next) {
|
nt_list_for_each_entry(option, options, list.next) {
|
||||||
const char *key = input_option_get_key(option);
|
const char *key = input_option_get_key(option);
|
||||||
const char *value = input_option_get_value(option);
|
const char *value = input_option_get_value(option);
|
||||||
|
|
||||||
|
@ -2267,7 +2268,7 @@ NewInputDeviceRequest(InputOption *options, InputAttributes *attrs,
|
||||||
|
|
||||||
/* FIXME: change this code below to use KdParseKbdOptions and
|
/* FIXME: change this code below to use KdParseKbdOptions and
|
||||||
* KdParsePointerOptions */
|
* KdParsePointerOptions */
|
||||||
nt_list_for_each_entry(option, options, next) {
|
nt_list_for_each_entry(option, options, list.next) {
|
||||||
const char *key = input_option_get_key(option);
|
const char *key = input_option_get_key(option);
|
||||||
const char *value = input_option_get_value(option);
|
const char *value = input_option_get_value(option);
|
||||||
|
|
||||||
|
|
|
@ -44,6 +44,7 @@
|
||||||
#include "xf86Xinput.h"
|
#include "xf86Xinput.h"
|
||||||
#include "xf86Optrec.h"
|
#include "xf86Optrec.h"
|
||||||
#include "xf86Parser.h"
|
#include "xf86Parser.h"
|
||||||
|
#include "optionstr.h"
|
||||||
|
|
||||||
static Bool ParseOptionValue(int scrnIndex, XF86OptionPtr options, OptionInfoPtr p,
|
static Bool ParseOptionValue(int scrnIndex, XF86OptionPtr options, OptionInfoPtr p,
|
||||||
Bool markUsed);
|
Bool markUsed);
|
||||||
|
|
|
@ -24,16 +24,7 @@
|
||||||
|
|
||||||
#ifndef XF86OPTIONSTR_H
|
#ifndef XF86OPTIONSTR_H
|
||||||
#define XF86OPTIONSTR_H
|
#define XF86OPTIONSTR_H
|
||||||
|
#include "list.h"
|
||||||
/*
|
|
||||||
* all records that need to be linked lists should contain a GenericList as
|
|
||||||
* their first field.
|
|
||||||
*/
|
|
||||||
typedef struct generic_list_rec
|
|
||||||
{
|
|
||||||
void *next;
|
|
||||||
}
|
|
||||||
GenericListRec, *GenericListPtr, *glp;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* All options are stored using this data type.
|
* All options are stored using this data type.
|
||||||
|
@ -48,6 +39,6 @@ typedef struct _XF86OptionRec
|
||||||
}
|
}
|
||||||
XF86OptionRec;
|
XF86OptionRec;
|
||||||
|
|
||||||
typedef struct _XF86OptionRec *XF86OptionPtr;
|
typedef struct _InputOption *XF86OptionPtr;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -68,6 +68,7 @@
|
||||||
#include "exglobals.h"
|
#include "exglobals.h"
|
||||||
#include "eventstr.h"
|
#include "eventstr.h"
|
||||||
#include "inpututils.h"
|
#include "inpututils.h"
|
||||||
|
#include "optionstr.h"
|
||||||
|
|
||||||
#include <string.h> /* InputClassMatches */
|
#include <string.h> /* InputClassMatches */
|
||||||
#ifdef HAVE_FNMATCH_H
|
#ifdef HAVE_FNMATCH_H
|
||||||
|
@ -908,7 +909,7 @@ NewInputDeviceRequest (InputOption *options, InputAttributes *attrs,
|
||||||
if (!pInfo)
|
if (!pInfo)
|
||||||
return BadAlloc;
|
return BadAlloc;
|
||||||
|
|
||||||
nt_list_for_each_entry(option, options, next) {
|
nt_list_for_each_entry(option, options, list.next) {
|
||||||
if (strcasecmp(input_option_get_key(option), "driver") == 0) {
|
if (strcasecmp(input_option_get_key(option), "driver") == 0) {
|
||||||
if (pInfo->driver) {
|
if (pInfo->driver) {
|
||||||
rval = BadRequest;
|
rval = BadRequest;
|
||||||
|
@ -946,7 +947,7 @@ NewInputDeviceRequest (InputOption *options, InputAttributes *attrs,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
nt_list_for_each_entry(option, options, next) {
|
nt_list_for_each_entry(option, options, list.next) {
|
||||||
/* Copy option key/value strings from the provided list */
|
/* Copy option key/value strings from the provided list */
|
||||||
pInfo->options = xf86AddNewOption(pInfo->options,
|
pInfo->options = xf86AddNewOption(pInfo->options,
|
||||||
input_option_get_key(option),
|
input_option_get_key(option),
|
||||||
|
|
|
@ -63,6 +63,7 @@
|
||||||
#include "Configint.h"
|
#include "Configint.h"
|
||||||
#include <X11/Xfuncproto.h>
|
#include <X11/Xfuncproto.h>
|
||||||
#include "Xprintf.h"
|
#include "Xprintf.h"
|
||||||
|
#include "optionstr.h"
|
||||||
|
|
||||||
extern LexRec val;
|
extern LexRec val;
|
||||||
|
|
||||||
|
@ -203,7 +204,7 @@ addNewOption2 (XF86OptionPtr head, char *name, char *val, int used)
|
||||||
free(new->opt_val);
|
free(new->opt_val);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
new = calloc (1, sizeof (XF86OptionRec));
|
new = calloc (1, sizeof (*new));
|
||||||
new->opt_name = name;
|
new->opt_name = name;
|
||||||
new->opt_val = val;
|
new->opt_val = val;
|
||||||
new->opt_used = used;
|
new->opt_used = used;
|
||||||
|
@ -284,7 +285,7 @@ xf86newOption(char *name, char *value)
|
||||||
{
|
{
|
||||||
XF86OptionPtr opt;
|
XF86OptionPtr opt;
|
||||||
|
|
||||||
opt = calloc(1, sizeof (XF86OptionRec));
|
opt = calloc(1, sizeof (*opt));
|
||||||
if (!opt)
|
if (!opt)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@
|
||||||
#include "xf86tokens.h"
|
#include "xf86tokens.h"
|
||||||
#include "Configint.h"
|
#include "Configint.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include "optionstr.h"
|
||||||
|
|
||||||
/* Needed for auto server layout */
|
/* Needed for auto server layout */
|
||||||
extern int xf86CheckBoolOption(void* optlist, const char *name, int deflt);
|
extern int xf86CheckBoolOption(void* optlist, const char *name, int deflt);
|
||||||
|
|
|
@ -621,11 +621,4 @@ static inline WindowPtr DeepestSpriteWin(SpritePtr sprite)
|
||||||
return sprite->spriteTrace[sprite->spriteTraceGood - 1];
|
return sprite->spriteTrace[sprite->spriteTraceGood - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
struct _InputOption {
|
|
||||||
char *key;
|
|
||||||
char *value;
|
|
||||||
struct _InputOption *next;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* INPUTSTRUCT_H */
|
#endif /* INPUTSTRUCT_H */
|
||||||
|
|
|
@ -438,4 +438,16 @@ list_is_empty(struct list *head)
|
||||||
nt_list_init(__e, _member); \
|
nt_list_init(__e, _member); \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DO NOT USE THIS.
|
||||||
|
* This is a remainder of the xfree86 DDX attempt of having a set of generic
|
||||||
|
* list functions. Unfortunately, the xf86OptionRec uses it and we can't
|
||||||
|
* easily get rid of it. Do not use for new code.
|
||||||
|
*/
|
||||||
|
typedef struct generic_list_rec
|
||||||
|
{
|
||||||
|
void *next;
|
||||||
|
}
|
||||||
|
GenericListRec, *GenericListPtr, *glp;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
#ifndef OPTIONSTR_H_
|
||||||
|
#define OPTIONSTR_H_
|
||||||
|
#include "list.h"
|
||||||
|
|
||||||
|
|
||||||
|
struct _InputOption {
|
||||||
|
GenericListRec list;
|
||||||
|
char *opt_name;
|
||||||
|
char *opt_val;
|
||||||
|
int opt_used;
|
||||||
|
char *opt_comment;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* INPUTSTRUCT_H */
|
Loading…
Reference in New Issue