include: fix comment

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
cursor: Move pointer barrier code over to XI

In order to send events to specific windows associated with the barrier,
we need to move the code that handles barriers to somewhere where it's
easier to construct and send events. Rather than duplicating XSync with
its XSyncSelectAlarm, re-use the existing XI infrastructure.

For now, just move a bunch of code over, rename some things, and initialize
the new structures, but still consider it a separate codebase. Pointer barrier
requests are still handled by XFixes, so this is a weird intermediate state.
It's unknown whether we'll add explicit requests to pointer barriers inside
XI.

Signed-off-by: Jasper St. Pierre <jstpierre@mecheye.net>
barriers: Don't loop over the server to destroy a barrier

This is completely pointless as far as I can tell.

Signed-off-by: Jasper St. Pierre <jstpierre@mecheye.net>
barriers: Switch to an explicit hook for barrier constrainment

Rather than riding on the ConstrainCursorHarder hook, which has
several issues, move to an explicit hook, which will help us with
some RANDR interaction issues.

Signed-off-by: Jasper St. Pierre <jstpierre@mecheye.net>
barriers: Switch to finding the nearest barrier client

When we add events, we eventually want to add more state to the
PointerBarrierClient, so return one of these instead of the dummy
public structure that's not very interesting.

Signed-off-by: Jasper St. Pierre <jstpierre@mecheye.net>
barriers: Reindent the constrainment hook

This is to make future diffs much cleaner. Best viewed with -w.

Signed-off-by: Jasper St. Pierre <jstpierre@mecheye.net>
Add support for XI2.3: Pointer barrier events and releases.

This adds support for clients that would like to get a notification
every time a barrier is hit, and allows clients to temporarily release
a barrier so that pointers can go through them, without having to
destroy and recreate barriers.

Based on work by Chris Halse Rogers <chris.halse.rogers@canonical.com>

Signed-off-by: Jasper St. Pierre <jstpierre@mecheye.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
barriers: Don't allow destroying other client's barriers

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
barriers: Don't allow releasing the pointer on other client's barriers

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
barriers: Add support for edge cases when releasing barriers

If we release a barrier, we want to ensure that we block all
other barriers afterwards, rather than capping the limit to
the two nearest barriers.

Signed-off-by: Jasper St. Pierre <jstpierre@mecheye.net>
barriers: Add a couple pixels of elbow room for the hit detection

Pointers (and the hands that drive them) aren't very precise, and the
slightest amount of nudging to either side might be enough to reset
the event ID, making clients think they have an entirely new hit. Allow
for a slightly bigger "hit box" before these barriers get reset.

Signed-off-by: Jasper St. Pierre <jstpierre@mecheye.net>
barriers: Increment event ID on hit box leave

We eventually want to send a new notify event on hitbox leave,
which signifies the dawn of a new barrier event ID, so it's
convenient if we can put the code here.

Signed-off-by: Jasper St. Pierre <jstpierre@mecheye.net>
barriers: Send a BarrierLeave event when we leave the hitbox

Additionally, add flags when the pointer is released.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
barriers: Clean up code

Rename a variable. This is to make the diff in the next commit cleaner.

Signed-off-by: Jasper St. Pierre <jstpierre@mecheye.net>
barriers: Send an XI_BarrierLeave event when a barrier is destroyed

This ensures that we always complete an event sequence.

Signed-off-by: Jasper St. Pierre <jstpierre@mecheye.net>
barriers: Replace complex intersection test with simpler math

Since barriers are axis-aligned, we can do the intersection test with
simple interpolation rather than line-segment intersection. This also
helps us out in the future when we want the barriers to extend to be
rays and lines rather than just segments.

Signed-off-by: Jasper St. Pierre <jstpierre@mecheye.net>
barriers: Support line and ray barriers

This allows clients to add barriers that extend to the edge of the
screen. Clients are encouraged to use these instead of precise coordinates
in these cases to help prevent pointer leaks.

Signed-off-by: Jasper St. Pierre <jstpierre@mecheye.net>
Pass the event list through to the pointer barrier code to return it

Instead of having the pointer barrier code enqueue events separately from
GetPointerEvents, pass the event list through and let it add to it.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Xi: fill in barrier root x/y after clamping to RandR outputs

x/y for barrier events should contain the actual pointer position.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
dix: skip delivery if it's not the right pointer barrier client

Only deliver to the client that created the barrier, not to other clients.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>