Patch for kjas (was: Java applets and ConfigureRequest)

Koos Vriezen koos.vriezen at xs4all.nl
Sat Dec 6 19:52:47 GMT 2003


On Sat, 6 Dec 2003, Koos Vriezen wrote:

Why do I always come with fresh ideas after discribing a problem and
sending it to kfm-devel?
Anyway, attached a patch that fixes the gray rectangle problem, simply by
calling 'frame.setUndecorated(true)'. Also changing JFrame to Frame,
saving three parents layering (actually the JPanel can be skipped to, but
leave it for now). I finally can use teletext on http://www.n-tv.de/ again
w/o random buttons not coming up)
Please review.

(of course, what has changed in kwin/qxembed that java windows needs this
now?)

> Hi,
>
> Trying to find the cause of applets being wrongly embedded, I found that
> the coordinates of the JFrame are totally wrong. To see this, do
> - add '-Dkjas.debug=1' to 'Additional Java Arguments' setting
> - start from the console eg
>   konqueror 'http://developer.netscape.com/docs/examples/java/hitman.html
>   press a few times F5 until a gray rectangle appears
> - get the dimension via javascript, eg
>   dcop konqueror-21639 html-widget1 evalJS '
>   var a1=document.applets[1].getParent().getParent().getParent().getParent().getParent().getBounds()'
>   (applets[1] means the second applet here)
> - now either look at the console output or get it from 'a1' like
>   a1.x/y/width/height eg.
>    dcop konqueror-21639 html-widget1 evalJS 'a1.height'
>
> (BTW, using a javax.swing.JFrame instead of java.awt.Frame makes no sense
> to me, it saves some parents if using a java.awt.Frame)
>
> Note, you probably need the latest java version because of a missing cast,
> jvm will exit otherwise.
>
> If I add in qxembed.cpp in QXEmbed::x11Event case ConfigureRequest
>
>     unsigned int value_mask = e->xconfigurerequest.value_mask
>                               |CWX|CWY|CWWidth|CWHeight|CWBorderWidth;
>     XWindowChanges xwc = {
>           0, 0, width(), height(),
>           0, None, Above
>     };
>     XConfigureWindow (qt_xdisplay(), window, value_mask, &xwc);
>
> instead of sending a ConfigureNotifyEvent (tried setting the x and y to
> zero too, like Leon suggests, but that didn't help - shouldn't this be
> fixed btw.), the dimensions are set correctly. However the borders are
> still wrong (use getInsets() instead off getBounds() and fields
> top/left/right/bottom). They should all be 0, no?
> Another thing is that calling XConfigureWindow blocks jvm for a second or
> two (XFlush didn't help).
> So the question is, shouldn't qxembed configure the window if it receives
> a ConfigureRequest (and any idea why it blocks the jvm for a while)?
> And how to set the border dimensions correctly?
> Or, of course, how come these values are messed up now and then?
>
> Koos
>
>
-------------- next part --------------
Index: org/kde/kjas/server/KJASAppletStub.java
===================================================================
RCS file: /home/kde/kdelibs/khtml/java/org/kde/kjas/server/KJASAppletStub.java,v
retrieving revision 1.49
diff -u -3 -p -r1.49 KJASAppletStub.java
--- org/kde/kjas/server/KJASAppletStub.java	13 Nov 2003 19:23:41 -0000	1.49
+++ org/kde/kjas/server/KJASAppletStub.java	6 Dec 2003 19:39:59 -0000
@@ -6,8 +6,6 @@ import java.net.*;
 import java.awt.*;
 import java.awt.event.*;
 
-import javax.swing.JFrame;
-
 
 /**
  * The stub used by Applets to communicate with their environment.
@@ -27,7 +25,7 @@ public final class KJASAppletStub
     private String            windowName;
     private String            className;
     private Class             appletClass;
-    private JFrame            frame;
+    private Frame             frame;
     private boolean           failed = false;
    
     
@@ -145,7 +143,7 @@ public final class KJASAppletStub
     
     void createApplet() {
         panel = new KJASAppletPanel();
-        frame = new JFrame(windowName);
+        frame = new Frame(windowName);
         // under certain circumstances, it may happen that the
         // applet is not embedded but shown in a separate window.
         // think of konqueror running under fvwm or gnome.
@@ -159,7 +157,9 @@ public final class KJASAppletStub
                 }
             }
         );
-        frame.getContentPane().add( "Center", panel );
+        frame.add( panel, BorderLayout.CENTER );
+        frame.setUndecorated(true);
+        frame.setLocation( 0, 0 );
         frame.pack();
         frame.setVisible(true);
         loader.addStatusListener(panel);
@@ -224,7 +224,10 @@ public final class KJASAppletStub
                 stateChange(INSTANCIATED);
                 app.setVisible(false);
                 panel.setApplet( app );
-                app.setSize(appletSize.getWidth() > 0 ? appletSize : panel.getSize());
+                if (appletSize.getWidth() > 0)
+                    app.setBounds( 0, 0, appletSize.width, appletSize.height );
+                else
+                    app.setBounds( 0, 0, panel.getSize().width, panel.getSize().height );
 
                 try {
                     app.init();


More information about the kfm-devel mailing list