Fix QDockWidget being unable to dock when initially floating.

When setFloating(true) is called before show, frame strut events
are not enabled for the native window (since there is none yet)
in QDockWidgetPrivate::setWindowState(). In that case, do
it in the show event handling.

Task-number: QTBUG-29012
Change-Id: I93b679f20200c149d608a1bcc65b4936a035c6a0
Reviewed-by: J-P Nurmi <jpnurmi@digia.com>
This commit is contained in:
Friedemann Kleint 2013-02-18 15:19:41 +01:00 committed by The Qt Project
parent 2f5b4d47f6
commit dd30f3e65b

View File

@ -1000,6 +1000,14 @@ void QDockWidgetPrivate::plug(const QRect &rect)
setWindowState(false, false, rect);
}
static void setFrameStrutEventsEnabled(const QWidget *w, bool enabled)
{
if (const QWindow *window = w->windowHandle())
if (QPlatformWindow *platformWindow = window->handle())
if (platformWindow->frameStrutEventsEnabled() != enabled)
platformWindow->setFrameStrutEventsEnabled(enabled);
}
void QDockWidgetPrivate::setWindowState(bool floating, bool unplug, const QRect &rect)
{
Q_Q(QDockWidget);
@ -1053,9 +1061,7 @@ void QDockWidgetPrivate::setWindowState(bool floating, bool unplug, const QRect
}
if (floating && nativeDeco)
if (const QWindow *window = q->windowHandle())
if (QPlatformWindow *platformWindow = window->handle())
platformWindow->setFrameStrutEventsEnabled(true);
setFrameStrutEventsEnabled(q, true);
resizer->setActive(QWidgetResizeHandler::Resize, !unplug && floating && !nativeDeco);
}
@ -1391,6 +1397,8 @@ bool QDockWidget::event(QEvent *event)
emit visibilityChanged(false);
break;
case QEvent::Show:
if (static_cast<QDockWidgetLayout *>(QDockWidget::layout())->nativeWindowDeco(isFloating()))
setFrameStrutEventsEnabled(this, true);
d->toggleViewAction->setChecked(true);
emit visibilityChanged(geometry().right() >= 0 && geometry().bottom() >= 0);
break;