Functions.c revision 1477040f
1/* $Xorg: Functions.c,v 1.4 2001/02/09 02:03:54 xorgcvs Exp $ */
2
3/*
4
5Copyright 1993 Sun Microsystems, Inc.  All rights reserved.
6
7Permission is hereby granted, free of charge, to any person obtaining a
8copy of this software and associated documentation files (the "Software"),
9to deal in the Software without restriction, including without limitation
10the rights to use, copy, modify, merge, publish, distribute, sublicense,
11and/or sell copies of the Software, and to permit persons to whom the
12Software is furnished to do so, subject to the following conditions:
13
14The above copyright notice and this permission notice (including the next
15paragraph) shall be included in all copies or substantial portions of the
16Software.
17
18THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
21THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24DEALINGS IN THE SOFTWARE.
25
26*/
27
28/*
29
30Copyright 1985, 1986, 1987, 1988, 1989, 1994, 1998  The Open Group
31
32Permission to use, copy, modify, distribute, and sell this software and its
33documentation for any purpose is hereby granted without fee, provided that
34the above copyright notice appear in all copies and that both that
35copyright notice and this permission notice appear in supporting
36documentation.
37
38The above copyright notice and this permission notice shall be included in
39all copies or substantial portions of the Software.
40
41THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
42IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
43FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
44OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
45AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
46CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
47
48Except as contained in this notice, the name of The Open Group shall not be
49used in advertising or otherwise to promote the sale, use or other dealings
50in this Software without prior written authorization from The Open Group.
51
52*/
53
54#ifdef HAVE_CONFIG_H
55#include <config.h>
56#endif
57#include "IntrinsicI.h"
58#include <X11/Shell.h>
59#include <X11/Vendor.h>
60
61/*
62 * This file defines functional equivalents to all macros defined
63 * in Intrinsic.h
64 *
65 */
66
67#undef XtIsRectObj
68Boolean XtIsRectObj(Widget object)
69{
70    return _XtCheckSubclassFlag(object, 0x02);
71}
72
73
74#undef XtIsWidget
75Boolean XtIsWidget(Widget object)
76{
77    return _XtCheckSubclassFlag(object, 0x04);
78}
79
80
81#undef XtIsComposite
82Boolean XtIsComposite(Widget object)
83{
84    return _XtCheckSubclassFlag(object, 0x08);
85}
86
87
88#undef XtIsConstraint
89Boolean XtIsConstraint(Widget object)
90{
91    return _XtCheckSubclassFlag(object, 0x10);
92}
93
94
95#undef XtIsShell
96Boolean XtIsShell(Widget object)
97{
98    return _XtCheckSubclassFlag(object, 0x20);
99}
100
101
102#undef XtIsOverrideShell
103Boolean XtIsOverrideShell(Widget object)
104{
105    return _XtIsSubclassOf(object, (WidgetClass)overrideShellWidgetClass,
106			   (WidgetClass)shellWidgetClass, 0x20);
107}
108
109
110#undef XtIsWMShell
111Boolean XtIsWMShell(Widget object)
112{
113    return _XtCheckSubclassFlag(object, 0x40);
114}
115
116
117#undef XtIsVendorShell
118Boolean XtIsVendorShell(Widget object)
119{
120    Boolean retval;
121
122    LOCK_PROCESS;
123    retval = _XtIsSubclassOf(object,
124#ifdef notdef
125/*
126 * We don't refer to vendorShell directly, because some shared libraries
127 * bind local references tightly.
128 */
129			   (WidgetClass)vendorShellWidgetClass,
130#endif
131			   transientShellWidgetClass->core_class.superclass,
132			   (WidgetClass)wmShellWidgetClass, 0x40);
133    UNLOCK_PROCESS;
134    return retval;
135}
136
137
138#undef XtIsTransientShell
139Boolean XtIsTransientShell(Widget object)
140{
141    return _XtIsSubclassOf(object, (WidgetClass)transientShellWidgetClass,
142			   (WidgetClass)wmShellWidgetClass, 0x40);
143}
144
145
146#undef XtIsTopLevelShell
147Boolean XtIsTopLevelShell(Widget object)
148{
149    return _XtCheckSubclassFlag(object, 0x80);
150}
151
152
153#undef XtIsApplicationShell
154Boolean XtIsApplicationShell(Widget object)
155{
156    return _XtIsSubclassOf(object, (WidgetClass)applicationShellWidgetClass,
157			   (WidgetClass)topLevelShellWidgetClass, 0x80);
158}
159
160#undef XtIsSessionShell
161Boolean XtIsSessionShell(Widget object)
162{
163    return _XtIsSubclassOf(object, (WidgetClass)sessionShellWidgetClass,
164			   (WidgetClass)topLevelShellWidgetClass, 0x80);
165}
166
167#undef XtMapWidget
168void XtMapWidget(Widget w)
169{
170    Widget hookobj;
171    WIDGET_TO_APPCON(w);
172
173    LOCK_APP(app);
174    XMapWindow(XtDisplay(w), XtWindow(w));
175    hookobj = XtHooksOfDisplay(XtDisplay(w));
176    if (XtHasCallbacks(hookobj, XtNchangeHook) == XtCallbackHasSome) {
177	XtChangeHookDataRec call_data;
178
179	call_data.type = XtHmapWidget;
180	call_data.widget = w;
181	XtCallCallbackList(hookobj,
182		((HookObject)hookobj)->hooks.changehook_callbacks,
183		(XtPointer)&call_data);
184    }
185    UNLOCK_APP(app);
186}
187
188
189#undef XtUnmapWidget
190void XtUnmapWidget(Widget w)
191{
192    Widget hookobj;
193    WIDGET_TO_APPCON(w);
194
195    LOCK_APP(app);
196    XUnmapWindow(XtDisplay(w), XtWindow(w));
197    hookobj = XtHooksOfDisplay(XtDisplay(w));
198    if (XtHasCallbacks(hookobj, XtNchangeHook) == XtCallbackHasSome) {
199	XtChangeHookDataRec call_data;
200
201	call_data.type = XtHunmapWidget;
202	call_data.widget = w;
203	XtCallCallbackList(hookobj,
204		((HookObject)hookobj)->hooks.changehook_callbacks,
205		(XtPointer)&call_data);
206    }
207    UNLOCK_APP(app);
208}
209
210
211#undef XtNewString
212String XtNewString(String str)
213{
214    if (str == NULL)
215	return NULL;
216    else
217	return strcpy(__XtMalloc((unsigned)strlen(str) + 1), str);
218}
219