Greetings,

I've spent the past few days hunting down a bug that involves an
interaction between FVWM and Java 7.

I can provide more detail for anyone who is curious, but here are the
key points:

a)    Java version 7 creates a special "FocusProxy" window to get
keyboard input.  See
 
http://www.docjar.com/html/api/sun/awt/X11/XFocusProxyWindow.java.html 

b)    frame.c contains a work around and a comment that begins with  the
fated phrase "For some reason".  
      It seems like there was a bug in a ~1999 X server that doesn't
exist in 2012 era Xorg.

c)    The code in frame.c takes focus away from java's "Focus Proxy"
window and gives it to a java window 
      that doesn't know what to do with keyboard input.

I'm including a proposed patch (very simple - comment out the hack from
1999) as well as java code that can be used to reproduce the issue.

Let me know if you have any thoughts.

Thanks and best regards,

Jonathan


=====================================================

diff -urNp fvwm-2.6.4/fvwm/frame.c fvwm-2.6.4-javafix/fvwm/frame.c
--- fvwm-2.6.4/fvwm/frame.c     2011-10-15 05:34:28.000000000 -0500
+++ fvwm-2.6.4-javafix/fvwm/frame.c     2012-04-11 16:54:25.090804806
-0500
@@ -1938,14 +1938,25 @@ void frame_free_move_resize_args(
        }
        update_absolute_geometry(fw);
        frame_reparent_hide_windows(Scr.NoFocusWin);
-       if (mra->w_with_focus != None)
-       {
-               /* domivogt (28-Dec-1999): For some reason the
XMoveResize() on
-                * the frame window removes the input focus from the
client
-                * window.  I have no idea why, but if we explicitly
restore
-                * the focus here everything works fine. */
-               FOCUS_SET(mra->w_with_focus);
-       }
+       
+       /* JPS:  11-Apr-2012:  The code which is now commented out was
introduced 
+        * in 1999  with the following comment:
+        *
+        *   For some reason the XMoveResize() on the frame window
removes 
+        *   the input focus from the client window.  I have no idea
why, 
+        *   but if we explicitly restore the focus here everything
works 
+        *   fine.
+        *
+        *      if (mra->w_with_focus != None)
+        *      {
+        *              FOCUS_SET(mra->w_with_focus);
+        *      }
+        *
+        * Unfortunately, the code doesn't work fine with Java 7's
"FocusProxy"
+        * and has been commented out since it doesn't seem to be
necessary 
+        * when using modern Xorg.
+        */
+
        if (mra->flags.do_update_shape)
        {
                /* unset shape */

=====================================================

/* simpleproblem.java
 * 
 * Install java 7 (either oracle or openjdk)
 * Run FVWM
 * compile with:  javac simpleproblem.java
 * run with:  java -cp . simpleproblem
 *
 * You will see that after resizing the window
 * text entry into the java app is impossible.
 */

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
import java.awt.FlowLayout;

public class simpleproblem extends JFrame
{
   
   private JLabel explanation;
   private JTextField entrybox;
   private FlowLayout thelayout;

   public simpleproblem() 
   {
      explanation = new JLabel("Resize the window then enter text:");
      entrybox = new JTextField(15);
      thelayout = new FlowLayout();
      setLayout(thelayout);
      add(explanation);
      add(entrybox);
   }

   public static void main( String args[] ) {
      simpleproblem entertext = new simpleproblem();
      entertext.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
      entertext.setSize( 400,200 );
      entertext.setVisible( true );
   }
}














Reply via email to