Beispiel #1
0
/******************************************************************************
*   MAIN function
******************************************************************************/
int main ( int argc, char **argv )
{
    trace_main = TRACE_MAIN;

    XtAppContext app;
    signal(SIGPIPE, SIG_IGN); /* ignore broken pipe on write */
    m_init();
    mv_init();


    XtSetLanguageProc (NULL, NULL, NULL);
    XawInitializeWidgetSet();
    /*  -- Intialize Toolkit creating the application shell
     */
    Widget appShell = XtOpenApplication (&app, APP_NAME,
	     options, XtNumber(options),  /* resources: can be set from argv */
	     &argc, argv,
	     fallback_resources,
	     sessionShellWidgetClass,
	     NULL, 0
	   );

    /* enable Editres support */
    XtAddEventHandler(appShell, (EventMask) 0, True, _XEditResCheckMessages, NULL);

    XtAddCallback( appShell, XtNdieCallback, quit_gui, NULL );

    /* not parsed options are removed by XtOpenApplication
       the only entry left should be the program name
    */
    if (argc != 1) { m_destruct(); syntax(); exit(1); }
    TopLevel = appShell;


    /*  -- Register all application specific callbacks and widget classes
     */
    RegisterApplication ( appShell );

    /*  -- Register all Athena and Public widget classes, CBs, ACTs
     */
    XpRegisterAll ( app );

    /*  -- Create widget tree below toplevel shell using Xrm database
     */
    WcWidgetCreation ( appShell );

    /* get application resources and widget ptr */
    XtGetApplicationResources(	appShell, (XtPointer)&SETTINGS,
				basicSettingRes,
				XtNumber(basicSettingRes),
				(ArgList)0, 0 );

    InitializeApplication(appShell);





    /*  -- Realize the widget tree and enter the main application loop
     */
    XtRealizeWidget ( appShell );
    grab_window_quit( appShell );
    //    pin_start_test();

    XtAppMainLoop ( app ); /* use XtAppSetExitFlag */
    XtDestroyWidget(appShell);

    v_free( SETTINGS.vset );
    mv_destroy();
    m_destruct();

    return EXIT_SUCCESS;
}
Beispiel #2
0
void InitWindow(int argc, char **argv) {
XGCValues gc_values;
XWMHints wmhints;
Widget w;
XClassHint classHint;
GC iconGC;

progName = (char *) rindex(argv[0], '/');
if (progName)
progName++;
else
progName = argv[0];

/*
 * We cheat here by using the Toolkit to do the initialization work.
 * We just ignore the top-level widget that gets created.
 */

w = XtAppInitialize(&app_con, progName, opTable, XtNumber(opTable), &argc, argv,
                    default_resources, NULL, ZERO);

if ((argc > 1) && (strcmp("-robot", argv[1]) == 0)) {
argc--;
app_resources.robotic = TRUE;
} else {
app_resources.robotic = FALSE;
}

printf("set robot. ");
dpy = XtDisplay(w);
screen = DefaultScreen(dpy);

printf("set Xscreen. ");

XtGetApplicationResources(w, (caddr_t) &app_resources, resources,
                          XtNumber(resources), NULL, (Cardinal) 0);

printf("set XResource. ");

if (!app_resources.scoreFont)
MWError("cannot open font");
scoreFontInfo = XQueryFont(dpy, app_resources.scoreFont);

printf("set XQueue. ");

cur_width = MIN_X_DIM;
cur_height = MIN_Y_DIM
  + (MAX_RATS + 1)
      * (scoreFontInfo->max_bounds.ascent + scoreFontInfo->max_bounds.descent);

mwWindow = XCreateSimpleWindow(dpy, RootWindow(dpy, screen), 0, 0, cur_width,
                               cur_height, app_resources.borderWidth, 0,
                               app_resources.bg_pixel);
XStoreName(dpy, mwWindow, "MazeWar");
XSetIconName(dpy, mwWindow, "MazeWar");
classHint.res_name = "cs244Bmazewar";
classHint.res_class = "cs244Bmazewar";
XSetClassHint(dpy, mwWindow, &classHint);

gc_values.function = GXcopy;
gc_values.foreground = app_resources.fg_pixel;
gc_values.background = app_resources.bg_pixel;
gc_values.font = app_resources.scoreFont;
gc_values.line_width = 0;
copyGC = XCreateGC(
  dpy, mwWindow,
  GCFunction | GCForeground | GCBackground | GCLineWidth | GCFont, &gc_values);

gc_values.function = GXxor;
gc_values.plane_mask = AllPlanes;
gc_values.foreground = app_resources.fg_pixel ^ app_resources.bg_pixel;
gc_values.background = 0;
xorGC = XCreateGC(dpy, mwWindow,
                  GCFunction | GCForeground | GCBackground | GCPlaneMask,
                  &gc_values);

icon_pixmap = XCreatePixmapFromBitmapData(dpy, mwWindow, (char *) icon_bits,
icon_width,
                                          icon_height, app_resources.fg_pixel,
                                          app_resources.bg_pixel,
                                          XDefaultDepth(dpy, screen));

/* is this even used? */
gc_values.function = GXclear;
gc_values.plane_mask = AllPlanes;
iconGC = XCreateGC(dpy, mwWindow, GCFunction | GCPlaneMask, &gc_values);
iconmask_pixmap = XCreatePixmap(dpy, mwWindow,
icon_width,
                                icon_height, XDefaultDepth(dpy, screen));
XFillRectangle(dpy, iconmask_pixmap, iconGC, 0, 0,
icon_width,
               icon_height);

icon_reverse_pixmap = XCreatePixmapFromBitmapData(dpy, mwWindow,
                                                  (char *) icon_bits,
                                                  icon_width,
                                                  icon_height,
                                                  app_resources.bg_pixel,
                                                  app_resources.fg_pixel,
                                                  XDefaultDepth(dpy, screen));

wmhints.input = TRUE;
wmhints.flags = IconPixmapHint | IconMaskHint | InputHint;
wmhints.icon_pixmap = icon_pixmap;
wmhints.icon_mask = iconmask_pixmap;
XSetWMHints(dpy, mwWindow, &wmhints);

initCursors();
arrowImage = XCreateImage(dpy, DefaultVisual(dpy, DefaultScreen(dpy)), 1,
                          XYBitmap, 0, NULL, 16, 16, 8, 2);
arrowImage->byte_order = MSBFirst;
arrowImage->bitmap_bit_order = MSBFirst;
}
Beispiel #3
0
/* return 1 if display opened successfully, else 0 */
int
mf_x11_initscreen() {
	XSetWindowAttributes	xwa;
	Widget			mf_toplevel;
	Widget			mf_canvas;
	XGCValues		gcv;
	Arg			args[1];
	int			mf_argc;
	char			*mf_argv[2];

	mf_argv[0] = "mf";
	mf_argv[1] = NULL;
	mf_argc = 1;

	mf_toplevel = XtInitialize("mf", "Metafont",
				   mf_optiondesclist,
				   XtNumber(mf_optiondesclist),
				   &mf_argc, mf_argv);

	XtGetApplicationResources(mf_toplevel, 0,
				  mf_resources, XtNumber(mf_resources),
				  NULL, 0 );


	if (mf_argc != 1) {
		(void) fprintf(stderr, "Usage: %s\n", mf_argv[0]);
		exit(1);
	}

	/*
	 * if nothing specified in their resources/.Xdefaults
	 * then use the values of metafont's "screen".
	 */
	if (mf_width == 0)
		mf_width = screenwidth;
	if (mf_height == 0)
		mf_height = screendepth;

	mf_canvas = XtCreateManagedWidget("canvas", widgetClass, mf_toplevel,
					  NULL, 0);

	XtSetArg(args[0], XtNwidth, mf_width);
	XtSetValues(mf_canvas, args, 1);
	XtSetArg(args[0], XtNheight, mf_height);
	XtSetValues(mf_canvas, args, 1);

	/* for mf_x11_updatescreen() */
	mf_app = XtWidgetToApplicationContext(mf_canvas);

	XtAddEventHandler(mf_canvas, (Cardinal) ExposureMask, True, 
			  mf_repaint, NULL);
	XtAddEventHandler(mf_canvas, (Cardinal) StructureNotifyMask, True, 
			  mf_mapstatus, NULL);

	XtRealizeWidget(mf_toplevel);

	mf_display = XtDisplay(mf_canvas);
	mf_window = XtWindow(mf_canvas);

	/*
	 * since metafont isn't your typical x window program that
	 * sits in xt_main_loop, if the server supports backing store
	 * and save unders this will help keep the output looking
	 * nice.
	 */
	xwa.backing_store = Always;
	xwa.save_under = True;
	XChangeWindowAttributes(mf_display, mf_window,
				CWBackingStore|CWSaveUnder, &xwa);

	gcv.background = mf_bg;
	gcv.foreground = mf_fg;
	gcv.function = GXcopy;

	/* copy plane gc */
	mf_cgc = XCreateGC(mf_display, mf_window,
			   GCForeground|GCBackground|GCFunction, &gcv);

	mf_newpixmap(screenwidth > mf_width ? screenwidth : mf_width,
		     screendepth > mf_height ? screendepth : mf_height);

	return(1);
}
Beispiel #4
0
/* Parse args and go */
int
main(int argc, char *argv[])
{
    XtAppContext context;

#ifndef HAVE_XTVAOPENAPPLICATION
    Display *display;
#endif
    XTickertapeRec rc;
    elvin_handle_t handle;
    elvin_error_t error;
    const char *user;
    const char *domain;
    const char *ticker_dir;
    const char *config_file;
    const char *groups_file;
    const char *usenet_file;
    const char *keys_file;
    const char *keys_dir;
    Widget top;
    const char *names[AN_MAX + 1];
    int i;

    /* Determine the name of the executable. */
    progname = xbasename(argv[0]);

#ifdef HAVE_XTVAOPENAPPLICATION
    /* Create the toplevel widget */
    top = XtVaOpenApplication(
        &context, "XTickertape",
        NULL, 0,
        &argc, argv, NULL,
        applicationShellWidgetClass,
        XtNborderWidth, 0,
        NULL);
#else
    /* Initialize the X Toolkit */
    XtToolkitInitialize();

    /* Create an application context */
    context = XtCreateApplicationContext();

    /* Open the display */
    display = XtOpenDisplay(context, NULL, NULL, "XTickertape",
                            NULL, 0, &argc, argv);
    if (display == NULL) {
        fprintf(stderr, "Error: Can't open display\n");
        exit(1);
    }

    /* Create the toplevel widget */
    top = XtAppCreateShell(NULL, "XTickertape", applicationShellWidgetClass,
                           display, NULL, 0);
#endif

    /* Load the application shell resources */
    XtGetApplicationResources(top, &rc, resources, XtNumber(resources),
                              NULL, 0);

    /* Make sure our app-defaults file has a version number */
    if (rc.version_tag == NULL) {
        app_defaults_version_error("app-defaults file not found or "
                                   "out of date");
        exit(1);
    }

    /* Make sure that version number is the one we want */
    if (strcmp(rc.version_tag, PACKAGE "-" VERSION) != 0) {
        app_defaults_version_error("app-defaults file has the wrong "
                                   "version number");
        exit(1);
    }

    /* Add a calback for when it gets destroyed */
    XtAppAddActions(context, actions, XtNumber(actions));

#if !defined(ELVIN_VERSION_AT_LEAST)
    /* Initialize the elvin client library */
    error = elvin_xt_init(context);
    if (error == NULL) {
        fprintf(stderr, "*** elvin_xt_init(): failed\n");
        exit(1);
    }

    /* Double-check that the initialization worked */
    if (elvin_error_is_error(error)) {
        eeprintf(error, "elvin_xt_init failed\n");
        exit(1);
    }

    /* Create a new elvin connection handle */
    handle = elvin_handle_alloc(error);
    if (handle == NULL) {
        eeprintf(error, "elvin_handle_alloc failed\n");
        exit(1);
    }

#elif ELVIN_VERSION_AT_LEAST(4, 1, -1)
    /* Allocate an error context */
    error = elvin_error_alloc(NULL, NULL);
    if (error == NULL) {
        fprintf(stderr, "%s: error: elvin_error_alloc failed\n", progname);
        exit(1);
    }

    /* Initialize the elvin client library */
    client = elvin_xt_init_default(context, error);
    if (client == NULL) {
        eeprintf(error, "elvin_xt_init failed\n");
        exit(1);
    }

    /* Create a new elvin connection handle */
    handle = elvin_handle_alloc(client, error);
    if (handle == NULL) {
        eeprintf(error, "elvin_handle_alloc failed\n");
        exit(1);
    }
#else /* ELVIN_VERSION_AT_LEAST */
# error "Unsupported Elvin library version"
#endif /* ELVIN_VERSION_AT_LEAST */

    /* Scan what's left of the arguments */
    parse_args(argc, argv, handle, &user, &domain,
               &ticker_dir, &config_file,
               &groups_file, &usenet_file,
               &keys_file, &keys_dir,
               error);

    /* Intern a bunch of atoms.  We jump through a few hoops in order
     * in order to do this in a single RPC to the X server. */
#ifdef USE_ASSERT
    memset(names, 0, sizeof(names));
#endif /* USE_ASSERT */
    for (i = 0; i <= AN_MAX; i++) {
        ASSERT(names[atom_list[i].index] == NULL);
        names[atom_list[i].index] = atom_list[i].name;
    }

    /* Make sure we've specified a name for each atom. */
    for (i = 0; i <= AN_MAX; i++) {
        ASSERT(names[i] != NULL);
    }

    /* Intern the atoms. */
    if (!XInternAtoms(XtDisplay(top), (char **)names, AN_MAX + 1,
                      False, atoms)) {
        fprintf(stderr, "%s: error: XInternAtoms failed\n", progname);
        exit(1);
    }

    /* Create an Icon for the root shell */
    XtVaSetValues(top, XtNiconWindow, create_icon(top), NULL);

    /* Create a tickertape */
    tickertape = tickertape_alloc(
        &rc, handle,
        user, domain,
        ticker_dir, config_file,
        groups_file, usenet_file,
        keys_file, keys_dir,
        top,
        error);

    /* Set up SIGHUP to reload the subscriptions */
    signal(SIGHUP, reload_subs);

#ifdef USE_VALGRIND
    /* Set up SIGUSR1 to invoke valgrind. */
    signal(SIGUSR1, count_leaks);
#endif /* USE_VALGRIND */

#ifdef HAVE_LIBXMU
    /* Enable editres support */
    XtAddEventHandler(top, (EventMask)0, True, _XEditResCheckMessages, NULL);
#endif /* HAVE_LIBXMU */

    /* Let 'er rip! */
    XtAppMainLoop(context);

    /* Keep the compiler happy */
    return 0;
}
Beispiel #5
0
int
main( 
     int argc,
     char **argv ) 
{
    Display *display;
    Arg args[20];
    int n=0;
    char *actionName;
    int numArgs = 0;
    DtActionArg *ap = NULL;
  
    XtSetLanguageProc(NULL, NULL, NULL);
    _DtEnvControl(DT_ENV_SET);
    (void) signal(SIGCHLD, (void (*)())SIG_IGN);

    /*  Initialize the toolkit and open the display  */
    XtToolkitInitialize() ;
    appContext = XtCreateApplicationContext() ;
    if ( !(display = XtOpenDisplay( appContext, NULL, argv[0], "Dtaction", 
                             option_list, 
			     sizeof(option_list)/sizeof(XrmOptionDescRec),
			     &argc, argv)) )
    {
	setlocale(LC_ALL, "");
        fprintf(stderr, "%s", GETMESSAGE(1,11,"Can't open display.\n"));
	exit(-1);
    }
  
    XtSetArg(args[n], XmNallowShellResize, True); n++;
    XtSetArg(args[n], XmNmappedWhenManaged, False); n++;
    XtSetArg(args[n], XmNheight, 1); n++;
    XtSetArg(args[n], XmNwidth, 1); n++;
    toplevel = XtAppCreateShell( argv[0], "Dtaction", 
            topLevelShellWidgetClass, display, args, n) ;

    XtRealizeWidget(toplevel);

    display = XtDisplay (toplevel);
    XtGetApplicationResources(toplevel, &appArgs, 
	resources, XtNumber(resources), NULL, 0);

    password = XtMalloc(1);
    password[0] = '\0';
    stars = XtMalloc(1);
    stars[0] = '\0';

   /*  Get Dt initialized  */
   if (DtInitialize (display, toplevel, argv[0], "Dtaction") == False)
   {
      /* Fatal Error: could not connect to the messaging system. */
      /* DtInitialize() has already logged an appropriate error msg */
      exit(-1);
   }

   /*
    * If the request specified that it wanted to run as a different
    * user, then take care of prompting for a password, and doing any
    * necessary verification and logging.
    */
   CheckUserRequest();
   
   /* Load the filetype/action dbs; DtInvokeAction() requires this */
   DtDbLoad();

   /*
    * Get the requested action name
    */
    if ( (actionName = argv[1]) == NULL)
    {
	fprintf(stderr, "%s", GETMESSAGE(1,10,"No action name specified.\n"));
	exit(-1);
    }

    if ( argc > 2 ) 
    {
	/*
	 * create an action arg array for the file objects for
	 * this action.  This number of objects should be one
	 * less than the argument count. The returned vector will
	 * be terminated by a null pointer.
	 */
	numArgs= argc - 2;
	ap = (DtActionArg *) XtCalloc(numArgs,sizeof(DtActionArg)); 
    }

	/*
	 * This client is restricted to FILE arguments.
	 * for the time being.
	 */
    for ( n = 0; n < numArgs; n++) {
        ap[n].argClass    = DtACTION_FILE;
	ap[n].u.file.name = argv[n+2];
    }

    actionId = DtActionInvoke(toplevel, actionName, ap, numArgs,
        appArgs.termOpts,
        appArgs.execHost,
        appArgs.contextDir,
        True,			/* use indicator */
        (DtActionCallbackProc) actionStatusCallback,
        NULL);

    /*
     * Set up a timer if we didn't get a valid procId -- since there will
     * be no invocation update in that case.
     * We must invoke XtMainLoop() at least once, to force any prompt or
     * error dialogs to get posted.
     */
    if ( !actionId)
	    XtAppAddTimeOut(appContext,
		10, (XtTimerCallbackProc)CheckForDone,
			   NULL);

    XtAppMainLoop(appContext);

    return EXIT_SUCCESS;
}
Beispiel #6
0
/*
 * ------------------------------------------------------------------------
 * Name: PdmShellCreate
 *
 * Description:
 *
 *     This function creates a top level application shell.
 *
 * Return value:
 *
 *     0 if successful; a PDM_EXIT code if not.
 *
 */
static int
PdmShellCreate(PdmShell* me,
	       const String* fallback_resources,
	       int* argc_in_out, String* argv_in_out)
{
    String app_class;
    String app_name;
    XmPixelSet pixelSets[XmCO_NUM_COLORS];
    XrmClass class_list[3];
    XrmDatabase db;
    XrmName name_list[3];
    XrmRepresentation rep_type;
    XrmValue value;
    int decor;
    int funcs;
    short secondary_id;
    /*
     * create the application context and open the video display
     */
    XtToolkitInitialize();
    XtSetLanguageProc((XtAppContext)NULL, (XtLanguageProc)NULL,
		      (XtPointer)NULL);
    me->app_context = XtCreateApplicationContext();

    XtAppSetFallbackResources(me->app_context, (String*)fallback_resources);

    me->display =
	XtOpenDisplay(me->app_context, (String)NULL,
		      (String)NULL, "Dtpdm",
		      PdmOptions, XtNumber(PdmOptions),
		      argc_in_out, argv_in_out);
    if((Display*)NULL == me->display)
	return PDM_EXIT_VXAUTH;
    XtGetApplicationNameAndClass(me->display, &app_name, &app_class);
    /*
     * the fallback resources are only intended for the video display, so
     * remove them from the application context
     */
    XtAppSetFallbackResources(me->app_context, (String*)NULL);
    /*
     * get the parent video window id from the display's resource database
     */
    db = XtDatabase(me->display);
    name_list[0] = XrmStringToQuark(app_name);
    name_list[1] = XrmStringToQuark("parentWindowStr");
    name_list[2] = NULLQUARK;
    class_list[0] = XrmStringToQuark(app_class);
    class_list[1] = XrmStringToQuark("ParentWindowStr");
    class_list[2] = NULLQUARK;
    XrmQGetResource(db, name_list, class_list, &rep_type, &value);
    if(!value.addr) return PDM_EXIT_ERROR;
    me->parent_window = (Window)strtoul((char*)value.addr, (char**)NULL, 0);
    /*
     * obtain the parent video window's attributes
     */
    if(!XGetWindowAttributes(me->display, me->parent_window, &me->parent_attr))
	return PDM_EXIT_ERROR;
    /*
     * register interest in the DestroyNotify event for the parent window
     */
    XSelectInput(me->display, me->parent_window, StructureNotifyMask);
    /*
     * create the application shell
     */
    decor = MWM_DECOR_ALL | MWM_DECOR_RESIZEH | MWM_DECOR_MINIMIZE
	| MWM_DECOR_MAXIMIZE;
    funcs = MWM_FUNC_ALL | MWM_FUNC_RESIZE | MWM_FUNC_MINIMIZE
	| MWM_FUNC_MAXIMIZE;
    me->widget = 
	XtVaAppCreateShell(app_name, app_class,
			   applicationShellWidgetClass,
			   me->display,
			   XmNdeleteResponse, XmDESTROY,
			   XmNmappedWhenManaged, False,
			   XmNmwmDecorations, decor,
			   XmNmwmFunctions, funcs,
			   XmNmwmInputMode,MWM_INPUT_PRIMARY_APPLICATION_MODAL,
			   XmNscreen, me->parent_attr.screen,
			   XmNtransient, True,
			   NULL);
    /*
     * pick up the secondary color set, so that the PDM presents the same
     * colors as a secondary window. (the XmColorObj is created by the
     * the XmDisplay object, which is created when the app shell is
     * created)
     */
    if(XmeGetColorObjData(XtScreen(me->widget), (int*)NULL,
			  pixelSets, XmCO_NUM_COLORS,
			  (short*)NULL, (short*)NULL, (short*)NULL,
			  &secondary_id, (short*)NULL))
    {
	/*
	 * In the Xrm database, reassign primary color resource values
	 * with the corresponding secondary color values. This will cause
	 * subsequently created widgets that utilize colors from the
	 * primary set to actually present secondary colors.
	 */
	db = XtScreenDatabase(XtScreen(me->widget));
	value.size = sizeof(Pixel);
	value.addr = (char*)&pixelSets[secondary_id].bg;
	XrmPutResource (&db, "*background", "Pixel", &value);
	XrmPutResource (&db, "*frameBackground", "Pixel", &value);
	value.addr = (char*)&pixelSets[secondary_id].fg;
	XrmPutResource (&db, "*foreground", "Pixel", &value);
	XrmPutResource (&db, "*backPageForeground", "Pixel", &value);
	value.addr = (char*)&pixelSets[secondary_id].bs;
	XrmPutResource (&db, "*bottomShadowColor", "Pixel", &value);
	value.addr = (char*)&pixelSets[secondary_id].ts;
	XrmPutResource (&db, "*topShadowColor", "Pixel", &value);
    }
    /*
     * get the application resources
     */
    XtGetApplicationResources(me->widget, me,
			      PdmResources, XtNumber(PdmResources),
			      NULL, 0);
    /*
     * return
     */
    return 0;
}
Beispiel #7
0
/******************************************************************************
*   MAIN function
******************************************************************************/
int main ( int argc, char **argv )
{
    trace_main = TRACE_MAIN;

    XtAppContext app;
    m_init();
    XtSetLanguageProc (NULL, NULL, NULL);
    XawInitializeWidgetSet();

    /*  --  Intialize Toolkit creating the application shell
     */
    Widget appShell = XtOpenApplication (&app, APP_NAME,
             /* resources: can be set from argv */
             options, XtNumber(options),
	     &argc, argv,
	     fallback_resources,
	     sessionShellWidgetClass,
	     NULL, 0
	   );
    load_icon(XtDisplay(appShell));
    //    load_icon_default();

    /*  --  Enable Editres support
     */
    XtAddEventHandler(appShell, (EventMask) 0, True, _XEditResCheckMessages, NULL);

    XtAddCallback( appShell, XtNdieCallback, quit_cb, NULL );

    /*  --  not parsed options are removed by XtOpenApplication
            the only entry left should be the program name
    */
    if (argc != 1) { m_destruct(); syntax(); exit(1); }
    TopLevel = appShell;


    /*  --  Register all application specific
            callbacks and widget classes
    */
    RegisterApplication ( appShell );

    /*  --  Register all Athena and Public
            widget classes, CBs, ACTs
    */
    XpRegisterAll ( app );

    /*  --  Create widget tree below toplevel shell
            using Xrm database
    */
    WcWidgetCreation ( appShell );


    /*  -- Get application resources and widget ptrs
     */
    XtGetApplicationResources(	appShell, (XtPointer)&CWNET,
				CWNET_CONFIG_RES,
				XtNumber(CWNET_CONFIG_RES),
				(ArgList)0, 0 );

    InitializeApplication(appShell);

    /*  --  Realize the widget tree and enter
            the main application loop  */
    XtRealizeWidget ( appShell );
    /*  --  Set Icon for Window */
    set_app_icon(appShell);

    grab_window_quit( appShell );


    /*------------------------------------------------------------------------*/
    CWNET.lgfx = lgfx_init( CWNET.widget_draw1 );

    /* init commands */
    cp_init();
    cp_add( "PUT:", cmd_put );
    cp_add( "EXIT", cmd_exit );
    cp_add( "CIRCLE:", cmd_circle );
    cp_add( "CLRSCR", cmd_clrscr );
    cp_add( "RECT:", cmd_rect );
    cp_add( "MEASURE", cmd_measure );
    int sln = sln_init();
    CWNET.sln = sln;
    XtAppAddTimeOut(app , 1000, try_connect, (XtPointer) (intptr_t) sln );
    /*------------------------------------------------------------------------*/

    
    XtAppMainLoop ( app ); /* use XtAppSetExitFlag */
    XtDestroyWidget(appShell);

    sln_destruct();
    m_destruct();

    return EXIT_SUCCESS;
}