void manage_and_raise(Widget w) { if (w != 0) { // If top-level shell is withdrawn or iconic, realize dialog as icon bool iconic = false; Widget shell = find_shell(w); if (shell != 0) { XWindowAttributes attr; iconic = (!XtIsRealized(shell) || XGetWindowAttributes(XtDisplay(shell), XtWindow(shell), &attr) && attr.map_state != IsViewable); if (iconic) XtVaSetValues(w, XmNinitialState, IconicState, XtPointer(0)); } XtManageChild(w); shell = w; while (shell != 0 && !XtIsShell(shell)) shell = XtParent(shell); if (shell != 0 && !XmIsDialogShell(shell)) { if (!XtIsRealized(shell)) XtRealizeWidget(shell); XtPopup(shell, XtGrabNone); } raise_shell(w); } }
Widget LocateShell(Widget w) { if(!w) return (Widget)0; while(w) { if(XtIsShell(w) || XmIsDialogShell(w)) return w; w = XtParent(w); } return (Widget)0; }
/* * Unmanage the dialog box which holds "w". */ void wl_dismiss(Widget w, XtPointer closure, XtPointer call) { USEUP(call); USEUP(closure); for(; XtParent(w) != NULL; w = XtParent(w)) if(XmIsDialogShell(XtParent(w))) break; XtUnmanageChild(w); }
// Unmanage specific widget void UnmanageThisCB(Widget, XtPointer client_data, XtPointer) { Widget w = Widget(client_data); Widget shell = w; if (!XtIsShell(shell)) shell = XtParent(shell); if (shell != 0 && XtIsShell(shell) && !XmIsDialogShell(shell)) XtPopdown(shell); XtUnmanageChild(w); }
static Widget widget_to_dialog(Widget w) { /* find dialog parent of w, if any */ while (w) { w = XtParent(w); if (w) { if ((XmIsFileSelectionBox(w)) || /* file selection dialog */ (XmIsMessageBox(w))) /* includes template dialog */ return(w); if ((XmIsDialogShell(w)) || (XtIsApplicationShell(w))) return(NULL); } } return(NULL); }
/* * border width and size and location are ty... * * 1. We allow the border width of a XmDialogShell child to change * size arbitrarily. * * 2. The border width of the shell widget tracks the child's * at all times, exactly. * * 3. The width of the shell is kept exactly the same as the * width of the child at all times. * * 4. The child is always positioned at the location * (- child_border, - child_border). * * the net result is the child has a border width which is always * what the user asked for; but none of it is ever seen, it's all * clipped by the shell (parent). The user sees the border * of the shell which is the size he set the child's border to. * * In the DEC window manager world the window manager does * exactly the same thing with the window it puts around the shell. * Hence the shell and child have a border width just as the user * set but the window manager overrides that and only a single * pixel border is displayed. In a non-wm environment the child * appears to have a border width, in reality this is the shell * widget border. You wanted to know... */ static void ChangeManaged( Widget wid ) { XmDialogShellWidget shell = (XmDialogShellWidget) wid ; /* * If the child went to unmanaged, call XtPopdown. * If the child went to managed, call XtPopup. */ Widget child; XmWidgetExtData extData = _XmGetWidgetExtData((Widget) shell, XmSHELL_EXTENSION); XmVendorShellExtObject ve = (XmVendorShellExtObject)extData->widget; XmDialogSavvyTrait trait ; if (((child = GetRectObjKid((CompositeWidget) shell)) == NULL) || (child->core.being_destroyed)) return; trait = (XmDialogSavvyTrait) XmeTraitGet((XtPointer) XtClass(child), XmQTdialogShellSavvy) ; /* MANAGED Case first ********/ if (child->core.managed) { XtWidgetGeometry request; Position kidX, kidY; Dimension kidBW; Boolean defaultPosition = True; /* * temporary workaround for setkeyboard focus ||| */ if (child != ve->vendor.old_managed) { XtSetKeyboardFocus((Widget)shell, (Widget)child); ve->vendor.old_managed = (Widget)child; } /* * if the child isn't realized, then we need to realize it * so we have a valid size. It will get created as a result * so we zero out it's position info so it'll * be okay and then restore it. */ if (!XtIsRealized(child)) { kidX = XtX(child); kidY = XtY(child); kidBW = XtBorderWidth(child); XtX(child) = 0; XtY(child) = 0; XtBorderWidth(child) = 0; /* Bug 4102306, This is an additional difference brought forward from motif 1.2 */ if (XtHeight(shell) != XtHeight(child)) { _XmImChangeManaged((Widget)shell); } /* End fix for Bug 4012306 */ XtRealizeWidget(child); XtX(child) = kidX; XtY(child) = kidY; XtBorderWidth(child) = kidBW; } else if (trait) { /* * Move the window to 0,0 * but don't tell the widget. It thinks it's where * the shell is... */ if ((XtX(child) != 0) || (XtY(child) != 0)) XMoveWindow (XtDisplay(child), XtWindow(child), 0, 0); } /* * map callback should occur BEFORE child default positioning * otherwise, widgets such as fileselection using map callback for * correct sizing have default positioning done before the widget * grows to its correct dimensions */ if(shell->core.mapped_when_managed && trait ) { trait->callMapUnmapCB(child, True); /* call Map callback */ } /* * Make sure that the shell has the same common parameters as * its child. Then move the child so that the shell will * correctly surround it. */ request.request_mode = 0; if (trait) { XtVaGetValues(child, XmNdefaultPosition, &defaultPosition, NULL); if (defaultPosition && (ve->vendor.externalReposition)) { defaultPosition = False; XtVaSetValues(child, XmNdefaultPosition, False, NULL); } } if (XtX(child) && trait) { kidX = XtX(child); XtX(child) = 0; } else kidX = XtX(shell); if (XtY(child) && trait) { kidY = XtY(child); XtY(child) = 0; } else kidY = XtY(shell); if (XtBorderWidth(child) && trait) { kidBW = XtBorderWidth(child); XtBorderWidth(child) = 0; } else kidBW = XtBorderWidth(shell); if (XtWidth (child) != XtWidth (shell)) { request.request_mode |= CWWidth; request.width = XtWidth(child); } if (XtHeight (child) + ve->vendor.im_height != XtHeight (shell)) { request.request_mode |= CWHeight; request.height = XtHeight(child) + ve->vendor.im_height; } if (trait) { if (defaultPosition) { GetDefaultPosition(child, XtParent(shell), &request.x, &request.y); if (request.x != kidX) request.request_mode |= CWX; if (request.y != kidY) request.request_mode |= CWY; } else { if (kidX != XtX(shell)) { request.request_mode |= CWX; if (kidX == XmDIALOG_SAVVY_FORCE_ORIGIN) request.x = 0; else request.x = kidX; } if (kidY != XtY(shell)) { request.request_mode |= CWY; if (kidY == XmDIALOG_SAVVY_FORCE_ORIGIN) request.y = 0; else request.y = kidY; } } } else { if (kidX != XtX(shell)) { request.request_mode |= CWX; request.x = kidX; } if (kidY != XtY(shell)) { request.request_mode |= CWY; request.y = kidY; } if (kidBW != XtBorderWidth(shell)) { request.request_mode |= CWBorderWidth; request.border_width = kidBW; } } if (request.request_mode) { unsigned int old_height = ve->vendor.im_height; XtMakeGeometryRequest((Widget) shell, &request, &request); _XmImResize((Widget)shell); if (ve->vendor.im_height != old_height) { request.request_mode = CWHeight; request.height = XtHeight(child) + ve->vendor.im_height; XtMakeGeometryRequest((Widget) shell, &request, &request); _XmImResize((Widget)shell); } } /* * the grab_kind is handled in the popup_callback */ if(shell->core.mapped_when_managed ) { XtPopup ((Widget) shell, XtGrabNone); } } /* * CHILD BEING UNMANAGED */ else { int i, j; /* * Fix for CR5043, CR5758 and CR8825 - * For nested Dialog Shells, it is necessary to unmanage * dialog shell popups of the child of this dialog shell. */ for (i = 0; i < child->core.num_popups; i++) { if (XmIsDialogShell(child->core.popup_list[i])) { XmDialogShellWidget next_shell = (XmDialogShellWidget)(child->core.popup_list[i]); for (j = 0; j < next_shell->composite.num_children; j++) { XtUnmanageChild(next_shell->composite.children[j]); } } } /* End Fix CR5043, CR5758 and CR8825 */ /* * take it down and then tell user */ XtPopdown((Widget) shell); if(trait ) { trait->callMapUnmapCB(child, False); /* call UnMap callback */ } } XmeNavigChangeManaged((Widget) shell); }