diff options
author | Kristian Høgsberg <krh@redhat.com> | 2009-04-14 16:21:04 -0400 |
---|---|---|
committer | Kristian Høgsberg <krh@redhat.com> | 2009-04-14 16:21:04 -0400 |
commit | 4a27618565f3151ab17f0ca9ecbde12fa7ba13c0 (patch) | |
tree | a6b92a85416718a7292b1788a86e2a319536e91f /composite/compext.c | |
parent | e7785e8af3e34f9d1089d8499d16802984ab9823 (diff) |
composite: Fix resource lookups
Diffstat (limited to 'composite/compext.c')
-rw-r--r-- | composite/compext.c | 87 |
1 files changed, 30 insertions, 57 deletions
diff --git a/composite/compext.c b/composite/compext.c index 4fff20efa..829c90fbf 100644 --- a/composite/compext.c +++ b/composite/compext.c @@ -136,21 +136,30 @@ ProcCompositeQueryVersion (ClientPtr client) return(client->noClientException); } +#define VERIFY_WINDOW(pWindow, wid, client, mode) \ + do { \ + int err; \ + err = dixLookupResourceByType((pointer *) &pWindow, wid, \ + RT_WINDOW, client, mode); \ + if (err == BadValue) { \ + client->errorValue = wid; \ + return BadWindow; \ + } else if (err != Success) { \ + client->errorValue = wid; \ + return err; \ + } \ + } while (0) + static int ProcCompositeRedirectWindow (ClientPtr client) { WindowPtr pWin; - int rc; REQUEST(xCompositeRedirectWindowReq); REQUEST_SIZE_MATCH(xCompositeRedirectWindowReq); - rc = dixLookupResourceByType((pointer *)&pWin, stuff->window, RT_WINDOW, client, - DixSetAttrAccess|DixManageAccess|DixBlendAccess); - if (rc != Success) - { - client->errorValue = stuff->window; - return (rc == BadValue) ? BadWindow : rc; - } + VERIFY_WINDOW(pWin, stuff->window, client, + DixSetAttrAccess|DixManageAccess|DixBlendAccess); + return compRedirectWindow (client, pWin, stuff->update); } @@ -158,17 +167,12 @@ static int ProcCompositeRedirectSubwindows (ClientPtr client) { WindowPtr pWin; - int rc; REQUEST(xCompositeRedirectSubwindowsReq); REQUEST_SIZE_MATCH(xCompositeRedirectSubwindowsReq); - rc = dixLookupResourceByType((pointer *)&pWin, stuff->window, RT_WINDOW, client, - DixSetAttrAccess|DixManageAccess|DixBlendAccess); - if (rc != Success) - { - client->errorValue = stuff->window; - return (rc == BadValue) ? BadWindow : rc; - } + VERIFY_WINDOW(pWin, stuff->window, client, + DixSetAttrAccess|DixManageAccess|DixBlendAccess); + return compRedirectSubwindows (client, pWin, stuff->update); } @@ -179,12 +183,9 @@ ProcCompositeUnredirectWindow (ClientPtr client) REQUEST(xCompositeUnredirectWindowReq); REQUEST_SIZE_MATCH(xCompositeUnredirectWindowReq); - pWin = (WindowPtr) LookupIDByType (stuff->window, RT_WINDOW); - if (!pWin) - { - client->errorValue = stuff->window; - return BadWindow; - } + VERIFY_WINDOW(pWin, stuff->window, client, + DixSetAttrAccess|DixManageAccess|DixBlendAccess); + return compUnredirectWindow (client, pWin, stuff->update); } @@ -195,12 +196,9 @@ ProcCompositeUnredirectSubwindows (ClientPtr client) REQUEST(xCompositeUnredirectSubwindowsReq); REQUEST_SIZE_MATCH(xCompositeUnredirectSubwindowsReq); - pWin = (WindowPtr) LookupIDByType (stuff->window, RT_WINDOW); - if (!pWin) - { - client->errorValue = stuff->window; - return BadWindow; - } + VERIFY_WINDOW(pWin, stuff->window, client, + DixSetAttrAccess|DixManageAccess|DixBlendAccess); + return compUnredirectSubwindows (client, pWin, stuff->update); } @@ -210,18 +208,10 @@ ProcCompositeCreateRegionFromBorderClip (ClientPtr client) WindowPtr pWin; CompWindowPtr cw; RegionPtr pBorderClip, pRegion; - int rc; REQUEST(xCompositeCreateRegionFromBorderClipReq); REQUEST_SIZE_MATCH(xCompositeCreateRegionFromBorderClipReq); - rc = dixLookupResourceByType((pointer *)&pWin, stuff->window, RT_WINDOW, client, - DixGetAttrAccess); - if (rc != Success) - { - client->errorValue = stuff->window; - return (rc == BadValue) ? BadWindow : rc; - } - + VERIFY_WINDOW(pWin, stuff->window, client, DixGetAttrAccess); LEGAL_NEW_RESOURCE (stuff->region, client); cw = GetCompWindow (pWin); @@ -250,13 +240,7 @@ ProcCompositeNameWindowPixmap (ClientPtr client) REQUEST(xCompositeNameWindowPixmapReq); REQUEST_SIZE_MATCH(xCompositeNameWindowPixmapReq); - rc = dixLookupResourceByType((pointer *)&pWin, stuff->window, RT_WINDOW, client, - DixGetAttrAccess); - if (rc != Success) - { - client->errorValue = stuff->window; - return (rc == BadValue) ? BadWindow : rc; - } + VERIFY_WINDOW(pWin, stuff->window, client, DixGetAttrAccess); if (!pWin->viewable) return BadMatch; @@ -298,13 +282,7 @@ ProcCompositeGetOverlayWindow (ClientPtr client) int rc; REQUEST_SIZE_MATCH(xCompositeGetOverlayWindowReq); - rc = dixLookupResourceByType((pointer *)&pWin, stuff->window, RT_WINDOW, client, - DixGetAttrAccess); - if (rc != Success) - { - client->errorValue = stuff->window; - return (rc == BadValue) ? BadWindow : rc; - } + VERIFY_WINDOW(pWin, stuff->window, client, DixGetAttrAccess); pScreen = pWin->drawable.pScreen; /* @@ -360,12 +338,7 @@ ProcCompositeReleaseOverlayWindow (ClientPtr client) CompOverlayClientPtr pOc; REQUEST_SIZE_MATCH(xCompositeReleaseOverlayWindowReq); - pWin = (WindowPtr) LookupIDByType (stuff->window, RT_WINDOW); - if (!pWin) - { - client->errorValue = stuff->window; - return BadWindow; - } + VERIFY_WINDOW(pWin, stuff->window, client, DixGetAttrAccess); pScreen = pWin->drawable.pScreen; /* |