diff options
Diffstat (limited to 'xorg-server/dix/devices.c')
-rw-r--r-- | xorg-server/dix/devices.c | 151 |
1 files changed, 76 insertions, 75 deletions
diff --git a/xorg-server/dix/devices.c b/xorg-server/dix/devices.c index d8e7f9c40..bbf6d3066 100644 --- a/xorg-server/dix/devices.c +++ b/xorg-server/dix/devices.c @@ -332,14 +332,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); } @@ -1038,6 +1039,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); @@ -1669,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); @@ -1701,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); @@ -1792,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 @@ -1866,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, @@ -1904,12 +1907,12 @@ ProcGetPointerMapping(ClientPtr client) return rc; nElts = (butc) ? butc->numButtons : 0; - rep = (xGetPointerMappingReply) { - .type = X_Reply, - .nElts = nElts, - .sequenceNumber = client->sequence, - .length = ((unsigned) nElts + (4 - 1)) / 4 - }; + + rep.type = X_Reply; + rep.nElts = nElts; + rep.sequenceNumber = client->sequence; + rep.length = ((unsigned) nElts + (4 - 1)) / 4; + WriteReplyToClient(client, sizeof(xGetPointerMappingReply), &rep); if (butc) WriteToClient(client, nElts, &butc->map[1]); @@ -1956,7 +1959,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; @@ -2158,17 +2161,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); @@ -2303,14 +2306,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; } @@ -2354,10 +2357,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); @@ -2405,11 +2408,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. @@ -2455,14 +2457,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; |