CAMLprim value ml_XtDestroyApplicationContext( value app_context ) { XtDestroyApplicationContext( *(XtAppContext_val(app_context)) ); return Val_unit; }
static void test_XtAppMainLoop_34715(void) { XtAppContext app; struct sigaction sa; XtToolkitInitialize(); app = XtCreateApplicationContext(); XtAppAddTimeOut(app, 1000, _Tick, app); /* AppTimeouts should finish and exit in 3 seconds. Give them 10 seconds just in case system is busy, then fail. */ sa.sa_handler = sigalrm; sa.sa_flags = SA_RESTART; sigemptyset (&sa.sa_mask); if (sigsetjmp(jump_env, 1) == 0) { sigaction(SIGALRM, &sa, NULL); alarm(10); XtAppMainLoop(app); } else { g_assert(XtAppGetExitFlag(app) == TRUE); g_assert(0 /* timed out */); } g_assert(XtAppGetExitFlag(app) == TRUE); XtDestroyApplicationContext(app); }
static void quit_action (Widget w, XtPointer client_data, XtPointer call_data) { Widget dialog = (Widget) client_data; destroy_popup_prompt (NULL, (XtPointer) dialog, (XtPointer) NULL); XtDestroyApplicationContext (XtWidgetToApplicationContext (w)); exit (0); }
void serve_client(int socket) { XEvent event; XtToolkitInitialize(); app_context = XtCreateApplicationContext(); LispAction.string = "Lisp"; LispAction.proc = LispActionProc; XtAppAddActions(app_context, &LispAction, 1); string_token_tag = find_type_entry(ExtRStringToken); string_tag = find_type_entry(XtRString); xm_string_tag = find_type_entry(XmRXmString); enum_tag = find_type_entry(XtREnum); int_tag = find_type_entry(XtRInt); window_tag = find_type_entry(XtRWindow); boolean_tag = find_type_entry(XtRBoolean); widget_tag = find_type_entry(XtRWidget); function_tag = find_type_entry(XtRFunction); callback_reason_tag = find_type_entry(ExtRCallbackReason); event_tag = find_type_entry(ExtREvent); resource_list_tag = find_type_entry(ExtRResourceList); translation_table_tag = find_type_entry(XtRTranslationTable); accelerator_table_tag = find_type_entry(XtRAcceleratorTable); atom_tag = find_type_entry(XtRAtom); font_list_tag = find_type_entry(XmRFontList); string_table_tag = find_type_entry(XtRStringTable); xm_string_table_tag = find_type_entry(XmRXmStringTable); int_list_tag = find_type_entry(ExtRIntList); cursor_tag = find_type_entry(XtRCursor); client_socket = socket; greet_client(socket); XtAppAddInput(app_context, socket, (XtPointer)XtInputReadMask, (XtInputCallbackProc)get_input, (XtPointer)NULL); XtAppSetErrorHandler(app_context, MyErrorHandler); XtAppSetWarningHandler(app_context, MyWarningHandler); /* Here is where we want to return on errors */ if( setjmp(env) ) { printf("Attempting to recover from error.\n"); fflush(stdout); } while( !terminate_server ) { XtAppNextEvent(app_context, &event); XtDispatchEvent(&event); } close(socket); XtDestroyApplicationContext(app_context); exit(0); }
/* * termination of program wrt X; freeing of resources, etc */ void dmTerminateX() { /* Remove the properties on the root window */ if(windowPropertyAtom != (Atom)NULL) XDeleteProperty(display,rootWindow,windowPropertyAtom); XFlush(display); XtDestroyApplicationContext(appContext); XtCloseDisplay(display); }
/******************************************************************************* Name: XclipsExit Description: exit CLIPS in case of abnormal exit Arguments: num - unused Returns: *******************************************************************************/ int XclipsExit( void *theEnv, int num) { EnvDribbleOff(theEnv); EnvDeleteRouter(theEnv,"wclips"); XtDestroyApplicationContext(app_con); ReleaseLogTable(); exit(0); }
void OnLibraryUnload() { #ifdef XT XtDestroyApplicationContext(app_context); #endif // Destroy the native displays. if (disp != NULL) { XCloseDisplay(disp); disp = NULL; } }
/* This routine closes the X connection. It is not to be called for finishing a graph. */ int X11_Close(void) { // don't, this has never been mapped, there is no window ... // XtUnmapWidget(toplevel); XtDestroyWidget(toplevel); XtAppContext app = XtDisplayToApplicationContext(display); XtDestroyApplicationContext(app); // don't, XtDestroyApplicationContext(app) seems to have done that // XCloseDisplay(display); return 0; }
/* * Function Name: main * Description: * Arguments: the usual suspects * Returns: nothing * */ int main(int argc, char **argv) { Widget top, pane; Arg args[10]; Cardinal num_args; XtAppContext app_con; num_args = 0; XtSetArg(args[num_args], XmNtitle, "Outline Demo"); num_args++; XtSetArg(args[num_args], XmNallowShellResize, True); num_args++; top = XtAppInitialize(&app_con, "Treedemo", NULL, 0, &argc, argv, fallbacks, args, num_args); { Widget sw; num_args = 0; pane = XtCreateManagedWidget("pane", xmPanedWindowWidgetClass, top, args, num_args); WriteUpHype(pane); num_args = 0; XtSetArg(args[num_args], XmNscrollingPolicy, XmAUTOMATIC); num_args++; XtSetArg(args[num_args], XmNheight, 500); num_args++; sw = XtCreateManagedWidget("pane", xmScrolledWindowWidgetClass, pane, args, num_args); BuildHierarchy(sw, xmOutlineWidgetClass); MakeControlPanel(pane); InitializePanel(pane); } XtRealizeWidget(top); /* Process events, unwrapping correctly. */ while (!done) { XEvent event; XtAppNextEvent(app_con, &event); XtDispatchEvent(&event); } XtDestroyWidget(top); XtDestroyApplicationContext(app_con); exit(0); }
static void NotifierExitHandler( ClientData clientData) /* Not used. */ { if (notifier.currentTimeout != 0) { XtRemoveTimeOut(notifier.currentTimeout); } for (; notifier.firstFileHandlerPtr != NULL; ) { Tcl_DeleteFileHandler(notifier.firstFileHandlerPtr->fd); } if (notifier.appContextCreated) { XtDestroyApplicationContext(notifier.appContext); notifier.appContextCreated = 0; notifier.appContext = NULL; } initialized = 0; }
XtActionProc reallyQuit(Widget w, XButtonEvent *ev ) { extern char *txtbuf; if(txtbuf) free(txtbuf); if(icon_pixmap) { XFreePixmap(XtDisplay(topLevel), icon_pixmap); } XtDestroyApplicationContext(app_con); /* fprintf(stderr,"Bye.\n");*/ exit(0); }
// Callback when done static void QuitCB(Widget, XtPointer, XtPointer) { if (VSEFlags::verbose) { std::cout << "Quit!\n"; std::cout.flush(); } XtDestroyApplicationContext(app_con); // Clear box if (thebox) thebox->unlink(); // Check if we really deleted everything if (UniqueId::inUse() > 0) std::cerr << "Warning: " << UniqueId::inUse() << " IDs still in use\n"; exit(EXIT_SUCCESS); }
int wind (int argc, char **argv, char *labtext) { /* Create the window and its contents' appearance. */ toplevel = XtOpenApplication (&app_context, "xcid", NULL, 0, &argc, argv, NULL, applicationShellWidgetClass, NULL, 0); XtVaSetValues(toplevel, XtNtitle, "XCid - Incoming Call", NULL); form = XtVaCreateManagedWidget ("form", formWidgetClass, toplevel, NULL); mlabel = XtVaCreateManagedWidget ("mlabel", labelWidgetClass, form, XtNwidth, 200, XtNheight, 200, NULL); telemar = XtVaCreateManagedWidget ("telemar", commandWidgetClass, form, XtNlabel, "Telemarketerize", XtNfromVert, mlabel, NULL); quit_button = XtVaCreateManagedWidget ("quit_button", commandWidgetClass, form, XtNlabel, "Close", XtNfromHoriz, telemar, XtNfromVert, mlabel, NULL); timer = XtAppAddTimeOut(app_context, 1000, htime, (XtPointer) 0); /* Create window's behavior. */ XtAddCallback (quit_button, XtNcallback, quit_proc, NULL); XtAddCallback(telemar, XtNcallback, telecall, NULL); /* Display the window. */ XtRealizeWidget (toplevel); XtVaSetValues (mlabel, XtNlabel, labtext, NULL); /* Infinite loop, waiting for events to happen. */ XtAppMainLoop (app_context); if(tflag) { #ifdef DEBUG printf("about...\n"); #endif XtDestroyApplicationContext (app_context); tflag = 0; tsec = 10; #ifdef DEBUG printf("done...\n"); #endif } return 0; }
/* ARGSUSED */ static void QuitProgram(Widget w, void *pp_con, XtPointer call_data) { fprintf(stderr, "Bye!\n"); XtDestroyApplicationContext((XtAppContext) app_con); exit(0); }
/* The callback function for the quit button. */ void quit_proc (Widget w, XtPointer client_data, XtPointer call_data) { XtDestroyApplicationContext (app_context); XtAppSetExitFlag (app_context); }
void do_quit(Widget w, XtPointer unused1, XtPointer unused2) { XtDestroyApplicationContext(application_context); exit(0); }
int XtTest(int argc, char** argv) { Widget toplevel; Display* display; XtAppContext context; Widget form, label, label1, label2, button; Screen* screen; String swap; if (NULL == (swap = strrchr(argv[0], '/'))) { swap = argv[0]; } else { swap++; } context = XtCreateApplicationContext(); display = XtOpenDisplay( context, NULL, NULL, NULL, NULL, 0, &argc, argv); if (NULL == display) { return 0; } screen = XDefaultScreenOfDisplay(display); toplevel = XtVaAppCreateShell("k", "XtTest", applicationShellWidgetClass, display, XtNtitle, swap, XtNx, (screen->width /3), XtNy, (screen->height /3), NULL ); if (NULL == toplevel) { return -2; } if (3 != argc) { form = XtVaCreateManagedWidget("form", xmFormWidgetClass, toplevel, XmNhorizontalSpacing, 5, XmNmarginHeight, 10, XmNmarginWidth, 10, NULL ); label = XtVaCreateManagedWidget("label", xmLabelGadgetClass, form, XmNlabelString, XmStringCreateLocalized("Usage"), XmNalignment, XmALIGNMENT_BEGINNING, XmNtopAttachment, XmATTACH_FORM, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, NULL ); label1 = XtVaCreateManagedWidget("label1", xmLabelGadgetClass, form, XmNlabelString, XmStringCreateLocalized(swap), XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, label, XmNleftAttachment, XmATTACH_FORM, XmNbottomAttachment, XmATTACH_FORM, NULL ); label2 = XtVaCreateManagedWidget("label2", xmLabelGadgetClass, form, XmNlabelString, XmStringCreateLocalized(": arg1 arg2"), XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, label, XmNleftAttachment, XmATTACH_WIDGET, XmNleftWidget, label1, XmNbottomAttachment, XmATTACH_FORM, NULL); button = XtVaCreateManagedWidget("button", xmPushButtonWidgetClass, form, XmNlabelString, XmStringCreateLocalized("Close"), XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, label, XmNleftAttachment, XmATTACH_WIDGET, XmNleftWidget, label2, XmNbottomAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, NULL); XtAddCallback(button, XmNactivateCallback, XtTestDC, context); XtRealizeWidget(toplevel); XtAppMainLoop(context); } XtDestroyWidget(toplevel); XtDestroyApplicationContext(context); return 0; }
int main (int argc, char **argv) { XtAppContext appContext; Widget topLevel; Boolean quit = False; // Initialize toolkit topLevel = XtVaAppInitialize (&appContext, "MDI", NULL, 0, &argc, argv, fallbacks, XmNdeleteResponse, XmDO_NOTHING, NULL); Display *dpy = XtDisplay (topLevel); // Add protocols Atom WM_DELETE_WINDOW = XmInternAtom (dpy, "WM_DELETE_WINDOW", False); XmAddWMProtocolCallback (topLevel, WM_DELETE_WINDOW, _destroyCallback, &quit); // Create the MDI canvas XsMDICanvas *canvas = new XsMDICanvas ("MDItest", topLevel); // Create the MDI documents MyDocument *win1 = new MyDocument ("Document", canvas); MyDocument2 *win2 = new MyDocument2 ("Document 2"); // Add documents to MDI canvas canvas->add (win1); canvas->add (win2); // Show the canvas canvas->show ( ); // Realize everything XtRealizeWidget (topLevel); // Let 'er rip XEvent event; while (!quit) { XtAppNextEvent (appContext, &event); XtDispatchEvent (&event); } // Cleanup delete win1; delete win2; delete canvas; // Close the X connection XtDestroyWidget (topLevel); XtCloseDisplay (dpy); XtDestroyApplicationContext (appContext); return (0); }
static void destroy_help(Widget widget, XtPointer client_data, XtPointer call_data) { XtDestroyApplicationContext(help_context); help_context = NULL; }
static void ActualExit () { XtDestroyApplicationContext (MyContext); exit (0); };
static void Syntax(XtAppContext app_con,char *call) { XtDestroyApplicationContext(app_con); fprintf( stderr, "Usage: %s \n", call); exit(1); }