Merge branch 'server-1.5-branch' into xorg-server-1.5-apple

This commit is contained in:
Jeremy Huddleston 2008-10-08 18:43:55 -07:00
commit 42d1454507
9 changed files with 169 additions and 140 deletions

View file

@ -411,9 +411,6 @@ GetKeyboardValuatorEvents(xEvent *events, DeviceIntPtr pDev, int type,
KeySym sym;
deviceKeyButtonPointer *kbp = NULL;
sym = map[(key_code - pDev->key->curKeySyms.minKeyCode)
* pDev->key->curKeySyms.mapWidth];
if (!events)
return 0;
@ -431,6 +428,9 @@ GetKeyboardValuatorEvents(xEvent *events, DeviceIntPtr pDev, int type,
map = pDev->key->curKeySyms.map;
sym = map[key_code * pDev->key->curKeySyms.mapWidth];
sym = map[(key_code - pDev->key->curKeySyms.minKeyCode)
* pDev->key->curKeySyms.mapWidth];
if (pDev->coreEvents)
numEvents = 2;
else

View file

@ -40,9 +40,8 @@ from The Open Group.
#include "inputstr.h"
struct _Private {
DevPrivateKey key;
pointer value;
struct _Private *next;
int state;
pointer value;
};
typedef struct _PrivateDesc {
@ -50,22 +49,36 @@ typedef struct _PrivateDesc {
unsigned size;
CallbackListPtr initfuncs;
CallbackListPtr deletefuncs;
struct _PrivateDesc *next;
} PrivateDescRec;
/* list of all allocated privates */
static PrivateDescRec *items = NULL;
#define PRIV_MAX 256
#define PRIV_STEP 16
static _X_INLINE PrivateDescRec *
/* list of all allocated privates */
static PrivateDescRec items[PRIV_MAX];
static int nextPriv;
static PrivateDescRec *
findItem(const DevPrivateKey key)
{
PrivateDescRec *item = items;
while (item) {
if (item->key == key)
return item;
item = item->next;
if (!*key) {
if (nextPriv >= PRIV_MAX)
return NULL;
items[nextPriv].key = key;
*key = nextPriv;
nextPriv++;
}
return NULL;
return items + *key;
}
static _X_INLINE int
privateExists(PrivateRec **privates, const DevPrivateKey key)
{
return *key && *privates &&
(*privates)[0].state > *key &&
(*privates)[*key].state;
}
/*
@ -75,21 +88,10 @@ _X_EXPORT int
dixRequestPrivate(const DevPrivateKey key, unsigned size)
{
PrivateDescRec *item = findItem(key);
if (item) {
if (size > item->size)
item->size = size;
} else {
item = (PrivateDescRec *)xalloc(sizeof(PrivateDescRec));
if (!item)
return FALSE;
memset(item, 0, sizeof(PrivateDescRec));
/* add privates descriptor */
item->key = key;
if (!item)
return FALSE;
if (size > item->size)
item->size = size;
item->next = items;
items = item;
}
return TRUE;
}
@ -100,25 +102,52 @@ _X_EXPORT pointer *
dixAllocatePrivate(PrivateRec **privates, const DevPrivateKey key)
{
PrivateDescRec *item = findItem(key);
PrivateCallbackRec calldata;
PrivateRec *ptr;
unsigned size = sizeof(PrivateRec);
if (item)
size += item->size;
pointer value;
int oldsize, newsize;
ptr = (PrivateRec *)xcalloc(size, 1);
if (!ptr)
newsize = (*key / PRIV_STEP + 1) * PRIV_STEP;
/* resize or init privates array */
if (!item)
return NULL;
ptr->key = key;
ptr->value = (size > sizeof(PrivateRec)) ? (ptr + 1) : NULL;
ptr->next = *privates;
*privates = ptr;
/* call any init funcs and return */
if (item) {
PrivateCallbackRec calldata = { key, &ptr->value };
CallCallbacks(&item->initfuncs, &calldata);
/* initialize privates array if necessary */
if (!*privates) {
ptr = xcalloc(newsize, sizeof(*ptr));
if (!ptr)
return NULL;
*privates = ptr;
(*privates)[0].state = newsize;
}
oldsize = (*privates)[0].state;
/* resize privates array if necessary */
if (*key >= oldsize) {
ptr = xrealloc(*privates, newsize * sizeof(*ptr));
if (!ptr)
return NULL;
memset(ptr + oldsize, 0, (newsize - oldsize) * sizeof(*ptr));
*privates = ptr;
(*privates)[0].state = newsize;
}
/* initialize slot */
ptr = *privates + *key;
ptr->state = 1;
if (item->size) {
value = xcalloc(item->size, 1);
if (!value)
return NULL;
ptr->value = value;
}
calldata.key = key;
calldata.value = &ptr->value;
CallCallbacks(&item->initfuncs, &calldata);
return &ptr->value;
}
@ -128,14 +157,10 @@ dixAllocatePrivate(PrivateRec **privates, const DevPrivateKey key)
_X_EXPORT pointer
dixLookupPrivate(PrivateRec **privates, const DevPrivateKey key)
{
PrivateRec *rec = *privates;
pointer *ptr;
while (rec) {
if (rec->key == key)
return rec->value;
rec = rec->next;
}
if (privateExists(privates, key))
return (*privates)[*key].value;
ptr = dixAllocatePrivate(privates, key);
return ptr ? *ptr : NULL;
@ -147,13 +172,8 @@ dixLookupPrivate(PrivateRec **privates, const DevPrivateKey key)
_X_EXPORT pointer *
dixLookupPrivateAddr(PrivateRec **privates, const DevPrivateKey key)
{
PrivateRec *rec = *privates;
while (rec) {
if (rec->key == key)
return &rec->value;
rec = rec->next;
}
if (privateExists(privates, key))
return &(*privates)[*key].value;
return dixAllocatePrivate(privates, key);
}
@ -164,16 +184,10 @@ dixLookupPrivateAddr(PrivateRec **privates, const DevPrivateKey key)
_X_EXPORT int
dixSetPrivate(PrivateRec **privates, const DevPrivateKey key, pointer val)
{
PrivateRec *rec;
top:
rec = *privates;
while (rec) {
if (rec->key == key) {
rec->value = val;
return TRUE;
}
rec = rec->next;
if (privateExists(privates, key)) {
(*privates)[*key].value = val;
return TRUE;
}
if (!dixAllocatePrivate(privates, key))
@ -187,27 +201,23 @@ dixSetPrivate(PrivateRec **privates, const DevPrivateKey key, pointer val)
_X_EXPORT void
dixFreePrivates(PrivateRec *privates)
{
PrivateRec *ptr, *next;
PrivateDescRec *item;
int i;
PrivateCallbackRec calldata;
/* first pass calls the delete callbacks */
for (ptr = privates; ptr; ptr = ptr->next) {
item = findItem(ptr->key);
if (item) {
calldata.key = ptr->key;
calldata.value = &ptr->value;
CallCallbacks(&item->deletefuncs, &calldata);
}
}
/* second pass frees the memory */
ptr = privates;
while (ptr) {
next = ptr->next;
xfree(ptr);
ptr = next;
}
if (privates)
for (i = 1; i < privates->state; i++)
if (privates[i].state) {
/* call the delete callbacks */
calldata.key = items[i].key;
calldata.value = &privates[i].value;
CallCallbacks(&items[i].deletefuncs, &calldata);
/* free pre-allocated memory */
if (items[i].size)
xfree(privates[i].value);
}
xfree(privates);
}
/*
@ -218,11 +228,9 @@ dixRegisterPrivateInitFunc(const DevPrivateKey key,
CallbackProcPtr callback, pointer data)
{
PrivateDescRec *item = findItem(key);
if (!item) {
if (!dixRequestPrivate(key, 0))
return FALSE;
item = findItem(key);
}
if (!item)
return FALSE;
return AddCallback(&item->initfuncs, callback, data);
}
@ -231,11 +239,9 @@ dixRegisterPrivateDeleteFunc(const DevPrivateKey key,
CallbackProcPtr callback, pointer data)
{
PrivateDescRec *item = findItem(key);
if (!item) {
if (!dixRequestPrivate(key, 0))
return FALSE;
item = findItem(key);
}
if (!item)
return FALSE;
return AddCallback(&item->deletefuncs, callback, data);
}
@ -292,16 +298,17 @@ dixLookupPrivateOffset(RESTYPE type)
int
dixResetPrivates(void)
{
PrivateDescRec *next;
int i;
/* reset internal structures */
while (items) {
next = items->next;
DeleteCallbackList(&items->initfuncs);
DeleteCallbackList(&items->deletefuncs);
xfree(items);
items = next;
/* reset private descriptors */
for (i = 1; i < nextPriv; i++) {
*items[i].key = 0;
DeleteCallbackList(&items[i].initfuncs);
DeleteCallbackList(&items[i].deletefuncs);
}
nextPriv = 1;
/* reset offsets */
if (offsets)
xfree(offsets);
offsetsSize = sizeof(offsetDefaults);

View file

@ -93,7 +93,7 @@ ProcXF86DGADirectVideo(ClientPtr client)
REQUEST_SIZE_MATCH(xXF86DGADirectVideoReq);
if (!DGAAvailable(stuff->screen))
if (!DGAAvailable(stuff->screen))
return DGAErrorBase + XF86DGANoDirectVideoMode;
if (stuff->enable & XF86DGADirectGraphics) {
@ -128,7 +128,7 @@ ProcXF86DGAGetViewPortSize(ClientPtr client)
rep.length = 0;
rep.sequenceNumber = client->sequence;
if (!DGAAvailable(stuff->screen))
if (!DGAAvailable(stuff->screen))
return (DGAErrorBase + XF86DGANoDirectVideoMode);
if(!(num = DGAGetOldDGAMode(stuff->screen)))
@ -153,6 +153,9 @@ ProcXF86DGASetViewPort(ClientPtr client)
REQUEST_SIZE_MATCH(xXF86DGASetViewPortReq);
if (!DGAAvailable(stuff->screen))
return (DGAErrorBase + XF86DGANoDirectVideoMode);
if (!DGAActive(stuff->screen))
{
int num;

View file

@ -478,22 +478,11 @@ pci_device_for_cfg_address (CARD32 addr)
struct pci_device_iterator *iter =
pci_slot_match_iterator_create (&slot_match);
if (iter)
dev = pci_device_next(iter);
if (!dev) {
char buf[128]; /* enough to store "%u@%u" */
xf86FormatPciBusNumber(tag >> 16, buf);
ErrorF("Failed to find device matching %s:%u:%u\n",
buf, slot_match.dev, slot_match.func);
return NULL;
}
if (pci_device_next(iter)) {
char buf[128]; /* enough to store "%u@%u" */
xf86FormatPciBusNumber(tag >> 16, buf);
ErrorF("Multiple devices matching %s:%u:%u\n",
buf, slot_match.dev, slot_match.func);
}
pci_iterator_destroy(iter);
return dev;
}

View file

@ -1903,7 +1903,8 @@ bestModeForAspect(xf86CrtcConfigPtr config, Bool *enabled, float aspect)
int o = -1, p;
DisplayModePtr mode = NULL, test = NULL, match = NULL;
nextEnabledOutput(config, enabled, &o);
if (!nextEnabledOutput(config, enabled, &o))
return NULL;
while ((mode = nextAspectMode(config->output[o], mode, aspect))) {
test = mode;
for (p = o; nextEnabledOutput(config, enabled, &p); ) {

View file

@ -19,7 +19,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* STUFF FOR PRIVATES
*****************************************************************/
typedef void *DevPrivateKey;
typedef int *DevPrivateKey;
struct _Private;
typedef struct _Private PrivateRec;

View file

@ -178,16 +178,23 @@ int nGroups,tmp,groupsWidth;
}
}
/* step 7: check for all groups identical or all width 1 */
/* step 7: check for all groups identical or all width 1
*
* Special feature: if group 1 has an explicit type and all other groups
* have canonical types with same symbols, we assume it's info lost from
* the core replication.
*/
if (nGroups>1) {
Bool sameType,allOneLevel;
Bool sameType,allOneLevel, canonical = True;
allOneLevel= (xkb->map->types[types_inout[0]].num_levels==1);
for (i=1,sameType=True;(allOneLevel||sameType)&&(i<nGroups);i++) {
sameType=(sameType&&(types_inout[i]==types_inout[XkbGroup1Index]));
if (allOneLevel)
allOneLevel= (xkb->map->types[types_inout[i]].num_levels==1);
if (types_inout[i] > XkbLastRequiredType)
canonical = False;
}
if ((sameType)&&
if (((sameType) || canonical)&&
(!(protected&(XkbExplicitKeyTypesMask&~XkbExplicitKeyType1Mask)))){
register int s;
Bool identical;

View file

@ -6423,13 +6423,10 @@ static int
_XkbSetDeviceInfo(ClientPtr client, DeviceIntPtr dev,
xkbSetDeviceInfoReq *stuff)
{
unsigned change;
char *wire;
change = stuff->change;
wire= (char *)&stuff[1];
if (change&XkbXI_ButtonActionsMask) {
if (stuff->change&XkbXI_ButtonActionsMask) {
if (!dev->button) {
client->errorValue = _XkbErrCode2(XkbErr_BadClass,ButtonClass);
return XkbKeyboardErrorCode;
@ -6458,14 +6455,13 @@ static int
_XkbSetDeviceInfoCheck(ClientPtr client, DeviceIntPtr dev,
xkbSetDeviceInfoReq *stuff)
{
unsigned change;
char *wire;
xkbExtensionDeviceNotify ed;
bzero((char *)&ed,SIZEOF(xkbExtensionDeviceNotify));
ed.deviceID= dev->id;
wire= (char *)&stuff[1];
if (change&XkbXI_ButtonActionsMask) {
if (stuff->change&XkbXI_ButtonActionsMask) {
int nBtns,sz,i;
XkbAction * acts;
DeviceIntPtr kbd;
@ -6495,8 +6491,8 @@ _XkbSetDeviceInfoCheck(ClientPtr client, DeviceIntPtr dev,
}
if (stuff->change&XkbXI_IndicatorsMask) {
int status= Success;
wire= SetDeviceIndicators(wire,dev,change,stuff->nDeviceLedFBs,
&status,client,&ed);
wire= SetDeviceIndicators(wire,dev,stuff->change,
stuff->nDeviceLedFBs, &status,client,&ed);
if (status!=Success)
return status;
}
@ -6508,7 +6504,6 @@ _XkbSetDeviceInfoCheck(ClientPtr client, DeviceIntPtr dev,
int
ProcXkbSetDeviceInfo(ClientPtr client)
{
unsigned int change;
DeviceIntPtr dev;
int rc;
@ -6518,10 +6513,8 @@ ProcXkbSetDeviceInfo(ClientPtr client)
if (!(client->xkbClientFlags&_XkbClientInitialized))
return BadAccess;
change = stuff->change;
CHK_ANY_DEVICE(dev, stuff->deviceSpec, client, DixManageAccess);
CHK_MASK_LEGAL(0x01,change,XkbXI_AllFeaturesMask);
CHK_MASK_LEGAL(0x01,stuff->change,XkbXI_AllFeaturesMask);
rc = _XkbSetDeviceInfoCheck(client, dev, stuff);

View file

@ -486,6 +486,40 @@ CARD8 keysPerMod[XkbNumModifiers];
if (groupWidth>2)
nOut= groupWidth;
}
/* See XKB Protocol Sec, Section 12.4.
A 1-group key with ABCDE on a 2 group keyboard must be
duplicated across all groups as ABABCDECDE.
*/
if (nGroups == 1)
{
int idx;
groupWidth = XkbKeyGroupWidth(xkb, key, XkbGroup1Index);
/* AB..CDE... -> ABABCDE... */
if (groupWidth > 0 && maxSymsPerKey >= 3)
pCore[2] = pCore[0];
if (groupWidth > 1 && maxSymsPerKey >= 4)
pCore[3] = pCore[1];
/* ABABCDE... -> ABABCDECDE */
idx = 2 + groupWidth;
while (groupWidth > 2 &&
idx < maxSymsPerKey &&
idx < groupWidth * 2)
{
pCore[idx] = pCore[idx - groupWidth + 2];
idx++;
}
idx = 2 * groupWidth;
if (idx < 4)
idx = 4;
/* 3 or more groups: ABABCDECDEABCDEABCDE */
for (n = 0; n < groupWidth && idx < maxSymsPerKey; n++)
pCore[idx++] = pXKB[n];
}
pXKB+= XkbKeyGroupsWidth(xkb,key);
nOut+= 2;
if (nGroups>1) {
@ -507,11 +541,6 @@ CARD8 keysPerMod[XkbNumModifiers];
}
pXKB+= XkbKeyGroupsWidth(xkb,key);
}
if (!pCore[2] && !pCore[3] && maxSymsPerKey >= 6 &&
(pCore[4] || pCore[5])) {
pCore[2] = pCore[4];
pCore[3] = pCore[5];
}
}
if (keyc->modifierMap[key]!=0) {
register unsigned bit,i,mask;