X11 Reparenting does not work.
-
I am trying to Reparent some widgets using x11 programming, but the windows are openings separately.
what i expect is green color window inside red color window.
what am i doing wrong.
@
using namespace std;
#include <iostream>
#include <QtWidgets>
#include <X11/Xlib.h>int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QWidget child ;
child.setGeometry(33,33,555,555);
child.setPalette(QPalette(QColor(0,255,0,255)));
child.setAutoFillBackground(true);
child.show();XSetWindowAttributes frame_attributes; QWidget widget1 ; widget1.setGeometry(44,44,666,666); widget1.setPalette(QPalette(QColor(255,0,0,255))); widget1.setAutoFillBackground(true); widget1.show(); Window w; Display *display = XOpenDisplay( 0 ); int screen = DefaultScreen(display); XSetWindowAttributes xswa; xswa.background_pixel=BlackPixel(display, screen); xswa.border_pixel=WhitePixel(display, screen); xswa.event_mask=ExposureMask|KeyPressMask|KeyReleaseMask|ButtonPressMask|ButtonReleaseMask|StructureNotifyMask; xswa.override_redirect = False;
if ( display != NULL )
{
w = XCreateWindow(display, DefaultRootWindow(display),
0, 0, 50, 50, 0,0,InputOutput, DefaultVisual(display, screen), CWEventMask|CWBackPixel|CWBorderPixel|CWOverrideRedirect, &xswa);XMapWindow(display, w); XReparentWindow(display, child->winId(),w, 0, 0); XReparentWindow(display,w, widget1.winId(), 0, 0);
}else {
std::cout << "Error: Opening display" << std::endl ;
}
return app.exec();
}@
-
Hi,
See http://stackoverflow.com/questions/10089323/embedding-qwidget-into-x11-window It's a bit old, but might still work
-
[quote author="JKSH" date="1384238774"]Hi,
See http://stackoverflow.com/questions/10089323/embedding-qwidget-into-x11-window It's a bit old, but might still work[/quote]
Thanks JKSH,
I forgot that .
I added
@ XFlush(display);@
after Reparenting, now windows are shown inside each other.
but the problem is when i close the main window, the windows are getting closed, but the terminal does not show the promt.
I am running application from terminal , do i need to destroy any windows on exit , if so where and which one to destroy.