How to set focus to another application?

Simon Hausmann hausmann at kde.org
Sat Sep 27 19:59:27 BST 2003


On Sat, Sep 27, 2003 at 06:46:11PM +0100, shaheed wrote:
> 
> Hi all,
> 
> How does one application cause the input focus to be moved to another 
> application? I have tried:
> 
>     XWarpPointer (dpy, None, window, 0, 0, 0, 0, x, y);
>     XSetInputFocus(dpy, window, RevertToPointerRoot, CurrentTime);
> 
> where "window" is the window of the other application (as reported by a 
> "event.xbutton.subwindow" returned from XWindowEvent()).
> 
> This correctly causes the current aplication to loose focus int that the title 
> bar changes from blue to grey, but the other application's title bar satys 
> grey (and it ignores key presses).
> 
> What am I doing wrong? From soem googling, I assume it is something to do with 
> the interaction between KDE and X, but I am waaay out of my depth here. Any 
> clues appreciated.

#include <netwm.h>

NETRootInfo( qt_xdisplay(), 0 ).setActiveWindow( window );

should do the trick, I think.

Simon




More information about the kde-core-devel mailing list