From 26b572903a800163972817cd717b5df454b96eb2 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Wed, 24 Mar 2010 11:36:40 +0100 Subject: Do not move keyboard focus to invisible windows on X11. When QWidget::activateWindow() is called we check if the window was already mapped and just do not do anything if it wasn't. We used to try to active it by giving it keyboard focus, but that always fails because it isn't allowed to call XSetInputFocus on invisible windows, and the error message was swalled by Qt in the error handler. So now we just don't bother even trying if we know the call will fail. Task-number: QTBUG-4042 Reviewed-by: Benjamin Poulain Reviewed-by: Bradley T. Hughes --- src/gui/kernel/qapplication_x11.cpp | 5 ----- src/gui/kernel/qwidget_x11.cpp | 3 ++- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/gui/kernel/qapplication_x11.cpp b/src/gui/kernel/qapplication_x11.cpp index 67e0865..78fc704 100644 --- a/src/gui/kernel/qapplication_x11.cpp +++ b/src/gui/kernel/qapplication_x11.cpp @@ -669,11 +669,6 @@ static int qt_x_errhandler(Display *dpy, XErrorEvent *err) return 0; break; - case BadMatch: - if (err->request_code == 42 /* X_SetInputFocus */) - return 0; - break; - default: #if !defined(QT_NO_XINPUT) if (err->request_code == X11->xinput_major diff --git a/src/gui/kernel/qwidget_x11.cpp b/src/gui/kernel/qwidget_x11.cpp index 457e92c..37ac6bf 100644 --- a/src/gui/kernel/qwidget_x11.cpp +++ b/src/gui/kernel/qwidget_x11.cpp @@ -1661,7 +1661,8 @@ void QWidget::activateWindow() XSendEvent(X11->display, RootWindow(X11->display, tlw->x11Info().screen()), false, SubstructureNotifyMask | SubstructureRedirectMask, &e); } else { - XSetInputFocus(X11->display, tlw->internalWinId(), XRevertToParent, X11->time); + if (!qt_widget_private(tlw)->topData()->waitingForMapNotify) + XSetInputFocus(X11->display, tlw->internalWinId(), XRevertToParent, X11->time); } } } -- cgit v0.12