? javaembed.cpp.diff Index: javaembed.cpp =================================================================== RCS file: /home/kde/kdebase/nsplugins/javaembed.cpp,v retrieving revision 1.1 diff -u -3 -p -r1.1 javaembed.cpp --- javaembed.cpp 2001/01/07 16:19:24 1.1 +++ javaembed.cpp 2001/03/13 00:32:15 @@ -396,12 +396,7 @@ KJavaEmbed::KJavaEmbed( QWidget *parent, */ KJavaEmbed::~KJavaEmbed() { - if ( window != 0 ) - { - XUnmapWindow( qt_xdisplay(), window ); - QApplication::flushX(); - } - + embed( 0 ); delete d; } @@ -481,14 +476,26 @@ void KJavaEmbed::embed( WId w ) { // kdDebug(6100) << "KJavaEmbed::embed" << endl; - if ( w == 0 ) - return; + if ( window != 0) { + // Undo current embedding. + XUnmapWindow( qt_xdisplay(), window ); + XReparentWindow( qt_xdisplay(), window, qt_xrootwin(), 0, 0 ); + window = 0; + QApplication::flushX(); + } window = w; + if ( w == 0 ) + return; //first withdraw the window XWithdrawWindow( qt_xdisplay(), window, qt_xscreen() ); QApplication::flushX(); + + //make sure we will receive destroy notifications for the embedded window. + XWindowAttributes xwattr; + XGetWindowAttributes(qt_xdisplay(), winId(), &xwattr); + XSelectInput(qt_xdisplay(), winId(), SubstructureNotifyMask | xwattr.your_event_mask); //now reparent the window to be swallowed by the KJavaEmbed widget XReparentWindow( qt_xdisplay(), window, winId(), 0, 0 );