Functions.c revision 1477040f
1444c061aSmrg/* $Xorg: Functions.c,v 1.4 2001/02/09 02:03:54 xorgcvs Exp $ */
2444c061aSmrg
3444c061aSmrg/*
4444c061aSmrg
51477040fSmrgCopyright 1993 Sun Microsystems, Inc.  All rights reserved.
61477040fSmrg
71477040fSmrgPermission is hereby granted, free of charge, to any person obtaining a
81477040fSmrgcopy of this software and associated documentation files (the "Software"),
91477040fSmrgto deal in the Software without restriction, including without limitation
101477040fSmrgthe rights to use, copy, modify, merge, publish, distribute, sublicense,
111477040fSmrgand/or sell copies of the Software, and to permit persons to whom the
121477040fSmrgSoftware is furnished to do so, subject to the following conditions:
131477040fSmrg
141477040fSmrgThe above copyright notice and this permission notice (including the next
151477040fSmrgparagraph) shall be included in all copies or substantial portions of the
161477040fSmrgSoftware.
171477040fSmrg
181477040fSmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
191477040fSmrgIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
201477040fSmrgFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
211477040fSmrgTHE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
221477040fSmrgLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
231477040fSmrgFROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
241477040fSmrgDEALINGS IN THE SOFTWARE.
25444c061aSmrg
26444c061aSmrg*/
27444c061aSmrg
28444c061aSmrg/*
29444c061aSmrg
30444c061aSmrgCopyright 1985, 1986, 1987, 1988, 1989, 1994, 1998  The Open Group
31444c061aSmrg
32444c061aSmrgPermission to use, copy, modify, distribute, and sell this software and its
33444c061aSmrgdocumentation for any purpose is hereby granted without fee, provided that
34444c061aSmrgthe above copyright notice appear in all copies and that both that
35444c061aSmrgcopyright notice and this permission notice appear in supporting
36444c061aSmrgdocumentation.
37444c061aSmrg
38444c061aSmrgThe above copyright notice and this permission notice shall be included in
39444c061aSmrgall copies or substantial portions of the Software.
40444c061aSmrg
41444c061aSmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
42444c061aSmrgIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
43444c061aSmrgFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
44444c061aSmrgOPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
45444c061aSmrgAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
46444c061aSmrgCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
47444c061aSmrg
48444c061aSmrgExcept as contained in this notice, the name of The Open Group shall not be
49444c061aSmrgused in advertising or otherwise to promote the sale, use or other dealings
50444c061aSmrgin this Software without prior written authorization from The Open Group.
51444c061aSmrg
52444c061aSmrg*/
53444c061aSmrg
54444c061aSmrg#ifdef HAVE_CONFIG_H
55444c061aSmrg#include <config.h>
56444c061aSmrg#endif
57444c061aSmrg#include "IntrinsicI.h"
58444c061aSmrg#include <X11/Shell.h>
59444c061aSmrg#include <X11/Vendor.h>
60444c061aSmrg
61444c061aSmrg/*
62444c061aSmrg * This file defines functional equivalents to all macros defined
63444c061aSmrg * in Intrinsic.h
64444c061aSmrg *
65444c061aSmrg */
66444c061aSmrg
67444c061aSmrg#undef XtIsRectObj
68444c061aSmrgBoolean XtIsRectObj(Widget object)
69444c061aSmrg{
70444c061aSmrg    return _XtCheckSubclassFlag(object, 0x02);
71444c061aSmrg}
72444c061aSmrg
73444c061aSmrg
74444c061aSmrg#undef XtIsWidget
75444c061aSmrgBoolean XtIsWidget(Widget object)
76444c061aSmrg{
77444c061aSmrg    return _XtCheckSubclassFlag(object, 0x04);
78444c061aSmrg}
79444c061aSmrg
80444c061aSmrg
81444c061aSmrg#undef XtIsComposite
82444c061aSmrgBoolean XtIsComposite(Widget object)
83444c061aSmrg{
84444c061aSmrg    return _XtCheckSubclassFlag(object, 0x08);
85444c061aSmrg}
86444c061aSmrg
87444c061aSmrg
88444c061aSmrg#undef XtIsConstraint
89444c061aSmrgBoolean XtIsConstraint(Widget object)
90444c061aSmrg{
91444c061aSmrg    return _XtCheckSubclassFlag(object, 0x10);
92444c061aSmrg}
93444c061aSmrg
94444c061aSmrg
95444c061aSmrg#undef XtIsShell
96444c061aSmrgBoolean XtIsShell(Widget object)
97444c061aSmrg{
98444c061aSmrg    return _XtCheckSubclassFlag(object, 0x20);
99444c061aSmrg}
100444c061aSmrg
101444c061aSmrg
102444c061aSmrg#undef XtIsOverrideShell
103444c061aSmrgBoolean XtIsOverrideShell(Widget object)
104444c061aSmrg{
105444c061aSmrg    return _XtIsSubclassOf(object, (WidgetClass)overrideShellWidgetClass,
106444c061aSmrg			   (WidgetClass)shellWidgetClass, 0x20);
107444c061aSmrg}
108444c061aSmrg
109444c061aSmrg
110444c061aSmrg#undef XtIsWMShell
111444c061aSmrgBoolean XtIsWMShell(Widget object)
112444c061aSmrg{
113444c061aSmrg    return _XtCheckSubclassFlag(object, 0x40);
114444c061aSmrg}
115444c061aSmrg
116444c061aSmrg
117444c061aSmrg#undef XtIsVendorShell
118444c061aSmrgBoolean XtIsVendorShell(Widget object)
119444c061aSmrg{
120444c061aSmrg    Boolean retval;
121444c061aSmrg
122444c061aSmrg    LOCK_PROCESS;
123444c061aSmrg    retval = _XtIsSubclassOf(object,
124444c061aSmrg#ifdef notdef
125444c061aSmrg/*
126444c061aSmrg * We don't refer to vendorShell directly, because some shared libraries
127444c061aSmrg * bind local references tightly.
128444c061aSmrg */
129444c061aSmrg			   (WidgetClass)vendorShellWidgetClass,
130444c061aSmrg#endif
131444c061aSmrg			   transientShellWidgetClass->core_class.superclass,
132444c061aSmrg			   (WidgetClass)wmShellWidgetClass, 0x40);
133444c061aSmrg    UNLOCK_PROCESS;
134444c061aSmrg    return retval;
135444c061aSmrg}
136444c061aSmrg
137444c061aSmrg
138444c061aSmrg#undef XtIsTransientShell
139444c061aSmrgBoolean XtIsTransientShell(Widget object)
140444c061aSmrg{
141444c061aSmrg    return _XtIsSubclassOf(object, (WidgetClass)transientShellWidgetClass,
142444c061aSmrg			   (WidgetClass)wmShellWidgetClass, 0x40);
143444c061aSmrg}
144444c061aSmrg
145444c061aSmrg
146444c061aSmrg#undef XtIsTopLevelShell
147444c061aSmrgBoolean XtIsTopLevelShell(Widget object)
148444c061aSmrg{
149444c061aSmrg    return _XtCheckSubclassFlag(object, 0x80);
150444c061aSmrg}
151444c061aSmrg
152444c061aSmrg
153444c061aSmrg#undef XtIsApplicationShell
154444c061aSmrgBoolean XtIsApplicationShell(Widget object)
155444c061aSmrg{
156444c061aSmrg    return _XtIsSubclassOf(object, (WidgetClass)applicationShellWidgetClass,
157444c061aSmrg			   (WidgetClass)topLevelShellWidgetClass, 0x80);
158444c061aSmrg}
159444c061aSmrg
160444c061aSmrg#undef XtIsSessionShell
161444c061aSmrgBoolean XtIsSessionShell(Widget object)
162444c061aSmrg{
163444c061aSmrg    return _XtIsSubclassOf(object, (WidgetClass)sessionShellWidgetClass,
164444c061aSmrg			   (WidgetClass)topLevelShellWidgetClass, 0x80);
165444c061aSmrg}
166444c061aSmrg
167444c061aSmrg#undef XtMapWidget
168444c061aSmrgvoid XtMapWidget(Widget w)
169444c061aSmrg{
170444c061aSmrg    Widget hookobj;
171444c061aSmrg    WIDGET_TO_APPCON(w);
172444c061aSmrg
173444c061aSmrg    LOCK_APP(app);
174444c061aSmrg    XMapWindow(XtDisplay(w), XtWindow(w));
175444c061aSmrg    hookobj = XtHooksOfDisplay(XtDisplay(w));
176444c061aSmrg    if (XtHasCallbacks(hookobj, XtNchangeHook) == XtCallbackHasSome) {
177444c061aSmrg	XtChangeHookDataRec call_data;
178444c061aSmrg
179444c061aSmrg	call_data.type = XtHmapWidget;
180444c061aSmrg	call_data.widget = w;
181444c061aSmrg	XtCallCallbackList(hookobj,
182444c061aSmrg		((HookObject)hookobj)->hooks.changehook_callbacks,
183444c061aSmrg		(XtPointer)&call_data);
184444c061aSmrg    }
185444c061aSmrg    UNLOCK_APP(app);
186444c061aSmrg}
187444c061aSmrg
188444c061aSmrg
189444c061aSmrg#undef XtUnmapWidget
190444c061aSmrgvoid XtUnmapWidget(Widget w)
191444c061aSmrg{
192444c061aSmrg    Widget hookobj;
193444c061aSmrg    WIDGET_TO_APPCON(w);
194444c061aSmrg
195444c061aSmrg    LOCK_APP(app);
196444c061aSmrg    XUnmapWindow(XtDisplay(w), XtWindow(w));
197444c061aSmrg    hookobj = XtHooksOfDisplay(XtDisplay(w));
198444c061aSmrg    if (XtHasCallbacks(hookobj, XtNchangeHook) == XtCallbackHasSome) {
199444c061aSmrg	XtChangeHookDataRec call_data;
200444c061aSmrg
201444c061aSmrg	call_data.type = XtHunmapWidget;
202444c061aSmrg	call_data.widget = w;
203444c061aSmrg	XtCallCallbackList(hookobj,
204444c061aSmrg		((HookObject)hookobj)->hooks.changehook_callbacks,
205444c061aSmrg		(XtPointer)&call_data);
206444c061aSmrg    }
207444c061aSmrg    UNLOCK_APP(app);
208444c061aSmrg}
209444c061aSmrg
210444c061aSmrg
211444c061aSmrg#undef XtNewString
212444c061aSmrgString XtNewString(String str)
213444c061aSmrg{
214444c061aSmrg    if (str == NULL)
215444c061aSmrg	return NULL;
216444c061aSmrg    else
217444c061aSmrg	return strcpy(__XtMalloc((unsigned)strlen(str) + 1), str);
218444c061aSmrg}
219