summaryrefslogtreecommitdiff
path: root/xfixes/cursor.c
diff options
context:
space:
mode:
authorJasper St. Pierre <jstpierre@mecheye.net>2012-11-03 20:23:44 -0400
committerPeter Hutterer <peter.hutterer@who-t.net>2012-11-06 10:48:32 +1000
commit1536bc2d213713af45541a15b5e49c552d8d0592 (patch)
treec39ca48af0df9464ce484a2c8f3b84156f07060e /xfixes/cursor.c
parent04c885de715a7c989e48fc8cf2e61db2b401de2d (diff)
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>
Diffstat (limited to 'xfixes/cursor.c')
-rw-r--r--xfixes/cursor.c42
1 files changed, 24 insertions, 18 deletions
diff --git a/xfixes/cursor.c b/xfixes/cursor.c
index 75b03749d..f66bd68cb 100644
--- a/xfixes/cursor.c
+++ b/xfixes/cursor.c
@@ -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;