3 Copyright 1994, 1998 The Open Group
5 Permission to use, copy, modify, distribute, and sell this software and its
6 documentation for any purpose is hereby granted without fee, provided that
7 the above copyright notice appear in all copies and that both that
8 copyright notice and this permission notice appear in supporting
11 The above copyright notice and this permission notice shall be included in
12 all copies or substantial portions of the Software.
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 Except as contained in this notice, the name of The Open Group shall not be
22 used in advertising or otherwise to promote the sale, use or other dealings
23 in this Software without prior written authorization from The Open Group.
32 #include "IntrinsicI.h"
35 static void FreeBlockHookList(
36 Widget widget, /* unused (and invalid) */
37 XtPointer closure, /* ActionHook* */
38 XtPointer call_data) /* unused */
40 BlockHook list = *(BlockHook*)closure;
41 while (list != NULL) {
42 BlockHook next = list->next;
43 XtFree( (XtPointer)list );
49 XtBlockHookId XtAppAddBlockHook(
54 BlockHook hook = XtNew(BlockHookRec);
56 hook->next = app->block_hook_list;
59 hook->closure = closure;
60 if (app->block_hook_list == NULL) {
61 _XtAddCallback( &app->destroy_callbacks,
63 (XtPointer)&app->block_hook_list
66 app->block_hook_list = hook;
68 return (XtBlockHookId)hook;
72 void XtRemoveBlockHook(
75 BlockHook *p, hook = (BlockHook)id;
76 XtAppContext app = hook->app;
78 for (p = &app->block_hook_list; p != NULL && *p != hook; p = &(*p)->next);
81 XtAppWarningMsg(app, "badId", "xtRemoveBlockHook", XtCXtToolkitError,
82 "XtRemoveBlockHook called with bad or old hook id",
83 (String*)NULL, (Cardinal*)NULL);
89 XtFree( (XtPointer)hook );
93 static void DeleteShellFromHookObj(
98 /* app_con is locked when this function is called */
100 HookObject ho = (HookObject) closure;
102 for (ii = 0; ii < ho->hooks.num_shells; ii++)
103 if (ho->hooks.shells[ii] == shell) {
104 /* collapse the list */
105 for (jj = ii; jj < ho->hooks.num_shells; jj++) {
106 if ((jj+1) < ho->hooks.num_shells)
107 ho->hooks.shells[jj] = ho->hooks.shells[jj+1];
111 ho->hooks.num_shells--;
116 void _XtAddShellToHookObj(
119 /* app_con is locked when this function is called */
120 HookObject ho = (HookObject) XtHooksOfDisplay(XtDisplay(shell));
122 if (ho->hooks.num_shells == ho->hooks.max_shells) {
123 ho->hooks.max_shells += SHELL_INCR;
125 (WidgetList)XtRealloc((char*)ho->hooks.shells,
126 ho->hooks.max_shells * sizeof (Widget));
128 ho->hooks.shells[ho->hooks.num_shells++] = shell;
130 XtAddCallback(shell, XtNdestroyCallback, DeleteShellFromHookObj,
134 Boolean _XtIsHookObject(
137 return (widget->core.widget_class == hookObjectClass);
140 Widget XtHooksOfDisplay(
148 pd = _XtGetPerDisplay(dpy);
149 if (pd->hook_object == NULL)
151 _XtCreateHookObj((Screen*)DefaultScreenOfDisplay(dpy));
152 retval = pd->hook_object;