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