GetActKey.c revision 1477040f
1/* $Xorg: GetActKey.c,v 1.4 2001/02/09 02:03:55 xorgcvs Exp $ */ 2 3/*LINTLIBRARY*/ 4 5/*********************************************************** 6Copyright 1993 Sun Microsystems, Inc. All rights reserved. 7 8Permission is hereby granted, free of charge, to any person obtaining a 9copy of this software and associated documentation files (the "Software"), 10to deal in the Software without restriction, including without limitation 11the rights to use, copy, modify, merge, publish, distribute, sublicense, 12and/or sell copies of the Software, and to permit persons to whom the 13Software is furnished to do so, subject to the following conditions: 14 15The above copyright notice and this permission notice (including the next 16paragraph) shall be included in all copies or substantial portions of the 17Software. 18 19THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 22THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 24FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 25DEALINGS IN THE SOFTWARE. 26 27Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts. 28 29 All Rights Reserved 30 31Permission to use, copy, modify, and distribute this software and its 32documentation for any purpose and without fee is hereby granted, 33provided that the above copyright notice appear in all copies and that 34both that copyright notice and this permission notice appear in 35supporting documentation, and that the name of Digital not be 36used in advertising or publicity pertaining to distribution of the 37software without specific, written prior permission. 38 39DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING 40ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL 41DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR 42ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 43WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 44ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS 45SOFTWARE. 46 47******************************************************************/ 48 49/* 50 51Copyright 1987, 1988, 1998 The Open Group 52 53Permission to use, copy, modify, distribute, and sell this software and its 54documentation for any purpose is hereby granted without fee, provided that 55the above copyright notice appear in all copies and that both that 56copyright notice and this permission notice appear in supporting 57documentation. 58 59The above copyright notice and this permission notice shall be included in 60all copies or substantial portions of the Software. 61 62THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 63IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 64FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 65OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 66AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 67CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 68 69Except as contained in this notice, the name of The Open Group shall not be 70used in advertising or otherwise to promote the sale, use or other dealings 71in this Software without prior written authorization from The Open Group. 72 73*/ 74 75#ifdef HAVE_CONFIG_H 76#include <config.h> 77#endif 78#include "IntrinsicI.h" 79 80KeySym XtGetActionKeysym( 81 XEvent *event, 82 Modifiers *modifiers_return) 83{ 84 TMKeyContext tm_context; 85 Modifiers modifiers; 86 KeySym keysym, retval; 87 88 LOCK_PROCESS; 89 tm_context= _XtGetPerDisplay(event->xany.display)->tm_context; 90 if (event->xany.type != KeyPress && event->xany.type != KeyRelease) { 91 UNLOCK_PROCESS; 92 return NoSymbol; 93 } 94 if (tm_context != NULL 95 && event == tm_context->event 96 && event->xany.serial == tm_context->serial ) { 97 98 if (modifiers_return != NULL) 99 *modifiers_return = tm_context->modifiers; 100 retval = tm_context->keysym; 101 UNLOCK_PROCESS; 102 return retval; 103 } 104 105 XtTranslateKeycode( event->xany.display, (KeyCode)event->xkey.keycode, 106 event->xkey.state, &modifiers, &keysym ); 107 108 if (modifiers_return != NULL) 109 *modifiers_return = event->xkey.state & modifiers; 110 111 UNLOCK_PROCESS; 112 return keysym; 113} 114