Xi: add helper functions to alloc/free InputClientPtrs
Currently not needed since the InputClientRec is a self-contained struct. As part of the touch rework that won't be the case in the future and a function to allocate/free memory appropriately is required. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
This commit is contained in:
parent
4acf999c29
commit
ee9346bb31
|
@ -1628,6 +1628,19 @@ SelectForWindow(DeviceIntPtr dev, WindowPtr pWin, ClientPtr client,
|
||||||
return Success;
|
return Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
FreeInputClient(InputClientsPtr *other)
|
||||||
|
{
|
||||||
|
free(*other);
|
||||||
|
*other = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static InputClientsPtr
|
||||||
|
AllocInputClient(void)
|
||||||
|
{
|
||||||
|
return calloc(1, sizeof(InputClients));
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
AddExtensionClient(WindowPtr pWin, ClientPtr client, Mask mask, int mskidx)
|
AddExtensionClient(WindowPtr pWin, ClientPtr client, Mask mask, int mskidx)
|
||||||
{
|
{
|
||||||
|
@ -1635,7 +1648,7 @@ AddExtensionClient(WindowPtr pWin, ClientPtr client, Mask mask, int mskidx)
|
||||||
|
|
||||||
if (!pWin->optional && !MakeWindowOptional(pWin))
|
if (!pWin->optional && !MakeWindowOptional(pWin))
|
||||||
return BadAlloc;
|
return BadAlloc;
|
||||||
others = calloc(1, sizeof(InputClients));
|
others = AllocInputClient();
|
||||||
if (!others)
|
if (!others)
|
||||||
return BadAlloc;
|
return BadAlloc;
|
||||||
if (!pWin->optional->inputMasks && !MakeInputMasks(pWin))
|
if (!pWin->optional->inputMasks && !MakeInputMasks(pWin))
|
||||||
|
@ -1649,7 +1662,7 @@ AddExtensionClient(WindowPtr pWin, ClientPtr client, Mask mask, int mskidx)
|
||||||
return Success;
|
return Success;
|
||||||
|
|
||||||
bail:
|
bail:
|
||||||
free(others);
|
FreeInputClient(&others);
|
||||||
return BadAlloc;
|
return BadAlloc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1721,14 +1734,14 @@ InputClientGone(WindowPtr pWin, XID id)
|
||||||
if (other->resource == id) {
|
if (other->resource == id) {
|
||||||
if (prev) {
|
if (prev) {
|
||||||
prev->next = other->next;
|
prev->next = other->next;
|
||||||
free(other);
|
FreeInputClient(&other);
|
||||||
} else if (!(other->next)) {
|
} else if (!(other->next)) {
|
||||||
if (ShouldFreeInputMasks(pWin, TRUE)) {
|
if (ShouldFreeInputMasks(pWin, TRUE)) {
|
||||||
wOtherInputMasks(pWin)->inputClients = other->next;
|
wOtherInputMasks(pWin)->inputClients = other->next;
|
||||||
free(wOtherInputMasks(pWin));
|
free(wOtherInputMasks(pWin));
|
||||||
pWin->optional->inputMasks = (OtherInputMasks *) NULL;
|
pWin->optional->inputMasks = (OtherInputMasks *) NULL;
|
||||||
CheckWindowOptionalNeed(pWin);
|
CheckWindowOptionalNeed(pWin);
|
||||||
free(other);
|
FreeInputClient(&other);
|
||||||
} else {
|
} else {
|
||||||
other->resource = FakeClientID(0);
|
other->resource = FakeClientID(0);
|
||||||
if (!AddResource(other->resource, RT_INPUTCLIENT,
|
if (!AddResource(other->resource, RT_INPUTCLIENT,
|
||||||
|
@ -1737,7 +1750,7 @@ InputClientGone(WindowPtr pWin, XID id)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
wOtherInputMasks(pWin)->inputClients = other->next;
|
wOtherInputMasks(pWin)->inputClients = other->next;
|
||||||
free(other);
|
FreeInputClient(&other);
|
||||||
}
|
}
|
||||||
RecalculateDeviceDeliverableEvents(pWin);
|
RecalculateDeviceDeliverableEvents(pWin);
|
||||||
return Success;
|
return Success;
|
||||||
|
|
Loading…
Reference in New Issue