예제 #1
0
파일: ex16.c 프로젝트: xtforever/xtcw
Widget init_application(int *argc, char **argv )
{
    m_init();
    XtAppContext app;
    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;
    RAC( appShell, wm_quit );
    RCB( appShell, quit_gui );

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

}
예제 #2
0
파일: wrap_xt.c 프로젝트: dmsh/ocaml-xlib
CAMLprim value
ml_XtOpenApplication( value application_class, value ml_widget_class, value ml_app_resources )
{
    CAMLparam3(application_class, ml_widget_class, ml_app_resources);
    CAMLlocal2(ret, app_context);
    alloc_XtAppContext(app_context);

    WidgetClass widget_class = get_shellWidgetClass(ml_widget_class);
    char *p_argv[] = { };
    int p_argc = 0;

    /*
    String app_resources[] = {
        "*command.Label: Write text to stdout",
        "*clear_command.Label: Clear",
        "*quit_command.Label: Quit",
        "*window.Title: Hello, world in Xt/Athena",
        "*window.Geometry: 300x200+10+10",
        "*ascii.Width: 280",
        "*ascii.Height: 150",
        NULL };
    */
    String * app_resources;
    app_resources = calloc(Wosize_val(ml_app_resources) + 1, sizeof(String *));
    int i;
    for (i=0; i<Wosize_val(ml_app_resources); ++i)
        app_resources[i] = String_val(Field(ml_app_resources, i));
    app_resources[i] = NULL;

    Widget window = XtOpenApplication(
        XtAppContext_val(app_context),
        String_val(application_class),
        NULL,    // XrmOptionDescList  options,
        0,       // Cardinal           num_options,
        &p_argc, // int*               argc_in_out,
        p_argv,  // String*            argv_in_out,
            //NULL,    // String*            app_resources,
            app_resources,
        widget_class,
        NULL,    // ArgList            args,
        0        // Cardinal           num_args
        );

    ret = caml_alloc(2, 0);
    Store_field(ret, 0, app_context );
    Store_field(ret, 1, Val_Widget(window) );
    CAMLreturn(ret);
}
예제 #3
0
파일: wind.c 프로젝트: amigan/phoned
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;
}
예제 #4
0
파일: hello.c 프로젝트: UlricE/SiagOffice
/* ---
*/
int main(int argc, char **argv)
{
	XtAppContext ac;
	Display *dpy;
	Widget w;

	topLevel = XtOpenApplication(&ac, "Hello",
		NULL, 0, &argc, argv, NULL,
		mwApplicationShellWidgetClass, NULL, 0);
	w = XtVaCreateManagedWidget("hello",
		commandWidgetClass, topLevel,
		XtNlabel, "Hello, World", (char *)0);
	XtAddCallback(w, XtNcallback, plugin_callback, NULL);
	dpy = XtDisplay(topLevel);
	plugin_protocol = XInternAtom(dpy, "_PLUGIN_PROTOCOL", False);

	XtRealizeWidget(topLevel);

	mainloop();
	return 0;
}
예제 #5
0
int
main(int argc, char *argv[])
{
    Widget toplevel;
    XtAppContext app_con;
    Widget panel;
    Widget base[XkbNumModifiers];
    Widget latched[XkbNumModifiers];
    Widget locked[XkbNumModifiers];
    Widget effective[XkbNumModifiers];
    Widget compat[XkbNumModifiers];
    Widget baseBox, latchBox, lockBox, effBox, compatBox;
    register int i;
    unsigned bit;
    XkbEvent ev;
    XkbStateRec state;
    static Arg hArgs[] = { {XtNorientation, (XtArgVal) XtorientHorizontal} };
    static Arg vArgs[] = { {XtNorientation, (XtArgVal) XtorientVertical} };
    static Arg onArgs[] = { {XtNon, (XtArgVal) True} };
    static Arg offArgs[] = { {XtNon, (XtArgVal) False} };
    static char *fallback_resources[] = {
        "*Box*background: grey50",
        "*Box*borderWidth: 0",
        "*Box*vSpace: 1",
        NULL
    };

    for (i = 1; i < argc; i++) {
        if (strcmp(argv[i], "-version") == 0) {
            printf("xkbwatch (%s) %s\n", PACKAGE_NAME, PACKAGE_VERSION);
            exit(0);
        }
    }

    uSetErrorFile(NullString);
    toplevel = XtOpenApplication(&app_con, "XkbWatch",
                                 options, XtNumber(options), &argc, argv,
                                 fallback_resources,
                                 sessionShellWidgetClass, NULL, ZERO);
    if (toplevel == NULL) {
        uFatalError("Couldn't create application top level\n");
        exit(1);
    }
    inDpy = outDpy = XtDisplay(toplevel);
    if (inDpy) {
        int i1, mn, mj;

        mj = XkbMajorVersion;
        mn = XkbMinorVersion;
        if (!XkbQueryExtension(inDpy, &i1, &evBase, &errBase, &mj, &mn)) {
            uFatalError("Server doesn't support a compatible XKB\n");
            exit(1);
        }
    }
    panel =
        XtCreateManagedWidget("xkbwatch", boxWidgetClass, toplevel, vArgs, 1);
    if (panel == NULL) {
        uFatalError("Couldn't create top level box\n");
        exit(1);
    }
    baseBox = XtCreateManagedWidget("base", boxWidgetClass, panel, hArgs, 1);
    if (baseBox == NULL)
        uFatalError("Couldn't create base modifiers box\n");
    latchBox =
        XtCreateManagedWidget("latched", boxWidgetClass, panel, hArgs, 1);
    if (latchBox == NULL)
        uFatalError("Couldn't create latched modifiers box\n");
    lockBox = XtCreateManagedWidget("locked", boxWidgetClass, panel, hArgs, 1);
    if (lockBox == NULL)
        uFatalError("Couldn't create locked modifiers box\n");
    effBox =
        XtCreateManagedWidget("effective", boxWidgetClass, panel, hArgs, 1);
    if (effBox == NULL)
        uFatalError("Couldn't create effective modifiers box\n");
    compatBox =
        XtCreateManagedWidget("compat", boxWidgetClass, panel, hArgs, 1);
    if (compatBox == NULL)
        uFatalError("Couldn't create compatibility state box\n");
    XkbSelectEvents(inDpy, XkbUseCoreKbd, XkbStateNotifyMask,
                    XkbStateNotifyMask);
    XkbGetState(inDpy, XkbUseCoreKbd, &state);
    for (i = XkbNumModifiers - 1, bit = 0x80; i >= 0; i--, bit >>= 1) {
        ArgList list;

        char buf[30];

        sprintf(buf, "base%d", i);
        if (state.base_mods & bit)
            list = onArgs;
        else
            list = offArgs;
        base[i] = XtCreateManagedWidget(buf, ledWidgetClass, baseBox, list, 1);
        sprintf(buf, "latched%d", i);
        if (state.latched_mods & bit)
            list = onArgs;
        else
            list = offArgs;
        latched[i] =
            XtCreateManagedWidget(buf, ledWidgetClass, latchBox, list, 1);
        sprintf(buf, "locked%d", i);
        if (state.locked_mods & bit)
            list = onArgs;
        else
            list = offArgs;
        locked[i] =
            XtCreateManagedWidget(buf, ledWidgetClass, lockBox, list, 1);
        sprintf(buf, "effective%d", i);
        if (state.mods & bit)
            list = onArgs;
        else
            list = offArgs;
        effective[i] =
            XtCreateManagedWidget(buf, ledWidgetClass, effBox, list, 1);
        sprintf(buf, "compat%d", i);
        if (state.compat_state & bit)
            list = onArgs;
        else
            list = offArgs;
        compat[i] =
            XtCreateManagedWidget(buf, ledWidgetClass, compatBox, list, 1);
    }
    XtRealizeWidget(toplevel);
    while (1) {
        XtAppNextEvent(app_con, &ev.core);
        if (ev.core.type == evBase + XkbEventCode) {
            if (ev.any.xkb_type == XkbStateNotify) {
                unsigned changed;

                if (ev.state.changed & XkbModifierBaseMask) {
                    changed = ev.state.base_mods ^ state.base_mods;
                    state.base_mods = ev.state.base_mods;
                    for (i = 0, bit = 1; i < XkbNumModifiers; i++, bit <<= 1) {
                        if (changed & bit) {
                            ArgList list;

                            if (state.base_mods & bit)
                                list = onArgs;
                            else
                                list = offArgs;
                            XtSetValues(base[i], list, 1);
                        }
                    }
                }
                if (ev.state.changed & XkbModifierLatchMask) {
                    changed = ev.state.latched_mods ^ state.latched_mods;
                    state.latched_mods = ev.state.latched_mods;
                    for (i = 0, bit = 1; i < XkbNumModifiers; i++, bit <<= 1) {
                        if (changed & bit) {
                            ArgList list;

                            if (state.latched_mods & bit)
                                list = onArgs;
                            else
                                list = offArgs;
                            XtSetValues(latched[i], list, 1);
                        }
                    }
                }
                if (ev.state.changed & XkbModifierLockMask) {
                    changed = ev.state.locked_mods ^ state.locked_mods;
                    state.locked_mods = ev.state.locked_mods;
                    for (i = 0, bit = 1; i < XkbNumModifiers; i++, bit <<= 1) {
                        if (changed & bit) {
                            ArgList list;

                            if (state.locked_mods & bit)
                                list = onArgs;
                            else
                                list = offArgs;
                            XtSetValues(locked[i], list, 1);
                        }
                    }
                }
                if (ev.state.changed & XkbModifierStateMask) {
                    changed = ev.state.mods ^ state.mods;
                    state.mods = ev.state.mods;
                    for (i = 0, bit = 1; i < XkbNumModifiers; i++, bit <<= 1) {
                        if (changed & bit) {
                            ArgList list;

                            if (state.mods & bit)
                                list = onArgs;
                            else
                                list = offArgs;
                            XtSetValues(effective[i], list, 1);
                        }
                    }
                }
                if (ev.state.changed & XkbCompatStateMask) {
                    changed = ev.state.compat_state ^ state.compat_state;
                    state.compat_state = ev.state.compat_state;
                    for (i = 0, bit = 1; i < XkbNumModifiers; i++, bit <<= 1) {
                        if (changed & bit) {
                            ArgList list;

                            if (state.compat_state & bit)
                                list = onArgs;
                            else
                                list = offArgs;
                            XtSetValues(compat[i], list, 1);
                        }
                    }
                }
            }
        }
        else
            XtDispatchEvent(&ev.core);
    }
/* BAIL: */
    if (inDpy)
        XCloseDisplay(inDpy);
    if (outDpy != inDpy)
        XCloseDisplay(outDpy);
    inDpy = outDpy = NULL;
    return 0;
}
예제 #6
0
/******************************************************************
main:
******************************************************************/
int
main(int argc, char **argv)
{
    static Widget  MainWindow;
    XtAppContext   app_context;
    Widget         Frame1, RC1, Label1, DrawingArea1;
    Pixmap         pixmap;
    GC             gc;

    XtSetLanguageProc(NULL, (XtLanguageProc) NULL, NULL);


    toplevel = XtOpenApplication(&app_context, "Test", NULL, 0,
                                 &argc, argv, NULL,
                                 sessionShellWidgetClass,
                                 NULL, 0);

    MainWindow = XtVaCreateManagedWidget("MainWindow1",
                                         xmMainWindowWidgetClass, toplevel,
                                         NULL);

    CreateMenus(MainWindow);

    RC1 = XtVaCreateManagedWidget("RC1", xmRowColumnWidgetClass,
                                  MainWindow, NULL);

    if (!argv[1]) {
        printf("usage: %s bitmap-file\n", *argv);
        exit(1);
    }

    /* Load bitmap given in argv[1] */
    pixmap = XmGetPixmap(XtScreen(toplevel), argv[1],
                         BlackPixelOfScreen(XtScreen(toplevel)),
                         WhitePixelOfScreen(XtScreen(toplevel)));

    if (pixmap == XmUNSPECIFIED_PIXMAP) {
        printf("can't create pixmap from %s\n", argv[1]);
        exit(1);
    }

    /* Now instantiate an XmLabel widget that displays pixmap. */
    Label1 = XtVaCreateManagedWidget("Label1",
                                     xmLabelWidgetClass, RC1,
                                     XmNlabelType,   XmPIXMAP,
                                     XmNlabelPixmap, pixmap,
                                     NULL);

    Frame1 = XtVaCreateManagedWidget("Frame1",
                                     xmFrameWidgetClass, RC1,
                                     XmNshadowThickness, 3,
                                     NULL);

    DrawingArea1 = XtVaCreateManagedWidget("DrawingArea1",
                                           xmDrawingAreaWidgetClass, Frame1,
                                           XmNwidth, 150,
                                           XmNheight, 150,
                                           XmNresizePolicy, XmRESIZE_NONE,
                                           NULL);
    XmeDropSink(DrawingArea1, NULL, 0);
    XtAddCallback(DrawingArea1, XmNdestinationCallback,
                  DestinationCallback, NULL);

    XtRealizeWidget(toplevel);
    XtAppMainLoop(app_context);

    return 0;    /* make compiler happy */
}
예제 #7
0
파일: xclock.c 프로젝트: 8l/x11
int 
main(int argc, char *argv[])
{
    Widget toplevel;
    Arg arg;
    Pixmap icon_pixmap = None;
    XtAppContext app_con;

#ifndef NO_I18N
    char *locale_name = setlocale(LC_ALL,"");
    XtSetLanguageProc ( NULL, NULL, NULL );

    if(!locale_name || 0 == strcmp(locale_name,"C")) {
	no_locale = True;
    }
    else {
	no_locale = False;
    }
#endif

    toplevel = XtOpenApplication(&app_con, "XClock",
				 options, XtNumber(options), &argc, argv, NULL,
				 sessionShellWidgetClass, NULL, ZERO);
    if (argc != 1) Syntax(argv[0]);
    XtAddCallback(toplevel, XtNdieCallback, die, NULL);
    XtAddCallback(toplevel, XtNsaveCallback, save, NULL);
    XtAppAddActions (app_con, xclock_actions, XtNumber(xclock_actions));

    /*
     * This is a hack so that wm_delete_window will do something useful
     * in this single-window application.
     */
    XtOverrideTranslations(toplevel, 
		    XtParseTranslationTable ("<Message>WM_PROTOCOLS: quit()"));

    XtSetArg(arg, XtNiconPixmap, &icon_pixmap);
    XtGetValues(toplevel, &arg, ONE);

    if (icon_pixmap == None) {
	arg.value = (XtArgVal)XCreateBitmapFromData(XtDisplay(toplevel),
				       XtScreen(toplevel)->root,
				       (char *)clock_bits, clock_width, clock_height);
	XtSetValues (toplevel, &arg, ONE);
    }

    XtSetArg(arg, XtNiconMask, &icon_pixmap);
    XtGetValues(toplevel, &arg, ONE);
    if (icon_pixmap == None) {
	arg.value = (XtArgVal)XCreateBitmapFromData(XtDisplay(toplevel),
				       XtScreen(toplevel)->root,
				       (char *)clock_mask_bits, clock_mask_width, 
				       clock_mask_height);
	XtSetValues (toplevel, &arg, ONE);
    }

    XtCreateManagedWidget ("clock", clockWidgetClass, toplevel, NULL, ZERO);
    XtRealizeWidget (toplevel);
    wm_delete_window = XInternAtom (XtDisplay(toplevel), "WM_DELETE_WINDOW",
				    False);
    (void) XSetWMProtocols (XtDisplay(toplevel), XtWindow(toplevel),
			    &wm_delete_window, 1);

#ifdef HAVE_GETPID
    {
	pid_t pid = getpid();
	XChangeProperty(XtDisplay(toplevel), XtWindow(toplevel),
			XInternAtom(XtDisplay(toplevel), "_NET_WM_PID", False),
			XA_CARDINAL, 32, PropModeReplace,
			(unsigned char *) &pid, 1);
    }
#endif
    
    XtAppMainLoop (app_con);
    exit(0);
}
예제 #8
0
파일: cwri.c 프로젝트: xtforever/xtcw
/******************************************************************************
*   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)&CWRI,
				CWRI_CONFIG_RES,
				XtNumber(CWRI_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 );

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

    return EXIT_SUCCESS;
}
예제 #9
0
파일: video.c 프로젝트: xtforever/xtcw
/******************************************************************************
*   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();
    trace_level = trace_main;

    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)&CONFIG,
				basicSettingRes,
				XtNumber(basicSettingRes),
				(ArgList)0, 0 );


    InitializeApplication(appShell);

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


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

    v_free(CONFIG.vset);
    m_destruct();

    return EXIT_SUCCESS;
}
예제 #10
0
파일: xtcal.c 프로젝트: xtforever/xtcw
/******************************************************************************
*   MAIN function
******************************************************************************/
int main ( int argc, char **argv )
{
    Display *dpy;
    XtAppContext app;
    Widget appShell,w;
    XtSetLanguageProc (NULL, NULL, NULL);
    XawInitializeWidgetSet();
    /*  -- Intialize Toolkit creating the application shell
     */
    appShell = XtOpenApplication (&app, argv[0],
                                        options, XtNumber(options),
                                         &argc, argv,
                                         fallback_resources,
                                         sessionShellWidgetClass,
                                         NULL, 0
                                         );
    TopLevel = appShell;
    dpy = XtDisplay(appShell);

    /* LOGIC:
       if deviceName is not given: show devices and ids and exit
       if deviceName is given and calibration matrix is supplied:
       apply calibration and exit.
       if deviceName is given and no matrix suplied start
       calibration process, calculate matrix, output matrix
       to stdout and apply matrix.
    */
    get_config(appShell);
    long int id = xi_get_deviceid(dpy,CONF.deviceName);
    if( id <0 ) {
        xi_list_devices(dpy);
        exit(EXIT_SUCCESS);
    }
    CONF.deviceId = id;

    if( CONF.matrix && *CONF.matrix ) {
        xi_apply_matrix_string(dpy,id,CONF.matrix);
        exit(EXIT_SUCCESS);
    }

    xi_apply_unity(dpy, id );

    w = XtVaCreateManagedWidget( "calib", calibWidgetClass, TopLevel,
                             NULL );
    XtAddCallback(w, XtNcallback, process_cal_data, NULL );

    /* enable Editres support */
    XtAddEventHandler(appShell, (EventMask) 0, True, _XEditResCheckMessages, NULL);
    /* grab window close event */
    XtAddCallback( appShell, XtNdieCallback, quit_gui, NULL );

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

    if( CONF.screenSize && *CONF.screenSize ) {
        parse_screen_size( CONF.screenSize, &x_width, &x_height );
    } else  {

	fprintf(stderr, "error: use -screenSize option\n" );
	exit(1);

    }
    
    make_borderless_window(appShell);
    XtAppMainLoop ( app ); /* use XtAppSetExitFlag */
    XtDestroyWidget(appShell);
    return EXIT_SUCCESS;
}
예제 #11
0
int main (int argc,char *argv[])
{/* Main */    
   static char FuncName[]={"prompt_user"}; 
   SUMA_GENERIC_PROG_OPTIONS_STRUCT *Opt;  
   SUMA_GENERIC_ARGV_PARSE *ps=NULL;
   char * esc_str = NULL;
   int ii;
   Widget w=NULL;
   XtAppContext    app;
   XEvent ev;
   XtInputMask pp;
   SUMA_Boolean LocalHead = NOPE;
   
   SUMA_STANDALONE_INIT;
	SUMA_mainENTRY;

   /* Allocate space for DO structure */
	SUMAg_DOv = SUMA_Alloc_DisplayObject_Struct (SUMA_MAX_DISPLAYABLE_OBJECTS);
   ps = SUMA_Parse_IO_Args(argc, argv, "");
   
   if (argc < 2) {
      usage_prompt_user(ps);
      exit (1);
   }
   
   Opt = SUMA_prompt_user_ParseInput (argv, argc, ps);

   w = XtOpenApplication(&app, "prompt_user", 
                           NULL, 0, &argc, argv,
                           SUMA_get_fallbackResources(), 
                           topLevelShellWidgetClass, NULL, 0); 
   
   switch (Opt->b1) {
      case 1:
         /* apply some escape characters     31 Jul 2009 [rickr] */
         esc_str = unescape_unix_str(Opt->in_name);
         ii = SUMA_PauseForUser(w, esc_str, SWP_POINTER_LEFT_BOTTOM, &app, 1);
         fprintf(SUMA_STDOUT,"%d\n", ii);
         break;
      default:
         SUMA_S_Err("Bad opt");
         exit(1);
         
   }
   
   /* because you have no XtAppMainLoop, you'll need to process the next 
   event for the XtDestroy command on w's child takes effect. So you'll
   just have this zombie widget that stares at you.
   In this simple command line program, the widget dies anyway when you
   exit the program, so the call below is a teaching moment for when
   functions like SUMA_PauseForUser are called from programs without an
   XtAppMainLoop. 
   See also SUMA_PAUSE_PROMPT macro */
   
   while ((pp = XtAppPending(app))) {  \
      XtAppProcessEvent(app, pp); \
   } 
   
   if (Opt->debug > 2) LocalHead = YUP;
   if (ps) SUMA_FreeGenericArgParse(ps); ps = NULL;
   if (Opt) Opt = SUMA_Free_Generic_Prog_Options_Struct(Opt);
   if (!SUMA_Free_CommonFields(SUMAg_CF)) 
      SUMA_error_message(FuncName,"SUMAg_CF Cleanup Failed!",1);

   if( esc_str ) free(esc_str);
   
   exit(0);
   
} 
예제 #12
0
파일: Application.C 프로젝트: juddy/edcde
void Application::initialize ( int *argcp, char **argv )
{
    DebugPrintf(2, "Application::initialize(%p %d, %p)\n", argcp, *argcp, argv);

    DebugPrintf(3, "Application::initialize - Initializing privileges.\n");

    // The Solaris sendmail operates differently than the HP/IBM sendmail. 
    // sendmail on Solaris runs as 'root' and so has access permissions 
    // to any file on the system. sendmail on HP/IBM runs as set-group-id 
    // 'mail' and so requires that all mailboxes that it may deliver e-mail 
    // to be writable either by being group mail group writable, or by being 
    // writable by the world. On those platforms, then, dtmail is required 
    // to always run with set-group-id mail otherwise, when mailboxes are 
    // saved, they will loose their group ownership and sendmail will no 
    // onger be able to deliver to those mailboxes.

    // we have to be set-gid to group "mail" when opening and storing
    // folders.  But we don't want to do everything as group mail.
    // here we record our original gid, and set the effective gid
    // back the the real gid.  We'll set it back when we're dealing
    // with folders...
    //
    _originalEgid = getegid();	// remember effective group ID
    _originalRgid = getgid();	// remember real group ID
    disableGroupPrivileges();	// disable group privileges from here on

    DebugPrintf(3, "Application::initialize - Initializing Xt.\n");

    _w = XtOpenApplication (
			&_appContext, 
			_applicationClass, 
			(XrmOptionDescList) NULL, 0, 
			argcp, argv, ApplicationFallbacks,
			sessionShellWidgetClass, (ArgList) NULL, 0 );
    
    // Extract and save a pointer to the X display structure
    DebugPrintf(3, "Application::initialize - Extracting display.\n");
    _display = XtDisplay ( _w );

    // Set virtual BMenu mouse binding
    int numButtons = XGetPointerMapping(_display, (unsigned char *)NULL, 0);
    _bMenuButton = (numButtons < 3) ? Button2 : Button3;
    
    // The Application class is less likely to need to handle
    // "surprise" widget destruction than other classes, but
    // we might as well install a callback to be safe and consistent
    DebugPrintf(3, "Application::initialize - Installing destroy handler.\n");
    installDestroyHandler();
    
    // Center the shell, and make sure it isn't visible
    DebugPrintf(3, "Application::initialize - Setting window size.\n");
    XtVaSetValues ( _w,
		   XmNmappedWhenManaged, FALSE,
		   XmNx, DisplayWidth ( _display, 0 ) / 2,
		   XmNy, DisplayHeight ( _display, 0 ) / 2,
		   XmNwidth,  1,
		   XmNheight, 1,
		   NULL );
    
    // The instance name of this object was set in the UIComponent 
    // constructor, before the name of the program was available
    // Free the old name and reset it to argv[0]
    DebugPrintf(3, "Application::initialize - Deleting name %p\n", _name);
    free(_name);
    _name = strdup ( argv[0] );

    // Force the shell window to exist so dialogs popped up from
    // this shell behave correctly
    DebugPrintf(3, "Application::initialize - Realizing shell window.\n");
    XtRealizeWidget ( _w );
    
    getResources(_appResources, XtNumber(_appResources));

    // Initialize and manage any windows registered
    // with this application.
    
    for ( int i = 0; i < _numWindows; i++ )
    {
	DebugPrintf(3, "Application::initialize - Initializing windows[%d]\n", i);
	_windows[i]->initialize();
	DebugPrintf(3, "Application::initialize - Managing windows[%d]\n", i);
	_windows[i]->manage();
    }
}
예제 #13
0
파일: xkbvleds.c 프로젝트: aosm/X11
int
main(int argc, char *argv[])
{
Widget		toplevel;
XtAppContext	app_con;
Widget		panel;
Widget		leds[XkbNumIndicators];
register int	i;
unsigned	bit;
unsigned	n;
XkbDescPtr	xkb;
XkbEvent	ev;
static Arg	boxArgs[]= {{ XtNorientation, (XtArgVal)XtorientHorizontal }};
static Arg	onArgs[]=  {{ XtNon, (XtArgVal)True }};
static Arg	offArgs[]=  {{ XtNon, (XtArgVal)False }};
static char *	fallback_resources[] = {
    "*Box*background: grey40",
    NULL
};

    uSetEntryFile(NullString);
    uSetDebugFile(NullString);
    uSetErrorFile(NullString);
    bzero(leds,XkbNumIndicators*sizeof(Widget));
    toplevel = XtOpenApplication(&app_con, "XkbLEDPanel", NULL, 0, &argc, argv, 
				 fallback_resources,
				 sessionShellWidgetClass, NULL, ZERO);
    if (toplevel==NULL) {
	uFatalError("Couldn't create application top level\n");
	return 1;
    }
    if ((argc>1)&&(!parseArgs(argc,argv))) {
	usage(argv[0]);
	return 1;
    }
    if ((wanted==0)&&(wantNamed==DONT_CARE)&&(wantExplicit==DONT_CARE)&&
			(wantAutomatic==DONT_CARE)&&(wantReal==DONT_CARE)) {
	wantNamed= YES;
	wantReal= YES;
	wantAutomatic= YES;
    }
    outDpy= XtDisplay(toplevel);
    if (inDpyName!=NULL) {
	inDpy= GetDisplay(argv[0],inDpyName);
	if (!inDpy)
	    return 1;
    }
    else {
	inDpy= outDpy;
    }
    if (inDpy) {
	int i1,mn,mj;
	mj= XkbMajorVersion;
	mn= XkbMinorVersion;
	if (!XkbLibraryVersion(&mj,&mn)) {
	    uInformation("%s was compiled with XKB version %d.%02d\n",
				argv[0],XkbMajorVersion,XkbMinorVersion);
	    uError("X library supports incompatible version %d.%02d\n",
				mj,mn);
	}
	if (!XkbQueryExtension(inDpy,&i1,&evBase,&errBase,&mj,&mn)) {
	    uFatalError("Server doesn't support a compatible XKB\n");
	    return 1;
	}
    }
    else {
	uFatalError("No input display\n");
	return 1;
    }
    panel= XtCreateManagedWidget("xkbleds",boxWidgetClass,toplevel,boxArgs,1);
    if (panel==NULL) {
	uFatalError("Couldn't create list of leds\n");
	return 1;
    }
    real= virtual= named= explicit= automatic= 0;
    if (wantReal || wantNamed || wantAutomatic || wantExplicit || wantVirtual) {
	register int i,bit;
	xkb= XkbGetMap(inDpy,0,XkbUseCoreKbd);
	if (!xkb) {
	    uFatalError("Couldn't read keymap\n");
	    return 1;
	}
	if (XkbGetIndicatorMap(inDpy,XkbAllIndicatorsMask,xkb)!=Success) {
	    uFatalError("Couldn't read indicator map\n");
	    return 1;
	}
	if (XkbGetNames(inDpy,XkbAllNamesMask,xkb)!=Success) {
	    uFatalError("Couldn't read indicator names\n");
	    return 1;
	}
	for (i=0,bit=1;i<XkbNumIndicators;i++,bit<<=1) {
	    XkbIndicatorMapPtr map= &xkb->indicators->maps[i];
	    if (xkb->names->indicators[i]!=None)
		named|= bit;
	    if (xkb->indicators->phys_indicators&bit)
		real|= bit;
	    if ((((map->which_groups!=0)&&(map->groups!=0))||
		((map->which_mods!=0)&&
		((map->mods.real_mods!=0)||(map->mods.vmods!=0)))||
		(map->ctrls!=0))&&
		((map->flags&XkbIM_NoAutomatic)==0)) {
		automatic|= bit;
	    }
	    else explicit|= bit;
	}
	virtual= ~real;
	if (wantReal==NO)			real= ~real;
	else if (wantReal==DONT_CARE)		real= (useUnion?0:~0);
	if (wantVirtual==NO)			virtual= ~virtual;
	else if (wantVirtual==DONT_CARE)	virtual= (useUnion?0:~0);
	if (wantNamed==NO)			named= ~named;
	else if (wantNamed==DONT_CARE)		named= (useUnion?0:~0);
	if (wantAutomatic==NO)			automatic= ~automatic;
	else if (wantAutomatic==DONT_CARE)	automatic= (useUnion?0:~0);
	if (wantExplicit==NO)			explicit= ~explicit;
	else if (wantExplicit==DONT_CARE)	explicit= (useUnion?0:~0);