summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorRobert Griebl <rgriebl@trolltech.com>2010-03-22 14:35:03 (GMT)
committerRobert Griebl <rgriebl@trolltech.com>2010-03-22 14:37:11 (GMT)
commit9da453e5579ebb6fb0361e4df4cfa7107e560b23 (patch)
tree063555054f167d61f1bd8052c3fb05b191077cb4 /src/gui
parent35ca28a576e7d71b789211bcad00fc4f907c6e91 (diff)
downloadQt-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')
-rw-r--r--src/gui/kernel/qwidget.cpp4
-rw-r--r--src/gui/kernel/qwidget_p.h1
-rw-r--r--src/gui/kernel/qwidget_x11.cpp22
3 files changed, 26 insertions, 1 deletions
diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp
index af5fcd1..e88026c 100644
--- a/src/gui/kernel/qwidget.cpp
+++ b/src/gui/kernel/qwidget.cpp
@@ -10550,6 +10550,10 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on)
case Qt::WA_X11OpenGLOverlay:
d->updateIsOpaque();
break;
+ case Qt::WA_X11DoNotAcceptFocus:
+ if (testAttribute(Qt::WA_WState_Created))
+ d->updateX11AcceptFocus();
+ break;
#endif
case Qt::WA_DontShowOnScreen: {
if (on && isVisible()) {
diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h
index 2cb8586..c32e1a1 100644
--- a/src/gui/kernel/qwidget_p.h
+++ b/src/gui/kernel/qwidget_p.h
@@ -703,6 +703,7 @@ public:
void setNetWmWindowTypes();
void x11UpdateIsOpaque();
bool isBackgroundInherited() const;
+ void updateX11AcceptFocus();
#elif defined(Q_WS_WIN) // <--------------------------------------------------------- WIN
uint noPaintOnScreen : 1; // see qwidget_win.cpp ::paintEngine()
uint nativeGesturePanEnabled : 1;
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