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 had this issue in my application as well, so here's the solution.
To raise the window you need not only to raise it, but you also need to notify the WM about it. The following code could be used:
// This is how to get it in Qt; if you don't use it,
// you can call XOpenDisplay and get it from there;
Display * display = x11Info().display();
// Main window identifier of your application
WId win = winId();
XEvent event = { 0 };
event.xclient.type = ClientMessage;
event.xclient.serial = 0;
event.xclient.send_event = True;
event.xclient.message_type = XInternAtom( display, "_NET_ACTIVE_WINDOW", False);
event.xclient.window = win;
event.xclient.format = 32;
XSendEvent( display, DefaultRootWindow(display), False, SubstructureRedirectMask | SubstructureNotifyMask, &event );
XMapRaised( display, win );