PDA

View Full Version : Formating problem in XReparentWindow



PstdEr
18th October 2013, 11:30
I am using the following program to embed a client window in another window using Qt and X11 code.

I run the server program first and gets the window id of server using xwininfo(http://tronche.com/gui/x/xlib/window-and-session-manager/XReparentWindow.html).
upon getting the window id , i run the client program by passing window id as a command line arguments.


the problem is that the client window is embedding at the bottom , or at sides , or other but never from (0,0) geometry.

and having the background of parent .

how can i make the window to embed from 0,0 and should cover the size of its parent with auto size adjustable.


client code



using namespace std;
#include <iostream>
#include <QtWidgets>
#include <X11/Xlib.h>

int main(int argc, char *argv[])
{
QApplication app(argc, argv);
unsigned long int WinId;
XSetWindowAttributes frame_attributes;
WinId = atoi(argv[1]);
cout<<"WinId :"<<WinId<<endl;

if(argc != 2){
cout<<"pass WinId as arguement"<<endl;
return 0;
}
Display *display = XOpenDisplay( 0 ); // 0 parameter for default values
frame_attributes.background_pixel = XWhitePixel(display, 0);
if ( display != NULL )
{
// Create the x11 window using XLib
Window w = XCreateWindow(display, DefaultRootWindow(display),
0, 0, 200, 300, 0,CopyFromParent, CopyFromParent, CopyFromParent, CWBackPixel, &frame_attributes);

XMapWindow(display, w);
XReparentWindow(display, w,WinId, 0, 0);
XFlush(display);
}
else
std::cout << "Error: Opening display" << std::endl ;

return app.exec();
}


server code:



MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
QWidget *ServerWin = new QWidget;
setCentralWidget(ServerWin);
setMinimumSize(800,700);
setPalette(QPalette(QColor(0,255,0,255)));
setAutoFillBackground(true);
}

MainWindow::~MainWindow()
{

}

anda_skoa
18th October 2013, 16:26
What if you pass the parent to XCreateWindow instead of reparenting?

Cheers,
_

PstdEr
18th October 2013, 19:25
What if you pass the parent to XCreateWindow instead of reparenting?

Cheers,
_

Thats Good,

But i am not able to resize the client, does not the client resize when we maximize the parent?
one more thing is , if i have some layouts on my server window and each layout is having different image then the cilent is having all those layouts as background instead of having its own parents.

anda_skoa
19th October 2013, 14:44
But i am not able to resize the client, does not the client resize when we maximize the parent?

I guess that since it is not a widget but just widget content, you'll have to resize it manually.
XResizeWindow in the resizeEvent() handler of the parent maybe.



one more thing is , if i have some layouts on my server window and each layout is having different image then the cilent is having all those layouts as background instead of having its own parents.

No idea, sorry.

Cheers,
_