diff options
author | Robert Griebl <rgriebl@trolltech.com> | 2010-03-22 14:35:03 (GMT) |
---|---|---|
committer | Robert Griebl <rgriebl@trolltech.com> | 2010-03-22 14:37:11 (GMT) |
commit | 9da453e5579ebb6fb0361e4df4cfa7107e560b23 (patch) | |
tree | 063555054f167d61f1bd8052c3fb05b191077cb4 /src/gui/kernel/qwidget_x11.cpp | |
parent | 35ca28a576e7d71b789211bcad00fc4f907c6e91 (diff) | |
download | Qt-9da453e5579ebb6fb0361e4df4cfa7107e560b23.zip Qt-9da453e5579ebb6fb0361e4df4cfa7107e560b23.tar.gz Qt-9da453e5579ebb6fb0361e4df4cfa7107e560b23.tar.bz2 |
Add a new WA_X11DoNotAcceptFocus attribute for top-level widgets.
This should prevent window managers from ever sending a WM_TAKE_FOCUS
message to those windows (useful for IM windows like virtual keyboards,
notification banners, etc.)
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 54dd300..c1363d2 100644 --- a/src/gui/kernel/qwidget_x11.cpp +++ b/src/gui/kernel/qwidget_x11.cpp @@ -780,7 +780,7 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO XWMHints wm_hints; // window manager hints memset(&wm_hints, 0, sizeof(wm_hints)); // make valgrind happy wm_hints.flags = InputHint | StateHint | WindowGroupHint; - wm_hints.input = True; + wm_hints.input = q->testAttribute(Qt::WA_X11DoNotAcceptFocus) ? False : True; wm_hints.initial_state = NormalState; wm_hints.window_group = X11->wm_client_leader; @@ -3050,4 +3050,24 @@ void qt_x11_getX11InfoForWindow(QX11Info * xinfo, const QX11WindowAttributes &at xinfo->setX11Data(xd); } +void QWidgetPrivate::updateX11AcceptFocus() +{ + Q_Q(QWidget); + if (!q->isWindow() || !q->internalWinId()) + return; + + XWMHints *h = XGetWMHints(X11->display, q->internalWinId()); + XWMHints wm_hints; + if (!h) { + memset(&wm_hints, 0, sizeof(wm_hints)); // make valgrind happy + h = &wm_hints; + } + h->flags |= InputHint; + h->input = q->testAttribute(Qt::WA_X11DoNotAcceptFocus) ? False : True; + + XSetWMHints(X11->display, q->internalWinId(), h); + if (h != &wm_hints) + XFree((char *)h); +} + QT_END_NAMESPACE |