summaryrefslogtreecommitdiffstats
path: root/src/widgets/kernel/qwidget.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets/kernel/qwidget.cpp')
-rw-r--r--src/widgets/kernel/qwidget.cpp32
1 files changed, 26 insertions, 6 deletions
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index db08a1d04f..02a1980e09 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -910,6 +910,8 @@ void QWidget::setAutoFillBackground(bool enabled)
and a compositing window manager.
\li Windows: The widget needs to have the Qt::FramelessWindowHint window flag set
for the translucency to work.
+ \li \macos: The widget needs to have the Qt::FramelessWindowHint window flag set
+ for the translucency to work.
\endlist
@@ -6715,6 +6717,9 @@ void QWidget::clearFocus()
QApplication::sendEvent(this, &focusAboutToChange);
}
+ QTLWExtra *extra = window()->d_func()->maybeTopData();
+ QObject *originalFocusObject = (extra && extra->window) ? extra->window->focusObject() : nullptr;
+
QWidget *w = this;
while (w) {
// Just like setFocus(), we update (clear) the focus_child of our parents
@@ -6723,14 +6728,12 @@ void QWidget::clearFocus()
w = w->parentWidget();
}
- // Since we've unconditionally cleared the focus_child of our parents, we need
+ // We've potentially cleared the focus_child of our parents, so we need
// to report this to the rest of Qt. Note that the focus_child is not the same
// thing as the application's focusWidget, which is why this piece of code is
- // not inside the hasFocus() block below.
- if (QTLWExtra *extra = window()->d_func()->maybeTopData()) {
- if (extra->window)
- emit extra->window->focusObjectChanged(extra->window->focusObject());
- }
+ // not inside a hasFocus() block.
+ if (originalFocusObject && originalFocusObject != extra->window->focusObject())
+ emit extra->window->focusObjectChanged(extra->window->focusObject());
#if QT_CONFIG(graphicsview)
QWExtra *topData = d_func()->extra;
@@ -8934,6 +8937,23 @@ bool QWidget::event(QEvent *event)
}
}
switch (event->type()) {
+ case QEvent::PlatformSurface: {
+ // Sync up QWidget's view of whether or not the widget has been created
+ switch (static_cast<QPlatformSurfaceEvent*>(event)->surfaceEventType()) {
+ case QPlatformSurfaceEvent::SurfaceCreated:
+ if (!testAttribute(Qt::WA_WState_Created))
+ create();
+ break;
+ case QPlatformSurfaceEvent::SurfaceAboutToBeDestroyed:
+ if (testAttribute(Qt::WA_WState_Created)) {
+ // Child windows have already been destroyed by QWindow,
+ // so we skip them here.
+ destroy(false, false);
+ }
+ break;
+ }
+ break;
+ }
case QEvent::MouseMove:
mouseMoveEvent((QMouseEvent*)event);
break;