void XtUnrealizeWidget ( Widget widget) { Window window; Widget hookobj; WIDGET_TO_APPCON(widget); LOCK_APP(app); window = XtWindow(widget); if (! XtIsRealized (widget)) { UNLOCK_APP(app); return; } if (widget->core.managed && widget->core.parent != NULL) XtUnmanageChild(widget); UnrealizeWidget(widget); if (window != None) XDestroyWindow(XtDisplay(widget), window); hookobj = XtHooksOfDisplay(XtDisplayOfObject(widget)); if (XtHasCallbacks(hookobj, XtNchangeHook) == XtCallbackHasSome) { XtChangeHookDataRec call_data; call_data.type = XtHunrealizeWidget; call_data.widget = widget; XtCallCallbackList(hookobj, ((HookObject)hookobj)->hooks.changehook_callbacks, (XtPointer)&call_data); } UNLOCK_APP(app); } /* XtUnrealizeWidget */
void XtRemoveAllCallbacks( Widget widget, _Xconst char* name) { InternalCallbackList *callbacks; Widget hookobj; XtAppContext app = XtWidgetToApplicationContext(widget); LOCK_APP(app); callbacks = FetchInternalList(widget, name); if (!callbacks) { XtAppWarningMsg(app, XtNinvalidCallbackList,XtNxtRemoveAllCallback,XtCXtToolkitError, "Cannot find callback list in XtRemoveAllCallbacks", (String *)NULL, (Cardinal *)NULL); UNLOCK_APP(app); return; } _XtRemoveAllCallbacks(callbacks); hookobj = XtHooksOfDisplay(XtDisplayOfObject(widget)); if (XtHasCallbacks(hookobj, XtNchangeHook) == XtCallbackHasSome) { XtChangeHookDataRec call_data; call_data.type = XtHremoveAllCallbacks; call_data.widget = widget; call_data.event_data = (XtPointer) name; XtCallCallbackList(hookobj, ((HookObject)hookobj)->hooks.changehook_callbacks, (XtPointer)&call_data); } UNLOCK_APP(app); } /* XtRemoveAllCallbacks */
void XtSetSensitive( register Widget widget, _XtBoolean sensitive) { Arg args[1]; register Cardinal i; register WidgetList children; WIDGET_TO_APPCON(widget); LOCK_APP(app); if (widget->core.sensitive == sensitive) { UNLOCK_APP(app); return; } XtSetArg(args[0], XtNsensitive, sensitive); XtSetValues(widget, args, XtNumber(args)); /* If widget's ancestor_sensitive is TRUE, propagate new sensitive to children's ancestor_sensitive; else do nothing as children's ancestor_sensitive is already FALSE */ if (widget->core.ancestor_sensitive && XtIsComposite (widget)) { children = ((CompositeWidget) widget)->composite.children; for (i = 0; i < ((CompositeWidget)widget)->composite.num_children; i++){ SetAncestorSensitive (children[i], sensitive); } } UNLOCK_APP(app); } /* XtSetSensitive */
void XtCallCallbackList( Widget widget, XtCallbackList callbacks, XtPointer call_data) { register InternalCallbackList icl; register XtCallbackList cl; register int i; char ostate; WIDGET_TO_APPCON(widget); LOCK_APP(app); if (!callbacks) { UNLOCK_APP(app); return; } icl = (InternalCallbackList)callbacks; cl = ToList(icl); if (icl->count == 1) { (*cl->callback) (widget, cl->closure, call_data); UNLOCK_APP(app); return; } ostate = icl->call_state; icl->call_state = _XtCBCalling; for (i = icl->count; --i >= 0; cl++) (*cl->callback) (widget, cl->closure, call_data); if (ostate) icl->call_state |= ostate; else if (icl->call_state & _XtCBFreeAfterCalling) XtFree((char *)icl); else icl->call_state = 0; UNLOCK_APP(app); } /* XtCallCallbackList */
Widget XtNameToWidget( Widget root, _Xconst char* name) { XrmName *names; XrmBinding *bindings; int len, depth, found = 10000; Widget result; WIDGET_TO_APPCON(root); len = strlen(name); if (len == 0) return NULL; LOCK_APP(app); names = (XrmName *) ALLOCATE_LOCAL((unsigned) (len+1) * sizeof(XrmName)); bindings = (XrmBinding *) ALLOCATE_LOCAL((unsigned) (len+1) * sizeof(XrmBinding)); if (names == NULL || bindings == NULL) _XtAllocError(NULL); XrmStringToBindingQuarkList(name, bindings, names); if (names[0] == NULLQUARK) { DEALLOCATE_LOCAL((char *) bindings); DEALLOCATE_LOCAL((char *) names); UNLOCK_APP(app); return NULL; } result = NameListToWidget(root, names, bindings, 0, &depth, &found); DEALLOCATE_LOCAL((char *) bindings); DEALLOCATE_LOCAL((char *) names); UNLOCK_APP(app); return result; } /* XtNameToWidget */
void XtRealizeWidget ( Widget widget) { WIDGET_TO_APPCON(widget); LOCK_APP(app); if (XtIsRealized (widget)) { UNLOCK_APP(app); return; } CallChangeManaged(widget); RealizeWidget(widget); UNLOCK_APP(app); } /* XtRealizeWidget */
void XtTranslateCoords( register Widget w, _XtPosition x, _XtPosition y, register Position *rootx, /* return */ register Position *rooty) /* return */ { Position garbagex, garbagey; XtAppContext app = XtWidgetToApplicationContext(w); LOCK_APP(app); if (rootx == NULL) rootx = &garbagex; if (rooty == NULL) rooty = &garbagey; *rootx = x; *rooty = y; for (; w != NULL && ! XtIsShell(w); w = w->core.parent) { *rootx += w->core.x + w->core.border_width; *rooty += w->core.y + w->core.border_width; } if (w == NULL) XtAppWarningMsg(app, "invalidShell","xtTranslateCoords",XtCXtToolkitError, "Widget has no shell ancestor", (String *)NULL, (Cardinal *)NULL); else { Position x, y; _XtShellGetCoordinates( w, &x, &y ); *rootx += x + w->core.border_width; *rooty += y + w->core.border_width; } UNLOCK_APP(app); }
void XtResizeWindow( Widget w) { XtConfigureHookDataRec req; Widget hookobj; WIDGET_TO_APPCON(w); LOCK_APP(app); if (XtIsRealized(w)) { req.changes.width = w->core.width; req.changes.height = w->core.height; req.changes.border_width = w->core.border_width; req.changeMask = CWWidth | CWHeight | CWBorderWidth; XConfigureWindow(XtDisplay(w), XtWindow(w), (unsigned) req.changeMask, &req.changes); hookobj = XtHooksOfDisplay(XtDisplayOfObject(w));; if (XtHasCallbacks(hookobj, XtNconfigureHook) == XtCallbackHasSome) { req.type = XtHconfigure; req.widget = w; XtCallCallbackList(hookobj, ((HookObject)hookobj)->hooks.confighook_callbacks, (XtPointer)&req); } } UNLOCK_APP(app); } /* XtResizeWindow */
Widget XtVaCreateManagedWidget( _Xconst char* name, WidgetClass widget_class, Widget parent, ...) { va_list var; register Widget widget; int total_count, typed_count; WIDGET_TO_APPCON(parent); LOCK_APP(app); va_start(var,parent); _XtCountVaList(var, &total_count, &typed_count); va_end(var); va_start(var,parent); widget = _XtVaCreateWidget((String)name, widget_class, parent, var, total_count); XtManageChild(widget); va_end(var); UNLOCK_APP(app); return widget; }
void XtCreateWindow( Widget widget, unsigned int window_class, Visual *visual, XtValueMask value_mask, XSetWindowAttributes *attributes) { XtAppContext app = XtWidgetToApplicationContext(widget); LOCK_APP(app); if (widget->core.window == None) { if (widget->core.width == 0 || widget->core.height == 0) { Cardinal count = 1; XtAppErrorMsg(app, "invalidDimension", "xtCreateWindow", XtCXtToolkitError, "Widget %s has zero width and/or height", &widget->core.name, &count); } widget->core.window = XCreateWindow ( XtDisplay (widget), (widget->core.parent ? widget->core.parent->core.window : widget->core.screen->root), (int)widget->core.x, (int)widget->core.y, (unsigned)widget->core.width, (unsigned)widget->core.height, (unsigned)widget->core.border_width, (int) widget->core.depth, window_class, visual, value_mask, attributes); } UNLOCK_APP(app); } /* XtCreateWindow */
EventMask XtBuildEventMask( Widget widget) { XtEventTable ev; EventMask mask = 0L; WIDGET_TO_APPCON(widget); LOCK_APP(app); for (ev = widget->core.event_table; ev != NULL; ev = ev->next) if (ev->select) { if (!ev->has_type_specifier) mask |= ev->mask; else { if (EXT_TYPE(ev) < LASTEvent) { Cardinal i; for (i = 0; i < ev->mask; i++) if (EXT_SELECT_DATA(ev, i)) mask |= *(EventMask*)EXT_SELECT_DATA(ev, i); } } } LOCK_PROCESS; if (widget->core.widget_class->core_class.expose != NULL) mask |= ExposureMask; if (widget->core.widget_class->core_class.visible_interest) mask |= VisibilityChangeMask; UNLOCK_PROCESS; if (widget->core.tm.translations) mask |= widget->core.tm.translations->eventMask; mask = mask & ~NonMaskableMask; UNLOCK_APP(app); return mask; }
XtGeometryResult XtMakeGeometryRequest ( Widget widget, XtWidgetGeometry *request, XtWidgetGeometry *reply) { Boolean junk; XtGeometryResult r; XtGeometryHookDataRec call_data; Widget hookobj = XtHooksOfDisplay(XtDisplayOfObject(widget)); WIDGET_TO_APPCON(widget); LOCK_APP(app); if (XtHasCallbacks(hookobj, XtNgeometryHook) == XtCallbackHasSome) { call_data.type = XtHpreGeometry; call_data.widget = widget; call_data.request = request; XtCallCallbackList(hookobj, ((HookObject)hookobj)->hooks.geometryhook_callbacks, (XtPointer)&call_data); call_data.result = r = _XtMakeGeometryRequest(widget, request, reply, &junk); call_data.type = XtHpostGeometry; call_data.reply = reply; XtCallCallbackList(hookobj, ((HookObject)hookobj)->hooks.geometryhook_callbacks, (XtPointer)&call_data); } else { r = _XtMakeGeometryRequest(widget, request, reply, &junk); } UNLOCK_APP(app); return ((r == XtGeometryDone) ? XtGeometryYes : r); }
void XtCallCallbacks( Widget widget, _Xconst char* name, XtPointer call_data ) { InternalCallbackList *callbacks; InternalCallbackList icl; XtCallbackList cl; int i; char ostate; XtAppContext app = XtWidgetToApplicationContext(widget); LOCK_APP(app); callbacks = FetchInternalList(widget, name); if (!callbacks) { XtAppWarningMsg(app, XtNinvalidCallbackList,XtNxtCallCallback,XtCXtToolkitError, "Cannot find callback list in XtCallCallbacks", (String *)NULL, (Cardinal *)NULL); UNLOCK_APP(app); return; } icl = *callbacks; if (!icl) { UNLOCK_APP(app); return; } cl = ToList(icl); if (icl->count == 1) { (*cl->callback) (widget, cl->closure, call_data); UNLOCK_APP(app); return; } ostate = icl->call_state; icl->call_state = _XtCBCalling; for (i = icl->count; --i >= 0; cl++) (*cl->callback) (widget, cl->closure, call_data); if (ostate) icl->call_state |= ostate; else if (icl->call_state & _XtCBFreeAfterCalling) XtFree((char *)icl); else icl->call_state = ostate; UNLOCK_APP(app); } /* XtCallCallbacks */
void XtSetMultiClickTime( Display *dpy, int time) { DPY_TO_APPCON(dpy); LOCK_APP(app); _XtGetPerDisplay(dpy)->multi_click_time = time; UNLOCK_APP(app); }
void XtUngrabPointer( Widget widget, Time time) { WIDGET_TO_APPCON(widget); LOCK_APP(app); UngrabDevice(widget, time, POINTER); UNLOCK_APP(app); }
void XtUngrabKeyboard( Widget widget, Time time) { WIDGET_TO_APPCON(widget); LOCK_APP(app); UngrabDevice(widget, time, KEYBOARD); UNLOCK_APP(app); }
void XtUnmanageChildren ( WidgetList children, Cardinal num_children) { Widget parent, hookobj; Cardinal ii; #ifdef XTHREADS XtAppContext app; #endif if (num_children == 0) return; if (children[0] == NULL) { XtWarningMsg(XtNinvalidChild,XtNxtUnmanageChildren,XtCXtToolkitError, "Null child found in argument list to unmanage", (String *)NULL, (Cardinal *)NULL); return; } #ifdef XTHREADS app = XtWidgetToApplicationContext(children[0]); #endif LOCK_APP(app); parent = children[0]->core.parent; if (parent->core.being_destroyed) { UNLOCK_APP(app); return; } UnmanageChildren(children, num_children, parent, &ii, (Boolean)True, XtNxtUnmanageChildren); hookobj = XtHooksOfDisplay(XtDisplayOfObject(children[0])); if (XtHasCallbacks(hookobj, XtNchangeHook) == XtCallbackHasSome) { XtChangeHookDataRec call_data; call_data.type = XtHunmanageChildren; call_data.widget = parent; call_data.event_data = (XtPointer) children; call_data.num_event_data = num_children; XtCallCallbackList(hookobj, ((HookObject)hookobj)->hooks.changehook_callbacks, (XtPointer)&call_data); } UNLOCK_APP(app); } /* XtUnmanageChildren */
void XtUngrabButton ( Widget widget, unsigned int button, Modifiers modifiers) { WIDGET_TO_APPCON(widget); LOCK_APP(app); UngrabKeyOrButton(widget, (KeyCode)button, modifiers, POINTER); UNLOCK_APP(app); }
Boolean XtIsRealized ( Widget object) { Boolean retval; WIDGET_TO_APPCON(object); LOCK_APP(app); retval = XtWindowOfObject(object) != None; UNLOCK_APP(app); return retval; } /* XtIsRealized */
int XtGetMultiClickTime( Display *dpy) { int retval; DPY_TO_APPCON(dpy); LOCK_APP(app); retval = _XtGetPerDisplay(dpy)->multi_click_time; UNLOCK_APP(app); return retval; }
void XtUngrabKey ( Widget widget, _XtKeyCode keycode, Modifiers modifiers) { WIDGET_TO_APPCON(widget); LOCK_APP(app); UngrabKeyOrButton(widget, (int)keycode, modifiers, KEYBOARD); UNLOCK_APP(app); }
void XtRemoveBlockHook( XtBlockHookId id) { BlockHook *p, hook = (BlockHook)id; XtAppContext app = hook->app; LOCK_APP(app); for (p = &app->block_hook_list; p != NULL && *p != hook; p = &(*p)->next); if (p == NULL) { #ifdef DEBUG XtAppWarningMsg(app, "badId", "xtRemoveBlockHook", XtCXtToolkitError, "XtRemoveBlockHook called with bad or old hook id", (String*)NULL, (Cardinal*)NULL); #endif /*DEBUG*/ UNLOCK_APP(app); return; } *p = hook->next; XtFree( (XtPointer)hook ); UNLOCK_APP(app); }
void XtSetMappedWhenManaged( Widget widget, _XtBoolean mapped_when_managed) { Widget hookobj; WIDGET_TO_APPCON(widget); LOCK_APP(app); if (widget->core.mapped_when_managed == mapped_when_managed) { UNLOCK_APP(app); return; } widget->core.mapped_when_managed = mapped_when_managed; hookobj = XtHooksOfDisplay(XtDisplay(widget)); if (XtHasCallbacks(hookobj, XtNchangeHook) == XtCallbackHasSome) { XtChangeHookDataRec call_data; call_data.type = XtHsetMappedWhenManaged; call_data.widget = widget; call_data.event_data = (XtPointer) (unsigned long) mapped_when_managed; XtCallCallbackList(hookobj, ((HookObject)hookobj)->hooks.changehook_callbacks, (XtPointer)&call_data); } if (! XtIsManaged(widget)) { UNLOCK_APP(app); return; } if (mapped_when_managed) { /* Didn't used to be mapped when managed. */ if (XtIsRealized(widget)) XtMapWidget(widget); } else { /* Used to be mapped when managed. */ if (XtIsRealized(widget)) XtUnmapWidget(widget); } UNLOCK_APP(app); } /* XtSetMappedWhenManaged */
XtGeometryResult XtMakeResizeRequest( Widget widget, _XtDimension width, _XtDimension height, Dimension *replyWidth, Dimension *replyHeight) { XtWidgetGeometry request, reply; XtGeometryResult r; XtGeometryHookDataRec call_data; Boolean junk; Widget hookobj = XtHooksOfDisplay(XtDisplayOfObject(widget)); WIDGET_TO_APPCON(widget); LOCK_APP(app); request.request_mode = CWWidth | CWHeight; request.width = width; request.height = height; if (XtHasCallbacks(hookobj, XtNgeometryHook) == XtCallbackHasSome) { call_data.type = XtHpreGeometry; call_data.widget = widget; call_data.request = &request; XtCallCallbackList(hookobj, ((HookObject)hookobj)->hooks.geometryhook_callbacks, (XtPointer)&call_data); call_data.result = r = _XtMakeGeometryRequest(widget, &request, &reply, &junk); call_data.type = XtHpostGeometry; call_data.reply = &reply; XtCallCallbackList(hookobj, ((HookObject)hookobj)->hooks.geometryhook_callbacks, (XtPointer)&call_data); } else { r = _XtMakeGeometryRequest(widget, &request, &reply, &junk); } if (replyWidth != NULL) { if (r == XtGeometryAlmost && reply.request_mode & CWWidth) *replyWidth = reply.width; else *replyWidth = width; } if (replyHeight != NULL) { if (r == XtGeometryAlmost && reply.request_mode & CWHeight) *replyHeight = reply.height; else *replyHeight = height; } UNLOCK_APP(app); return ((r == XtGeometryDone) ? XtGeometryYes : r); } /* XtMakeResizeRequest */
void XtRemoveEventTypeHandler( Widget widget, int type, XtPointer select_data, XtEventHandler proc, XtPointer closure) { WIDGET_TO_APPCON(widget); LOCK_APP(app); RemoveEventHandler(widget, select_data, type, TRUE, FALSE, proc, closure, FALSE); UNLOCK_APP(app); }
void XtAddRawEventHandler( Widget widget, EventMask eventMask, _XtBoolean other, XtEventHandler proc, XtPointer closure) { WIDGET_TO_APPCON(widget); LOCK_APP(app); AddEventHandler(widget, (XtPointer) &eventMask, 0, FALSE, other, proc, closure, XtListTail, FALSE, TRUE); UNLOCK_APP(app); }
void XtRemoveEventHandler( Widget widget, EventMask eventMask, _XtBoolean other, XtEventHandler proc, XtPointer closure) { WIDGET_TO_APPCON(widget); LOCK_APP(app); RemoveEventHandler(widget, (XtPointer) &eventMask, 0, FALSE, other, proc, closure, FALSE); UNLOCK_APP(app); }
void XtInsertEventTypeHandler( Widget widget, int type, XtPointer select_data, XtEventHandler proc, XtPointer closure, XtListPosition position) { WIDGET_TO_APPCON(widget); LOCK_APP(app); AddEventHandler(widget, select_data, type, TRUE, FALSE, proc, closure, position, TRUE, FALSE); UNLOCK_APP(app); }
void XtInsertEventHandler( Widget widget, EventMask eventMask, _XtBoolean other, XtEventHandler proc, XtPointer closure, XtListPosition position) { WIDGET_TO_APPCON(widget); LOCK_APP(app); AddEventHandler(widget, (XtPointer) &eventMask, 0, FALSE, other, proc, closure, position, TRUE, FALSE); UNLOCK_APP(app); }
Boolean XtIsSensitive( Widget object) { Boolean retval; WIDGET_TO_APPCON(object); LOCK_APP(app); if (XtIsRectObj(object)) retval = object->core.sensitive && object->core.ancestor_sensitive; else retval = False; UNLOCK_APP(app); return retval; }