dix: replace wClient() macro by dixClientForWindow() inline function
Hide internals (drop the need to include windowstr.h), make it typesafe as well as the naming easier to understand. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
parent
261c49b4c2
commit
d697618c16
|
@ -32,6 +32,7 @@ in this Software without prior written authorization from The Open Group.
|
|||
|
||||
#include "dix/dix_priv.h"
|
||||
#include "dix/registry_priv.h"
|
||||
#include "dix/resource_priv.h"
|
||||
#include "include/extinit_priv.h"
|
||||
#include "os/audit.h"
|
||||
#include "os/auth.h"
|
||||
|
@ -856,13 +857,13 @@ SecurityProperty(CallbackListPtr *pcbl, void *unused, void *calldata)
|
|||
Mask allowed = SecurityResourceMask | DixReadAccess;
|
||||
|
||||
subj = dixLookupPrivate(&rec->client->devPrivates, stateKey);
|
||||
obj = dixLookupPrivate(&wClient(rec->pWin)->devPrivates, stateKey);
|
||||
obj = dixLookupPrivate(&dixClientForWindow(rec->pWin)->devPrivates, stateKey);
|
||||
|
||||
if (SecurityDoCheck(subj, obj, requested, allowed) != Success) {
|
||||
SecurityAudit("Security: denied client %d access to property %s "
|
||||
"(atom 0x%x) window 0x%lx of client %d on request %s\n",
|
||||
rec->client->index, NameForAtom(name), name,
|
||||
(unsigned long)rec->pWin->drawable.id, wClient(rec->pWin)->index,
|
||||
(unsigned long)rec->pWin->drawable.id, dixClientForWindow(rec->pWin)->index,
|
||||
SecurityLookupRequestName(rec->client));
|
||||
rec->status = BadAccess;
|
||||
}
|
||||
|
@ -878,7 +879,7 @@ SecuritySend(CallbackListPtr *pcbl, void *unused, void *calldata)
|
|||
int i;
|
||||
|
||||
subj = dixLookupPrivate(&rec->client->devPrivates, stateKey);
|
||||
obj = dixLookupPrivate(&wClient(rec->pWin)->devPrivates, stateKey);
|
||||
obj = dixLookupPrivate(&dixClientForWindow(rec->pWin)->devPrivates, stateKey);
|
||||
|
||||
if (SecurityDoCheck(subj, obj, DixSendAccess, 0) == Success)
|
||||
return;
|
||||
|
@ -893,7 +894,7 @@ SecuritySend(CallbackListPtr *pcbl, void *unused, void *calldata)
|
|||
rec->client->index,
|
||||
LookupEventName(rec->events[i].u.u.type),
|
||||
(unsigned long)rec->pWin->drawable.id,
|
||||
wClient(rec->pWin)->index);
|
||||
dixClientForWindow(rec->pWin)->index);
|
||||
rec->status = BadAccess;
|
||||
return;
|
||||
}
|
||||
|
@ -907,7 +908,7 @@ SecurityReceive(CallbackListPtr *pcbl, void *unused, void *calldata)
|
|||
SecurityStateRec *subj, *obj;
|
||||
|
||||
subj = dixLookupPrivate(&rec->client->devPrivates, stateKey);
|
||||
obj = dixLookupPrivate(&wClient(rec->pWin)->devPrivates, stateKey);
|
||||
obj = dixLookupPrivate(&dixClientForWindow(rec->pWin)->devPrivates, stateKey);
|
||||
|
||||
if (SecurityDoCheck(subj, obj, DixReceiveAccess, 0) == Success)
|
||||
return;
|
||||
|
@ -915,7 +916,7 @@ SecurityReceive(CallbackListPtr *pcbl, void *unused, void *calldata)
|
|||
SecurityAudit("Security: denied client %d from receiving an event "
|
||||
"sent to window 0x%lx of client %d\n",
|
||||
rec->client->index, (unsigned long)rec->pWin->drawable.id,
|
||||
wClient(rec->pWin)->index);
|
||||
dixClientForWindow(rec->pWin)->index);
|
||||
rec->status = BadAccess;
|
||||
}
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
|
||||
#include "dix/input_priv.h"
|
||||
#include "dix/registry_priv.h"
|
||||
#include "dix/resource_priv.h"
|
||||
#include "os/client_priv.h"
|
||||
|
||||
#include "selection.h"
|
||||
|
@ -772,7 +773,7 @@ SELinuxResourceState(CallbackListPtr *pcbl, void *unused, void *calldata)
|
|||
return;
|
||||
|
||||
pWin = (WindowPtr) rec->value;
|
||||
subj = dixLookupPrivate(&wClient(pWin)->devPrivates, subjectKey);
|
||||
subj = dixLookupPrivate(&dixClientForWindow(pWin)->devPrivates, subjectKey);
|
||||
|
||||
if (subj->sid) {
|
||||
char *ctx;
|
||||
|
|
|
@ -96,6 +96,7 @@ SOFTWARE.
|
|||
#include "dix/eventconvert.h"
|
||||
#include "dix/exevents_priv.h"
|
||||
#include "dix/input_priv.h"
|
||||
#include "dix/resource_priv.h"
|
||||
#include "mi/mi_priv.h"
|
||||
|
||||
#include "inputstr.h"
|
||||
|
@ -1427,7 +1428,7 @@ RetrieveTouchDeliveryData(DeviceIntPtr dev, TouchPointInfoPtr ti,
|
|||
break;
|
||||
|
||||
/* if owner selected, oclients is NULL */
|
||||
*client = oclients ? rClient(oclients) : wClient(*win);
|
||||
*client = oclients ? rClient(oclients) : dixClientForWindow(*win);
|
||||
}
|
||||
|
||||
*grab = NULL;
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include <dix-config.h>
|
||||
|
||||
#include "dix/dix_priv.h"
|
||||
#include "dix/resource_priv.h"
|
||||
#include "os/osdep.h"
|
||||
|
||||
#include "compint.h"
|
||||
|
@ -216,7 +217,7 @@ updateOverlayWindow(ScreenPtr pScreen)
|
|||
/* Let's resize the overlay window. */
|
||||
vlist[0] = w;
|
||||
vlist[1] = h;
|
||||
return ConfigureWindow(pWin, CWWidth | CWHeight, vlist, wClient(pWin));
|
||||
return ConfigureWindow(pWin, CWWidth | CWHeight, vlist, dixClientForWindow(pWin));
|
||||
}
|
||||
|
||||
/* Let's be on the safe side and not assume an overlay window is
|
||||
|
|
29
dix/events.c
29
dix/events.c
|
@ -125,6 +125,7 @@ Equipment Corporation.
|
|||
#include "dix/eventconvert.h"
|
||||
#include "dix/exevents_priv.h"
|
||||
#include "dix/reqhandlers_priv.h"
|
||||
#include "dix/resource_priv.h"
|
||||
#include "os/bug_priv.h"
|
||||
#include "os/client_priv.h"
|
||||
#include "os/fmt.h"
|
||||
|
@ -2199,11 +2200,11 @@ DeliverToWindowOwner(DeviceIntPtr dev, WindowPtr win,
|
|||
!((wOtherEventMasks(win) | win->eventMask) & filter))
|
||||
return EVENT_SKIP;
|
||||
|
||||
if (IsInterferingGrab(wClient(win), dev, events))
|
||||
if (IsInterferingGrab(dixClientForWindow(win), dev, events))
|
||||
return EVENT_SKIP;
|
||||
|
||||
if (!XaceHookReceiveAccess(wClient(win), win, events, count)) {
|
||||
int attempt = TryClientEvents(wClient(win), dev, events,
|
||||
if (!XaceHookReceiveAccess(dixClientForWindow(win), win, events, count)) {
|
||||
int attempt = TryClientEvents(dixClientForWindow(win), dev, events,
|
||||
count, win->eventMask,
|
||||
filter, grab);
|
||||
|
||||
|
@ -2377,7 +2378,7 @@ DeliverEventsToWindow(DeviceIntPtr pDev, WindowPtr pWin, xEvent
|
|||
case EVENT_DELIVERED:
|
||||
/* We delivered to the owner, with our event mask */
|
||||
deliveries++;
|
||||
client = wClient(pWin);
|
||||
client = dixClientForWindow(pWin);
|
||||
deliveryMask = pWin->eventMask;
|
||||
break;
|
||||
case EVENT_NOT_DELIVERED:
|
||||
|
@ -2551,16 +2552,16 @@ Bool MaybeDeliverEventToClient(WindowPtr pWin, xEvent *pEvents,
|
|||
OtherClients *other;
|
||||
|
||||
if (pWin->eventMask & filter) {
|
||||
if (wClient(pWin) == dontClient)
|
||||
if (dixClientForWindow(pWin) == dontClient)
|
||||
return FALSE;
|
||||
#ifdef XINERAMA
|
||||
if (!noPanoramiXExtension && pWin->drawable.pScreen->myNum)
|
||||
return XineramaTryClientEventsResult(wClient(pWin), NullGrab,
|
||||
return XineramaTryClientEventsResult(dixClientForWindow(pWin), NullGrab,
|
||||
pWin->eventMask, filter);
|
||||
#endif /* XINERAMA */
|
||||
if (XaceHookReceiveAccess(wClient(pWin), pWin, pEvents, 1))
|
||||
if (XaceHookReceiveAccess(dixClientForWindow(pWin), pWin, pEvents, 1))
|
||||
return TRUE; /* don't send, but pretend we did */
|
||||
return TryClientEvents(wClient(pWin), NULL, pEvents, 1,
|
||||
return TryClientEvents(dixClientForWindow(pWin), NULL, pEvents, 1,
|
||||
pWin->eventMask, filter, NullGrab) == 1;
|
||||
}
|
||||
for (other = wOtherClients(pWin); other; other = other->next) {
|
||||
|
@ -4560,14 +4561,14 @@ XRetCode EventSelectForWindow(WindowPtr pWin, ClientPtr client, Mask mask)
|
|||
/* It is illegal for two different clients to select on any of the
|
||||
events for AtMostOneClient. However, it is OK, for some client to
|
||||
continue selecting on one of those events. */
|
||||
if ((wClient(pWin) != client) && (check & pWin->eventMask))
|
||||
if ((dixClientForWindow(pWin) != client) && (check & pWin->eventMask))
|
||||
return BadAccess;
|
||||
for (others = wOtherClients(pWin); others; others = others->next) {
|
||||
if (!SameClient(others, client) && (check & others->mask))
|
||||
return BadAccess;
|
||||
}
|
||||
}
|
||||
if (wClient(pWin) == client) {
|
||||
if (dixClientForWindow(pWin) == client) {
|
||||
check = pWin->eventMask;
|
||||
pWin->eventMask = mask;
|
||||
}
|
||||
|
@ -4721,7 +4722,7 @@ CoreEnterLeaveEvent(DeviceIntPtr mouse,
|
|||
xKeymapEvent ke = {
|
||||
.type = KeymapNotify
|
||||
};
|
||||
ClientPtr client = grab ? rClient(grab) : wClient(pWin);
|
||||
ClientPtr client = grab ? rClient(grab) : dixClientForWindow(pWin);
|
||||
int rc;
|
||||
|
||||
rc = XaceHookDeviceAccess(client, keybd, DixReadAccess);
|
||||
|
@ -4834,7 +4835,7 @@ CoreFocusEvent(DeviceIntPtr dev, int type, int mode, int detail, WindowPtr pWin)
|
|||
xKeymapEvent ke = {
|
||||
.type = KeymapNotify
|
||||
};
|
||||
ClientPtr client = wClient(pWin);
|
||||
ClientPtr client = dixClientForWindow(pWin);
|
||||
int rc;
|
||||
|
||||
rc = XaceHookDeviceAccess(client, dev, DixReadAccess);
|
||||
|
@ -5895,7 +5896,7 @@ DeleteWindowFromAnyEvents(WindowPtr pWin, Bool freeResources)
|
|||
of ending up reverting to a dying window and thence
|
||||
to None */
|
||||
#ifdef NOTDEF
|
||||
|| wClient(parent)->clientGone
|
||||
|| dixClientForWindow(parent)->clientGone
|
||||
#endif
|
||||
);
|
||||
if (!ActivateFocusInGrab(keybd, pWin, parent))
|
||||
|
@ -5967,7 +5968,7 @@ EventMaskForClient(WindowPtr pWin, ClientPtr client)
|
|||
{
|
||||
OtherClientsPtr other;
|
||||
|
||||
if (wClient(pWin) == client)
|
||||
if (dixClientForWindow(pWin) == client)
|
||||
return pWin->eventMask;
|
||||
for (other = wOtherClients(pWin); other; other = other->next) {
|
||||
if (SameClient(other, client))
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
/* SPDX-License-Identifier: MIT OR X11
|
||||
*
|
||||
* Copyright © 2024 Enrico Weigelt, metux IT consult <info@metux.net>
|
||||
*
|
||||
* @brief DIX lookup functions
|
||||
*/
|
||||
#include <dix-config.h>
|
||||
|
||||
#include "dix/dix_priv.h"
|
||||
#include "include/windowstr.h"
|
||||
|
||||
ClientPtr dixClientForWindow(WindowPtr pWin) {
|
||||
if (!pWin)
|
||||
return NullClient;
|
||||
|
||||
return clients[CLIENT_ID(pWin->drawable.id)];
|
||||
}
|
|
@ -20,6 +20,7 @@ srcs_dix = [
|
|||
'glyphcurs.c',
|
||||
'grabs.c',
|
||||
'inpututils.c',
|
||||
'lookup.c',
|
||||
'pixmap.c',
|
||||
'privates.c',
|
||||
'property.c',
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
/* SPDX-License-Identifier: MIT OR X11
|
||||
*
|
||||
* Copyright © 2024 Enrico Weigelt, metux IT consult <info@metux.net>
|
||||
*/
|
||||
#ifndef _XSERVER_DIX_RESOURCE_PRIV_H
|
||||
#define _XSERVER_DIX_RESOURCE_PRIV_H
|
||||
|
||||
#include "include/dix.h"
|
||||
|
||||
/*
|
||||
* @brief retrieve client that owns given window
|
||||
*
|
||||
* XIDs carry the ID of the client who created/owns the resource in upper bits.
|
||||
* (every client so is assigned a range of XIDs it may use for resource creation)
|
||||
*
|
||||
* @param WindowPtr to the window whose client shall be retrieved
|
||||
* @return pointer to ClientRec structure or NullClient (NULL)
|
||||
*/
|
||||
ClientPtr dixClientForWindow(WindowPtr pWin);
|
||||
|
||||
#endif /* _XSERVER_DIX_RESOURCE_PRIV_H */
|
|
@ -104,6 +104,7 @@ Equipment Corporation.
|
|||
#include "dix/exevents_priv.h"
|
||||
#include "dix/input_priv.h"
|
||||
#include "dix/property_priv.h"
|
||||
#include "dix/resource_priv.h"
|
||||
#include "mi/mi_priv.h" /* miPaintWindow */
|
||||
#include "os/auth.h"
|
||||
#include "os/client_priv.h"
|
||||
|
@ -921,7 +922,7 @@ CreateWindow(Window wid, WindowPtr pParent, int x, int y, unsigned w,
|
|||
RecalculateDeliverableEvents(pWin);
|
||||
|
||||
if (vmask)
|
||||
*error = ChangeWindowAttributes(pWin, vmask, vlist, wClient(pWin));
|
||||
*error = ChangeWindowAttributes(pWin, vmask, vlist, dixClientForWindow(pWin));
|
||||
else
|
||||
*error = Success;
|
||||
|
||||
|
@ -2940,7 +2941,7 @@ HandleSaveSet(ClientPtr client)
|
|||
else
|
||||
{
|
||||
pParent = pWin->parent;
|
||||
while (pParent && (wClient(pParent) == client))
|
||||
while (pParent && (dixClientForWindow(pParent) == client))
|
||||
pParent = pParent->parent;
|
||||
}
|
||||
if (pParent) {
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
|
||||
#include "dix/dix_priv.h"
|
||||
#include "dix/input_priv.h"
|
||||
#include "dix/resource_priv.h"
|
||||
#include "randr/randrstr_priv.h"
|
||||
|
||||
#include "xwayland-cvt.h"
|
||||
|
@ -574,7 +575,7 @@ xwl_output_set_window_randr_emu_props(struct xwl_screen *xwl_screen,
|
|||
{
|
||||
struct xwl_output_randr_emu_prop prop = {};
|
||||
|
||||
xwl_output_randr_emu_prop(xwl_screen, wClient(window), &prop);
|
||||
xwl_output_randr_emu_prop(xwl_screen, dixClientForWindow(window), &prop);
|
||||
xwl_output_set_randr_emu_prop(window, &prop);
|
||||
}
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
|
||||
#include "dix/dix_priv.h"
|
||||
#include "dix/property_priv.h"
|
||||
#include "dix/resource_priv.h"
|
||||
|
||||
#include "compositeext.h"
|
||||
#include "compint.h"
|
||||
|
@ -570,7 +571,7 @@ xwl_window_should_enable_viewport(struct xwl_window *xwl_window,
|
|||
if (!window)
|
||||
return FALSE;
|
||||
|
||||
owner = wClient(window);
|
||||
owner = dixClientForWindow(window);
|
||||
drawable = &window->drawable;
|
||||
|
||||
/* 1. Test if the window matches the emulated mode on one of the outputs
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include <xwin-config.h>
|
||||
#endif
|
||||
|
||||
#include "dix/resource_priv.h"
|
||||
#include "mi/mi_priv.h"
|
||||
|
||||
#include "win.h"
|
||||
|
@ -662,7 +663,7 @@ XID
|
|||
winGetWindowID(WindowPtr pWin)
|
||||
{
|
||||
WindowIDPairRec wi = { pWin, 0 };
|
||||
ClientPtr c = wClient(pWin);
|
||||
ClientPtr c = dixClientForWindow(pWin);
|
||||
|
||||
/* */
|
||||
FindClientResourcesByType(c, X11_RESTYPE_WINDOW, winFindWindow, &wi);
|
||||
|
@ -732,14 +733,14 @@ winReorderWindowsMultiWindow(void)
|
|||
if (!pWinSib) { /* 1st window - raise to the top */
|
||||
vlist[0] = Above;
|
||||
|
||||
ConfigureWindow(pWin, CWStackMode, vlist, wClient(pWin));
|
||||
ConfigureWindow(pWin, CWStackMode, vlist, dixClientForWindow(pWin));
|
||||
}
|
||||
else { /* 2nd or deeper windows - just below the previous one */
|
||||
vlist[0] = winGetWindowID(pWinSib);
|
||||
vlist[1] = Below;
|
||||
|
||||
ConfigureWindow(pWin, CWSibling | CWStackMode,
|
||||
vlist, wClient(pWin));
|
||||
vlist, dixClientForWindow(pWin));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -798,7 +799,7 @@ winAdjustXWindow(WindowPtr pWin, HWND hwnd)
|
|||
*/
|
||||
vlist[0] = 0;
|
||||
vlist[1] = 0;
|
||||
return ConfigureWindow(pWin, CWX | CWY, vlist, wClient(pWin));
|
||||
return ConfigureWindow(pWin, CWX | CWY, vlist, dixClientForWindow(pWin));
|
||||
}
|
||||
|
||||
pDraw = &pWin->drawable;
|
||||
|
@ -860,7 +861,7 @@ winAdjustXWindow(WindowPtr pWin, HWND hwnd)
|
|||
(unsigned int)vlist[2], (unsigned int)vlist[3]);
|
||||
#endif
|
||||
return ConfigureWindow(pWin, CWX | CWY | CWWidth | CWHeight,
|
||||
vlist, wClient(pWin));
|
||||
vlist, dixClientForWindow(pWin));
|
||||
|
||||
#undef WIDTH
|
||||
#undef HEIGHT
|
||||
|
|
|
@ -193,7 +193,6 @@ extern _X_EXPORT Mask DontPropagateMasks[];
|
|||
#define wBoundingShape(w) wUseDefault(w, boundingShape, NULL)
|
||||
#define wClipShape(w) wUseDefault(w, clipShape, NULL)
|
||||
#define wInputShape(w) wUseDefault(w, inputShape, NULL)
|
||||
#define wClient(w) (clients[CLIENT_ID((w)->drawable.id)])
|
||||
#define wBorderWidth(w) ((int) (w)->borderWidth)
|
||||
|
||||
static inline PropertyPtr wUserProps(WindowPtr pWin) { return pWin->properties; }
|
||||
|
|
Loading…
Reference in New Issue