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

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? ›

Tue, 08/07/2012 - 15:13
#1
2 posts / 0 new
Last post
-4
 
Tue, 08/07/2012 - 15:13