I seem to be unable to figure out how to get a TGMainFrame’s screen position. Neither GetWMPosition(Int_t&,Int_t&) nor GetX()/GetY() return anything useful. The following code is a small example of how i try to get the position:
[code]#include <TApplication.h>
#include <TGFrame.h>
#include
using std::cout;
using std::endl;
TGMainFrame* mainframe;
int main(int argc, char** argv)
{
TApplication runroot(“PositionTest”, &argc, argv);
mainframe = new TGMainFrame();
mainframe->Connect(“ProcessedEvent(Event_t*)”,NULL,NULL, “printPos(Event_t*)”);
mainframe->Connect(“CloseWindow()”,“TApplication”,gApplication, “Terminate()”);
mainframe->MapSubwindows();
mainframe->Resize(100,100);
mainframe->MapWindow();
runroot.Run();
return 0;
}
void printPos(Event_t* event)
{
cout << "X: " << mainframe->GetX() << endl;
cout << "Y: " << mainframe->GetY() << endl;
Int_t x, y;
mainframe->GetWMPosition(x,y);
cout << "WM X: " << x << endl;
cout << "WM Y: " << y << endl;
}[/code]
The ouput always looks likeX: 0
Y: 0
WM X: -1
WM Y: -1
no matter where the window is positioned.
Using ROOT-2.6.27 and have tested this in both Metacity and Openbox (Linux).
Grateful of any help.