summaryrefslogtreecommitdiff
path: root/composite
diff options
context:
space:
mode:
Diffstat (limited to 'composite')
-rw-r--r--composite/compalloc.c10
-rw-r--r--composite/compext.c57
-rw-r--r--composite/compinit.c30
-rw-r--r--composite/compint.h16
4 files changed, 57 insertions, 56 deletions
diff --git a/composite/compalloc.c b/composite/compalloc.c
index 006e80840..4666ff01f 100644
--- a/composite/compalloc.c
+++ b/composite/compalloc.c
@@ -137,7 +137,7 @@ compRedirectWindow (ClientPtr pClient, WindowPtr pWin, int update)
cw->oldy = COMP_ORIGIN_INVALID;
cw->damageRegistered = FALSE;
cw->damaged = FALSE;
- pWin->devPrivates[CompWindowPrivateIndex].ptr = cw;
+ dixSetPrivate(&pWin->devPrivates, CompWindowPrivateKey, cw);
}
ccw->next = cw->clients;
cw->clients = ccw;
@@ -212,7 +212,7 @@ compFreeClientWindow (WindowPtr pWin, XID id)
REGION_UNINIT (pScreen, &cw->borderClip);
- pWin->devPrivates[CompWindowPrivateIndex].ptr = 0;
+ dixSetPrivate(&pWin->devPrivates, CompWindowPrivateKey, NULL);
xfree (cw);
}
else if (cw->update == CompositeRedirectAutomatic &&
@@ -297,7 +297,7 @@ compRedirectSubwindows (ClientPtr pClient, WindowPtr pWin, int update)
}
csw->update = CompositeRedirectAutomatic;
csw->clients = 0;
- pWin->devPrivates[CompSubwindowsPrivateIndex].ptr = csw;
+ dixSetPrivate(&pWin->devPrivates, CompSubwindowsPrivateKey, csw);
}
/*
* Redirect all existing windows
@@ -312,7 +312,7 @@ compRedirectSubwindows (ClientPtr pClient, WindowPtr pWin, int update)
if (!csw->clients)
{
xfree (csw);
- pWin->devPrivates[CompSubwindowsPrivateIndex].ptr = 0;
+ dixSetPrivate(&pWin->devPrivates, CompSubwindowsPrivateKey, 0);
}
xfree (ccw);
return ret;
@@ -385,7 +385,7 @@ compFreeClientSubwindows (WindowPtr pWin, XID id)
*/
if (!csw->clients)
{
- pWin->devPrivates[CompSubwindowsPrivateIndex].ptr = 0;
+ dixSetPrivate(&pWin->devPrivates, CompSubwindowsPrivateKey, NULL);
xfree (csw);
}
}
diff --git a/composite/compext.c b/composite/compext.c
index ece51d099..2918556f8 100644
--- a/composite/compext.c
+++ b/composite/compext.c
@@ -45,12 +45,13 @@
#endif
#include "compint.h"
+#include "xace.h"
#define SERVER_COMPOSITE_MAJOR 0
#define SERVER_COMPOSITE_MINOR 4
static CARD8 CompositeReqCode;
-static int CompositeClientPrivateIndex;
+static DevPrivateKey CompositeClientPrivateKey = &CompositeClientPrivateKey;
RESTYPE CompositeClientWindowType;
RESTYPE CompositeClientSubwindowsType;
static RESTYPE CompositeClientOverlayType;
@@ -63,7 +64,8 @@ typedef struct _CompositeClient {
int minor_version;
} CompositeClientRec, *CompositeClientPtr;
-#define GetCompositeClient(pClient) ((CompositeClientPtr) (pClient)->devPrivates[CompositeClientPrivateIndex].ptr)
+#define GetCompositeClient(pClient) ((CompositeClientPtr) \
+ dixLookupPrivate(&(pClient)->devPrivates, CompositeClientPrivateKey))
static void
CompositeClientCallback (CallbackListPtr *list,
@@ -156,14 +158,16 @@ static int
ProcCompositeRedirectWindow (ClientPtr client)
{
WindowPtr pWin;
+ int rc;
REQUEST(xCompositeRedirectWindowReq);
REQUEST_SIZE_MATCH(xCompositeRedirectWindowReq);
- pWin = (WindowPtr) LookupIDByType (stuff->window, RT_WINDOW);
- if (!pWin)
+ rc = dixLookupResource((pointer *)&pWin, stuff->window, RT_WINDOW, client,
+ DixSetAttrAccess|DixManageAccess|DixBlendAccess);
+ if (rc != Success)
{
client->errorValue = stuff->window;
- return BadWindow;
+ return (rc == BadValue) ? BadWindow : rc;
}
return compRedirectWindow (client, pWin, stuff->update);
}
@@ -172,14 +176,16 @@ static int
ProcCompositeRedirectSubwindows (ClientPtr client)
{
WindowPtr pWin;
+ int rc;
REQUEST(xCompositeRedirectSubwindowsReq);
REQUEST_SIZE_MATCH(xCompositeRedirectSubwindowsReq);
- pWin = (WindowPtr) LookupIDByType (stuff->window, RT_WINDOW);
- if (!pWin)
+ rc = dixLookupResource((pointer *)&pWin, stuff->window, RT_WINDOW, client,
+ DixSetAttrAccess|DixManageAccess|DixBlendAccess);
+ if (rc != Success)
{
client->errorValue = stuff->window;
- return BadWindow;
+ return (rc == BadValue) ? BadWindow : rc;
}
return compRedirectSubwindows (client, pWin, stuff->update);
}
@@ -222,14 +228,16 @@ ProcCompositeCreateRegionFromBorderClip (ClientPtr client)
WindowPtr pWin;
CompWindowPtr cw;
RegionPtr pBorderClip, pRegion;
+ int rc;
REQUEST(xCompositeCreateRegionFromBorderClipReq);
REQUEST_SIZE_MATCH(xCompositeCreateRegionFromBorderClipReq);
- pWin = (WindowPtr) LookupIDByType (stuff->window, RT_WINDOW);
- if (!pWin)
+ rc = dixLookupResource((pointer *)&pWin, stuff->window, RT_WINDOW, client,
+ DixGetAttrAccess);
+ if (rc != Success)
{
client->errorValue = stuff->window;
- return BadWindow;
+ return (rc == BadValue) ? BadWindow : rc;
}
LEGAL_NEW_RESOURCE (stuff->region, client);
@@ -256,14 +264,16 @@ ProcCompositeNameWindowPixmap (ClientPtr client)
WindowPtr pWin;
CompWindowPtr cw;
PixmapPtr pPixmap;
+ int rc;
REQUEST(xCompositeNameWindowPixmapReq);
REQUEST_SIZE_MATCH(xCompositeNameWindowPixmapReq);
- pWin = (WindowPtr) LookupIDByType (stuff->window, RT_WINDOW);
- if (!pWin)
+ rc = dixLookupResource((pointer *)&pWin, stuff->window, RT_WINDOW, client,
+ DixGetAttrAccess);
+ if (rc != Success)
{
client->errorValue = stuff->window;
- return BadWindow;
+ return (rc == BadValue) ? BadWindow : rc;
}
if (!pWin->viewable)
@@ -428,13 +438,15 @@ ProcCompositeGetOverlayWindow (ClientPtr client)
ScreenPtr pScreen;
CompScreenPtr cs;
CompOverlayClientPtr pOc;
+ int rc;
REQUEST_SIZE_MATCH(xCompositeGetOverlayWindowReq);
- pWin = (WindowPtr) LookupIDByType (stuff->window, RT_WINDOW);
- if (!pWin)
+ rc = dixLookupResource((pointer *)&pWin, stuff->window, RT_WINDOW, client,
+ DixGetAttrAccess);
+ if (rc != Success)
{
client->errorValue = stuff->window;
- return BadWindow;
+ return (rc == BadValue) ? BadWindow : rc;
}
pScreen = pWin->drawable.pScreen;
@@ -445,6 +457,12 @@ ProcCompositeGetOverlayWindow (ClientPtr client)
return BadAlloc;
}
}
+
+ rc = XaceHook(XACE_RESOURCE_ACCESS, client, cs->pOverlayWin->drawable.id,
+ RT_WINDOW, cs->pOverlayWin, RT_NONE, NULL, DixGetAttrAccess);
+ if (rc != Success)
+ return rc;
+
MapWindow(cs->pOverlayWin, serverClient);
/* Record that client is using this overlay window */
@@ -715,9 +733,8 @@ CompositeExtensionInit (void)
if (!CompositeClientOverlayType)
return;
- CompositeClientPrivateIndex = AllocateClientPrivateIndex ();
- if (!AllocateClientPrivate (CompositeClientPrivateIndex,
- sizeof (CompositeClientRec)))
+ if (!dixRequestPrivate(CompositeClientPrivateKey,
+ sizeof(CompositeClientRec)))
return;
if (!AddCallback (&ClientStateCallback, CompositeClientCallback, 0))
return;
diff --git a/composite/compinit.c b/composite/compinit.c
index 5f09fe2a4..49b2044b0 100644
--- a/composite/compinit.c
+++ b/composite/compinit.c
@@ -46,10 +46,9 @@
#include "compint.h"
-int CompScreenPrivateIndex;
-int CompWindowPrivateIndex;
-int CompSubwindowsPrivateIndex;
-static int CompGeneration;
+DevPrivateKey CompScreenPrivateKey = &CompScreenPrivateKey;
+DevPrivateKey CompWindowPrivateKey = &CompWindowPrivateKey;
+DevPrivateKey CompSubwindowsPrivateKey = &CompSubwindowsPrivateKey;
static Bool
@@ -86,7 +85,7 @@ compCloseScreen (int index, ScreenPtr pScreen)
cs->pOverlayWin = NULL;
xfree (cs);
- pScreen->devPrivates[CompScreenPrivateIndex].ptr = 0;
+ dixSetPrivate(&pScreen->devPrivates, CompScreenPrivateKey, NULL);
ret = (*pScreen->CloseScreen) (index, pScreen);
return ret;
@@ -374,25 +373,6 @@ compScreenInit (ScreenPtr pScreen)
{
CompScreenPtr cs;
- if (CompGeneration != serverGeneration)
- {
- CompScreenPrivateIndex = AllocateScreenPrivateIndex ();
- if (CompScreenPrivateIndex == -1)
- return FALSE;
- CompWindowPrivateIndex = AllocateWindowPrivateIndex ();
- if (CompWindowPrivateIndex == -1)
- return FALSE;
- CompSubwindowsPrivateIndex = AllocateWindowPrivateIndex ();
- if (CompSubwindowsPrivateIndex == -1)
- return FALSE;
- CompGeneration = serverGeneration;
- }
- if (!AllocateWindowPrivate (pScreen, CompWindowPrivateIndex, 0))
- return FALSE;
-
- if (!AllocateWindowPrivate (pScreen, CompSubwindowsPrivateIndex, 0))
- return FALSE;
-
if (GetCompScreen (pScreen))
return TRUE;
cs = (CompScreenPtr) xalloc (sizeof (CompScreenRec));
@@ -457,7 +437,7 @@ compScreenInit (ScreenPtr pScreen)
cs->CloseScreen = pScreen->CloseScreen;
pScreen->CloseScreen = compCloseScreen;
- pScreen->devPrivates[CompScreenPrivateIndex].ptr = (pointer) cs;
+ dixSetPrivate(&pScreen->devPrivates, CompScreenPrivateKey, cs);
RegisterRealChildHeadProc(CompositeRealChildHead);
diff --git a/composite/compint.h b/composite/compint.h
index 535e1a423..4b0fe0834 100644
--- a/composite/compint.h
+++ b/composite/compint.h
@@ -64,6 +64,7 @@
#include "globals.h"
#include "picturestr.h"
#include "extnsionst.h"
+#include "privates.h"
#include "mi.h"
#include "damage.h"
#include "damageextint.h"
@@ -158,13 +159,16 @@ typedef struct _CompScreen {
} CompScreenRec, *CompScreenPtr;
-extern int CompScreenPrivateIndex;
-extern int CompWindowPrivateIndex;
-extern int CompSubwindowsPrivateIndex;
+extern DevPrivateKey CompScreenPrivateKey;
+extern DevPrivateKey CompWindowPrivateKey;
+extern DevPrivateKey CompSubwindowsPrivateKey;
-#define GetCompScreen(s) ((CompScreenPtr) ((s)->devPrivates[CompScreenPrivateIndex].ptr))
-#define GetCompWindow(w) ((CompWindowPtr) ((w)->devPrivates[CompWindowPrivateIndex].ptr))
-#define GetCompSubwindows(w) ((CompSubwindowsPtr) ((w)->devPrivates[CompSubwindowsPrivateIndex].ptr))
+#define GetCompScreen(s) ((CompScreenPtr) \
+ dixLookupPrivate(&(s)->devPrivates, CompScreenPrivateKey))
+#define GetCompWindow(w) ((CompWindowPtr) \
+ dixLookupPrivate(&(w)->devPrivates, CompWindowPrivateKey))
+#define GetCompSubwindows(w) ((CompSubwindowsPtr) \
+ dixLookupPrivate(&(w)->devPrivates, CompSubwindowsPrivateKey))
extern RESTYPE CompositeClientWindowType;
extern RESTYPE CompositeClientSubwindowsType;