PutBEvent.c revision 1ab64890
1/* $Xorg: PutBEvent.c,v 1.4 2001/02/09 02:03:35 xorgcvs Exp $ */ 2/* 3 4Copyright 1986, 1998 The Open Group 5 6Permission to use, copy, modify, distribute, and sell this software and its 7documentation for any purpose is hereby granted without fee, provided that 8the above copyright notice appear in all copies and that both that 9copyright notice and this permission notice appear in supporting 10documentation. 11 12The above copyright notice and this permission notice shall be included 13in all copies or substantial portions of the Software. 14 15THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 16OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 18IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR 19OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 20ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 21OTHER DEALINGS IN THE SOFTWARE. 22 23Except as contained in this notice, the name of The Open Group shall 24not be used in advertising or otherwise to promote the sale, use or 25other dealings in this Software without prior written authorization 26from The Open Group. 27 28*/ 29/* $XFree86: xc/lib/X11/PutBEvent.c,v 1.3 2001/01/17 19:41:41 dawes Exp $ */ 30 31/* XPutBackEvent puts an event back at the head of the queue. */ 32#define NEED_EVENTS 33#ifdef HAVE_CONFIG_H 34#include <config.h> 35#endif 36#include "Xlibint.h" 37 38int 39_XPutBackEvent ( 40 register Display *dpy, 41 register XEvent *event) 42 { 43 register _XQEvent *qelt; 44 45 if (!dpy->qfree) { 46 if ((dpy->qfree = (_XQEvent *) Xmalloc (sizeof (_XQEvent))) == NULL) { 47 return 0; 48 } 49 dpy->qfree->next = NULL; 50 } 51 qelt = dpy->qfree; 52 dpy->qfree = qelt->next; 53 qelt->qserial_num = dpy->next_event_serial_num++; 54 qelt->next = dpy->head; 55 qelt->event = *event; 56 dpy->head = qelt; 57 if (dpy->tail == NULL) 58 dpy->tail = qelt; 59 dpy->qlen++; 60 return 0; 61 } 62 63int 64XPutBackEvent ( 65 register Display * dpy, 66 register XEvent *event) 67 { 68 int ret; 69 70 LockDisplay(dpy); 71 ret = _XPutBackEvent(dpy, event); 72 UnlockDisplay(dpy); 73 return ret; 74 } 75