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