1 /*********************************************************** 2 3 Copyright 1987, 1988, 1994, 1998 The Open Group 4 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 9 documentation. 10 11 The above copyright notice and this permission notice shall be included in 12 all copies or substantial portions of the Software. 13 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. 20 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. 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 #ifdef HAVE_CONFIG_H 48 #include <config.h> 49 #endif 50 #include "IntrinsicI.h" 51 #include "ShellP.h" 52 53 void 54 _XtPopup(Widget widget, XtGrabKind grab_kind, _XtBoolean spring_loaded) 55 { 56 register ShellWidget shell_widget = (ShellWidget) widget; 57 58 if (!XtIsShell(widget)) { 59 XtAppErrorMsg(XtWidgetToApplicationContext(widget), 60 "invalidClass", "xtPopup", XtCXtToolkitError, 61 "XtPopup requires a subclass of shellWidgetClass", 62 NULL, NULL); 63 } 64 65 if (!shell_widget->shell.popped_up) { 66 XtGrabKind call_data = grab_kind; 67 68 XtCallCallbacks(widget, XtNpopupCallback, (XtPointer) &call_data); 69 shell_widget->shell.popped_up = TRUE; 70 shell_widget->shell.grab_kind = grab_kind; 71 shell_widget->shell.spring_loaded = (Boolean) spring_loaded; 72 if (shell_widget->shell.create_popup_child_proc != NULL) { 73 (*(shell_widget->shell.create_popup_child_proc)) (widget); 74 } 75 if (grab_kind == XtGrabExclusive) { 76 XtAddGrab(widget, TRUE, spring_loaded); 77 } 78 else if (grab_kind == XtGrabNonexclusive) { 79 XtAddGrab(widget, FALSE, spring_loaded); 80 } 81 XtRealizeWidget(widget); 82 XMapRaised(XtDisplay(widget), XtWindow(widget)); 83 } 84 else 85 XRaiseWindow(XtDisplay(widget), XtWindow(widget)); 86 87 } /* _XtPopup */ 88 89 void 90 XtPopup(Widget widget, XtGrabKind grab_kind) 91 { 92 Widget hookobj; 93 94 switch (grab_kind) { 95 96 case XtGrabNone: 97 case XtGrabExclusive: 98 case XtGrabNonexclusive: 99 break; 100 101 default: 102 XtAppWarningMsg(XtWidgetToApplicationContext(widget), 103 "invalidGrabKind", "xtPopup", XtCXtToolkitError, 104 "grab kind argument has invalid value; XtGrabNone assumed", 105 NULL, NULL); 106 grab_kind = XtGrabNone; 107 } 108 109 _XtPopup(widget, grab_kind, FALSE); 110 111 hookobj = XtHooksOfDisplay(XtDisplay(widget)); 112 if (XtHasCallbacks(hookobj, XtNchangeHook) == XtCallbackHasSome) { 113 XtChangeHookDataRec call_data; 114 115 call_data.type = XtHpopup; 116 call_data.widget = widget; 117 call_data.event_data = (XtPointer) (XtIntPtr) grab_kind; 118 XtCallCallbackList(hookobj, 119 ((HookObject) hookobj)->hooks.changehook_callbacks, 120 (XtPointer) &call_data); 121 } 122 } /* XtPopup */ 123 124 void 125 XtPopupSpringLoaded(Widget widget) 126 { 127 Widget hookobj; 128 129 _XtPopup(widget, XtGrabExclusive, True); 130 131 hookobj = XtHooksOfDisplay(XtDisplay(widget)); 132 if (XtHasCallbacks(hookobj, XtNchangeHook) == XtCallbackHasSome) { 133 XtChangeHookDataRec call_data; 134 135 call_data.type = XtHpopupSpringLoaded; 136 call_data.widget = widget; 137 XtCallCallbackList(hookobj, 138 ((HookObject) hookobj)->hooks.changehook_callbacks, 139 (XtPointer) &call_data); 140 } 141 } 142 143 void 144 XtPopdown(Widget widget) 145 { 146 /* Unmap a shell widget if it is mapped, and remove from grab list */ 147 Widget hookobj; 148 ShellWidget shell_widget = (ShellWidget) widget; 149 XtGrabKind grab_kind; 150 151 if (!XtIsShell(widget)) { 152 XtAppErrorMsg(XtWidgetToApplicationContext(widget), 153 "invalidClass", "xtPopdown", XtCXtToolkitError, 154 "XtPopdown requires a subclass of shellWidgetClass", 155 NULL, NULL); 156 } 157 158 #ifndef X_NO_XT_POPDOWN_CONFORMANCE 159 if (!shell_widget->shell.popped_up) 160 return; 161 #endif 162 163 grab_kind = shell_widget->shell.grab_kind; 164 XWithdrawWindow(XtDisplay(widget), XtWindow(widget), 165 XScreenNumberOfScreen(XtScreen(widget))); 166 if (grab_kind != XtGrabNone) 167 XtRemoveGrab(widget); 168 shell_widget->shell.popped_up = FALSE; 169 XtCallCallbacks(widget, XtNpopdownCallback, (XtPointer) &grab_kind); 170 171 hookobj = XtHooksOfDisplay(XtDisplay(widget)); 172 if (XtHasCallbacks(hookobj, XtNchangeHook) == XtCallbackHasSome) { 173 XtChangeHookDataRec call_data; 174 175 call_data.type = XtHpopdown; 176 call_data.widget = widget; 177 XtCallCallbackList(hookobj, 178 ((HookObject) hookobj)->hooks.changehook_callbacks, 179 (XtPointer) &call_data); 180 } 181 } /* XtPopdown */ 182 183 void 184 XtCallbackPopdown(Widget widget _X_UNUSED, 185 XtPointer closure, 186 XtPointer call_data _X_UNUSED) 187 { 188 register XtPopdownID id = (XtPopdownID) closure; 189 190 XtPopdown(id->shell_widget); 191 if (id->enable_widget != NULL) { 192 XtSetSensitive(id->enable_widget, TRUE); 193 } 194 } /* XtCallbackPopdown */ 195