105b261ecSmrg/*
205b261ecSmrg * Copyright © 2002 Keith Packard
305b261ecSmrg *
405b261ecSmrg * Permission to use, copy, modify, distribute, and sell this software and its
505b261ecSmrg * documentation for any purpose is hereby granted without fee, provided that
605b261ecSmrg * the above copyright notice appear in all copies and that both that
705b261ecSmrg * copyright notice and this permission notice appear in supporting
805b261ecSmrg * documentation, and that the name of Keith Packard not be used in
905b261ecSmrg * advertising or publicity pertaining to distribution of the software without
1005b261ecSmrg * specific, written prior permission.  Keith Packard makes no
1105b261ecSmrg * representations about the suitability of this software for any purpose.  It
1205b261ecSmrg * is provided "as is" without express or implied warranty.
1305b261ecSmrg *
1405b261ecSmrg * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
1505b261ecSmrg * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
1605b261ecSmrg * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
1705b261ecSmrg * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
1805b261ecSmrg * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
1905b261ecSmrg * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
2005b261ecSmrg * PERFORMANCE OF THIS SOFTWARE.
2105b261ecSmrg */
2205b261ecSmrg
2305b261ecSmrg#ifdef HAVE_DIX_CONFIG_H
2405b261ecSmrg#include <dix-config.h>
2505b261ecSmrg#endif
2605b261ecSmrg
2705b261ecSmrg#include "xfixesint.h"
2805b261ecSmrg
2905b261ecSmrgint
3005b261ecSmrgProcXFixesChangeSaveSet(ClientPtr client)
3105b261ecSmrg{
3235c4bbdfSmrg    Bool toRoot, map;
3335c4bbdfSmrg    int result;
3435c4bbdfSmrg    WindowPtr pWin;
3535c4bbdfSmrg
3605b261ecSmrg    REQUEST(xXFixesChangeSaveSetReq);
3735c4bbdfSmrg
3805b261ecSmrg    REQUEST_SIZE_MATCH(xXFixesChangeSaveSetReq);
394642e01fSmrg    result = dixLookupWindow(&pWin, stuff->window, client, DixManageAccess);
4005b261ecSmrg    if (result != Success)
4105b261ecSmrg        return result;
4205b261ecSmrg    if (client->clientAsMask == (CLIENT_BITS(pWin->drawable.id)))
4305b261ecSmrg        return BadMatch;
4435c4bbdfSmrg    if ((stuff->mode != SetModeInsert) && (stuff->mode != SetModeDelete)) {
4535c4bbdfSmrg        client->errorValue = stuff->mode;
4635c4bbdfSmrg        return BadValue;
4705b261ecSmrg    }
4835c4bbdfSmrg    if ((stuff->target != SaveSetNearest) && (stuff->target != SaveSetRoot)) {
4935c4bbdfSmrg        client->errorValue = stuff->target;
5035c4bbdfSmrg        return BadValue;
5105b261ecSmrg    }
5235c4bbdfSmrg    if ((stuff->map != SaveSetMap) && (stuff->map != SaveSetUnmap)) {
5335c4bbdfSmrg        client->errorValue = stuff->map;
5435c4bbdfSmrg        return BadValue;
5505b261ecSmrg    }
5605b261ecSmrg    toRoot = (stuff->target == SaveSetRoot);
574642e01fSmrg    map = (stuff->map == SaveSetMap);
586747b715Smrg    return AlterSaveSetForClient(client, pWin, stuff->mode, toRoot, map);
5905b261ecSmrg}
6005b261ecSmrg
617e31ba66Smrgint _X_COLD
6205b261ecSmrgSProcXFixesChangeSaveSet(ClientPtr client)
6305b261ecSmrg{
6405b261ecSmrg    REQUEST(xXFixesChangeSaveSetReq);
656e78d31fSmrg    REQUEST_SIZE_MATCH(xXFixesChangeSaveSetReq);
6605b261ecSmrg
6735c4bbdfSmrg    swaps(&stuff->length);
6835c4bbdfSmrg    swapl(&stuff->window);
6935c4bbdfSmrg    return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
7005b261ecSmrg}
71