From kwin Sun Oct 12 19:01:32 2003 From: Koos Vriezen Date: Sun, 12 Oct 2003 19:01:32 +0000 To: kwin Subject: [Kwin] Re: Embedding multible java applets and focus problems X-MARC-Message: https://marc.info/?l=kwin&m=106598534306845 On Sun, 12 Oct 2003, Koos Vriezen wrote: > hi, > > HTML pages with multible applets have sometimes trouble embedding some of > those. I sometimes see this as debug output: > > kjas: swallowing our window: KJAS Applet - Ticket number 24, window id = 31457789 > konqueror: ************************** Embed 0x1e001fd into 0x1803cb8 window=0x0 ********** > konqueror: >>> before reparent: parent=0x41 > konqueror: >>> Loop 0: reparent of 0x1e001fd into 0x1803cb8 successful > kjas: swallowing our window: KJAS Applet - Ticket number 25, window id = 31457795 > konqueror: ************************** Embed 0x1e00203 into 0x1803ccd window=0x0 ********** > konqueror: >>> before reparent: parent=0x41 > konqueror: >>> Loop 0: reparent of 0x1e00203 into 0x1803ccd successful > konqueror: ************************** Embed 0x1e001fd into 0x1803cb8 window=0x1e001fd ********** > konqueror: ************************** Embed 0x1e00203 into 0x1803ccd window=0x1e00203 ********** [..] > which means they interleave somehow. > QXEmbed.embed(Window) is called from KJavaAppletWidget::setWindow > (KWin::windowInfo windowAdded signal). The window itself are created by > the jvm process. > What I don't understand, how can this signal come, from within > QXEmbed.embed. This method does do something so the wm may trigger an > event, but that shouldn't be delivered right away, should/can it? and how > to avoid it? Found out why this interleaves, it doesn't :). What happens is that a call to embed(WId) triggers a ReparentNotify event. And QXEmbed::x11Event calls embed(WId). Proposed fix: diff -u -3 -p -r1.44 qxembed.cpp --- qxembed.cpp 25 Sep 2003 18:16:54 -0000 1.44 +++ qxembed.cpp 12 Oct 2003 18:16:52 -0000 @@ -828,8 +828,10 @@ bool QXEmbed::x11Event( XEvent* e) windowChanged( window ); } else if ( e->xreparent.parent == winId() ){ // we got a window - window = e->xreparent.window; - embed( window ); + if (window != e->xreparent.window) { + window = e->xreparent.window; + embed( window ); + } } break; case ButtonPress: or diff -u -3 -p -r1.44 qxembed.cpp --- qxembed.cpp 25 Sep 2003 18:16:54 -0000 1.44 +++ qxembed.cpp 12 Oct 2003 18:16:52 -0000 @@ -759,6 +759,7 @@ void QXEmbed::embed(WId w) USLEEP(1000); } QApplication::syncX(); + return; // let ReparentNotify finish the job } XResizeWindow(qt_xdisplay(), w, width(), height()); If ReparentNotify is a guaranteed event, I think second patch is preferable (might make QApplication::syncX() not needed any more ... yes work like before). One additional remark, the XAddToSaveSet call prevents the embedded window to be destroyed when the parent (QXEmbed) gets destroyed. Do we really want that for java/nsplugin? (protecting this call with 'if (!d->xplain)' does seem to get rid of those ugly window flashes after closing konq) > Koos > > _______________________________________________ Kwin mailing list Kwin@mail.kde.org http://mail.kde.org/mailman/listinfo/kwin