Merge remote-tracking branch 'whot/for-keith'

This commit is contained in:
Keith Packard 2014-02-09 16:05:42 -08:00
commit 5300212ce8
24 changed files with 179 additions and 134 deletions

View File

@ -1169,8 +1169,8 @@ IResetProc(ExtensionEntry * unused)
EventSwapVector[DevicePropertyNotify] = NotImplemented; EventSwapVector[DevicePropertyNotify] = NotImplemented;
RestoreExtensionEvents(); RestoreExtensionEvents();
free((void *) xi_all_devices.name); free(xi_all_devices.name);
free((void *) xi_all_master_devices.name); free(xi_all_master_devices.name);
XIBarrierReset(); XIBarrierReset();
} }

View File

@ -121,7 +121,7 @@ SizeDeviceInfo(DeviceIntPtr d, int *namesize, int *size)
static void static void
CopyDeviceName(char **namebuf, const char *name) CopyDeviceName(char **namebuf, const char *name)
{ {
char *nameptr = (char *) *namebuf; char *nameptr = *namebuf;
if (name) { if (name) {
*nameptr++ = strlen(name); *nameptr++ = strlen(name);

View File

@ -242,16 +242,16 @@ device_added(struct udev_device *udev_device)
free(config_info); free(config_info);
input_option_free_list(&input_options); input_option_free_list(&input_options);
free((void *) attrs.usb_id); free(attrs.usb_id);
free((void *) attrs.pnp_id); free(attrs.pnp_id);
free((void *) attrs.product); free(attrs.product);
free((void *) attrs.device); free(attrs.device);
free((void *) attrs.vendor); free(attrs.vendor);
if (attrs.tags) { if (attrs.tags) {
const char **tag = attrs.tags; char **tag = attrs.tags;
while (*tag) { while (*tag) {
free((void *) *tag); free(*tag);
tag++; tag++;
} }
free(attrs.tags); free(attrs.tags);

View File

@ -955,7 +955,7 @@ CloseDevice(DeviceIntPtr dev)
while (dev->xkb_interest) while (dev->xkb_interest)
XkbRemoveResourceClient((DevicePtr) dev, dev->xkb_interest->resource); XkbRemoveResourceClient((DevicePtr) dev, dev->xkb_interest->resource);
free((void *) dev->name); free(dev->name);
classes = (ClassesPtr) &dev->key; classes = (ClassesPtr) &dev->key;
FreeAllDeviceClasses(classes); FreeAllDeviceClasses(classes);
@ -1279,6 +1279,7 @@ InitButtonClassDeviceStruct(DeviceIntPtr dev, int numButtons, Atom *labels,
BUG_RETURN_VAL(dev == NULL, FALSE); BUG_RETURN_VAL(dev == NULL, FALSE);
BUG_RETURN_VAL(dev->button != NULL, FALSE); BUG_RETURN_VAL(dev->button != NULL, FALSE);
BUG_RETURN_VAL(numButtons >= MAX_BUTTONS, FALSE);
butc = calloc(1, sizeof(ButtonClassRec)); butc = calloc(1, sizeof(ButtonClassRec));
if (!butc) if (!butc)

View File

@ -478,9 +478,9 @@ SetVendorRelease(int release)
} }
void void
SetVendorString(const char *string) SetVendorString(const char *vendor)
{ {
VendorString = string; VendorString = vendor;
} }
Bool Bool

View File

@ -1655,6 +1655,8 @@ GetPointerEvents(InternalEvent *events, DeviceIntPtr pDev, int type,
} }
#endif #endif
BUG_RETURN_VAL(buttons >= MAX_BUTTONS, 0);
/* refuse events from disabled devices */ /* refuse events from disabled devices */
if (!pDev->enabled) if (!pDev->enabled)
return 0; return 0;

View File

@ -60,7 +60,8 @@ check_butmap_change(DeviceIntPtr dev, CARD8 *map, int len, CARD32 *errval_out,
} }
for (i = 0; i < len; i++) { for (i = 0; i < len; i++) {
if (dev->button->map[i + 1] != map[i] && dev->button->down[i + 1]) if (dev->button->map[i + 1] != map[i] &&
button_is_down(dev, i + 1, BUTTON_PROCESSED))
return MappingBusy; return MappingBusy;
} }
@ -351,7 +352,7 @@ DuplicateInputAttributes(InputAttributes * attrs)
{ {
InputAttributes *new_attr; InputAttributes *new_attr;
int ntags = 0; int ntags = 0;
const char **tags, **new_tags; char **tags, **new_tags;
if (!attrs) if (!attrs)
return NULL; return NULL;
@ -403,20 +404,20 @@ DuplicateInputAttributes(InputAttributes * attrs)
void void
FreeInputAttributes(InputAttributes * attrs) FreeInputAttributes(InputAttributes * attrs)
{ {
const char **tags; char **tags;
if (!attrs) if (!attrs)
return; return;
free((void *) attrs->product); free(attrs->product);
free((void *) attrs->vendor); free(attrs->vendor);
free((void *) attrs->device); free(attrs->device);
free((void *) attrs->pnp_id); free(attrs->pnp_id);
free((void *) attrs->usb_id); free(attrs->usb_id);
if ((tags = attrs->tags)) if ((tags = attrs->tags))
while (*tags) while (*tags)
free((void *) *tags++); free(*tags++);
free(attrs->tags); free(attrs->tags);
free(attrs); free(attrs);

View File

@ -777,13 +777,7 @@ configServerFlags(XF86ConfFlagsPtr flagsconf, XF86OptionPtr layoutopts)
MessageType from; MessageType from;
const char *s; const char *s;
XkbRMLVOSet set; XkbRMLVOSet set;
const char *rules;
/* Default options. */
set.rules = "base";
set.model = "pc105";
set.layout = "us";
set.variant = NULL;
set.options = NULL;
/* /*
* Merge the ServerLayout and ServerFlags options. The former have * Merge the ServerLayout and ServerFlags options. The former have
@ -963,9 +957,15 @@ configServerFlags(XF86ConfFlagsPtr flagsconf, XF86OptionPtr layoutopts)
* evdev rules set. */ * evdev rules set. */
#if defined(linux) #if defined(linux)
if (!xf86Info.forceInputDevices) if (!xf86Info.forceInputDevices)
set.rules = "evdev"; rules = "evdev";
else
#endif #endif
rules = "base";
/* Xkb default options. */
XkbInitRules(&set, rules, "pc105", "us", NULL, NULL);
XkbSetRulesDflts(&set); XkbSetRulesDflts(&set);
XkbFreeRMLVOSet(&set, FALSE);
xf86Info.useDefaultFontPath = TRUE; xf86Info.useDefaultFontPath = TRUE;
xf86Info.useDefaultFontPathFrom = X_DEFAULT; xf86Info.useDefaultFontPathFrom = X_DEFAULT;

View File

@ -159,8 +159,8 @@ configureInputSection(void)
parsePrologue(XF86ConfInputPtr, XF86ConfInputRec) parsePrologue(XF86ConfInputPtr, XF86ConfInputRec)
ptr->inp_identifier = "Keyboard0"; ptr->inp_identifier = xnfstrdup("Keyboard0");
ptr->inp_driver = "kbd"; ptr->inp_driver = xnfstrdup("kbd");
ptr->list.next = NULL; ptr->list.next = NULL;
/* Crude mechanism to auto-detect mouse (os dependent) */ /* Crude mechanism to auto-detect mouse (os dependent) */
@ -175,17 +175,17 @@ configureInputSection(void)
} }
mouse = calloc(1, sizeof(XF86ConfInputRec)); mouse = calloc(1, sizeof(XF86ConfInputRec));
mouse->inp_identifier = "Mouse0"; mouse->inp_identifier = xnfstrdup("Mouse0");
mouse->inp_driver = "mouse"; mouse->inp_driver = xnfstrdup("mouse");
mouse->inp_option_lst = mouse->inp_option_lst =
xf86addNewOption(mouse->inp_option_lst, strdup("Protocol"), xf86addNewOption(mouse->inp_option_lst, xnfstrdup("Protocol"),
strdup(DFLT_MOUSE_PROTO)); xnfstrdup(DFLT_MOUSE_PROTO));
mouse->inp_option_lst = mouse->inp_option_lst =
xf86addNewOption(mouse->inp_option_lst, strdup("Device"), xf86addNewOption(mouse->inp_option_lst, xnfstrdup("Device"),
strdup(DFLT_MOUSE_DEV)); xnfstrdup(DFLT_MOUSE_DEV));
mouse->inp_option_lst = mouse->inp_option_lst =
xf86addNewOption(mouse->inp_option_lst, strdup("ZAxisMapping"), xf86addNewOption(mouse->inp_option_lst, xnfstrdup("ZAxisMapping"),
strdup("4 5 6 7")); xnfstrdup("4 5 6 7"));
ptr = (XF86ConfInputPtr) xf86addListItem((glp) ptr, (glp) mouse); ptr = (XF86ConfInputPtr) xf86addListItem((glp) ptr, (glp) mouse);
return ptr; return ptr;
} }
@ -290,7 +290,7 @@ configureDeviceSection(int screennum)
" ### <string>: \"String\", <freq>: \"<f> Hz/kHz/MHz\",\n" " ### <string>: \"String\", <freq>: \"<f> Hz/kHz/MHz\",\n"
" ### <percent>: \"<f>%\"\n" " ### <percent>: \"<f>%\"\n"
" ### [arg]: arg optional\n"; " ### [arg]: arg optional\n";
ptr->dev_comment = strdup(descrip); ptr->dev_comment = xnfstrdup(descrip);
if (ptr->dev_comment) { if (ptr->dev_comment) {
for (p = DevToConfig[screennum].GDev.options; p->name != NULL; p++) { for (p = DevToConfig[screennum].GDev.options; p->name != NULL; p++) {
char *p_e; char *p_e;
@ -337,9 +337,9 @@ configureLayoutSection(void)
iptr = malloc(sizeof(XF86ConfInputrefRec)); iptr = malloc(sizeof(XF86ConfInputrefRec));
iptr->list.next = NULL; iptr->list.next = NULL;
iptr->iref_option_lst = NULL; iptr->iref_option_lst = NULL;
iptr->iref_inputdev_str = "Mouse0"; iptr->iref_inputdev_str = xnfstrdup("Mouse0");
iptr->iref_option_lst = iptr->iref_option_lst =
xf86addNewOption(iptr->iref_option_lst, strdup("CorePointer"), xf86addNewOption(iptr->iref_option_lst, xnfstrdup("CorePointer"),
NULL); NULL);
ptr->lay_input_lst = (XF86ConfInputrefPtr) ptr->lay_input_lst = (XF86ConfInputrefPtr)
xf86addListItem((glp) ptr->lay_input_lst, (glp) iptr); xf86addListItem((glp) ptr->lay_input_lst, (glp) iptr);
@ -351,9 +351,9 @@ configureLayoutSection(void)
iptr = malloc(sizeof(XF86ConfInputrefRec)); iptr = malloc(sizeof(XF86ConfInputrefRec));
iptr->list.next = NULL; iptr->list.next = NULL;
iptr->iref_option_lst = NULL; iptr->iref_option_lst = NULL;
iptr->iref_inputdev_str = "Keyboard0"; iptr->iref_inputdev_str = xnfstrdup("Keyboard0");
iptr->iref_option_lst = iptr->iref_option_lst =
xf86addNewOption(iptr->iref_option_lst, strdup("CoreKeyboard"), xf86addNewOption(iptr->iref_option_lst, xnfstrdup("CoreKeyboard"),
NULL); NULL);
ptr->lay_input_lst = (XF86ConfInputrefPtr) ptr->lay_input_lst = (XF86ConfInputrefPtr)
xf86addListItem((glp) ptr->lay_input_lst, (glp) iptr); xf86addListItem((glp) ptr->lay_input_lst, (glp) iptr);
@ -431,9 +431,9 @@ configureFilesSection(void)
parsePrologue(XF86ConfFilesPtr, XF86ConfFilesRec) parsePrologue(XF86ConfFilesPtr, XF86ConfFilesRec)
if (xf86ModulePath) if (xf86ModulePath)
ptr->file_modulepath = strdup(xf86ModulePath); ptr->file_modulepath = xnfstrdup(xf86ModulePath);
if (defaultFontPath) if (defaultFontPath)
ptr->file_fontpath = strdup(defaultFontPath); ptr->file_fontpath = xnfstrdup(defaultFontPath);
return ptr; return ptr;
} }
@ -446,8 +446,8 @@ configureMonitorSection(int screennum)
XNFasprintf(&tmp, "Monitor%d", screennum); XNFasprintf(&tmp, "Monitor%d", screennum);
ptr->mon_identifier = tmp; ptr->mon_identifier = tmp;
ptr->mon_vendor = strdup("Monitor Vendor"); ptr->mon_vendor = xnfstrdup("Monitor Vendor");
ptr->mon_modelname = strdup("Monitor Model"); ptr->mon_modelname = xnfstrdup("Monitor Model");
return ptr; return ptr;
} }
@ -491,7 +491,7 @@ configureDDCMonitorSection(int screennum)
XNFasprintf(&tmp, "Monitor%d", screennum); XNFasprintf(&tmp, "Monitor%d", screennum);
ptr->mon_identifier = tmp; ptr->mon_identifier = tmp;
ptr->mon_vendor = strdup(ConfiguredMonitor->vendor.name); ptr->mon_vendor = xnfstrdup(ConfiguredMonitor->vendor.name);
XNFasprintf(&ptr->mon_modelname, "%x", ConfiguredMonitor->vendor.prod_id); XNFasprintf(&ptr->mon_modelname, "%x", ConfiguredMonitor->vendor.prod_id);
/* features in centimetres, we want millimetres */ /* features in centimetres, we want millimetres */
@ -529,7 +529,7 @@ configureDDCMonitorSection(int screennum)
if (ConfiguredMonitor->features.dpms) { if (ConfiguredMonitor->features.dpms) {
ptr->mon_option_lst = ptr->mon_option_lst =
xf86addNewOption(ptr->mon_option_lst, strdup("DPMS"), NULL); xf86addNewOption(ptr->mon_option_lst, xnfstrdup("DPMS"), NULL);
} }
return ptr; return ptr;

View File

@ -539,7 +539,7 @@ MatchAttrToken(const char *attr, struct xorg_list *patterns,
* match. Each list entry is a separate Match line of the same type. * match. Each list entry is a separate Match line of the same type.
*/ */
xorg_list_for_each_entry(group, patterns, entry) { xorg_list_for_each_entry(group, patterns, entry) {
const char *const *cur; char *const *cur;
Bool match = FALSE; Bool match = FALSE;
for (cur = group->values; *cur; cur++) for (cur = group->values; *cur; cur++)
@ -598,7 +598,7 @@ InputClassMatches(const XF86ConfInputClassPtr iclass, const InputInfoPtr idev,
* See if any of the device's tags match any of the MatchTag tokens. * See if any of the device's tags match any of the MatchTag tokens.
*/ */
if (!xorg_list_is_empty(&iclass->match_tag)) { if (!xorg_list_is_empty(&iclass->match_tag)) {
const char *const *tag; char *const *tag;
Bool match; Bool match;
if (!attrs->tags) if (!attrs->tags)

View File

@ -82,8 +82,8 @@ typedef struct _InputDriverRec {
typedef struct _InputInfoRec { typedef struct _InputInfoRec {
struct _InputInfoRec *next; struct _InputInfoRec *next;
const char *name; char *name;
const char *driver; char *driver;
int flags; int flags;

View File

@ -63,7 +63,7 @@ xf86ConfigSymTabRec InputClassTab[] = {
#define TOKEN_SEP "|" #define TOKEN_SEP "|"
static void static void
add_group_entry(struct xorg_list *head, const char **values) add_group_entry(struct xorg_list *head, char **values)
{ {
xf86MatchGroup *group; xf86MatchGroup *group;
@ -256,7 +256,7 @@ void
xf86printInputClassSection(FILE * cf, XF86ConfInputClassPtr ptr) xf86printInputClassSection(FILE * cf, XF86ConfInputClassPtr ptr)
{ {
const xf86MatchGroup *group; const xf86MatchGroup *group;
const char *const *cur; char *const *cur;
while (ptr) { while (ptr) {
fprintf(cf, "Section \"InputClass\"\n"); fprintf(cf, "Section \"InputClass\"\n");
@ -362,7 +362,7 @@ xf86freeInputClassList(XF86ConfInputClassPtr ptr)
while (ptr) { while (ptr) {
xf86MatchGroup *group, *next; xf86MatchGroup *group, *next;
const char **list; char **list;
TestFree(ptr->identifier); TestFree(ptr->identifier);
TestFree(ptr->driver); TestFree(ptr->driver);
@ -370,55 +370,55 @@ xf86freeInputClassList(XF86ConfInputClassPtr ptr)
xorg_list_for_each_entry_safe(group, next, &ptr->match_product, entry) { xorg_list_for_each_entry_safe(group, next, &ptr->match_product, entry) {
xorg_list_del(&group->entry); xorg_list_del(&group->entry);
for (list = group->values; *list; list++) for (list = group->values; *list; list++)
free((void *) *list); free(*list);
free(group); free(group);
} }
xorg_list_for_each_entry_safe(group, next, &ptr->match_vendor, entry) { xorg_list_for_each_entry_safe(group, next, &ptr->match_vendor, entry) {
xorg_list_del(&group->entry); xorg_list_del(&group->entry);
for (list = group->values; *list; list++) for (list = group->values; *list; list++)
free((void *) *list); free(*list);
free(group); free(group);
} }
xorg_list_for_each_entry_safe(group, next, &ptr->match_device, entry) { xorg_list_for_each_entry_safe(group, next, &ptr->match_device, entry) {
xorg_list_del(&group->entry); xorg_list_del(&group->entry);
for (list = group->values; *list; list++) for (list = group->values; *list; list++)
free((void *) *list); free(*list);
free(group); free(group);
} }
xorg_list_for_each_entry_safe(group, next, &ptr->match_os, entry) { xorg_list_for_each_entry_safe(group, next, &ptr->match_os, entry) {
xorg_list_del(&group->entry); xorg_list_del(&group->entry);
for (list = group->values; *list; list++) for (list = group->values; *list; list++)
free((void *) *list); free(*list);
free(group); free(group);
} }
xorg_list_for_each_entry_safe(group, next, &ptr->match_pnpid, entry) { xorg_list_for_each_entry_safe(group, next, &ptr->match_pnpid, entry) {
xorg_list_del(&group->entry); xorg_list_del(&group->entry);
for (list = group->values; *list; list++) for (list = group->values; *list; list++)
free((void *) *list); free(*list);
free(group); free(group);
} }
xorg_list_for_each_entry_safe(group, next, &ptr->match_usbid, entry) { xorg_list_for_each_entry_safe(group, next, &ptr->match_usbid, entry) {
xorg_list_del(&group->entry); xorg_list_del(&group->entry);
for (list = group->values; *list; list++) for (list = group->values; *list; list++)
free((void *) *list); free(*list);
free(group); free(group);
} }
xorg_list_for_each_entry_safe(group, next, &ptr->match_driver, entry) { xorg_list_for_each_entry_safe(group, next, &ptr->match_driver, entry) {
xorg_list_del(&group->entry); xorg_list_del(&group->entry);
for (list = group->values; *list; list++) for (list = group->values; *list; list++)
free((void *) *list); free(*list);
free(group); free(group);
} }
xorg_list_for_each_entry_safe(group, next, &ptr->match_tag, entry) { xorg_list_for_each_entry_safe(group, next, &ptr->match_tag, entry) {
xorg_list_del(&group->entry); xorg_list_del(&group->entry);
for (list = group->values; *list; list++) for (list = group->values; *list; list++)
free((void *) *list); free(*list);
free(group); free(group);
} }
xorg_list_for_each_entry_safe(group, next, &ptr->match_layout, entry) { xorg_list_for_each_entry_safe(group, next, &ptr->match_layout, entry) {
xorg_list_del(&group->entry); xorg_list_del(&group->entry);
for (list = group->values; *list; list++) for (list = group->values; *list; list++)
free((void *) *list); free(*list);
free(group); free(group);
} }

View File

@ -279,8 +279,8 @@ typedef struct {
typedef struct { typedef struct {
GenericListRec list; GenericListRec list;
const char *inp_identifier; char *inp_identifier;
const char *inp_driver; char *inp_driver;
XF86OptionPtr inp_option_lst; XF86OptionPtr inp_option_lst;
char *inp_comment; char *inp_comment;
} XF86ConfInputRec, *XF86ConfInputPtr; } XF86ConfInputRec, *XF86ConfInputPtr;
@ -288,7 +288,7 @@ typedef struct {
typedef struct { typedef struct {
GenericListRec list; GenericListRec list;
XF86ConfInputPtr iref_inputdev; XF86ConfInputPtr iref_inputdev;
const char *iref_inputdev_str; char *iref_inputdev_str;
XF86OptionPtr iref_option_lst; XF86OptionPtr iref_option_lst;
} XF86ConfInputrefRec, *XF86ConfInputrefPtr; } XF86ConfInputrefRec, *XF86ConfInputrefPtr;
@ -299,13 +299,13 @@ typedef struct {
typedef struct { typedef struct {
struct xorg_list entry; struct xorg_list entry;
const char **values; char **values;
} xf86MatchGroup; } xf86MatchGroup;
typedef struct { typedef struct {
GenericListRec list; GenericListRec list;
char *identifier; char *identifier;
const char *driver; char *driver;
struct xorg_list match_product; struct xorg_list match_product;
struct xorg_list match_vendor; struct xorg_list match_vendor;
struct xorg_list match_device; struct xorg_list match_device;

View File

@ -95,8 +95,8 @@ SOFTWARE.
#define NO_AXIS_LIMITS -1 #define NO_AXIS_LIMITS -1
#define MAP_LENGTH 256 #define MAP_LENGTH MAX_BUTTONS
#define DOWN_LENGTH 32 /* 256/8 => number of bytes to hold 256 bits */ #define DOWN_LENGTH (MAX_BUTTONS/8) /* 256/8 => number of bytes to hold 256 bits */
#define NullGrab ((GrabPtr)NULL) #define NullGrab ((GrabPtr)NULL)
#define PointerRootWin ((WindowPtr)PointerRoot) #define PointerRootWin ((WindowPtr)PointerRoot)
#define NoneWin ((WindowPtr)None) #define NoneWin ((WindowPtr)None)
@ -221,12 +221,12 @@ typedef struct _InputOption InputOption;
typedef struct _XI2Mask XI2Mask; typedef struct _XI2Mask XI2Mask;
typedef struct _InputAttributes { typedef struct _InputAttributes {
const char *product; char *product;
const char *vendor; char *vendor;
const char *device; char *device;
const char *pnp_id; char *pnp_id;
const char *usb_id; char *usb_id;
const char **tags; /* null-terminated */ char **tags; /* null-terminated */
uint32_t flags; uint32_t flags;
} InputAttributes; } InputAttributes;

View File

@ -542,7 +542,7 @@ typedef struct _DeviceIntRec {
GrabInfoRec deviceGrab; /* grab on the device */ GrabInfoRec deviceGrab; /* grab on the device */
int type; /* MASTER_POINTER, MASTER_KEYBOARD, SLAVE */ int type; /* MASTER_POINTER, MASTER_KEYBOARD, SLAVE */
Atom xinput_type; Atom xinput_type;
const char *name; char *name;
int id; int id;
KeyClassPtr key; KeyClassPtr key;
ValuatorClassPtr valuator; ValuatorClassPtr valuator;

View File

@ -246,7 +246,7 @@ padding_for_int32(const int bytes)
} }
extern const char **xstrtokenize(const char *str, const char *separators); extern char **xstrtokenize(const char *str, const char *separators);
extern void FormatInt64(int64_t num, char *string); extern void FormatInt64(int64_t num, char *string);
extern void FormatUInt64(uint64_t num, char *string); extern void FormatUInt64(uint64_t num, char *string);
extern void FormatUInt64Hex(uint64_t num, char *string); extern void FormatUInt64Hex(uint64_t num, char *string);

View File

@ -30,11 +30,11 @@
/***====================================================================***/ /***====================================================================***/
typedef struct _XkbRMLVOSet { typedef struct _XkbRMLVOSet {
const char *rules; char *rules;
const char *model; char *model;
const char *layout; char *layout;
const char *variant; char *variant;
const char *options; char *options;
} XkbRMLVOSet; } XkbRMLVOSet;
typedef struct _XkbRF_VarDefs { typedef struct _XkbRF_VarDefs {

View File

@ -738,6 +738,14 @@ extern _X_EXPORT void XkbClearAllLatchesAndLocks(DeviceIntPtr /* dev */ ,
XkbEventCausePtr /* cause */ XkbEventCausePtr /* cause */
); );
extern _X_EXPORT void XkbInitRules(XkbRMLVOSet * /* rmlvo */,
const char * /* rules */,
const char * /* model */,
const char * /* layout */,
const char * /* variant */,
const char * /* options */
) ;
extern _X_EXPORT void XkbGetRulesDflts(XkbRMLVOSet * /* rmlvo */ extern _X_EXPORT void XkbGetRulesDflts(XkbRMLVOSet * /* rmlvo */
); );

View File

@ -286,7 +286,7 @@ mieqEnqueue(DeviceIntPtr pDev, InternalEvent *e)
else if (miEventQueue.dropped % QUEUE_DROP_BACKTRACE_FREQUENCY == 0 && else if (miEventQueue.dropped % QUEUE_DROP_BACKTRACE_FREQUENCY == 0 &&
miEventQueue.dropped / QUEUE_DROP_BACKTRACE_FREQUENCY <= miEventQueue.dropped / QUEUE_DROP_BACKTRACE_FREQUENCY <=
QUEUE_DROP_BACKTRACE_MAX) { QUEUE_DROP_BACKTRACE_MAX) {
ErrorFSigSafe("[mi] EQ overflow continuing. %u events have been " ErrorFSigSafe("[mi] EQ overflow continuing. %zu events have been "
"dropped.\n", miEventQueue.dropped); "dropped.\n", miEventQueue.dropped);
if (miEventQueue.dropped / QUEUE_DROP_BACKTRACE_FREQUENCY == if (miEventQueue.dropped / QUEUE_DROP_BACKTRACE_FREQUENCY ==
QUEUE_DROP_BACKTRACE_MAX) { QUEUE_DROP_BACKTRACE_MAX) {

View File

@ -1973,10 +1973,10 @@ CheckUserAuthorization(void)
* Tokenize a string into a NULL terminated array of strings. Always returns * Tokenize a string into a NULL terminated array of strings. Always returns
* an allocated array unless an error occurs. * an allocated array unless an error occurs.
*/ */
const char ** char **
xstrtokenize(const char *str, const char *separators) xstrtokenize(const char *str, const char *separators)
{ {
const char **list, **nlist; char **list, **nlist;
char *tok, *tmp; char *tok, *tmp;
unsigned num = 0, n; unsigned num = 0, n;
@ -2004,7 +2004,7 @@ xstrtokenize(const char *str, const char *separators)
error: error:
free(tmp); free(tmp);
for (n = 0; n < num; n++) for (n = 0; n < num; n++)
free((void *) list[n]); free(list[n]);
free(list); free(list);
return NULL; return NULL;
} }

View File

@ -1101,7 +1101,7 @@ xi_unregister_handlers(void)
static void static void
cmp_attr_fields(InputAttributes * attr1, InputAttributes * attr2) cmp_attr_fields(InputAttributes * attr1, InputAttributes * attr2)
{ {
const char **tags1, **tags2; char **tags1, **tags2;
assert(attr1 && attr2); assert(attr1 && attr2);
assert(attr1 != attr2); assert(attr1 != attr2);
@ -1180,50 +1180,54 @@ cmp_attr_fields(InputAttributes * attr1, InputAttributes * attr2)
static void static void
dix_input_attributes(void) dix_input_attributes(void)
{ {
InputAttributes orig = { 0 }; InputAttributes *orig;
InputAttributes *new; InputAttributes *new;
const char *tags[4] = { "tag1", "tag2", "tag2", NULL };
new = DuplicateInputAttributes(NULL); new = DuplicateInputAttributes(NULL);
assert(!new); assert(!new);
new = DuplicateInputAttributes(&orig); orig = calloc(1, sizeof(InputAttributes));
assert(memcmp(&orig, new, sizeof(InputAttributes)) == 0); assert(orig);
orig.product = "product name"; new = DuplicateInputAttributes(orig);
new = DuplicateInputAttributes(&orig); assert(memcmp(orig, new, sizeof(InputAttributes)) == 0);
cmp_attr_fields(&orig, new);
orig->product = xnfstrdup("product name");
new = DuplicateInputAttributes(orig);
cmp_attr_fields(orig, new);
FreeInputAttributes(new); FreeInputAttributes(new);
orig.vendor = "vendor name"; orig->vendor = xnfstrdup("vendor name");
new = DuplicateInputAttributes(&orig); new = DuplicateInputAttributes(orig);
cmp_attr_fields(&orig, new); cmp_attr_fields(orig, new);
FreeInputAttributes(new); FreeInputAttributes(new);
orig.device = "device path"; orig->device = xnfstrdup("device path");
new = DuplicateInputAttributes(&orig); new = DuplicateInputAttributes(orig);
cmp_attr_fields(&orig, new); cmp_attr_fields(orig, new);
FreeInputAttributes(new); FreeInputAttributes(new);
orig.pnp_id = "PnPID"; orig->pnp_id = xnfstrdup("PnPID");
new = DuplicateInputAttributes(&orig); new = DuplicateInputAttributes(orig);
cmp_attr_fields(&orig, new); cmp_attr_fields(orig, new);
FreeInputAttributes(new); FreeInputAttributes(new);
orig.usb_id = "USBID"; orig->usb_id = xnfstrdup("USBID");
new = DuplicateInputAttributes(&orig); new = DuplicateInputAttributes(orig);
cmp_attr_fields(&orig, new); cmp_attr_fields(orig, new);
FreeInputAttributes(new); FreeInputAttributes(new);
orig.flags = 0xF0; orig->flags = 0xF0;
new = DuplicateInputAttributes(&orig); new = DuplicateInputAttributes(orig);
cmp_attr_fields(&orig, new); cmp_attr_fields(orig, new);
FreeInputAttributes(new); FreeInputAttributes(new);
orig.tags = tags; orig->tags = xstrtokenize("tag1 tag2 tag3", " ");
new = DuplicateInputAttributes(&orig); new = DuplicateInputAttributes(orig);
cmp_attr_fields(&orig, new); cmp_attr_fields(orig, new);
FreeInputAttributes(new); FreeInputAttributes(new);
FreeInputAttributes(orig);
} }
static void static void

View File

@ -40,7 +40,7 @@ touch_grow_queue(void)
int i; int i;
memset(&dev, 0, sizeof(dev)); memset(&dev, 0, sizeof(dev));
dev.name = "test device"; dev.name = xnfstrdup("test device");
dev.id = 2; dev.id = 2;
dev.valuator = &val; dev.valuator = &val;
val.numAxes = 5; val.numAxes = 5;
@ -82,6 +82,8 @@ touch_grow_queue(void)
assert(t->client_id == 0); assert(t->client_id == 0);
assert(t->ddx_id == 0); assert(t->ddx_id == 0);
} }
free(dev.name);
} }
static void static void
@ -95,7 +97,7 @@ touch_find_ddxid(void)
int i; int i;
memset(&dev, 0, sizeof(dev)); memset(&dev, 0, sizeof(dev));
dev.name = "test device"; dev.name = xnfstrdup("test device");
dev.id = 2; dev.id = 2;
dev.valuator = &val; dev.valuator = &val;
val.numAxes = 5; val.numAxes = 5;
@ -150,6 +152,8 @@ touch_find_ddxid(void)
ProcessWorkQueue(); ProcessWorkQueue();
ti = TouchFindByDDXID(&dev, 40, TRUE); ti = TouchFindByDDXID(&dev, 40, TRUE);
assert(ti == &dev.last.touches[size]); assert(ti == &dev.last.touches[size]);
free(dev.name);
} }
static void static void
@ -164,7 +168,7 @@ touch_begin_ddxtouch(void)
int size = 5; int size = 5;
memset(&dev, 0, sizeof(dev)); memset(&dev, 0, sizeof(dev));
dev.name = "test device"; dev.name = xnfstrdup("test device");
dev.id = 2; dev.id = 2;
dev.valuator = &val; dev.valuator = &val;
val.numAxes = 5; val.numAxes = 5;
@ -195,6 +199,8 @@ touch_begin_ddxtouch(void)
assert(ti->client_id > last_client_id); assert(ti->client_id > last_client_id);
assert(!ti->emulate_pointer); assert(!ti->emulate_pointer);
last_client_id = ti->client_id; last_client_id = ti->client_id;
free(dev.name);
} }
static void static void
@ -212,7 +218,7 @@ touch_begin_touch(void)
screenInfo.screens[0] = &screen; screenInfo.screens[0] = &screen;
memset(&dev, 0, sizeof(dev)); memset(&dev, 0, sizeof(dev));
dev.name = "test device"; dev.name = xnfstrdup("test device");
dev.id = 2; dev.id = 2;
memset(&sprite, 0, sizeof(sprite)); memset(&sprite, 0, sizeof(sprite));
@ -237,6 +243,8 @@ touch_begin_touch(void)
assert(ti->emulate_pointer); assert(ti->emulate_pointer);
assert(touch.num_touches == 1); assert(touch.num_touches == 1);
free(dev.name);
} }
static void static void
@ -251,7 +259,7 @@ touch_init(void)
screenInfo.screens[0] = &screen; screenInfo.screens[0] = &screen;
memset(&dev, 0, sizeof(dev)); memset(&dev, 0, sizeof(dev));
dev.name = "test device"; dev.name = xnfstrdup("test device");
memset(&sprite, 0, sizeof(sprite)); memset(&sprite, 0, sizeof(sprite));
dev.spriteInfo = &sprite; dev.spriteInfo = &sprite;
@ -264,6 +272,8 @@ touch_init(void)
rc = InitTouchClassDeviceStruct(&dev, 1, XIDirectTouch, 2); rc = InitTouchClassDeviceStruct(&dev, 1, XIDirectTouch, 2);
assert(rc == TRUE); assert(rc == TRUE);
assert(dev.touch); assert(dev.touch);
free(dev.name);
} }
int int

View File

@ -82,15 +82,17 @@ xkb_get_rules_test(void)
static void static void
xkb_set_rules_test(void) xkb_set_rules_test(void)
{ {
XkbRMLVOSet rmlvo = { XkbRMLVOSet rmlvo;
.rules = "test-rules",
.model = "test-model",
.layout = "test-layout",
.variant = "test-variant",
.options = "test-options"
};
XkbRMLVOSet rmlvo_new = { NULL }; XkbRMLVOSet rmlvo_new = { NULL };
XkbInitRules(&rmlvo, "test-rules", "test-model", "test-layout",
"test-variant", "test-options");
assert(rmlvo.rules);
assert(rmlvo.model);
assert(rmlvo.layout);
assert(rmlvo.variant);
assert(rmlvo.options);
XkbSetRulesDflts(&rmlvo); XkbSetRulesDflts(&rmlvo);
XkbGetRulesDflts(&rmlvo_new); XkbGetRulesDflts(&rmlvo_new);
@ -106,6 +108,8 @@ xkb_set_rules_test(void)
assert(strcmp(rmlvo.layout, rmlvo_new.layout) == 0); assert(strcmp(rmlvo.layout, rmlvo_new.layout) == 0);
assert(strcmp(rmlvo.variant, rmlvo_new.variant) == 0); assert(strcmp(rmlvo.variant, rmlvo_new.variant) == 0);
assert(strcmp(rmlvo.options, rmlvo_new.options) == 0); assert(strcmp(rmlvo.options, rmlvo_new.options) == 0);
XkbFreeRMLVOSet(&rmlvo, FALSE);
} }
/** /**

View File

@ -129,11 +129,11 @@ XkbFreeRMLVOSet(XkbRMLVOSet * rmlvo, Bool freeRMLVO)
if (!rmlvo) if (!rmlvo)
return; return;
free((void *) rmlvo->rules); free(rmlvo->rules);
free((void *) rmlvo->model); free(rmlvo->model);
free((void *) rmlvo->layout); free(rmlvo->layout);
free((void *) rmlvo->variant); free(rmlvo->variant);
free((void *) rmlvo->options); free(rmlvo->options);
if (freeRMLVO) if (freeRMLVO)
free(rmlvo); free(rmlvo);
@ -206,6 +206,21 @@ XkbWriteRulesProp(ClientPtr client, void *closure)
return TRUE; return TRUE;
} }
void
XkbInitRules(XkbRMLVOSet *rmlvo,
const char *rules,
const char *model,
const char *layout,
const char *variant,
const char *options)
{
rmlvo->rules = rules ? xnfstrdup(rules) : NULL;
rmlvo->model = model ? xnfstrdup(model) : NULL;
rmlvo->layout = layout ? xnfstrdup(layout) : NULL;
rmlvo->variant = variant ? xnfstrdup(variant) : NULL;
rmlvo->options = options ? xnfstrdup(options) : NULL;
}
static void static void
XkbSetRulesUsed(XkbRMLVOSet * rmlvo) XkbSetRulesUsed(XkbRMLVOSet * rmlvo)
{ {