mirror of
https://gitlab.freedesktop.org/xorg/xserver.git
synced 2026-06-06 03:48:25 +02:00
input: Record grab pointer in TouchListener
This places a pointer to the grab related to a TouchListener directly
in the TouchListener structure rather than hoping to find the grab
later on using the resource ID.
Passive grabs have resource ID in the resource DB so they can be
removed when a client exits, and those resource IDs get copied when
activated, but implicit grabs are constructed on-the-fly and have no
resource DB entry.
Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
(cherry picked from commit 9ad0fdb135)
This commit is contained in:
parent
5272f71cf8
commit
df12c4daa7
5 changed files with 23 additions and 28 deletions
|
|
@ -1197,7 +1197,6 @@ TouchRejected(DeviceIntPtr sourcedev, TouchPointInfoPtr ti, XID resource,
|
|||
TouchOwnershipEvent *ev)
|
||||
{
|
||||
Bool was_owner = (resource == ti->listeners[0].listener);
|
||||
void *grab;
|
||||
int i;
|
||||
|
||||
/* Send a TouchEnd event to the resource being removed, but only if they
|
||||
|
|
@ -1212,11 +1211,7 @@ TouchRejected(DeviceIntPtr sourcedev, TouchPointInfoPtr ti, XID resource,
|
|||
|
||||
/* Remove the resource from the listener list, updating
|
||||
* ti->num_listeners, as well as ti->num_grabs if it was a grab. */
|
||||
if (TouchRemoveListener(ti, resource)) {
|
||||
if (dixLookupResourceByType(&grab, resource, RT_PASSIVEGRAB,
|
||||
serverClient, DixGetAttrAccess) == Success)
|
||||
ti->num_grabs--;
|
||||
}
|
||||
TouchRemoveListener(ti, resource);
|
||||
|
||||
/* If the current owner was removed and there are further listeners, deliver
|
||||
* the TouchOwnership or TouchBegin event to the new owner. */
|
||||
|
|
@ -1310,21 +1305,10 @@ RetrieveTouchDeliveryData(DeviceIntPtr dev, TouchPointInfoPtr ti,
|
|||
|
||||
if (listener->type == LISTENER_GRAB ||
|
||||
listener->type == LISTENER_POINTER_GRAB) {
|
||||
rc = dixLookupResourceByType((pointer *) grab, listener->listener,
|
||||
RT_PASSIVEGRAB,
|
||||
serverClient, DixSendAccess);
|
||||
if (rc != Success) {
|
||||
/* the grab doesn't exist but we have a grabbing listener - this
|
||||
* is an implicit/active grab */
|
||||
rc = dixLookupClient(client, listener->listener, serverClient,
|
||||
DixSendAccess);
|
||||
if (rc != Success)
|
||||
return FALSE;
|
||||
|
||||
*grab = dev->deviceGrab.grab;
|
||||
if (!*grab)
|
||||
return FALSE;
|
||||
}
|
||||
*grab = listener->grab;
|
||||
|
||||
BUG_RETURN_VAL(!*grab, FALSE);
|
||||
|
||||
*client = rClient(*grab);
|
||||
*win = (*grab)->window;
|
||||
|
|
@ -1477,6 +1461,7 @@ DeliverTouchEmulatedEvent(DeviceIntPtr dev, TouchPointInfoPtr ti,
|
|||
*/
|
||||
l = &ti->listeners[ti->num_listeners - 1];
|
||||
l->listener = devgrab->resource;
|
||||
l->grab = devgrab;
|
||||
|
||||
if (devgrab->grabtype != XI2 || devgrab->type != XI_TouchBegin)
|
||||
l->type = LISTENER_POINTER_GRAB;
|
||||
|
|
|
|||
|
|
@ -1435,6 +1435,7 @@ UpdateTouchesForGrab(DeviceIntPtr mouse)
|
|||
ti->listeners[0].type = LISTENER_POINTER_GRAB;
|
||||
else
|
||||
ti->listeners[0].type = LISTENER_GRAB;
|
||||
ti->listeners[0].grab = grab;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
22
dix/touch.c
22
dix/touch.c
|
|
@ -684,13 +684,17 @@ TouchResourceIsOwner(TouchPointInfoPtr ti, XID resource)
|
|||
void
|
||||
TouchAddListener(TouchPointInfoPtr ti, XID resource, enum InputLevel level,
|
||||
enum TouchListenerType type, enum TouchListenerState state,
|
||||
WindowPtr window)
|
||||
WindowPtr window,
|
||||
GrabPtr grab)
|
||||
{
|
||||
ti->listeners[ti->num_listeners].listener = resource;
|
||||
ti->listeners[ti->num_listeners].level = level;
|
||||
ti->listeners[ti->num_listeners].state = state;
|
||||
ti->listeners[ti->num_listeners].type = type;
|
||||
ti->listeners[ti->num_listeners].window = window;
|
||||
ti->listeners[ti->num_listeners].grab = grab;
|
||||
if (grab)
|
||||
ti->num_grabs++;
|
||||
ti->num_listeners++;
|
||||
}
|
||||
|
||||
|
|
@ -709,6 +713,11 @@ TouchRemoveListener(TouchPointInfoPtr ti, XID resource)
|
|||
if (ti->listeners[i].listener == resource) {
|
||||
int j;
|
||||
|
||||
if (ti->listeners[i].grab) {
|
||||
ti->listeners[i].grab = NULL;
|
||||
ti->num_grabs--;
|
||||
}
|
||||
|
||||
for (j = i; j < ti->num_listeners - 1; j++)
|
||||
ti->listeners[j] = ti->listeners[j + 1];
|
||||
ti->num_listeners--;
|
||||
|
|
@ -740,8 +749,7 @@ TouchAddGrabListener(DeviceIntPtr dev, TouchPointInfoPtr ti,
|
|||
}
|
||||
|
||||
TouchAddListener(ti, grab->resource, grab->grabtype,
|
||||
type, LISTENER_AWAITING_BEGIN, grab->window);
|
||||
ti->num_grabs++;
|
||||
type, LISTENER_AWAITING_BEGIN, grab->window, grab);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -797,7 +805,7 @@ TouchAddRegularListener(DeviceIntPtr dev, TouchPointInfoPtr ti,
|
|||
TouchEventHistoryAllocate(ti);
|
||||
|
||||
TouchAddListener(ti, iclients->resource, XI2,
|
||||
type, LISTENER_AWAITING_BEGIN, win);
|
||||
type, LISTENER_AWAITING_BEGIN, win, NULL);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
|
@ -813,7 +821,7 @@ TouchAddRegularListener(DeviceIntPtr dev, TouchPointInfoPtr ti,
|
|||
TouchEventHistoryAllocate(ti);
|
||||
TouchAddListener(ti, iclients->resource, XI,
|
||||
LISTENER_POINTER_REGULAR, LISTENER_AWAITING_BEGIN,
|
||||
win);
|
||||
win, NULL);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
|
@ -828,7 +836,7 @@ TouchAddRegularListener(DeviceIntPtr dev, TouchPointInfoPtr ti,
|
|||
TouchEventHistoryAllocate(ti);
|
||||
TouchAddListener(ti, win->drawable.id, CORE,
|
||||
LISTENER_POINTER_REGULAR, LISTENER_AWAITING_BEGIN,
|
||||
win);
|
||||
win, NULL);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
@ -839,7 +847,7 @@ TouchAddRegularListener(DeviceIntPtr dev, TouchPointInfoPtr ti,
|
|||
|
||||
TouchEventHistoryAllocate(ti);
|
||||
TouchAddListener(ti, oclients->resource, CORE,
|
||||
type, LISTENER_AWAITING_BEGIN, win);
|
||||
type, LISTENER_AWAITING_BEGIN, win, NULL);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -562,7 +562,7 @@ extern void TouchEventHistoryReplay(TouchPointInfoPtr ti, DeviceIntPtr dev,
|
|||
extern Bool TouchResourceIsOwner(TouchPointInfoPtr ti, XID resource);
|
||||
extern void TouchAddListener(TouchPointInfoPtr ti, XID resource,
|
||||
enum InputLevel level, enum TouchListenerType type,
|
||||
enum TouchListenerState state, WindowPtr window);
|
||||
enum TouchListenerState state, WindowPtr window, GrabPtr grab);
|
||||
extern Bool TouchRemoveListener(TouchPointInfoPtr ti, XID resource);
|
||||
extern void TouchSetupListeners(DeviceIntPtr dev, TouchPointInfoPtr ti,
|
||||
InternalEvent *ev);
|
||||
|
|
|
|||
|
|
@ -305,6 +305,7 @@ typedef struct _TouchListener {
|
|||
enum TouchListenerState state;
|
||||
enum InputLevel level; /* matters only for emulating touches */
|
||||
WindowPtr window;
|
||||
GrabPtr grab;
|
||||
} TouchListener;
|
||||
|
||||
typedef struct _TouchPointInfo {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue