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