xace: typesafe hook function for XACE_RECEIVE_ACCESS
The generic XaceHook() call isn't typesafe (und unnecessarily slow). Better add an explicit function, just like we already have for others. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net> Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1556>
This commit is contained in:
parent
67e468c8bd
commit
3dfe00d5e0
19
Xext/xace.c
19
Xext/xace.c
|
@ -86,13 +86,20 @@ int XaceHookSendAccess(ClientPtr client, DeviceIntPtr dev, WindowPtr win,
|
|||
return rec.status;
|
||||
}
|
||||
|
||||
int XaceHookReceiveAccess(ClientPtr client, WindowPtr win,
|
||||
xEventPtr ev, int count)
|
||||
{
|
||||
XaceReceiveAccessRec rec = { client, win, ev, count, Success };
|
||||
CallCallbacks(&XaceHooks[XACE_RECEIVE_ACCESS], &rec);
|
||||
return rec.status;
|
||||
}
|
||||
|
||||
/* Entry point for hook functions. Called by Xserver.
|
||||
*/
|
||||
int
|
||||
XaceHook(int hook, ...)
|
||||
{
|
||||
union {
|
||||
XaceReceiveAccessRec recv;
|
||||
XaceClientAccessRec client;
|
||||
XaceExtAccessRec ext;
|
||||
XaceServerAccessRec server;
|
||||
|
@ -114,16 +121,6 @@ XaceHook(int hook, ...)
|
|||
* sets calldata directly to a single argument (with no return result)
|
||||
*/
|
||||
switch (hook) {
|
||||
case XACE_RECEIVE_ACCESS:
|
||||
u.recv.client = va_arg(ap, ClientPtr);
|
||||
u.recv.pWin = va_arg(ap, WindowPtr);
|
||||
|
||||
u.recv.events = va_arg(ap, xEventPtr);
|
||||
u.recv.count = va_arg(ap, int);
|
||||
|
||||
u.recv.status = Success; /* default allow */
|
||||
prv = &u.recv.status;
|
||||
break;
|
||||
case XACE_CLIENT_ACCESS:
|
||||
u.client.client = va_arg(ap, ClientPtr);
|
||||
u.client.target = va_arg(ap, ClientPtr);
|
||||
|
|
|
@ -86,6 +86,7 @@ int XaceHookDeviceAccess(ClientPtr client, DeviceIntPtr dev, Mask access_mode);
|
|||
|
||||
int XaceHookSendAccess(ClientPtr client, DeviceIntPtr dev, WindowPtr win,
|
||||
xEventPtr ev, int count);
|
||||
int XaceHookReceiveAccess(ClientPtr client, WindowPtr win, xEventPtr ev, int count);
|
||||
|
||||
/* Register a callback for a given hook.
|
||||
*/
|
||||
|
|
|
@ -1094,7 +1094,7 @@ DeliverOneTouchEvent(ClientPtr client, DeviceIntPtr dev, TouchPointInfoPtr ti,
|
|||
|
||||
FixUpEventFromWindow(&ti->sprite, xi2, win, child, FALSE);
|
||||
filter = GetEventFilter(dev, xi2);
|
||||
if (XaceHook(XACE_RECEIVE_ACCESS, client, win, xi2, 1) != Success)
|
||||
if (XaceHookReceiveAccess(client, win, xi2, 1) != Success)
|
||||
return FALSE;
|
||||
err = TryClientEvents(client, dev, xi2, 1, filter, filter, NullGrab);
|
||||
free(xi2);
|
||||
|
@ -2240,7 +2240,7 @@ DeliverOneGestureEvent(ClientPtr client, DeviceIntPtr dev, GestureInfoPtr gi,
|
|||
|
||||
FixUpEventFromWindow(&gi->sprite, xi2, win, child, FALSE);
|
||||
filter = GetEventFilter(dev, xi2);
|
||||
if (XaceHook(XACE_RECEIVE_ACCESS, client, win, xi2, 1) != Success)
|
||||
if (XaceHookReceiveAccess(client, win, xi2, 1) != Success)
|
||||
return FALSE;
|
||||
err = TryClientEvents(client, dev, xi2, 1, filter, filter, NullGrab);
|
||||
free(xi2);
|
||||
|
|
11
dix/events.c
11
dix/events.c
|
@ -2179,7 +2179,7 @@ DeliverToWindowOwner(DeviceIntPtr dev, WindowPtr win,
|
|||
if (IsInterferingGrab(wClient(win), dev, events))
|
||||
return EVENT_SKIP;
|
||||
|
||||
if (!XaceHook(XACE_RECEIVE_ACCESS, wClient(win), win, events, count)) {
|
||||
if (!XaceHookReceiveAccess(wClient(win), win, events, count)) {
|
||||
int attempt = TryClientEvents(wClient(win), dev, events,
|
||||
count, win->eventMask,
|
||||
filter, grab);
|
||||
|
@ -2257,7 +2257,7 @@ DeliverEventToInputClients(DeviceIntPtr dev, InputClients * inputclients,
|
|||
|
||||
mask = GetEventMask(dev, events, inputclients);
|
||||
|
||||
if (XaceHook(XACE_RECEIVE_ACCESS, client, win, events, count))
|
||||
if (XaceHookReceiveAccess(client, win, events, count))
|
||||
/* do nothing */ ;
|
||||
else if ((attempt = TryClientEvents(client, dev,
|
||||
events, count,
|
||||
|
@ -2536,7 +2536,7 @@ MaybeDeliverEventsToClient(WindowPtr pWin, xEvent *pEvents,
|
|||
return XineramaTryClientEventsResult(wClient(pWin), NullGrab,
|
||||
pWin->eventMask, filter);
|
||||
#endif
|
||||
if (XaceHook(XACE_RECEIVE_ACCESS, wClient(pWin), pWin, pEvents, count))
|
||||
if (XaceHookReceiveAccess(wClient(pWin), pWin, pEvents, count))
|
||||
return 1; /* don't send, but pretend we did */
|
||||
return TryClientEvents(wClient(pWin), NULL, pEvents, count,
|
||||
pWin->eventMask, filter, NullGrab);
|
||||
|
@ -2550,7 +2550,7 @@ MaybeDeliverEventsToClient(WindowPtr pWin, xEvent *pEvents,
|
|||
return XineramaTryClientEventsResult(rClient(other), NullGrab,
|
||||
other->mask, filter);
|
||||
#endif
|
||||
if (XaceHook(XACE_RECEIVE_ACCESS, rClient(other), pWin, pEvents,
|
||||
if (XaceHookReceiveAccess(rClient(other), pWin, pEvents,
|
||||
count))
|
||||
return 1; /* don't send, but pretend we did */
|
||||
return TryClientEvents(rClient(other), NULL, pEvents, count,
|
||||
|
@ -4303,8 +4303,7 @@ DeliverOneGrabbedEvent(InternalEvent *event, DeviceIntPtr dev,
|
|||
if (rc == Success) {
|
||||
FixUpEventFromWindow(pSprite, xE, grab->window, None, TRUE);
|
||||
if (XaceHookSendAccess(0, dev, grab->window, xE, count) ||
|
||||
XaceHook(XACE_RECEIVE_ACCESS, rClient(grab),
|
||||
grab->window, xE, count))
|
||||
XaceHookReceiveAccess(rClient(grab), grab->window, xE, count))
|
||||
deliveries = 1; /* don't send, but pretend we did */
|
||||
else if (level != CORE || !IsInterferingGrab(rClient(grab), dev, xE)) {
|
||||
deliveries = TryClientEvents(rClient(grab), dev,
|
||||
|
|
Loading…
Reference in New Issue