Используй для этого такую функцию:
C++ (Qt)
//
#ifdef Q_WS_X11
#include <QX11Info>
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#endif
void QUActivateWindow( QWidget* w )
{
if( !w->isVisible() )
w->show();
if( w->window() != w )
{
if( QWidget* fw = w->focusWidget() )
fw->setFocus();
return;
}
w->raise();
#ifdef Q_WS_X11
Display* dpy = QX11Info::display();
XClientMessageEvent ev;
bzero( &ev, sizeof( XClientMessageEvent ) );
ev.type = ClientMessage;
ev.window = w->winId();
ev.message_type = XInternAtom( dpy, "_NET_ACTIVE_WINDOW", False );
ev.format = 32;
ev.send_event = True;
ev.data.l[1] = QX11Info::appUserTime();
XSendEvent( dpy,
RootWindowOfScreen( DefaultScreenOfDisplay( dpy) ), False,
SubstructureRedirectMask | SubstructureNotifyMask, (XEvent*) &ev );
XSync( dpy, False );
#elif defined(Q_OS_WIN)
SetWindowPos ( w->winId(), HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE );
#endif
w->activateWindow();
}