mirror of
https://github.com/X11Libre/xserver.git
synced 2026-03-26 19:04:50 +00:00
dix: lookup function for WindowPtr by XID
This new lookup function retrieves a pointer to WindowRec structure by associated XID. Unlike dixLookupWindow(), this one works globally, instead of just on one specific client, and it doesn't do any XACE calls. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
@@ -807,4 +807,15 @@ static inline void SwapLongs(CARD32 *list, unsigned long count) {
|
||||
#define SwapRestL(stuff) \
|
||||
SwapLongs((CARD32 *)(stuff + 1), (client->req_len - (sizeof(*stuff) >> 2)))
|
||||
|
||||
/*
|
||||
* @brief lookup window by XID
|
||||
*
|
||||
* This globally looks for Window with given XID (all screens, all clients)
|
||||
* and returns a pointer to it. If not found, returns NULL.
|
||||
*
|
||||
* Unlike ::dixLookupWindow() it doesn't scan only one given client, nor does
|
||||
* it do any XACE calls.
|
||||
*/
|
||||
WindowPtr dixLookupWindowByXID(Window window);
|
||||
|
||||
#endif /* _XSERVER_DIX_PRIV_H */
|
||||
|
||||
32
dix/lookup.c
32
dix/lookup.c
@@ -39,3 +39,35 @@ ClientPtr dixClientForOtherClients(OtherClientsPtr pOtherClients) {
|
||||
|
||||
return dixClientForXID(pOtherClients->resource);
|
||||
}
|
||||
|
||||
struct window_xid_match {
|
||||
WindowPtr pWin;
|
||||
Window id;
|
||||
};
|
||||
|
||||
static int dix_match_window_xid(WindowPtr pWin, void *ptr)
|
||||
{
|
||||
struct window_xid_match *walk = (struct window_xid_match*) ptr;
|
||||
|
||||
if (walk->id == pWin->drawable.id) {
|
||||
walk->pWin = pWin;
|
||||
return WT_STOPWALKING;
|
||||
}
|
||||
else
|
||||
return WT_WALKCHILDREN;
|
||||
}
|
||||
|
||||
WindowPtr dixLookupWindowByXID(Window window)
|
||||
{
|
||||
struct window_xid_match walk = {
|
||||
.id = window,
|
||||
};
|
||||
|
||||
for (int i = 0; i < screenInfo.numScreens; i++) {
|
||||
WalkTree(screenInfo.screens[i], dix_match_window_xid, &walk);
|
||||
if (walk.pWin)
|
||||
break;
|
||||
}
|
||||
|
||||
return walk.pWin;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user