1b0a0317aSmrg/*
2a7e741d5Smrg * Copyright (c) 2006, Oracle and/or its affiliates.
3b0a0317aSmrg * Copyright 2021 Red Hat, Inc.
4b0a0317aSmrg *
5b0a0317aSmrg * Permission is hereby granted, free of charge, to any person obtaining a
6b0a0317aSmrg * copy of this software and associated documentation files (the "Software"),
7b0a0317aSmrg * to deal in the Software without restriction, including without limitation
8b0a0317aSmrg * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9b0a0317aSmrg * and/or sell copies of the Software, and to permit persons to whom the
10b0a0317aSmrg * Software is furnished to do so, subject to the following conditions:
11b0a0317aSmrg *
12b0a0317aSmrg * The above copyright notice and this permission notice (including the next
13b0a0317aSmrg * paragraph) shall be included in all copies or substantial portions of the
14b0a0317aSmrg * Software.
15b0a0317aSmrg *
16b0a0317aSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17b0a0317aSmrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18b0a0317aSmrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
19b0a0317aSmrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20b0a0317aSmrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21b0a0317aSmrg * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22b0a0317aSmrg * DEALINGS IN THE SOFTWARE.
23b0a0317aSmrg */
24b0a0317aSmrg/*
25b0a0317aSmrg * Copyright © 2002 Keith Packard, member of The XFree86 Project, Inc.
26b0a0317aSmrg *
27b0a0317aSmrg * Permission to use, copy, modify, distribute, and sell this software and its
28b0a0317aSmrg * documentation for any purpose is hereby granted without fee, provided that
29b0a0317aSmrg * the above copyright notice appear in all copies and that both that
30b0a0317aSmrg * copyright notice and this permission notice appear in supporting
31b0a0317aSmrg * documentation, and that the name of Keith Packard not be used in
32b0a0317aSmrg * advertising or publicity pertaining to distribution of the software without
33b0a0317aSmrg * specific, written prior permission.  Keith Packard makes no
34b0a0317aSmrg * representations about the suitability of this software for any purpose.  It
35b0a0317aSmrg * is provided "as is" without express or implied warranty.
36b0a0317aSmrg *
37b0a0317aSmrg * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
38b0a0317aSmrg * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
39b0a0317aSmrg * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
40b0a0317aSmrg * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
41b0a0317aSmrg * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
42b0a0317aSmrg * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
43b0a0317aSmrg * PERFORMANCE OF THIS SOFTWARE.
44b0a0317aSmrg */
45b0a0317aSmrg
46b0a0317aSmrg#ifdef HAVE_CONFIG_H
47b0a0317aSmrg#include <config.h>
48b0a0317aSmrg#endif
49b0a0317aSmrg#include "Xfixesint.h"
50b0a0317aSmrg#include <limits.h>
51b0a0317aSmrg
52b0a0317aSmrgvoid
53b0a0317aSmrgXFixesSetClientDisconnectMode(Display *dpy, int disconnect_mode)
54b0a0317aSmrg{
55b0a0317aSmrg    XFixesExtDisplayInfo *info = XFixesFindDisplay(dpy);
56b0a0317aSmrg    xXFixesSetClientDisconnectModeReq *req;
57b0a0317aSmrg
58b0a0317aSmrg    XFixesSimpleCheckExtension(dpy, info);
59b0a0317aSmrg    if (info->major_version < 6)
60b0a0317aSmrg	return;
61b0a0317aSmrg
62b0a0317aSmrg    LockDisplay(dpy);
63b0a0317aSmrg    GetReq(XFixesSetClientDisconnectMode, req);
64a7e741d5Smrg    req->reqType = (CARD8) info->codes->major_opcode;
65b0a0317aSmrg    req->xfixesReqType = X_XFixesSetClientDisconnectMode;
66a7e741d5Smrg    req->disconnect_mode = (CARD32) disconnect_mode;
67b0a0317aSmrg    UnlockDisplay(dpy);
68b0a0317aSmrg    SyncHandle();
69b0a0317aSmrg}
70b0a0317aSmrg
71b0a0317aSmrgint
72b0a0317aSmrgXFixesGetClientDisconnectMode(Display *dpy)
73b0a0317aSmrg{
74b0a0317aSmrg    XFixesExtDisplayInfo *info = XFixesFindDisplay(dpy);
75b0a0317aSmrg    xXFixesGetClientDisconnectModeReq *req;
76b0a0317aSmrg    xXFixesGetClientDisconnectModeReply rep;
77b0a0317aSmrg    int disconnect_mode;
78b0a0317aSmrg
79b0a0317aSmrg    XFixesCheckExtension(dpy, info, 0);
80b0a0317aSmrg    if (info->major_version < 6)
81b0a0317aSmrg	return XFixesClientDisconnectFlagDefault;
82b0a0317aSmrg
83b0a0317aSmrg    LockDisplay(dpy);
84b0a0317aSmrg    GetReq(XFixesGetClientDisconnectMode, req);
85a7e741d5Smrg    req->reqType = (CARD8) info->codes->major_opcode;
86b0a0317aSmrg    req->xfixesReqType = X_XFixesGetClientDisconnectMode;
87b0a0317aSmrg
88b0a0317aSmrg    if (!_XReply(dpy, (xReply *) &rep, 0, xFalse))
89b0a0317aSmrg    {
90b0a0317aSmrg	UnlockDisplay(dpy);
91b0a0317aSmrg	SyncHandle();
92b0a0317aSmrg	return XFixesClientDisconnectFlagDefault;
93b0a0317aSmrg    }
94b0a0317aSmrg
95a7e741d5Smrg    disconnect_mode = (int) rep.disconnect_mode;
96b0a0317aSmrg    UnlockDisplay(dpy);
97b0a0317aSmrg    SyncHandle();
98b0a0317aSmrg
99b0a0317aSmrg    return disconnect_mode;
100b0a0317aSmrg}
101