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