To activate another window, the right thing at the Xlib protocol level is to send the _NET_ACTIVE_WINDOW message as described in the EWMH specification http://standards.freedesktop.org/wm-spec/wm-spec-1.3.html
This can be done using python-xlib (presumably) or using gdk_window_focus () on someone else's GdkWindow using GDK via pygtk
_NET_ACTIVE_WINDOW is superior to XRaiseWindow () and has been in all important WMs for many years.
You should avoid XSetInputFocus (), which will cause problems (especially if you made a mistake in the timestamp). The problem is that WM cannot intercept SetInputFocus (), so it causes strange race conditions and user interface mismatches.
Indeed, only _NET_ACTIVE_WINDOW works correctly, so it was invented because previous hacks were bad.
There is a library called libwnck that allows you to activate windows (by the way), but unfortunately it adds a lot of overhead because it always keeps track of all open windows from any application, even if you donβt need to do this, however, if you want to track windows from other applications anyway, then libwnck has a function to activate those windows that do the right thing, and that would be a good choice.
A strictly correct approach is to check EWMH support _NET_ACTIVE_WINDOW (EWMH documents how to do it) and return to XRaiseWindow if WM does not have _NET_ACTIVE_WINDOW. However, since any WM that has been active over the past many years has EWMH, many people are lazy to cancel for legacy WM servers.
Havoc p
source share