How to send data from a non-motif application to a motif app

This forum is read only. No new submissions are accepted.

Questions about motif? Contact us

2 posts / 0 new
Last post
How to send data from a non-motif application to a motif app

Hi everyone!
I am new with Motif. These days I am developing a GUI for my another application which monitors a data stream.
The senario is like this:
I have one non-Motif application named "monitor.cc" and a Motif-based GUI application named "gui".
Whenever "monitor " generates an data tuple, I want to send it to "gui" and want to show the data tuple in "gui".
How can I accomplish this?
I failed in my own way as following:
I defined all the widgets as file scope variables which are shared by all subthreads.
Then I create the widgets of the graphical interface in main thread and realize all the widgets. Then before entering the Motif event loop, I create another subthread.
In the subthread, I use XClearArea for the purpose of sending an XExposeEvent to do some drawing.
Necessary codes are listed below. Can anyone find what's the problem with my method? Thank you!
-----------------------------------------------------------------------------
// define all the widgets, including a drawing area
Widgets drawarea;
GC drawarea_gc;
GCValues drawarea_gcv;
// Thread function
void *thread_fun( void *data );
int main( int argc, char **argv )
{
pthread_t thread;
CreateWidgets( argc, argv ); // Create all the widgets
RegisterCallback(); // Register some callbacks
RegisterEventHandler(); // Register some event handlers
XtRealizeWidget( shell );
printf( "In main thread, drawarea's window: %d\n", XtWindow(drawarea) );
pthread_create( &thread, NULL, thread_fun, NULL );
XtAppMainLoop( app );
return 0;
}
void *thread_fun( void *arg )
{
printf( "In subthread, rmssd_da's window: %d\n", XtWindow(rmssd_da) );
sleep(3); // To prevent the drawing action when the widget window is initialized
// Wants to tell the widget drawarea to draw a line
int ret = XClearArea( XtDisplay( drawarea ), 50, 50, 100, 100, XtWindow( drawarea ), TRUE ); // To send XExposeEvent
printf( "%d, %d, %d: %d\n", BadMatch, BadValue, BadWindow, ret );
}
void RegisterEventHandler()
{
XtAddEventHandler( drawarea, ExposureMask, FALSE, DrawLine, NULL );
}
void DrawLine( Widget da, XtPointer clientData, XEvent *event, Boolean *contDispatch )
{
drawarea_gcv.line_style = LineOnOffDash;
drawarea = XtGetGC( drawarea, GCLineStyle, & drawarea_gcv );
XDrawLine( XtDisplay( drawarea ), XtWindow( drawarea ), drawarea_gc, 60, 60, 120, 120 ); // Draw a line
}
-----------------------------------------------------------------------------
‹ Xdrawstring not drawing text on Pixmap Xmon - an x-event monitor - How to use? ›

 

 

Hi xiaoruijiang
In function 'DrawLine':
...
drawarea = XtGetGC( drawarea, GCLineStyle, & drawarea_gcv );
...
XtGetGC returns GC but not Widget type.
According the sample replace drawarea by drawarea_gc please:
...
drawarea_gc = XtGetGC( drawarea, GCLineStyle, & drawarea_gcv );
...

Why you shouldn't use IPC, Unix-sockets or SHM to communicate between Motif and non-Motif applications? In case your application is network oriented try to use TCP sockets.
Please find some examples at: http://users.actcom.co.il/~choo/lupg/tu ... ocess.html .

If the problem still persist, please provide real example that I would compile. It will take less time to help you.
Thanks,