summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenneth Rohde Christiansen <kenneth.christiansen@openbossa.org>2009-04-30 07:59:04 (GMT)
committerSimon Hausmann <simon.hausmann@nokia.com>2009-05-06 12:40:08 (GMT)
commit2dc5bf5c17f5b07e1387796977c69d3354acfd06 (patch)
treec6447725c0c23481e5652a3d952a1a6a113eeecb
parent8cd19116ae81c99fe28fbf91aa7f4c1c08163fe0 (diff)
downloadQt-2dc5bf5c17f5b07e1387796977c69d3354acfd06.zip
Qt-2dc5bf5c17f5b07e1387796977c69d3354acfd06.tar.gz
Qt-2dc5bf5c17f5b07e1387796977c69d3354acfd06.tar.bz2
Fix focus issues in QX11EmbedContainer, affecting Flash plugin in QtWebKit.
We are now moving focus to the XEmbed focus proxy when we accept a client and when we get window activation. Window activation did that before, but only when we were the active container, thus had focus in. Now we do it always. Due to race conditions with the window manager, the time stamt we used for XSetInputFocus was the same as that of the window manager. This broke it from time to time in Metacity and Xfce but always in KWin. With other tested window manager we didn't have this issue. Following Owen Tayler's advice (one of the authors of the XEmbed specification) we now use CurrentTime and not qt_x11Data->time when moving the input focus as there is no explicit user interaction involved. Reviewed-by: Denis Dzyubenko <denis.dzyubenko@nokia.com> Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
-rw-r--r--src/gui/kernel/qx11embed_x11.cpp19
1 files changed, 8 insertions, 11 deletions
diff --git a/src/gui/kernel/qx11embed_x11.cpp b/src/gui/kernel/qx11embed_x11.cpp
index 6329135..ae93efe 100644
--- a/src/gui/kernel/qx11embed_x11.cpp
+++ b/src/gui/kernel/qx11embed_x11.cpp
@@ -1297,9 +1297,6 @@ bool QX11EmbedContainer::eventFilter(QObject *o, QEvent *event)
// focus is set to our focus proxy. We want to intercept all
// keypresses.
if (o == window() && d->client) {
- if (!d->isEmbedded() && d->activeContainer == this)
- d->moveInputToProxy();
-
if (d->clientIsXEmbed) {
sendXEmbedMessage(d->client, x11Info().display(), XEMBED_WINDOW_ACTIVATE);
} else {
@@ -1307,6 +1304,8 @@ bool QX11EmbedContainer::eventFilter(QObject *o, QEvent *event)
if (hasFocus())
XSetInputFocus(x11Info().display(), d->client, XRevertToParent, x11Time());
}
+ if (!d->isEmbedded())
+ d->moveInputToProxy();
}
break;
case QEvent::WindowDeactivate:
@@ -1729,10 +1728,10 @@ void QX11EmbedContainerPrivate::acceptClient(WId window)
checkGrab();
if (q->hasFocus()) {
XSetInputFocus(q->x11Info().display(), client, XRevertToParent, x11Time());
- } else {
- if (!isEmbedded())
- moveInputToProxy();
}
+ } else {
+ if (!isEmbedded())
+ moveInputToProxy();
}
emit q->clientIsEmbedded();
@@ -1749,11 +1748,9 @@ void QX11EmbedContainerPrivate::acceptClient(WId window)
void QX11EmbedContainerPrivate::moveInputToProxy()
{
Q_Q(QX11EmbedContainer);
- WId focus;
- int revert_to;
- XGetInputFocus(q->x11Info().display(), &focus, &revert_to);
- if (focus != focusProxy->internalWinId())
- XSetInputFocus(q->x11Info().display(), focusProxy->internalWinId(), XRevertToParent, x11Time());
+ // Following Owen Taylor's advice from the XEmbed specification to
+ // always use CurrentTime when no explicit user action is involved.
+ XSetInputFocus(q->x11Info().display(), focusProxy->internalWinId(), XRevertToParent, CurrentTime);
}
/*! \internal