cursor: Clean up pointer barrier creation code a tiny bit

This will make it much simpler when we add more error paths to the code
that constructs pointer barrier clients.

Signed-off-by: Jasper St. Pierre <jstpierre@mecheye.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Jasper St. Pierre 2012-11-03 20:23:44 -04:00 committed by Peter Hutterer
parent 04c885de71
commit 1536bc2d21

View File

@ -1245,28 +1245,34 @@ CursorConstrainCursorHarder(DeviceIntPtr dev, ScreenPtr screen, int mode,
}
}
static struct PointerBarrierClient *
static int
CreatePointerBarrierClient(ScreenPtr screen, ClientPtr client,
xXFixesCreatePointerBarrierReq * stuff)
xXFixesCreatePointerBarrierReq * stuff,
PointerBarrierClientPtr *client_out)
{
CursorScreenPtr cs = GetCursorScreen(screen);
struct PointerBarrierClient *ret = malloc(sizeof(*ret));
if (ret) {
ret->screen = screen;
ret->barrier.x1 = min(stuff->x1, stuff->x2);
ret->barrier.x2 = max(stuff->x1, stuff->x2);
ret->barrier.y1 = min(stuff->y1, stuff->y2);
ret->barrier.y2 = max(stuff->y1, stuff->y2);
ret->barrier.directions = stuff->directions & 0x0f;
if (barrier_is_horizontal(&ret->barrier))
ret->barrier.directions &= ~(BarrierPositiveX | BarrierNegativeX);
if (barrier_is_vertical(&ret->barrier))
ret->barrier.directions &= ~(BarrierPositiveY | BarrierNegativeY);
xorg_list_add(&ret->entry, &cs->barriers);
*client_out = NULL;
if (!ret) {
return BadAlloc;
}
return ret;
ret->screen = screen;
ret->barrier.x1 = min(stuff->x1, stuff->x2);
ret->barrier.x2 = max(stuff->x1, stuff->x2);
ret->barrier.y1 = min(stuff->y1, stuff->y2);
ret->barrier.y2 = max(stuff->y1, stuff->y2);
ret->barrier.directions = stuff->directions & 0x0f;
if (barrier_is_horizontal(&ret->barrier))
ret->barrier.directions &= ~(BarrierPositiveX | BarrierNegativeX);
if (barrier_is_vertical(&ret->barrier))
ret->barrier.directions &= ~(BarrierPositiveY | BarrierNegativeY);
xorg_list_add(&ret->entry, &cs->barriers);
*client_out = ret;
return Success;
}
int
@ -1304,9 +1310,9 @@ ProcXFixesCreatePointerBarrier(ClientPtr client)
if (barrier_is_horizontal(&b) && barrier_is_vertical(&b))
return BadValue;
if (!(barrier = CreatePointerBarrierClient(pWin->drawable.pScreen,
client, stuff)))
return BadAlloc;
if ((err = CreatePointerBarrierClient(pWin->drawable.pScreen,
client, stuff, &barrier)))
return err;
if (!AddResource(stuff->barrier, PointerBarrierType, &barrier->barrier))
return BadAlloc;