xenocara/xserver/composite/compext.c

915 lines
26 KiB
C
Raw Normal View History

2006-11-26 11:13:41 -07:00
/*
2011-11-05 07:32:40 -06:00
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
2006-11-26 11:13:41 -07:00
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
2006-11-26 11:13:41 -07:00
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
2006-11-26 11:13:41 -07:00
*
* Copyright © 2003 Keith Packard
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of Keith Packard not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Keith Packard makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include "compint.h"
#include "xace.h"
#include "protocol-versions.h"
2007-11-24 10:55:21 -07:00
static CARD8 CompositeReqCode;
static DevPrivateKeyRec CompositeClientPrivateKeyRec;
#define CompositeClientPrivateKey (&CompositeClientPrivateKeyRec)
RESTYPE CompositeClientWindowType;
RESTYPE CompositeClientSubwindowsType;
RESTYPE CompositeClientOverlayType;
2006-11-26 11:13:41 -07:00
typedef struct _CompositeClient {
int major_version;
int minor_version;
2006-11-26 11:13:41 -07:00
} CompositeClientRec, *CompositeClientPtr;
#define GetCompositeClient(pClient) ((CompositeClientPtr) \
dixLookupPrivate(&(pClient)->devPrivates, CompositeClientPrivateKey))
2006-11-26 11:13:41 -07:00
static void
CompositeClientCallback(CallbackListPtr *list, pointer closure, pointer data)
2006-11-26 11:13:41 -07:00
{
NewClientInfoRec *clientinfo = (NewClientInfoRec *) data;
ClientPtr pClient = clientinfo->client;
CompositeClientPtr pCompositeClient = GetCompositeClient(pClient);
2006-11-26 11:13:41 -07:00
pCompositeClient->major_version = 0;
pCompositeClient->minor_version = 0;
}
static int
FreeCompositeClientWindow(pointer value, XID ccwid)
2006-11-26 11:13:41 -07:00
{
WindowPtr pWin = value;
2006-11-26 11:13:41 -07:00
compFreeClientWindow(pWin, ccwid);
2006-11-26 11:13:41 -07:00
return Success;
}
static int
FreeCompositeClientSubwindows(pointer value, XID ccwid)
2006-11-26 11:13:41 -07:00
{
WindowPtr pWin = value;
2006-11-26 11:13:41 -07:00
compFreeClientSubwindows(pWin, ccwid);
2006-11-26 11:13:41 -07:00
return Success;
}
static int
FreeCompositeClientOverlay(pointer value, XID ccwid)
2006-11-26 11:13:41 -07:00
{
CompOverlayClientPtr pOc = (CompOverlayClientPtr) value;
compFreeOverlayClient(pOc);
2006-11-26 11:13:41 -07:00
return Success;
}
static int
ProcCompositeQueryVersion(ClientPtr client)
2006-11-26 11:13:41 -07:00
{
CompositeClientPtr pCompositeClient = GetCompositeClient(client);
2006-11-26 11:13:41 -07:00
xCompositeQueryVersionReply rep;
2006-11-26 11:13:41 -07:00
REQUEST(xCompositeQueryVersionReq);
REQUEST_SIZE_MATCH(xCompositeQueryVersionReq);
rep.type = X_Reply;
rep.length = 0;
rep.sequenceNumber = client->sequence;
if (stuff->majorVersion < SERVER_COMPOSITE_MAJOR_VERSION) {
rep.majorVersion = stuff->majorVersion;
rep.minorVersion = stuff->minorVersion;
}
else {
rep.majorVersion = SERVER_COMPOSITE_MAJOR_VERSION;
rep.minorVersion = SERVER_COMPOSITE_MINOR_VERSION;
2006-11-26 11:13:41 -07:00
}
pCompositeClient->major_version = rep.majorVersion;
pCompositeClient->minor_version = rep.minorVersion;
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swapl(&rep.majorVersion);
swapl(&rep.minorVersion);
2006-11-26 11:13:41 -07:00
}
WriteToClient(client, sizeof(xCompositeQueryVersionReply), (char *) &rep);
return Success;
2006-11-26 11:13:41 -07:00
}
#define VERIFY_WINDOW(pWindow, wid, client, mode) \
do { \
int err; \
err = dixLookupResourceByType((pointer *) &pWindow, wid, \
RT_WINDOW, client, mode); \
if (err != Success) { \
client->errorValue = wid; \
return err; \
} \
} while (0)
2006-11-26 11:13:41 -07:00
static int
ProcCompositeRedirectWindow(ClientPtr client)
2006-11-26 11:13:41 -07:00
{
WindowPtr pWin;
2006-11-26 11:13:41 -07:00
REQUEST(xCompositeRedirectWindowReq);
REQUEST_SIZE_MATCH(xCompositeRedirectWindowReq);
VERIFY_WINDOW(pWin, stuff->window, client,
DixSetAttrAccess | DixManageAccess | DixBlendAccess);
return compRedirectWindow(client, pWin, stuff->update);
2006-11-26 11:13:41 -07:00
}
static int
ProcCompositeRedirectSubwindows(ClientPtr client)
2006-11-26 11:13:41 -07:00
{
WindowPtr pWin;
2006-11-26 11:13:41 -07:00
REQUEST(xCompositeRedirectSubwindowsReq);
REQUEST_SIZE_MATCH(xCompositeRedirectSubwindowsReq);
VERIFY_WINDOW(pWin, stuff->window, client,
DixSetAttrAccess | DixManageAccess | DixBlendAccess);
return compRedirectSubwindows(client, pWin, stuff->update);
2006-11-26 11:13:41 -07:00
}
static int
ProcCompositeUnredirectWindow(ClientPtr client)
2006-11-26 11:13:41 -07:00
{
WindowPtr pWin;
2006-11-26 11:13:41 -07:00
REQUEST(xCompositeUnredirectWindowReq);
REQUEST_SIZE_MATCH(xCompositeUnredirectWindowReq);
VERIFY_WINDOW(pWin, stuff->window, client,
DixSetAttrAccess | DixManageAccess | DixBlendAccess);
return compUnredirectWindow(client, pWin, stuff->update);
2006-11-26 11:13:41 -07:00
}
static int
ProcCompositeUnredirectSubwindows(ClientPtr client)
2006-11-26 11:13:41 -07:00
{
WindowPtr pWin;
2006-11-26 11:13:41 -07:00
REQUEST(xCompositeUnredirectSubwindowsReq);
REQUEST_SIZE_MATCH(xCompositeUnredirectSubwindowsReq);
VERIFY_WINDOW(pWin, stuff->window, client,
DixSetAttrAccess | DixManageAccess | DixBlendAccess);
return compUnredirectSubwindows(client, pWin, stuff->update);
2006-11-26 11:13:41 -07:00
}
static int
ProcCompositeCreateRegionFromBorderClip(ClientPtr client)
2006-11-26 11:13:41 -07:00
{
WindowPtr pWin;
CompWindowPtr cw;
RegionPtr pBorderClip, pRegion;
2006-11-26 11:13:41 -07:00
REQUEST(xCompositeCreateRegionFromBorderClipReq);
REQUEST_SIZE_MATCH(xCompositeCreateRegionFromBorderClipReq);
VERIFY_WINDOW(pWin, stuff->window, client, DixGetAttrAccess);
LEGAL_NEW_RESOURCE(stuff->region, client);
cw = GetCompWindow(pWin);
2006-11-26 11:13:41 -07:00
if (cw)
pBorderClip = &cw->borderClip;
2006-11-26 11:13:41 -07:00
else
pBorderClip = &pWin->borderClip;
pRegion = XFixesRegionCopy(pBorderClip);
2006-11-26 11:13:41 -07:00
if (!pRegion)
return BadAlloc;
RegionTranslate(pRegion, -pWin->drawable.x, -pWin->drawable.y);
if (!AddResource(stuff->region, RegionResType, (pointer) pRegion))
return BadAlloc;
2006-11-26 11:13:41 -07:00
return Success;
2006-11-26 11:13:41 -07:00
}
static int
ProcCompositeNameWindowPixmap(ClientPtr client)
2006-11-26 11:13:41 -07:00
{
WindowPtr pWin;
CompWindowPtr cw;
PixmapPtr pPixmap;
int rc;
2006-11-26 11:13:41 -07:00
REQUEST(xCompositeNameWindowPixmapReq);
REQUEST_SIZE_MATCH(xCompositeNameWindowPixmapReq);
VERIFY_WINDOW(pWin, stuff->window, client, DixGetAttrAccess);
if (!pWin->viewable)
return BadMatch;
LEGAL_NEW_RESOURCE(stuff->pixmap, client);
cw = GetCompWindow(pWin);
2006-11-26 11:13:41 -07:00
if (!cw)
return BadMatch;
2006-11-26 11:13:41 -07:00
pPixmap = (*pWin->drawable.pScreen->GetWindowPixmap) (pWin);
if (!pPixmap)
return BadMatch;
2006-11-26 11:13:41 -07:00
/* security creation/labeling check */
rc = XaceHook(XACE_RESOURCE_ACCESS, client, stuff->pixmap, RT_PIXMAP,
pPixmap, RT_WINDOW, pWin, DixCreateAccess);
if (rc != Success)
return rc;
2006-11-26 11:13:41 -07:00
++pPixmap->refcnt;
if (!AddResource(stuff->pixmap, RT_PIXMAP, (pointer) pPixmap))
return BadAlloc;
2006-11-26 11:13:41 -07:00
return Success;
2006-11-26 11:13:41 -07:00
}
2007-11-24 10:55:21 -07:00
static int
ProcCompositeGetOverlayWindow(ClientPtr client)
2006-11-26 11:13:41 -07:00
{
REQUEST(xCompositeGetOverlayWindowReq);
2006-11-26 11:13:41 -07:00
xCompositeGetOverlayWindowReply rep;
WindowPtr pWin;
ScreenPtr pScreen;
CompScreenPtr cs;
CompOverlayClientPtr pOc;
int rc;
2006-11-26 11:13:41 -07:00
REQUEST_SIZE_MATCH(xCompositeGetOverlayWindowReq);
VERIFY_WINDOW(pWin, stuff->window, client, DixGetAttrAccess);
2006-11-26 11:13:41 -07:00
pScreen = pWin->drawable.pScreen;
/*
* Create an OverlayClient structure to mark this client's
* interest in the overlay window
*/
pOc = compCreateOverlayClient(pScreen, client);
if (pOc == NULL)
return BadAlloc;
/*
* Make sure the overlay window exists
*/
2006-11-26 11:13:41 -07:00
cs = GetCompScreen(pScreen);
if (cs->pOverlayWin == NULL)
if (!compCreateOverlayWindow(pScreen)) {
FreeResource(pOc->resource, RT_NONE);
return BadAlloc;
}
rc = XaceHook(XACE_RESOURCE_ACCESS, client, cs->pOverlayWin->drawable.id,
RT_WINDOW, cs->pOverlayWin, RT_NONE, NULL, DixGetAttrAccess);
if (rc != Success) {
FreeResource(pOc->resource, RT_NONE);
return rc;
2006-11-26 11:13:41 -07:00
}
rep.type = X_Reply;
rep.sequenceNumber = client->sequence;
rep.length = 0;
rep.overlayWin = cs->pOverlayWin->drawable.id;
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swapl(&rep.overlayWin);
2006-11-26 11:13:41 -07:00
}
(void) WriteToClient(client, sz_xCompositeGetOverlayWindowReply,
(char *) &rep);
2006-11-26 11:13:41 -07:00
return Success;
2006-11-26 11:13:41 -07:00
}
2007-11-24 10:55:21 -07:00
static int
ProcCompositeReleaseOverlayWindow(ClientPtr client)
2006-11-26 11:13:41 -07:00
{
REQUEST(xCompositeReleaseOverlayWindowReq);
2006-11-26 11:13:41 -07:00
WindowPtr pWin;
ScreenPtr pScreen;
CompOverlayClientPtr pOc;
REQUEST_SIZE_MATCH(xCompositeReleaseOverlayWindowReq);
VERIFY_WINDOW(pWin, stuff->window, client, DixGetAttrAccess);
2006-11-26 11:13:41 -07:00
pScreen = pWin->drawable.pScreen;
/*
* Has client queried a reference to the overlay window
* on this screen? If not, generate an error.
*/
pOc = compFindOverlayClient(pWin->drawable.pScreen, client);
if (pOc == NULL)
return BadMatch;
2006-11-26 11:13:41 -07:00
/* The delete function will free the client structure */
FreeResource(pOc->resource, RT_NONE);
2006-11-26 11:13:41 -07:00
return Success;
2006-11-26 11:13:41 -07:00
}
static int (*ProcCompositeVector[CompositeNumberRequests]) (ClientPtr) = {
ProcCompositeQueryVersion,
ProcCompositeRedirectWindow,
ProcCompositeRedirectSubwindows,
ProcCompositeUnredirectWindow,
ProcCompositeUnredirectSubwindows,
ProcCompositeCreateRegionFromBorderClip,
ProcCompositeNameWindowPixmap,
ProcCompositeGetOverlayWindow, ProcCompositeReleaseOverlayWindow,};
2006-11-26 11:13:41 -07:00
static int
ProcCompositeDispatch(ClientPtr client)
2006-11-26 11:13:41 -07:00
{
REQUEST(xReq);
2006-11-26 11:13:41 -07:00
if (stuff->data < CompositeNumberRequests)
return (*ProcCompositeVector[stuff->data]) (client);
2006-11-26 11:13:41 -07:00
else
return BadRequest;
2006-11-26 11:13:41 -07:00
}
static int
SProcCompositeQueryVersion(ClientPtr client)
2006-11-26 11:13:41 -07:00
{
REQUEST(xCompositeQueryVersionReq);
swaps(&stuff->length);
2006-11-26 11:13:41 -07:00
REQUEST_SIZE_MATCH(xCompositeQueryVersionReq);
swapl(&stuff->majorVersion);
swapl(&stuff->minorVersion);
2006-11-26 11:13:41 -07:00
return (*ProcCompositeVector[stuff->compositeReqType]) (client);
}
static int
SProcCompositeRedirectWindow(ClientPtr client)
2006-11-26 11:13:41 -07:00
{
REQUEST(xCompositeRedirectWindowReq);
swaps(&stuff->length);
2006-11-26 11:13:41 -07:00
REQUEST_SIZE_MATCH(xCompositeRedirectWindowReq);
swapl(&stuff->window);
2006-11-26 11:13:41 -07:00
return (*ProcCompositeVector[stuff->compositeReqType]) (client);
}
static int
SProcCompositeRedirectSubwindows(ClientPtr client)
2006-11-26 11:13:41 -07:00
{
REQUEST(xCompositeRedirectSubwindowsReq);
swaps(&stuff->length);
2006-11-26 11:13:41 -07:00
REQUEST_SIZE_MATCH(xCompositeRedirectSubwindowsReq);
swapl(&stuff->window);
2006-11-26 11:13:41 -07:00
return (*ProcCompositeVector[stuff->compositeReqType]) (client);
}
static int
SProcCompositeUnredirectWindow(ClientPtr client)
2006-11-26 11:13:41 -07:00
{
REQUEST(xCompositeUnredirectWindowReq);
swaps(&stuff->length);
2006-11-26 11:13:41 -07:00
REQUEST_SIZE_MATCH(xCompositeUnredirectWindowReq);
swapl(&stuff->window);
2006-11-26 11:13:41 -07:00
return (*ProcCompositeVector[stuff->compositeReqType]) (client);
}
static int
SProcCompositeUnredirectSubwindows(ClientPtr client)
2006-11-26 11:13:41 -07:00
{
REQUEST(xCompositeUnredirectSubwindowsReq);
swaps(&stuff->length);
2006-11-26 11:13:41 -07:00
REQUEST_SIZE_MATCH(xCompositeUnredirectSubwindowsReq);
swapl(&stuff->window);
2006-11-26 11:13:41 -07:00
return (*ProcCompositeVector[stuff->compositeReqType]) (client);
}
static int
SProcCompositeCreateRegionFromBorderClip(ClientPtr client)
2006-11-26 11:13:41 -07:00
{
REQUEST(xCompositeCreateRegionFromBorderClipReq);
swaps(&stuff->length);
2006-11-26 11:13:41 -07:00
REQUEST_SIZE_MATCH(xCompositeCreateRegionFromBorderClipReq);
swapl(&stuff->region);
swapl(&stuff->window);
2006-11-26 11:13:41 -07:00
return (*ProcCompositeVector[stuff->compositeReqType]) (client);
}
static int
SProcCompositeNameWindowPixmap(ClientPtr client)
2006-11-26 11:13:41 -07:00
{
REQUEST(xCompositeNameWindowPixmapReq);
swaps(&stuff->length);
2006-11-26 11:13:41 -07:00
REQUEST_SIZE_MATCH(xCompositeNameWindowPixmapReq);
swapl(&stuff->window);
swapl(&stuff->pixmap);
2006-11-26 11:13:41 -07:00
return (*ProcCompositeVector[stuff->compositeReqType]) (client);
}
2007-11-24 10:55:21 -07:00
static int
SProcCompositeGetOverlayWindow(ClientPtr client)
2006-11-26 11:13:41 -07:00
{
REQUEST(xCompositeGetOverlayWindowReq);
swaps(&stuff->length);
2006-11-26 11:13:41 -07:00
REQUEST_SIZE_MATCH(xCompositeGetOverlayWindowReq);
swapl(&stuff->window);
2006-11-26 11:13:41 -07:00
return (*ProcCompositeVector[stuff->compositeReqType]) (client);
}
2007-11-24 10:55:21 -07:00
static int
SProcCompositeReleaseOverlayWindow(ClientPtr client)
2006-11-26 11:13:41 -07:00
{
REQUEST(xCompositeReleaseOverlayWindowReq);
swaps(&stuff->length);
2006-11-26 11:13:41 -07:00
REQUEST_SIZE_MATCH(xCompositeReleaseOverlayWindowReq);
swapl(&stuff->window);
2006-11-26 11:13:41 -07:00
return (*ProcCompositeVector[stuff->compositeReqType]) (client);
}
static int (*SProcCompositeVector[CompositeNumberRequests]) (ClientPtr) = {
SProcCompositeQueryVersion,
SProcCompositeRedirectWindow,
SProcCompositeRedirectSubwindows,
SProcCompositeUnredirectWindow,
SProcCompositeUnredirectSubwindows,
SProcCompositeCreateRegionFromBorderClip,
SProcCompositeNameWindowPixmap,
SProcCompositeGetOverlayWindow, SProcCompositeReleaseOverlayWindow,};
2006-11-26 11:13:41 -07:00
static int
SProcCompositeDispatch(ClientPtr client)
2006-11-26 11:13:41 -07:00
{
REQUEST(xReq);
2006-11-26 11:13:41 -07:00
if (stuff->data < CompositeNumberRequests)
return (*SProcCompositeVector[stuff->data]) (client);
2006-11-26 11:13:41 -07:00
else
return BadRequest;
2006-11-26 11:13:41 -07:00
}
void
CompositeExtensionInit(void)
2006-11-26 11:13:41 -07:00
{
ExtensionEntry *extEntry;
int s;
2006-11-26 11:13:41 -07:00
2007-12-13 14:06:02 -07:00
/* Assume initialization is going to fail */
noCompositeExtension = TRUE;
2007-11-24 10:55:21 -07:00
for (s = 0; s < screenInfo.numScreens; s++) {
ScreenPtr pScreen = screenInfo.screens[s];
VisualPtr vis;
/* Composite on 8bpp pseudocolor root windows appears to fail, so
* just disable it on anything pseudocolor for safety.
*/
for (vis = pScreen->visuals; vis->vid != pScreen->rootVisual; vis++);
if ((vis->class | DynamicClass) == PseudoColor)
return;
/* Ensure that Render is initialized, which is required for automatic
* compositing.
*/
if (GetPictureScreenIfSet(pScreen) == NULL)
return;
2007-11-24 10:55:21 -07:00
}
CompositeClientWindowType = CreateNewResourceType
(FreeCompositeClientWindow, "CompositeClientWindow");
2006-11-26 11:13:41 -07:00
if (!CompositeClientWindowType)
return;
2006-11-26 11:13:41 -07:00
CompositeClientSubwindowsType = CreateNewResourceType
(FreeCompositeClientSubwindows, "CompositeClientSubwindows");
2006-11-26 11:13:41 -07:00
if (!CompositeClientSubwindowsType)
return;
2006-11-26 11:13:41 -07:00
CompositeClientOverlayType = CreateNewResourceType
(FreeCompositeClientOverlay, "CompositeClientOverlay");
2006-11-26 11:13:41 -07:00
if (!CompositeClientOverlayType)
return;
2006-11-26 11:13:41 -07:00
if (!dixRegisterPrivateKey(&CompositeClientPrivateKeyRec, PRIVATE_CLIENT,
sizeof(CompositeClientRec)))
return;
if (!AddCallback(&ClientStateCallback, CompositeClientCallback, 0))
return;
2006-11-26 11:13:41 -07:00
for (s = 0; s < screenInfo.numScreens; s++)
if (!compScreenInit(screenInfo.screens[s]))
return;
extEntry = AddExtension(COMPOSITE_NAME, 0, 0,
ProcCompositeDispatch, SProcCompositeDispatch,
NULL, StandardMinorOpcode);
2006-11-26 11:13:41 -07:00
if (!extEntry)
return;
2006-11-26 11:13:41 -07:00
CompositeReqCode = (CARD8) extEntry->base;
miRegisterRedirectBorderClipProc(compSetRedirectBorderClip,
compGetRedirectBorderClip);
2007-12-13 14:06:02 -07:00
/* Initialization succeeded */
noCompositeExtension = FALSE;
2006-11-26 11:13:41 -07:00
}
2011-11-05 07:32:40 -06:00
#ifdef PANORAMIX
#include "panoramiXsrv.h"
int (*PanoramiXSaveCompositeVector[CompositeNumberRequests]) (ClientPtr);
static int
PanoramiXCompositeRedirectWindow(ClientPtr client)
2011-11-05 07:32:40 -06:00
{
PanoramiXRes *win;
int rc = 0, j;
2011-11-05 07:32:40 -06:00
REQUEST(xCompositeRedirectWindowReq);
REQUEST_SIZE_MATCH(xCompositeRedirectWindowReq);
if ((rc = dixLookupResourceByType((void **) &win, stuff->window, XRT_WINDOW,
client, DixUnknownAccess))) {
client->errorValue = stuff->window;
return rc;
2011-11-05 07:32:40 -06:00
}
FOR_NSCREENS_FORWARD(j) {
stuff->window = win->info[j].id;
rc = (*PanoramiXSaveCompositeVector[stuff->compositeReqType]) (client);
if (rc != Success)
break;
2011-11-05 07:32:40 -06:00
}
return rc;
}
static int
PanoramiXCompositeRedirectSubwindows(ClientPtr client)
2011-11-05 07:32:40 -06:00
{
PanoramiXRes *win;
int rc = 0, j;
2011-11-05 07:32:40 -06:00
REQUEST(xCompositeRedirectSubwindowsReq);
REQUEST_SIZE_MATCH(xCompositeRedirectSubwindowsReq);
if ((rc = dixLookupResourceByType((void **) &win, stuff->window, XRT_WINDOW,
client, DixUnknownAccess))) {
client->errorValue = stuff->window;
return rc;
2011-11-05 07:32:40 -06:00
}
FOR_NSCREENS_FORWARD(j) {
stuff->window = win->info[j].id;
rc = (*PanoramiXSaveCompositeVector[stuff->compositeReqType]) (client);
if (rc != Success)
break;
2011-11-05 07:32:40 -06:00
}
return rc;
}
static int
PanoramiXCompositeUnredirectWindow(ClientPtr client)
2011-11-05 07:32:40 -06:00
{
PanoramiXRes *win;
int rc = 0, j;
2011-11-05 07:32:40 -06:00
REQUEST(xCompositeUnredirectWindowReq);
REQUEST_SIZE_MATCH(xCompositeUnredirectWindowReq);
if ((rc = dixLookupResourceByType((void **) &win, stuff->window, XRT_WINDOW,
client, DixUnknownAccess))) {
client->errorValue = stuff->window;
return rc;
2011-11-05 07:32:40 -06:00
}
FOR_NSCREENS_FORWARD(j) {
stuff->window = win->info[j].id;
rc = (*PanoramiXSaveCompositeVector[stuff->compositeReqType]) (client);
if (rc != Success)
break;
2011-11-05 07:32:40 -06:00
}
return rc;
}
static int
PanoramiXCompositeUnredirectSubwindows(ClientPtr client)
2011-11-05 07:32:40 -06:00
{
PanoramiXRes *win;
int rc = 0, j;
2011-11-05 07:32:40 -06:00
REQUEST(xCompositeUnredirectSubwindowsReq);
REQUEST_SIZE_MATCH(xCompositeUnredirectSubwindowsReq);
if ((rc = dixLookupResourceByType((void **) &win, stuff->window, XRT_WINDOW,
client, DixUnknownAccess))) {
client->errorValue = stuff->window;
return rc;
2011-11-05 07:32:40 -06:00
}
FOR_NSCREENS_FORWARD(j) {
stuff->window = win->info[j].id;
rc = (*PanoramiXSaveCompositeVector[stuff->compositeReqType]) (client);
if (rc != Success)
break;
2011-11-05 07:32:40 -06:00
}
return rc;
}
static int
PanoramiXCompositeNameWindowPixmap(ClientPtr client)
2011-11-05 07:32:40 -06:00
{
WindowPtr pWin;
CompWindowPtr cw;
PixmapPtr pPixmap;
2011-11-05 07:32:40 -06:00
int rc;
PanoramiXRes *win, *newPix;
int i;
2011-11-05 07:32:40 -06:00
REQUEST(xCompositeNameWindowPixmapReq);
REQUEST_SIZE_MATCH(xCompositeNameWindowPixmapReq);
if ((rc = dixLookupResourceByType((void **) &win, stuff->window, XRT_WINDOW,
client, DixUnknownAccess))) {
client->errorValue = stuff->window;
return rc;
2011-11-05 07:32:40 -06:00
}
LEGAL_NEW_RESOURCE(stuff->pixmap, client);
2011-11-05 07:32:40 -06:00
if (!(newPix = malloc(sizeof(PanoramiXRes))))
return BadAlloc;
2011-11-05 07:32:40 -06:00
newPix->type = XRT_PIXMAP;
newPix->u.pix.shared = FALSE;
panoramix_setup_ids(newPix, client, stuff->pixmap);
FOR_NSCREENS(i) {
rc = dixLookupResourceByType((void **) &pWin, win->info[i].id,
RT_WINDOW, client, DixGetAttrAccess);
if (rc != Success) {
client->errorValue = stuff->window;
free(newPix);
return rc;
}
if (!pWin->viewable) {
free(newPix);
return BadMatch;
}
cw = GetCompWindow(pWin);
if (!cw) {
free(newPix);
return BadMatch;
}
pPixmap = (*pWin->drawable.pScreen->GetWindowPixmap) (pWin);
if (!pPixmap) {
free(newPix);
return BadMatch;
}
if (!AddResource(newPix->info[i].id, RT_PIXMAP, (pointer) pPixmap))
return BadAlloc;
++pPixmap->refcnt;
2011-11-05 07:32:40 -06:00
}
if (!AddResource(stuff->pixmap, XRT_PIXMAP, (pointer) newPix))
return BadAlloc;
2011-11-05 07:32:40 -06:00
return Success;
}
static int
PanoramiXCompositeGetOverlayWindow(ClientPtr client)
2011-11-05 07:32:40 -06:00
{
REQUEST(xCompositeGetOverlayWindowReq);
xCompositeGetOverlayWindowReply rep;
WindowPtr pWin;
ScreenPtr pScreen;
CompScreenPtr cs;
CompOverlayClientPtr pOc;
int rc;
PanoramiXRes *win, *overlayWin = NULL;
int i;
REQUEST_SIZE_MATCH(xCompositeGetOverlayWindowReq);
if ((rc = dixLookupResourceByType((void **) &win, stuff->window, XRT_WINDOW,
client, DixUnknownAccess))) {
client->errorValue = stuff->window;
return rc;
2011-11-05 07:32:40 -06:00
}
cs = GetCompScreen(screenInfo.screens[0]);
if (!cs->pOverlayWin) {
if (!(overlayWin = malloc(sizeof(PanoramiXRes))))
return BadAlloc;
2011-11-05 07:32:40 -06:00
overlayWin->type = XRT_WINDOW;
overlayWin->u.win.root = FALSE;
2011-11-05 07:32:40 -06:00
}
FOR_NSCREENS_BACKWARD(i) {
rc = dixLookupResourceByType((pointer *) &pWin, win->info[i].id,
RT_WINDOW, client, DixGetAttrAccess);
if (rc != Success) {
client->errorValue = stuff->window;
return rc;
}
pScreen = pWin->drawable.pScreen;
/*
* Create an OverlayClient structure to mark this client's
* interest in the overlay window
*/
pOc = compCreateOverlayClient(pScreen, client);
if (pOc == NULL)
return BadAlloc;
/*
* Make sure the overlay window exists
*/
cs = GetCompScreen(pScreen);
if (cs->pOverlayWin == NULL)
if (!compCreateOverlayWindow(pScreen)) {
FreeResource(pOc->resource, RT_NONE);
return BadAlloc;
}
rc = XaceHook(XACE_RESOURCE_ACCESS, client,
cs->pOverlayWin->drawable.id,
RT_WINDOW, cs->pOverlayWin, RT_NONE, NULL,
DixGetAttrAccess);
if (rc != Success) {
FreeResource(pOc->resource, RT_NONE);
return rc;
}
2011-11-05 07:32:40 -06:00
}
if (overlayWin) {
FOR_NSCREENS(i) {
cs = GetCompScreen(screenInfo.screens[i]);
overlayWin->info[i].id = cs->pOverlayWin->drawable.id;
}
2011-11-05 07:32:40 -06:00
AddResource(overlayWin->info[0].id, XRT_WINDOW, overlayWin);
2011-11-05 07:32:40 -06:00
}
cs = GetCompScreen(screenInfo.screens[0]);
rep.type = X_Reply;
rep.sequenceNumber = client->sequence;
rep.length = 0;
rep.overlayWin = cs->pOverlayWin->drawable.id;
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swapl(&rep.overlayWin);
2011-11-05 07:32:40 -06:00
}
(void) WriteToClient(client, sz_xCompositeGetOverlayWindowReply,
(char *) &rep);
2011-11-05 07:32:40 -06:00
return Success;
}
static int
PanoramiXCompositeReleaseOverlayWindow(ClientPtr client)
2011-11-05 07:32:40 -06:00
{
REQUEST(xCompositeReleaseOverlayWindowReq);
WindowPtr pWin;
ScreenPtr pScreen;
CompOverlayClientPtr pOc;
PanoramiXRes *win;
int i, rc;
REQUEST_SIZE_MATCH(xCompositeReleaseOverlayWindowReq);
if ((rc = dixLookupResourceByType((void **) &win, stuff->window, XRT_WINDOW,
client, DixUnknownAccess))) {
client->errorValue = stuff->window;
return rc;
2011-11-05 07:32:40 -06:00
}
FOR_NSCREENS_BACKWARD(i) {
if ((rc = dixLookupResourceByType((void **) &pWin, win->info[i].id,
XRT_WINDOW, client,
DixUnknownAccess))) {
client->errorValue = stuff->window;
return rc;
}
pScreen = pWin->drawable.pScreen;
/*
* Has client queried a reference to the overlay window
* on this screen? If not, generate an error.
*/
pOc = compFindOverlayClient(pWin->drawable.pScreen, client);
if (pOc == NULL)
return BadMatch;
/* The delete function will free the client structure */
FreeResource(pOc->resource, RT_NONE);
2011-11-05 07:32:40 -06:00
}
return Success;
}
void
PanoramiXCompositeInit(void)
2011-11-05 07:32:40 -06:00
{
int i;
for (i = 0; i < CompositeNumberRequests; i++)
PanoramiXSaveCompositeVector[i] = ProcCompositeVector[i];
2011-11-05 07:32:40 -06:00
/*
* Stuff in Xinerama aware request processing hooks
*/
ProcCompositeVector[X_CompositeRedirectWindow] =
PanoramiXCompositeRedirectWindow;
2011-11-05 07:32:40 -06:00
ProcCompositeVector[X_CompositeRedirectSubwindows] =
PanoramiXCompositeRedirectSubwindows;
2011-11-05 07:32:40 -06:00
ProcCompositeVector[X_CompositeUnredirectWindow] =
PanoramiXCompositeUnredirectWindow;
2011-11-05 07:32:40 -06:00
ProcCompositeVector[X_CompositeUnredirectSubwindows] =
PanoramiXCompositeUnredirectSubwindows;
2011-11-05 07:32:40 -06:00
ProcCompositeVector[X_CompositeNameWindowPixmap] =
PanoramiXCompositeNameWindowPixmap;
2011-11-05 07:32:40 -06:00
ProcCompositeVector[X_CompositeGetOverlayWindow] =
PanoramiXCompositeGetOverlayWindow;
2011-11-05 07:32:40 -06:00
ProcCompositeVector[X_CompositeReleaseOverlayWindow] =
PanoramiXCompositeReleaseOverlayWindow;
2011-11-05 07:32:40 -06:00
}
void
PanoramiXCompositeReset(void)
2011-11-05 07:32:40 -06:00
{
int i;
for (i = 0; i < CompositeNumberRequests; i++)
ProcCompositeVector[i] = PanoramiXSaveCompositeVector[i];
2011-11-05 07:32:40 -06:00
}
#endif