mirror of
https://github.com/X11Libre/xserver.git
synced 2026-09-28 21:33:09 +00:00
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
10 changed files with 59 additions and 43 deletions
|
|
@ -38,6 +38,7 @@
|
|||
#include "inpututils.h"
|
||||
#include "eventstr.h"
|
||||
#include "scrnintstr.h"
|
||||
#include "optionstr.h"
|
||||
|
||||
/* Check if a button map change is okay with the device.
|
||||
* Returns -1 for BadValue, as it collides with MappingBusy. */
|
||||
|
|
@ -670,8 +671,9 @@ point_on_screen(ScreenPtr pScreen, int x, int y)
|
|||
static void
|
||||
input_option_free(InputOption *o)
|
||||
{
|
||||
free(o->key);
|
||||
free(o->value);
|
||||
free(o->opt_name);
|
||||
free(o->opt_val);
|
||||
free(o->opt_comment);
|
||||
free(o);
|
||||
}
|
||||
|
||||
|
|
@ -701,7 +703,7 @@ input_option_new(InputOption* list, const char *key, const char *value)
|
|||
|
||||
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)
|
||||
{
|
||||
|
|
@ -715,13 +717,13 @@ input_option_new(InputOption* list, const char *key, const char *value)
|
|||
if (!opt)
|
||||
return NULL;
|
||||
|
||||
nt_list_init(opt, next);
|
||||
nt_list_init(opt, list.next);
|
||||
input_option_set_key(opt, key);
|
||||
input_option_set_value(opt, value);
|
||||
|
||||
if (list)
|
||||
{
|
||||
nt_list_append(opt, list, InputOption, next);
|
||||
nt_list_append(opt, list, InputOption, list.next);
|
||||
return list;
|
||||
} else
|
||||
return opt;
|
||||
|
|
@ -732,9 +734,9 @@ input_option_free_element(InputOption *list, const char *key)
|
|||
{
|
||||
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) {
|
||||
nt_list_del(element, list, InputOption, next);
|
||||
nt_list_del(element, list, InputOption, list.next);
|
||||
input_option_free(element);
|
||||
break;
|
||||
}
|
||||
|
|
@ -750,8 +752,8 @@ input_option_free_list(InputOption **opt)
|
|||
{
|
||||
InputOption *element, *tmp;
|
||||
|
||||
nt_list_for_each_entry_safe(element, tmp, *opt, next) {
|
||||
nt_list_del(element, *opt, InputOption, next);
|
||||
nt_list_for_each_entry_safe(element, tmp, *opt, list.next) {
|
||||
nt_list_del(element, *opt, InputOption, list.next);
|
||||
input_option_free(element);
|
||||
}
|
||||
*opt = NULL;
|
||||
|
|
@ -768,7 +770,7 @@ input_option_find(InputOption *list, const char *key)
|
|||
{
|
||||
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)
|
||||
return element;
|
||||
}
|
||||
|
|
@ -779,29 +781,29 @@ input_option_find(InputOption *list, const char *key)
|
|||
const char*
|
||||
input_option_get_key(const InputOption *opt)
|
||||
{
|
||||
return opt->key;
|
||||
return opt->opt_name;
|
||||
}
|
||||
|
||||
const char*
|
||||
input_option_get_value(const InputOption *opt)
|
||||
{
|
||||
return opt->value;
|
||||
return opt->opt_val;
|
||||
}
|
||||
|
||||
void
|
||||
input_option_set_key(InputOption *opt, const char *key)
|
||||
{
|
||||
free(opt->key);
|
||||
free(opt->opt_name);
|
||||
if (key)
|
||||
opt->key = strdup(key);
|
||||
opt->opt_name = strdup(key);
|
||||
}
|
||||
|
||||
void
|
||||
input_option_set_value(InputOption *opt, const char *value)
|
||||
{
|
||||
free(opt->value);
|
||||
free(opt->opt_val);
|
||||
if (value)
|
||||
opt->value = strdup(value);
|
||||
opt->opt_val = strdup(value);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue