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 a680ed8d7..c5c8daafe 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.
*/
@@ -332,14 +336,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);
}
@@ -1037,6 +1042,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);
@@ -1729,11 +1738,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);
@@ -1761,13 +1769,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);
@@ -1852,12 +1859,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
@@ -1926,13 +1933,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,
@@ -1964,12 +1971,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]);
@@ -2016,7 +2023,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;
@@ -2218,17 +2225,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);
@@ -2363,14 +2370,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;
}
@@ -2414,10 +2421,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);
@@ -2465,11 +2472,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.
@@ -2515,14 +2521,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;