[comp.windows.x] Xt/Xaw and signals

rjh@hare.udev.cdc.com (rj huebsch) (01/04/91)

I'm working on a X11R4 Xt/Xaw client that acts as a current
configuration display.  It receives a signal when the configuration
is changed rereads the configuration files to update its display.

The problem is that although the application receives the signal,
the display is not updated UNTIL the cursor pointer is placed 
somewhere in the applications window.

The following test program exemplifies this behavior.  Please
respond via e-mail and I'll summarize if there's interest.

=============================================================
To send a signal to the client, use "kill -USR1 <xtest-pid>" 
=============================================================
Compile statement:
  cc  -o xtest xtest.c -lXaw -lXmu -lXt -lXext -lX11
==============================================================
  /*  xtest.c  */
#include <stdio.h>
#include <signal.h>
#include <X11/Intrinsic.h>
#include <X11/StringDefs.h>
#include <X11/Xaw/Cardinals.h>
#include <X11/Xaw/Command.h>
#include <X11/Xaw/Form.h>
#include <X11/Xaw/Label.h>

#define CHANGEMESSAGE { \
	sprintf(buff," %d signals received", sigcount++); \
	XtSetArg(args[0], XtNlabel, buff); \
	XtSetValues(message, args, ONE); }

Widget toplevel, topform, quitbtn, message;
int sigcount=0;
Arg args[10];
char buff[80];

/*-------------------------------------------------------*/
void sighandler()
{
	XBell (XtDisplay(toplevel),100);
	CHANGEMESSAGE;
	signal(SIGUSR1,sighandler);
	fprintf(stderr,"Got Signal!!!\n");
}

/*-------------------------------------------------------*/
void Quit()
{
	exit(0);
}

/*-------------------------------------------------------*/
main(argc,argv)
 int argc;
 char **argv;
{
	
	toplevel = XtInitialize( argv[0], "Xtest", NULL, 0, &argc, argv);

	topform = XtCreateManagedWidget( "form", formWidgetClass, toplevel, 
			NULL, ZERO); 

	XtSetArg ( args[0], XtNlabel, "Quit");
	quitbtn = XtCreateManagedWidget( "quit", commandWidgetClass, topform,
			args, ONE); 
	XtAddCallback(quitbtn, XtNcallback, Quit, 0);

	XtSetArg ( args[0], XtNlabel, "xxx");
	XtSetArg ( args[1], XtNwidth, 400);
	XtSetArg ( args[2], XtNfromVert, quitbtn);
	XtSetArg ( args[3], XtNvertDistance, 10);
	message = XtCreateManagedWidget( "message", labelWidgetClass, topform,
			args, FOUR); 

	XtRealizeWidget(toplevel);

	CHANGEMESSAGE;

	signal(SIGUSR1,sighandler);
  	XtMainLoop();
}

-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Rick Huebsch                  E-mail:  rjh@udev.cdc.com
Control Data Corporation      AT&T:    (612) 482-3544