diff options
Diffstat (limited to 'xorg-server/dix/devices.c')
-rw-r--r-- | xorg-server/dix/devices.c | 153 |
1 files changed, 79 insertions, 74 deletions
diff --git a/xorg-server/dix/devices.c b/xorg-server/dix/devices.c index 839de35aa..b9225a195 100644 --- a/xorg-server/dix/devices.c +++ b/xorg-server/dix/devices.c @@ -86,6 +86,10 @@ SOFTWARE. #include "xichangehierarchy.h" /* For XISendDeviceHierarchyEvent */ #include "syncsrv.h" +#ifdef _MSC_VER +#define isfinite(val) _finite(val) +#endif + /** @file * This file handles input device-related stuff. */ @@ -321,14 +325,15 @@ AddInputDevice(ClientPtr client, DeviceProc deviceProc, Bool autoStart) void SendDevicePresenceEvent(int deviceid, int type) { - DeviceIntRec dummyDev = { .id = XIAllDevices }; - devicePresenceNotify ev = { - .type = DevicePresenceNotify, - .time = currentTime.milliseconds, - .devchange = type, - .deviceid = deviceid - }; + DeviceIntRec dummyDev; + devicePresenceNotify ev; + memset(&dummyDev, 0, sizeof(DeviceIntRec)); + ev.type = DevicePresenceNotify; + ev.time = currentTime.milliseconds; + ev.devchange = type; + ev.deviceid = deviceid; + dummyDev.id = XIAllDevices; SendEventToAllWindows(&dummyDev, DevicePresenceNotifyMask, (xEvent *) &ev, 1); } @@ -1017,6 +1022,10 @@ CloseDownDevices(void) for (dev = inputInfo.devices; dev; dev = dev->next) { if (!IsMaster(dev) && !IsFloating(dev)) dev->master = NULL; + /* Initialise the sprite and paired members of all devices + to avoid crashes in CloseDevice later */ + dev->spriteInfo->sprite=NULL; + dev->spriteInfo->paired=NULL; } CloseDeviceList(&inputInfo.devices); @@ -1665,11 +1674,10 @@ ProcSetModifierMapping(ClientPtr client) bytes_to_int32(sizeof(xSetModifierMappingReq)))) return BadLength; - rep = (xSetModifierMappingReply) { - .type = X_Reply, - .sequenceNumber = client->sequence, - .length = 0 - }; + + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + rep.length = 0; rc = change_modmap(client, PickKeyboard(client), (KeyCode *) &stuff[1], stuff->numKeyPerModifier); @@ -1697,13 +1705,12 @@ ProcGetModifierMapping(ClientPtr client) generate_modkeymap(client, PickKeyboard(client), &modkeymap, &max_keys_per_mod); - rep = (xGetModifierMappingReply) { - .type = X_Reply, - .numKeyPerModifier = max_keys_per_mod, - .sequenceNumber = client->sequence, + memset(&rep, 0, sizeof(xGetModifierMappingReply)); + rep.type = X_Reply; + rep.numKeyPerModifier = max_keys_per_mod; + rep.sequenceNumber = client->sequence; /* length counts 4 byte quantities - there are 8 modifiers 1 byte big */ - .length = max_keys_per_mod << 1 - }; + rep.length = max_keys_per_mod << 1; WriteReplyToClient(client, sizeof(xGetModifierMappingReply), &rep); WriteToClient(client, max_keys_per_mod * 8, modkeymap); @@ -1788,12 +1795,12 @@ ProcSetPointerMapping(ClientPtr client) bytes_to_int32(sizeof(xSetPointerMappingReq) + stuff->nElts)) return BadLength; - rep = (xSetPointerMappingReply) { - .type = X_Reply, - .success = MappingSuccess, - .sequenceNumber = client->sequence, - .length = 0 - }; + + rep.type = X_Reply; + rep.success = MappingSuccess; + rep.sequenceNumber = client->sequence; + rep.length = 0; + map = (BYTE *) &stuff[1]; /* So we're bounded here by the number of core buttons. This check @@ -1862,13 +1869,13 @@ ProcGetKeyboardMapping(ClientPtr client) if (!syms) return BadAlloc; - rep = (xGetKeyboardMappingReply) { - .type = X_Reply, - .keySymsPerKeyCode = syms->mapWidth, - .sequenceNumber = client->sequence, - /* length is a count of 4 byte quantities and KeySyms are 4 bytes */ - .length = syms->mapWidth * stuff->count - }; + memset(&rep, 0, sizeof(xGetKeyboardMappingReply)); + rep.type = X_Reply; + rep.keySymsPerKeyCode = syms->mapWidth; + rep.sequenceNumber = client->sequence; + /* length is a count of 4 byte quantities and KeySyms are 4 bytes */ + rep.length = syms->mapWidth * stuff->count; + WriteReplyToClient(client, sizeof(xGetKeyboardMappingReply), &rep); client->pSwapReplyFunc = (ReplySwapPtr) CopySwap32Write; WriteSwappedDataToClient(client, @@ -1898,12 +1905,12 @@ ProcGetPointerMapping(ClientPtr client) if (rc != Success) return rc; - rep = (xGetPointerMappingReply) { - .type = X_Reply, - .nElts = (butc) ? butc->numButtons : 0, - .sequenceNumber = client->sequence, - .length = ((unsigned) rep.nElts + (4 - 1)) / 4 - }; + + rep.type = X_Reply; + rep.nElts = (butc) ? butc->numButtons : 0; + rep.sequenceNumber = client->sequence; + rep.length = ((unsigned) rep.nElts + (4 - 1)) / 4; + WriteReplyToClient(client, sizeof(xGetPointerMappingReply), &rep); if (butc) WriteToClient(client, (int) rep.nElts, &butc->map[1]); @@ -1950,7 +1957,7 @@ DoChangeKeyboardControl(ClientPtr client, DeviceIntPtr keybd, XID *vlist, vmask &= ~index2; switch (index2) { case KBKeyClickPercent: - t = (INT8) *vlist; + t = *vlist; vlist++; if (t == -1) { t = defaultKeyboardControl.click; @@ -2152,17 +2159,17 @@ ProcGetKeyboardControl(ClientPtr client) if (rc != Success) return rc; - rep = (xGetKeyboardControlReply) { - .type = X_Reply, - .globalAutoRepeat = ctrl->autoRepeat, - .sequenceNumber = client->sequence, - .length = 5, - .ledMask = ctrl->leds, - .keyClickPercent = ctrl->click, - .bellPercent = ctrl->bell, - .bellPitch = ctrl->bell_pitch, - .bellDuration = ctrl->bell_duration - }; + + rep.type = X_Reply; + rep.globalAutoRepeat = ctrl->autoRepeat; + rep.sequenceNumber = client->sequence; + rep.length = 5; + rep.ledMask = ctrl->leds; + rep.keyClickPercent = ctrl->click; + rep.bellPercent = ctrl->bell; + rep.bellPitch = ctrl->bell_pitch; + rep.bellDuration = ctrl->bell_duration; + for (i = 0; i < 32; i++) rep.map[i] = ctrl->autoRepeats[i]; WriteReplyToClient(client, sizeof(xGetKeyboardControlReply), &rep); @@ -2297,14 +2304,14 @@ ProcGetPointerControl(ClientPtr client) if (rc != Success) return rc; - rep = (xGetPointerControlReply) { - .type = X_Reply, - .sequenceNumber = client->sequence, - .length = 0, - .accelNumerator = ctrl->num, - .accelDenominator = ctrl->den, - .threshold = ctrl->threshold - }; + + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + rep.length = 0; + rep.accelNumerator = ctrl->num; + rep.accelDenominator = ctrl->den; + rep.threshold = ctrl->threshold; + WriteReplyToClient(client, sizeof(xGenericReply), &rep); return Success; } @@ -2348,10 +2355,10 @@ ProcGetMotionEvents(ClientPtr client) if (mouse->valuator->motionHintWindow) MaybeStopHint(mouse, client); - rep = (xGetMotionEventsReply) { - .type = X_Reply, - .sequenceNumber = client->sequence - }; + + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + nEvents = 0; start = ClientTimeToServerTime(stuff->start); stop = ClientTimeToServerTime(stuff->stop); @@ -2399,11 +2406,10 @@ ProcQueryKeymap(ClientPtr client) CARD8 *down = keybd->key->down; REQUEST_SIZE_MATCH(xReq); - rep = (xQueryKeymapReply) { - .type = X_Reply, - .sequenceNumber = client->sequence, - .length = 2 - }; + + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + rep.length = 2; rc = XaceHook(XACE_DEVICE_ACCESS, client, keybd, DixReadAccess); /* If rc is Success, we're allowed to copy out the keymap. @@ -2449,14 +2455,13 @@ RecalculateMasterButtons(DeviceIntPtr slave) if (master->button && master->button->numButtons != maxbuttons) { int i; - DeviceChangedEvent event = { - .header = ET_Internal, - .type = ET_DeviceChanged, - .time = GetTimeInMillis(), - .deviceid = master->id, - .flags = DEVCHANGE_POINTER_EVENT | DEVCHANGE_DEVICE_CHANGE, - .buttons.num_buttons = maxbuttons - }; + DeviceChangedEvent event; memset(&event, 0, sizeof(event)); + event.header = ET_Internal; + event.type = ET_DeviceChanged; + event.time = GetTimeInMillis(); + event.deviceid = master->id; + event.flags = DEVCHANGE_POINTER_EVENT | DEVCHANGE_DEVICE_CHANGE; + event.buttons.num_buttons = maxbuttons; master->button->numButtons = maxbuttons; |