1/* 2 * event handling stuff 3 */ 4/* 5 6Copyright 1990, 1991, 1998 The Open Group 7 8Permission to use, copy, modify, distribute, and sell this software and its 9documentation for any purpose is hereby granted without fee, provided that 10the above copyright notice appear in all copies and that both that 11copyright notice and this permission notice appear in supporting 12documentation. 13 14The above copyright notice and this permission notice shall be included in 15all copies or substantial portions of the Software. 16 17THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 21AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 24Except as contained in this notice, the name of The Open Group shall not be 25used in advertising or otherwise to promote the sale, use or other dealings 26in this Software without prior written authorization from The Open Group. 27 28 * Copyright 1990, 1991 Network Computing Devices; 29 * Portions Copyright 1987 by Digital Equipment Corporation 30 * 31 * Permission to use, copy, modify, distribute, and sell this software and 32 * its documentation for any purpose is hereby granted without fee, provided 33 * that the above copyright notice appear in all copies and that both that 34 * copyright notice and this permission notice appear in supporting 35 * documentation, and that the names of Network Computing Devices, or Digital 36 * not be used in advertising or publicity pertaining to distribution 37 * of the software without specific, written prior permission. 38 * 39 * NETWORK COMPUTING DEVICES, AND DIGITAL DISCLAIM ALL WARRANTIES WITH 40 * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF 41 * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES, 42 * OR DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL 43 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 44 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS 45 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF 46 * THIS SOFTWARE. 47 */ 48 49#include "config.h" 50 51#include <swaprep.h> 52 53#include "clientstr.h" 54#include <X11/fonts/FSproto.h> 55#include "globals.h" 56#include "fsevents.h" 57#include "dispatch.h" 58#include "difs.h" 59 60 61static Mask lastEventMask = FontChangeNotifyMask; 62 63#define AllEventMasks (lastEventMask | (lastEventMask - 1)) 64 65void 66WriteErrorToClient(ClientPtr client, fsError *error) 67{ 68 if (client->swapped) { 69 fsError errorTo; 70 71 SErrorEvent(error, &errorTo); 72 (void) WriteToClient(client, SIZEOF(fsError), (char *) &errorTo); 73 } else { 74 (void) WriteToClient(client, SIZEOF(fsError), 75 (char *) error); 76 } 77} 78 79int 80ProcSetEventMask(ClientPtr client) 81{ 82 REQUEST(fsSetEventMaskReq); 83 REQUEST_AT_LEAST_SIZE(fsSetEventMaskReq); 84 85 if (stuff->event_mask & ~AllEventMasks) { 86 SendErrToClient(client, FSBadEventMask, (pointer) &stuff->event_mask); 87 return FSBadEventMask; 88 } 89 client->eventmask = stuff->event_mask; 90 return client->noClientException; 91} 92 93int 94ProcGetEventMask(ClientPtr client) 95{ 96 fsGetEventMaskReply rep = { 97 .type = FS_Reply, 98 .sequenceNumber = client->sequence, 99 .length = SIZEOF(fsGetEventMaskReply) >> 2, 100 .event_mask = client->eventmask 101 }; 102 103 REQUEST(fsGetEventMaskReq); 104 REQUEST_AT_LEAST_SIZE(fsGetEventMaskReq); 105 106 WriteReplyToClient(client, SIZEOF(fsGetEventMaskReply), &rep); 107 return client->noClientException; 108} 109 110void 111SendKeepAliveEvent(ClientPtr client) 112{ 113 fsKeepAliveEvent ev = { 114 .type = FS_Event, 115 .event_code = KeepAlive, 116 .sequenceNumber = client->sequence, 117 .length = SIZEOF(fsKeepAliveEvent) >> 2, 118 .timestamp = GetTimeInMillis() 119 }; 120 121#ifdef DEBUG 122 fprintf(stderr, "client #%d is getting a KeepAlive\n", client->index); 123#endif 124 125 if (client->swapped) { 126 /* SErrorEvent requires two fsError pointers */ 127 fsError evTo; 128 129 SErrorEvent((fsError *) & ev, (fsError *) &evTo); 130 (void) WriteToClient(client, SIZEOF(fsKeepAliveEvent), (char *) &evTo); 131 } else { 132 (void) WriteToClient(client, SIZEOF(fsKeepAliveEvent), (char *) &ev); 133 } 134} 135