[Search for users]
[Overall Top Noters]
[List of all Conferences]
[Download this site]
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 |
3241.0. "can I bypass the Xtmainloop ???" by TOWNS::BEECHER () Tue Aug 21 1990 20:53
I have a customer who wants to set up some libray functions that
can be called from a C program and let the programmer take advantage
of DECWWindows without having to know all the ins and outys of using
the Toolkit. Because a DECWindows program relies on getting its
events from the XtMainLoop, Iit makes it impossible to uses it as such
a library because all callbacks return to the loop and the only way
to exit the loop is to exit the program that would prevent a return
to the calling function. My customer wants to be able to access the
program from one machine and send the output to one or more machines.
From the notes file I was able to come up with the following solution that
all most works. Can anyone help me ?? This function can be called from the
same machine it works fine, but if I try to send it to different nodes
calling it severaltimes, strange things happen. When the widget appears
on the second node, I lose some of the widget and get an X window error:
BadDRawable - parameter not a Pixmap or Window and BadValue - integer
parameter out of range.
Here is the "library function" :
#include <decw$include:DwtWidget.h>
#define NULL '\0'
#define window_name "DWL_ERROR_BOX"
#define window_class "ERROR"
#define widget_name "DWL_ERROR"
#define error_x 400
#define error_y 400
#define error_style DwtModal
#define error_label DwtLatin1String("")
#define yes_label DwtLatin1String("Acknowledge")
#define no_label DwtLatin1String("No")
#define cancel_label DwtLatin1String("Cancel")
#define default_button DwtYesButton
#define help_callback NULL
yes_button_activated();
static DwtCallback yes_callback[] = {
{yes_button_activated, NULL},
{NULL, NULL}
};
Widget top_level;
Widget dwl_error_widget;
Display *display;
int status;
Arg arglist[2];
extern char *node_name;
short dwl_error_flag = True;
dwl_error(char *node_name)
{
unsigned int argc = 0;
char *argv;
XtAppContext app_context;
XEvent event;
XtToolkitInitialize();
app_context = XtCreateApplicationContext();
if(!(display = XtOpenDisplay(app_context, node_name, window_name,
window_class, NULL, 0, &argc, argv)))
{
printf(" Could not open display !!!\n");
return;
}
top_level = XtAppCreateShell( "error", window_class,
applicationShellWidgetClass, display, NULL, 0);
dwl_error_widget = DwtCautionBox(top_level, widget_name, False,
error_x, error_y, error_style,
DwtLatin1String(error_mesdsage), yes_label,
no_label, cancel_label, default_button,
yes_callback, help_callback);
XtManageChild(dwl_error_widget);
dwl_error_flag = True;
while(dwl_error_flag)
{
XtAppNextEvent(app_context, &event);
XtDispatchEvent(&event);
XtAppProcessEvent(app_context, XtIMALL);
}
return;
}
yes_button_activated(widget, tag, reason)
Widget widget;
char *tag;
DwtAnyCallbackStruct *reason;
{
dwl_error_flag = False;
XtDestroyWidget(dwl_error_widget);
}
The following is the routine that calls this library function.
#include <stdio.h>
#define NULL '\0'
char *node_name = "NODE1::0";
int status;
main()
{
char *error_message = " This is a test message ";
status = dwl_error(error_message);
strcpy(node_name, "NODE2::0");
status = dwl_error(error_message);
strcpy(node_name, "NODE1::0");
status = dwl_error(error_message);
strcpy(node_name, "NODE2::0");
status = dwl_error(error_message);
exit(0);
T.R | Title | User | Personal Name | Date | Lines |
---|
3241.1 | Polling is probably the most brain damaged aspect of X... | IO::MCCARTNEY | James T. McCartney III - DTN 381-2244 ZK02-2/N24 | Mon Aug 27 1990 18:05 | 17 |
|
If your "library" function uses only Xlib calls, it can use asynchronous
event notification to process it's events. Several notes in this conference
or related conferences discuss how this is done.
If you must use the toolkit, you can "unwind the mainloop" by using timer
ASTs (on VMS) to ensure that you empty the event queue periodicly.
The third alternative is to wait for a thread-reenterant toolkit and make
your library functions execute as separate threads (which can then have
their own mainloops).
All in all a polling architecture being passed off as "state of the art" is
pretty weak...
James
|
3241.2 | | PSW::WINALSKI | Careful with that VAX, Eugene | Mon Aug 27 1990 19:26 | 6 |
| Your example program has one global variable each for top_level and,
dwl_error_widget. You have to have one of these for each of the displays
you're working with. Your dispatching loop code may very well be getting its
widgets and displays confused.
--PSW
|