I am trying to use XGetWindowAttributes and it is just returning me a "bad request" error. I have tried everything including all the examples I found online, but nothing works. I am really looking to gather the current geometry information of a window, and also the current icon location, so that I can blow the window away and execl a new one exactly where the old one was.
Here is a test program I have written. In the PushNotify function I have replaced top_level with panel and wid,in all combinations, but it still doesn't work.
// standard include files
#include
#include
// Motif include files
#include
#include
#include
#include
// global variables
Widget top_level; // top level widget
Widget panel; // panel
// callback
void PushNotify( Widget wid, caddr_t client_data, caddr_t client_args );
//**************************************************************************
//
// Function: main
//
// Purpose: Initial execution of the test process.
//
//**************************************************************************
int main( int argc, char* argv[] )
{
// local variables
XtAppContext app; // application context
WidgetList childList = NULL; // child widget list
// create top level shell for Motif dialogs
top_level = XtVaAppInitialize( &app, "TopLevel", NULL, 0, &argc, argv,
NULL,
XmNwidth, 150,
XmNheight, 100,
NULL );
// create panel
panel = XtVaCreateWidget( "panel",
xmFormWidgetClass, top_level,
XmNmarginWidth, 0,
XmNmarginHeight, 0,
XmNautoUnmanage, FALSE,
XmNallowOverlap, TRUE,
XmNwidth, 150,
XmNheight, 50,
NULL);
XtManageChild( panel );
// create push button
Widget w = XtVaCreateWidget( "button", xmPushButtonWidgetClass,
panel, NULL );
XtManageChild( w );
XtVaSetValues( w,
XmNx, 20,
XmNy, 50,
NULL );
XtAddCallback( w, XmNactivateCallback, ( XtCallbackProc ) PushNotify,
NULL );
// enter main application loop
XtRealizeWidget( top_level );
XtAppMainLoop( app );
}
void PushNotify( Widget wid, caddr_t client_data, caddr_t client_args )
{
// local variable
XWindowAttributes wa; // window attributes
#if 0
// have also tried this and substituting d/tshell for top_level
Widget dshell;
Widget tshell;
for ( dshell = wid; !XtIsShell( dshell ); dshell = XtParent( dshell ) );
for ( tshell = dshell; !XtIsTopLevelShell( tshell ); tshell = XtParent( tshell ) );
#endif
if ( Success != XGetWindowAttributes( XtDisplay( top_level ),
XtWindow( top_level ), &wa ) )
{
cout << "Failed to get window attributes." << endl;
} // end failed to get window attributes
}
jwobido
Re: XGetWindowAttributes not working
Nevermind.
One of the man pages told me to check for "Success", however on our system Success is defined as zero. So, the function is working, I'm just checking for the wrong return. Very confusing.