aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/Xi/xichangehierarchy.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2012-03-23 10:05:55 +0100
committermarha <marha@users.sourceforge.net>2012-03-23 10:05:55 +0100
commit0f834b91a4768673833ab4917e87d86c237bb1a6 (patch)
tree363489504ed4b2d360259b8de4c9e392918e5d02 /xorg-server/Xi/xichangehierarchy.c
parentfc72edebf875378459368c5383d9023730cbca54 (diff)
downloadvcxsrv-0f834b91a4768673833ab4917e87d86c237bb1a6.tar.gz
vcxsrv-0f834b91a4768673833ab4917e87d86c237bb1a6.tar.bz2
vcxsrv-0f834b91a4768673833ab4917e87d86c237bb1a6.zip
libX11 xserver fontconfig mesa pixman xkbcomp xkeyboard-config git update
23 Mar 2012
Diffstat (limited to 'xorg-server/Xi/xichangehierarchy.c')
-rw-r--r--xorg-server/Xi/xichangehierarchy.c217
1 files changed, 93 insertions, 124 deletions
diff --git a/xorg-server/Xi/xichangehierarchy.c b/xorg-server/Xi/xichangehierarchy.c
index 503404e64..756aaac06 100644
--- a/xorg-server/Xi/xichangehierarchy.c
+++ b/xorg-server/Xi/xichangehierarchy.c
@@ -30,16 +30,15 @@
*
*/
-
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
-#include <X11/X.h> /* for inputstr.h */
-#include <X11/Xproto.h> /* Request macro */
-#include "inputstr.h" /* DeviceIntPtr */
-#include "windowstr.h" /* window structure */
-#include "scrnintstr.h" /* screen structure */
+#include <X11/X.h> /* for inputstr.h */
+#include <X11/Xproto.h> /* Request macro */
+#include "inputstr.h" /* DeviceIntPtr */
+#include "windowstr.h" /* window structure */
+#include "scrnintstr.h" /* screen structure */
#include <X11/extensions/XI.h>
#include <X11/extensions/XI2proto.h>
#include <X11/extensions/geproto.h>
@@ -48,7 +47,7 @@
#include "exglobals.h"
#include "geext.h"
#include "xace.h"
-#include "xiquerydevice.h" /* for GetDeviceUse */
+#include "xiquerydevice.h" /* for GetDeviceUse */
#include "xkbsrv.h"
@@ -57,7 +56,8 @@
/**
* Send the current state of the device hierarchy to all clients.
*/
-void XISendDeviceHierarchyEvent(int flags[MAXDEVICES])
+void
+XISendDeviceHierarchyEvent(int flags[MAXDEVICES])
{
xXIHierarchyEvent *ev;
xXIHierarchyInfo *info;
@@ -69,7 +69,7 @@ void XISendDeviceHierarchyEvent(int flags[MAXDEVICES])
return;
ev = calloc(1, sizeof(xXIHierarchyEvent) +
- MAXDEVICES * sizeof(xXIHierarchyInfo));
+ MAXDEVICES * sizeof(xXIHierarchyInfo));
if (!ev)
return;
ev->type = GenericEvent;
@@ -79,9 +79,8 @@ void XISendDeviceHierarchyEvent(int flags[MAXDEVICES])
ev->flags = 0;
ev->num_info = inputInfo.numDevices;
- info = (xXIHierarchyInfo*)&ev[1];
- for (dev = inputInfo.devices; dev; dev = dev->next)
- {
+ info = (xXIHierarchyInfo *) & ev[1];
+ for (dev = inputInfo.devices; dev; dev = dev->next) {
info->deviceid = dev->id;
info->enabled = dev->enabled;
info->use = GetDeviceUse(dev, &info->attachment);
@@ -89,8 +88,7 @@ void XISendDeviceHierarchyEvent(int flags[MAXDEVICES])
ev->flags |= info->flags;
info++;
}
- for (dev = inputInfo.off_devices; dev; dev = dev->next)
- {
+ for (dev = inputInfo.off_devices; dev; dev = dev->next) {
info->deviceid = dev->id;
info->enabled = dev->enabled;
info->use = GetDeviceUse(dev, &info->attachment);
@@ -99,11 +97,8 @@ void XISendDeviceHierarchyEvent(int flags[MAXDEVICES])
info++;
}
-
- for (i = 0; i < MAXDEVICES; i++)
- {
- if (flags[i] & (XIMasterRemoved | XISlaveRemoved))
- {
+ for (i = 0; i < MAXDEVICES; i++) {
+ if (flags[i] & (XIMasterRemoved | XISlaveRemoved)) {
info->deviceid = i;
info->enabled = FALSE;
info->flags = flags[i];
@@ -119,11 +114,11 @@ void XISendDeviceHierarchyEvent(int flags[MAXDEVICES])
memset(&dummyDev, 0, sizeof(dummyDev));
dummyDev.id = XIAllDevices;
dummyDev.type = SLAVE;
- SendEventToAllWindows(&dummyDev, (XI_HierarchyChangedMask >> 8), (xEvent*)ev, 1);
+ SendEventToAllWindows(&dummyDev, (XI_HierarchyChangedMask >> 8),
+ (xEvent *) ev, 1);
free(ev);
}
-
/***********************************************************************
*
* This procedure allows a client to change the device hierarchy through
@@ -131,7 +126,8 @@ void XISendDeviceHierarchyEvent(int flags[MAXDEVICES])
*
*/
-int SProcXIChangeHierarchy(ClientPtr client)
+int
+SProcXIChangeHierarchy(ClientPtr client)
{
REQUEST(xXIChangeHierarchyReq);
swaps(&stuff->length);
@@ -139,14 +135,14 @@ int SProcXIChangeHierarchy(ClientPtr client)
}
static int
-add_master(ClientPtr client, xXIAddMasterInfo *c, int flags[MAXDEVICES])
+add_master(ClientPtr client, xXIAddMasterInfo * c, int flags[MAXDEVICES])
{
DeviceIntPtr ptr, keybd, XTestptr, XTestkeybd;
- char* name;
+ char *name;
int rc;
name = calloc(c->name_len + 1, sizeof(char));
- strncpy(name, (char*)&c[1], c->name_len);
+ strncpy(name, (char *) &c[1], c->name_len);
rc = AllocDevicePair(client, name, &ptr, &keybd,
CorePointerProc, CoreKeyboardProc, TRUE);
@@ -154,12 +150,11 @@ add_master(ClientPtr client, xXIAddMasterInfo *c, int flags[MAXDEVICES])
goto unwind;
if (!c->send_core)
- ptr->coreEvents = keybd->coreEvents = FALSE;
+ ptr->coreEvents = keybd->coreEvents = FALSE;
/* Allocate virtual slave devices for xtest events */
rc = AllocXTestDevice(client, name, &XTestptr, &XTestkeybd, ptr, keybd);
- if (rc != Success)
- {
+ if (rc != Success) {
DeleteInputDeviceRequest(ptr);
DeleteInputDeviceRequest(keybd);
goto unwind;
@@ -175,8 +170,7 @@ add_master(ClientPtr client, xXIAddMasterInfo *c, int flags[MAXDEVICES])
flags[XTestptr->id] |= XISlaveAdded;
flags[XTestkeybd->id] |= XISlaveAdded;
- if (c->enable)
- {
+ if (c->enable) {
EnableDevice(ptr, FALSE);
EnableDevice(keybd, FALSE);
flags[ptr->id] |= XIDeviceEnabled;
@@ -195,7 +189,7 @@ add_master(ClientPtr client, xXIAddMasterInfo *c, int flags[MAXDEVICES])
flags[XTestptr->id] |= XISlaveAttached;
flags[XTestkeybd->id] |= XISlaveAttached;
-unwind:
+ unwind:
free(name);
return rc;
}
@@ -205,44 +199,39 @@ disable_clientpointer(DeviceIntPtr dev)
{
int i;
- for (i = 0; i < currentMaxClients; i++)
- {
+ for (i = 0; i < currentMaxClients; i++) {
ClientPtr client = clients[i];
+
if (client && client->clientPtr == dev)
client->clientPtr = NULL;
}
}
static int
-remove_master(ClientPtr client, xXIRemoveMasterInfo *r,
- int flags[MAXDEVICES])
+remove_master(ClientPtr client, xXIRemoveMasterInfo * r, int flags[MAXDEVICES])
{
DeviceIntPtr ptr, keybd, XTestptr, XTestkeybd;
int rc = Success;
- if (r->return_mode != XIAttachToMaster &&
- r->return_mode != XIFloating)
+ if (r->return_mode != XIAttachToMaster && r->return_mode != XIFloating)
return BadValue;
rc = dixLookupDevice(&ptr, r->deviceid, client, DixDestroyAccess);
if (rc != Success)
goto unwind;
- if (!IsMaster(ptr))
- {
+ if (!IsMaster(ptr)) {
client->errorValue = r->deviceid;
rc = BadDevice;
goto unwind;
}
/* XXX: For now, don't allow removal of VCP, VCK */
- if (ptr == inputInfo.pointer || ptr == inputInfo.keyboard)
- {
+ if (ptr == inputInfo.pointer ||ptr == inputInfo.keyboard) {
rc = BadDevice;
goto unwind;
}
-
ptr = GetMaster(ptr, MASTER_POINTER);
rc = dixLookupDevice(&ptr, ptr->id, client, DixDestroyAccess);
if (rc != Success)
@@ -258,8 +247,7 @@ remove_master(ClientPtr client, xXIRemoveMasterInfo *r,
goto unwind;
XTestkeybd = GetXTestDevice(keybd);
- rc = dixLookupDevice(&XTestkeybd, XTestkeybd->id, client,
- DixDestroyAccess);
+ rc = dixLookupDevice(&XTestkeybd, XTestkeybd->id, client, DixDestroyAccess);
if (rc != Success)
goto unwind;
@@ -267,18 +255,14 @@ remove_master(ClientPtr client, xXIRemoveMasterInfo *r,
/* Disabling sends the devices floating, reattach them if
* desired. */
- if (r->return_mode == XIAttachToMaster)
- {
- DeviceIntPtr attached,
- newptr,
- newkeybd;
+ if (r->return_mode == XIAttachToMaster) {
+ DeviceIntPtr attached, newptr, newkeybd;
rc = dixLookupDevice(&newptr, r->return_pointer, client, DixAddAccess);
if (rc != Success)
goto unwind;
- if (!IsMaster(newptr))
- {
+ if (!IsMaster(newptr)) {
client->errorValue = r->return_pointer;
rc = BadDevice;
goto unwind;
@@ -289,23 +273,19 @@ remove_master(ClientPtr client, xXIRemoveMasterInfo *r,
if (rc != Success)
goto unwind;
- if (!IsMaster(newkeybd))
- {
+ if (!IsMaster(newkeybd)) {
client->errorValue = r->return_keyboard;
rc = BadDevice;
goto unwind;
}
- for (attached = inputInfo.devices; attached; attached = attached->next)
- {
+ for (attached = inputInfo.devices; attached; attached = attached->next) {
if (!IsMaster(attached)) {
- if (GetMaster(attached, MASTER_ATTACHED) == ptr)
- {
+ if (GetMaster(attached, MASTER_ATTACHED) == ptr) {
AttachDevice(client, attached, newptr);
flags[attached->id] |= XISlaveAttached;
}
- if (GetMaster(attached, MASTER_ATTACHED) == keybd)
- {
+ if (GetMaster(attached, MASTER_ATTACHED) == keybd) {
AttachDevice(client, attached, newkeybd);
flags[attached->id] |= XISlaveAttached;
}
@@ -339,12 +319,12 @@ remove_master(ClientPtr client, xXIRemoveMasterInfo *r,
flags[keybd->id] |= XIMasterRemoved;
flags[ptr->id] |= XIMasterRemoved;
-unwind:
+ unwind:
return rc;
}
static int
-detach_slave(ClientPtr client, xXIDetachSlaveInfo *c, int flags[MAXDEVICES])
+detach_slave(ClientPtr client, xXIDetachSlaveInfo * c, int flags[MAXDEVICES])
{
DeviceIntPtr dev;
int rc;
@@ -353,16 +333,14 @@ detach_slave(ClientPtr client, xXIDetachSlaveInfo *c, int flags[MAXDEVICES])
if (rc != Success)
goto unwind;
- if (IsMaster(dev))
- {
+ if (IsMaster(dev)) {
client->errorValue = c->deviceid;
rc = BadDevice;
goto unwind;
}
/* Don't allow changes to XTest Devices, these are fixed */
- if (IsXTestDevice(dev, NULL))
- {
+ if (IsXTestDevice(dev, NULL)) {
client->errorValue = c->deviceid;
rc = BadDevice;
goto unwind;
@@ -372,13 +350,12 @@ detach_slave(ClientPtr client, xXIDetachSlaveInfo *c, int flags[MAXDEVICES])
AttachDevice(client, dev, NULL);
flags[dev->id] |= XISlaveDetached;
-unwind:
+ unwind:
return rc;
}
static int
-attach_slave(ClientPtr client, xXIAttachSlaveInfo *c,
- int flags[MAXDEVICES])
+attach_slave(ClientPtr client, xXIAttachSlaveInfo * c, int flags[MAXDEVICES])
{
DeviceIntPtr dev;
DeviceIntPtr newmaster;
@@ -388,16 +365,14 @@ attach_slave(ClientPtr client, xXIAttachSlaveInfo *c,
if (rc != Success)
goto unwind;
- if (IsMaster(dev))
- {
+ if (IsMaster(dev)) {
client->errorValue = c->deviceid;
rc = BadDevice;
goto unwind;
}
/* Don't allow changes to XTest Devices, these are fixed */
- if (IsXTestDevice(dev, NULL))
- {
+ if (IsXTestDevice(dev, NULL)) {
client->errorValue = c->deviceid;
rc = BadDevice;
goto unwind;
@@ -406,16 +381,14 @@ attach_slave(ClientPtr client, xXIAttachSlaveInfo *c,
rc = dixLookupDevice(&newmaster, c->new_master, client, DixAddAccess);
if (rc != Success)
goto unwind;
- if (!IsMaster(newmaster))
- {
+ if (!IsMaster(newmaster)) {
client->errorValue = c->new_master;
rc = BadDevice;
goto unwind;
}
if (!((IsPointerDevice(newmaster) && IsPointerDevice(dev)) ||
- (IsKeyboardDevice(newmaster) && IsKeyboardDevice(dev))))
- {
+ (IsKeyboardDevice(newmaster) && IsKeyboardDevice(dev)))) {
rc = BadDevice;
goto unwind;
}
@@ -424,12 +397,10 @@ attach_slave(ClientPtr client, xXIAttachSlaveInfo *c,
AttachDevice(client, dev, newmaster);
flags[dev->id] |= XISlaveAttached;
-unwind:
+ unwind:
return rc;
}
-
-
#define SWAPIF(cmd) if (client->swapped) { cmd; }
int
@@ -438,7 +409,7 @@ ProcXIChangeHierarchy(ClientPtr client)
xXIAnyHierarchyChangeInfo *any;
int required_len = sizeof(xXIChangeHierarchyReq);
int rc = Success;
- int flags[MAXDEVICES] = {0};
+ int flags[MAXDEVICES] = { 0 };
REQUEST(xXIChangeHierarchyReq);
REQUEST_AT_LEAST_SIZE(xXIChangeHierarchyReq);
@@ -446,9 +417,8 @@ ProcXIChangeHierarchy(ClientPtr client)
if (!stuff->num_changes)
return rc;
- any = (xXIAnyHierarchyChangeInfo*)&stuff[1];
- while(stuff->num_changes--)
- {
+ any = (xXIAnyHierarchyChangeInfo *) &stuff[1];
+ while (stuff->num_changes--) {
SWAPIF(swaps(&any->type));
SWAPIF(swaps(&any->length));
@@ -456,53 +426,52 @@ ProcXIChangeHierarchy(ClientPtr client)
if ((stuff->length * 4) < required_len)
return BadLength;
- switch(any->type)
+ switch (any->type) {
+ case XIAddMaster:
{
- case XIAddMaster:
- {
- xXIAddMasterInfo* c = (xXIAddMasterInfo*)any;
- SWAPIF(swaps(&c->name_len));
-
- rc = add_master(client, c, flags);
- if (rc != Success)
- goto unwind;
- }
- break;
- case XIRemoveMaster:
- {
- xXIRemoveMasterInfo* r = (xXIRemoveMasterInfo*)any;
-
- rc = remove_master(client, r, flags);
- if (rc != Success)
- goto unwind;
- }
- break;
- case XIDetachSlave:
- {
- xXIDetachSlaveInfo* c = (xXIDetachSlaveInfo*)any;
-
- rc = detach_slave(client, c, flags);
- if (rc != Success)
- goto unwind;
- }
- break;
- case XIAttachSlave:
- {
- xXIAttachSlaveInfo* c = (xXIAttachSlaveInfo*)any;
-
- rc = attach_slave(client, c, flags);
- if (rc != Success)
- goto unwind;
- }
- break;
+ xXIAddMasterInfo *c = (xXIAddMasterInfo *) any;
+
+ SWAPIF(swaps(&c->name_len));
+
+ rc = add_master(client, c, flags);
+ if (rc != Success)
+ goto unwind;
}
+ break;
+ case XIRemoveMaster:
+ {
+ xXIRemoveMasterInfo *r = (xXIRemoveMasterInfo *) any;
+
+ rc = remove_master(client, r, flags);
+ if (rc != Success)
+ goto unwind;
+ }
+ break;
+ case XIDetachSlave:
+ {
+ xXIDetachSlaveInfo *c = (xXIDetachSlaveInfo *) any;
- any = (xXIAnyHierarchyChangeInfo*)((char*)any + any->length * 4);
+ rc = detach_slave(client, c, flags);
+ if (rc != Success)
+ goto unwind;
+ }
+ break;
+ case XIAttachSlave:
+ {
+ xXIAttachSlaveInfo *c = (xXIAttachSlaveInfo *) any;
+
+ rc = attach_slave(client, c, flags);
+ if (rc != Success)
+ goto unwind;
+ }
+ break;
+ }
+
+ any = (xXIAnyHierarchyChangeInfo *) ((char *) any + any->length * 4);
}
-unwind:
+ unwind:
XISendDeviceHierarchyEvent(flags);
return rc;
}
-