aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/dix/devices.c
diff options
context:
space:
mode:
Diffstat (limited to 'xorg-server/dix/devices.c')
-rw-r--r--xorg-server/dix/devices.c153
1 files changed, 79 insertions, 74 deletions
diff --git a/xorg-server/dix/devices.c b/xorg-server/dix/devices.c
index 613323fa2..c190b1bde 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.
*/
@@ -326,14 +330,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);
}
@@ -1023,6 +1028,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);
@@ -1671,11 +1680,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);
@@ -1703,13 +1711,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);
@@ -1794,12 +1801,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
@@ -1868,13 +1875,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,
@@ -1906,12 +1913,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]);
@@ -1958,7 +1965,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;
@@ -2160,17 +2167,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);
@@ -2305,14 +2312,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;
}
@@ -2356,10 +2363,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);
@@ -2407,11 +2414,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.
@@ -2457,14 +2463,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;