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()
{
}
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()
{
}