diff options
author | Robert Griebl <rgriebl@trolltech.com> | 2010-03-22 13:45:07 (GMT) |
---|---|---|
committer | Robert Griebl <rgriebl@trolltech.com> | 2010-03-22 13:45:07 (GMT) |
commit | 6390248b11b3596d8c946c232e9b0d832dc42941 (patch) | |
tree | c9227081815a68b061c8a4f57612bb9ec7da3ef9 /src/gui/kernel/qwidget_x11.cpp | |
parent | f7c9db16be26c0c273ae141a88da80fae44c2304 (diff) | |
download | Qt-6390248b11b3596d8c946c232e9b0d832dc42941.zip Qt-6390248b11b3596d8c946c232e9b0d832dc42941.tar.gz Qt-6390248b11b3596d8c946c232e9b0d832dc42941.tar.bz2 |
Make QWidget::activateWindow() NET window manager aware.
Use the _NET_ACTIVE_WINDOW atom if the current window manager supports it -
otherwise fall back to XSetInputFocus()
Reviewed-by: bhughes
Diffstat (limited to 'src/gui/kernel/qwidget_x11.cpp')
-rw-r--r-- | src/gui/kernel/qwidget_x11.cpp | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/gui/kernel/qwidget_x11.cpp b/src/gui/kernel/qwidget_x11.cpp index 47f91f8..54dd300 100644 --- a/src/gui/kernel/qwidget_x11.cpp +++ b/src/gui/kernel/qwidget_x11.cpp @@ -1641,7 +1641,27 @@ void QWidget::activateWindow() if (X11->userTime == 0) X11->userTime = X11->time; qt_net_update_user_time(tlw, X11->userTime); - XSetInputFocus(X11->display, tlw->internalWinId(), XRevertToParent, X11->time); + + if (X11->isSupportedByWM(ATOM(_NET_ACTIVE_WINDOW))) { + XEvent e; + e.xclient.type = ClientMessage; + e.xclient.message_type = ATOM(_NET_ACTIVE_WINDOW); + e.xclient.display = X11->display; + e.xclient.window = tlw->internalWinId(); + e.xclient.format = 32; + e.xclient.data.l[0] = 1; // 1 == application + e.xclient.data.l[1] = X11->userTime; + if (QWidget *aw = QApplication::activeWindow()) + e.xclient.data.l[2] = aw->internalWinId(); + else + e.xclient.data.l[2] = XNone; + e.xclient.data.l[3] = 0; + e.xclient.data.l[4] = 0; + XSendEvent(X11->display, RootWindow(X11->display, tlw->x11Info().screen()), + false, SubstructureNotifyMask | SubstructureRedirectMask, &e); + } else { + XSetInputFocus(X11->display, tlw->internalWinId(), XRevertToParent, X11->time); + } } } |