Re: Keyboard focus lost in Swing applications (ex: Netbeans) after changing to window

Ole Jørgen Brønner <[email protected]> Mon, 14 Dec 2009 20:10:24 +0100
Newsgroups gmane.comp.window-managers.ion.general
Message-ID <op.u4xzjms6vocxtk@tabole-debian>
This http://code.google.com/p/xmonad/issues/detail?id=177 xmonad bug  
report is probably relevant. Preventing XSetInputFocus to be called on  
windows with WM_TAKE_FOCUS set seems to fix the issue for me (ion3plus,  
sun-java-6)

I will run with the change for a while and see if it breaks other apps.  
(and possible test other java versions)

On Thu, 15 Jan 2009 10:35:49 +0100, Daniel Clemente  
<dcl441-bugs-/[email protected]> wrote:

> Hi, sorry if this message comes twice (I posted yesterday via NNTP  
> without being subscribed to the list).
>
>
>   ion3 is stealing keyboard focus to Swing applications. This happens  
> for instance with Netbeans 6.5:
>
> 1. Open netbeans and some other programs in tabs next to it.
> 2. Select netbeans and open an editor with some code; the cursor is  
> inside the editor
> 3. Select another tab (either clicking teh tab or with keyboard).
> 4. Select netbeans again (either clicking the tab or with keyboard).
> 5. Try to continue typing, but you can't. The cursor is nowhere, and *no  
> key* works (space, cursors, A-S-o, ... all gone). You must click again  
> in the editor and then you can type again.
>
> In fact any Swing application has this problem. You can use this one to  
> test:
>
> --- TypeInSwing.java ----------------------------------------
>
> import javax.swing.JFrame;
> import javax.swing.JTextField;
>
> public class TypeInSwing {
>   public static void main(String[] args) {
>     JFrame frame = new JFrame("HelloWorldSwing");
>     final JTextField field = new JTextField("type here");
>
>     frame.getContentPane().add(field);
>
>     frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
>     frame.pack();
>     frame.setVisible(true);
>   }
> }
>
> --------------------------------------------------------------
>
> It happens with latest version 20090110 (with 20080207 too).
>
> I am using:
>
> $ java -version
> java version "1.6.0_06"
> Java(TM) SE Runtime Environment (build 1.6.0_06-b02)
> Java HotSpot(TM) Server VM (build 10.0-b22, mixed mode)
>
>
>   Why is it so?
>
>
> Daniel
>
>
>


-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
java-focus.patch (application/octet-stream, 249 B)
diff -rN old-experimental/ioncore/focus.c new-experimental/ioncore/focus.c
357d356
<     
358a358,361
>     /* fixes most java apps focus bugs */
>     if(OBJ_IS(reg, WClientWin) && reg->flags&CLIENTWIN_P_WM_TAKE_FOCUS){
>         return;
>     }