[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference bulova::decw_jan-89_to_nov-90

Title:DECWINDOWS 26-JAN-89 to 29-NOV-90
Notice:See 1639.0 for VMS V5.3 kit; 2043.0 for 5.4 IFT kit
Moderator:STAR::VATNE
Created:Mon Oct 30 1989
Last Modified:Mon Dec 31 1990
Last Successful Update:Fri Jun 06 1997
Number of topics:3726
Total number of notes:19516

1461.0. "Heavy CPU usage with application contexts?" by EPIK::BUEHLER (Live today, for tommorrow isn't here yet) Tue Sep 19 1989 11:50

    This has come up before, but I'd like to knock on it one more time.
    
    If an application wishes to manage windows on multiple displays, it's
    necessary to set up an application context and do the other things
    which are slightly out of the ordinary for the single display case.  I
    haven't any problem with this.
    
    However, the event processing of the multiple display connections
    within DECwindows seems to rely on a polling approach.  This results in
    massive CPU usage by an application, regardless of whether or not any
    events are being processed.
    
    Is there any way, using C, to implement a multiple display application
    using DECwindows which does not have this deficiency?  For example, if
    the application has a mode where it works from a single display and a
    mode where it works from multiple displays?  Is it possible to cause
    DECwindows to poll only in the multiple display case?
    
    I'm aware of the ADA multi-thread approach, but ADA is not the
    solution.
    
    I haven't QAR'd the behavior because I'm not sure if there is a
    reasonable workaround available.
    
John

T.RTitleUserPersonal
Name
DateLines
1461.1X*InputDECWIN::FISHERBurns Fisher 381-1466, ZKO3-4/W23Tue Sep 19 1989 20:217
    I'm home so I can't look this up:  Doesn't XtAddInput do what you
    want?  If not, there is an unsupported routine called XMultiplexInput
    which surely does.  Search through the notes file for more info on it.
    
    Burns
    

1461.2Misconception?LEOVAX::TREGGIARIThu Sep 21 1989 14:0411
I think there may be a misconception (started by Mike Collins' example program
in this area...) tht multiple application contexts are needed in order to
support multiple displays.  I believe one application context can support
more than one display.  Using one application context means that you can
simply call XtAppMainLoop (which calls XMultiplexInput and blocks...) and
not do "polling" from your application.

Example (modified from Mike's) follows in next reply.

Leo

1461.3Example of multiple displays from one application contextLEOVAX::TREGGIARIThu Sep 21 1989 14:05127
    
#include <stdio.h>
#include <DECW$INCLUDE/DwtWidget.h>

#define	CS(x)	DwtLatin1String(x)

Widget		toplevel[2];
XEvent		event;

Widget		CreateToplevel();
void		SetUpTree();
void		quit_callback();
void		error();

DwtCallback	quit[] =   { { quit_callback,NULL}, NULL };

XtAppContext	Context;

char		*display[2] =	{ "node1::0", "node2::0" };

main( argc, argv)
    int	    argc;
    char    *argv[];
{
    int	    n=0;
    int	    start = 0,
	    end = 2;

    XtToolkitInitialize();

    Context = XtCreateApplicationContext();

    for(n=start;n<end;n++)
    {

	toplevel[n] = CreateToplevel(	Context, 
					display[n], 
					argc, 
					argv );

	SetUpTree( toplevel[n] );

	XtRealizeWidget( toplevel[n] );
    };


    XtAppMainLoop (Context);

}   /* End of main program */

    
    
void	quit_callback( w, tag, reason )
    Widget		    *w;
    int			    *tag;
    DwtAnyCallbackStruct    *reason;
{
    exit(0);
}
    
    
    
void error( char	*error_string )
{
    printf( "%s\n", error_string );
}
    
    
    
Widget	CreateToplevel( context, display, argc, argv)
    XtAppContext    context;
    char	    *display;
    int		    argc;
    char	    *argv[];
{
    Display	*dpy;
    Widget	toplevel;
    char	*application_name[] = "SetNode";
    char	*class_name[] = "ClassName";

    dpy = XtOpenDisplay(    context,
			    display,
			    application_name,
			    class_name,
			    NULL,
			    0,
			    &argc,
			    &argv );

    toplevel = XtAppCreateShell(    "TopLevel",
    				    "",
				    topLevelShellWidgetClass,
				    dpy,
				    NULL,
				    0 );

    return( toplevel );
}
    
    
void SetUpTree( top )
    Widget  top;
{
    Widget  mainwidget, pushbutton;

    mainwidget = DwtMainWindow(	top,
				"MainWindow",
				100,
				100,
				100,
				100 );

    XtManageChild( mainwidget );

    pushbutton = DwtPushButton(	mainwidget,
				"PushButton",
				30,
				30,
				CS("Press"),
				quit,
				NULL );

    XtManageChild( pushbutton );
};



1461.4Just saved me lots of computes...EPIK::BUEHLERLive today, for tommorrow isn&#039;t here yetThu Sep 21 1989 15:4821
    I was using a single application context.  I believe my understanding
    of that area is sufficient not to get into too much trouble.  However,
    my substitute for XtAppMainLoop was incomplete because it did not have
    a call to XMultiplexInput.  It has been added and all is well in
    BuehlerLand.  Thanks to Burns for pointing out XMultiplexInput to me.
    
    Thanks anyway, Leo.  I'm sure it will help others.
    
    The substitute I have for XtAppMainLoop goes more or less like this:
    
    while (1)
       {
        XMultiplexInput(...)
        while (mask = XtAppPending(context))
           XtAppProcessEvent(context, mask);
       }
    
    It appears to work just fine (now).
    
John