I have the PID for the process (and the name), I want to bring it to the front on linux (ubuntu). On mac I would simply do SetFrontProcess(pid)
, on windows I\'d
I haven't tried this myself, but putting these two methods together may work:
The XRaiseWindow API Call in xlib lets you raise a Window to the front if you know the Window ID.
http://www.unix.com/man-page/Linux/3/XRaiseWindow/
This stackoverflow answer explains how to get a Window ID from a PID:
How to get an X11 Window from a Process ID?
EDIT:
I've had limited success with XRaiseWindow. The Following program does work under twm window manager, but not ion which I usually use. The Window Manager must have ways of preventing applications from 'popping up'. To make this work, i also had to pass it the Window ID of the Window Manager's frame for the window, not the window itself. run xwininfo -frame and click on the window and you get the frame ID instead, compile this program with gcc test.c -lX and pass it that hexid on the command line and it will raise the window.
#include
#include
#include
int main(int argc, char **argv)
{
Display *dsp = XOpenDisplay(NULL);
long id = strtol(argv[1], NULL, 16);
XSetWindowAttributes xswa;
xswa.override_redirect=True;
XChangeWindowAttributes (dsp,id,CWOverrideRedirect, &xswa);
XRaiseWindow ( dsp, id );
XCloseDisplay ( dsp );
}