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