[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-bugs-dist
Subject:    Bug#20645: More patches to let nspluginviewer work with DjVu.
From:       Leon Bottou <leonb () research ! att ! com>
Date:       2001-03-13 0:47:33
[Download RAW message or body]

Stefan.

After a few trials and errors, I have found that the following 
patch to nsplugins/javaembed.cpp considerably increases the 
stability of the plugin system with the dejavu plugin.  
It seems that nspluginviewer no longer crashes.

I am still unable to make the <embed ...> tags work.
Only full frame dejavu plugin instances seem to work.

Thanks for having a look at this.

- Leon Bottou


P.S.: javaembed vs qxtwidget

  I believe that the javaembed approach 
  (i.e. the part reparents the main window of the viewer)
  is better than the qxtwidget approach
  (i.e. the viewer reparents itself into the part).

  The reason is that, in the first case, 
  the part acts as a window manager for the viewer.  
  Window managers are obviously well supported by X.
  There are tons of examples around for problems 
  such as focus management, mapping management, etc.
  No such support and experience is available 
  for the converse case. 

  Therefore I tend to see the viewer as an Xt application
  (the main loop is Xt main loop) whose toplevel window
  is managed by the part.  It happens that this Xt application
  uses some Qt stuff.  This is made possible
  by your qt_set_socket_handler() function and by a small 
  fraction of the code in kxt.cpp.
["javaembed.cpp.diff" (text/plain)]

? 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 );


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic