Hi; thanks for the helpful explanations. I tried doing that change and it stayed the same. I also tried doing a sleep(2) before sending the WM_TAKE_FOCUS (with the +2s timestamp), but without success.
What did work is this: static void clientwin_do_set_focus(WClientWin *cwin, bool warp) { if(cwin->flags&CLIENTWIN_P_WM_TAKE_FOCUS){ Time stmp=ioncore_get_timestamp(); send_clientmsg(cwin->win, ioncore_g.atom_wm_take_focus, stmp); } else { region_finalise_focusing((WRegion*)cwin, cwin->win, warp); } XSync(ioncore_g.dpy, 0); } I just added the „else“ keyword so that region_finalise_focusing is not called if the WM_TAKE_FOCUS is sent. I don't know the meaning of this, but only that it solves all problems with Netbeans and my example Swing application. Focus is set to the last active widget. This, however, makes Konqueror 4 stop receiving focus. This makes me think: - Konqueror has flag CLIENTWIN_P_WM_TAKE_FOCUS and apparently needs both the WM_TAKE_FOCUS call and the region_finalise_focusing - Netbeans/Swing also has flag CLIENTWIN_P_WM_TAKE_FOCUS, but if you run the region_finalise_focusing code on it, it loses focus Maybe region_finalise_focusing should sometimes be doing nothing in windows like Netbeans. Or maybe Swing should be correctly handling the XSetInputFocus(ioncore_g.dpy, win, RevertToParent, CurrentTime) in region_finalise_focusing. It is exactly at that XSetInputFocus where the text field at the Swing application loses the keyboard focus (I tested it inserting sleeps between calls). I filed this bug to Sun but I don't know whether they think the bug is in JDK. The bug report is at http://bugs.sun.com/view_bug.do?bug_id=6798064 Greetings, Daniel