Toggling visibility of floating docked windows protected against external hide/show cycle by QWebEngineView. (#821)
Co-authored-by: AlbertoM <ma-robox@users.noreply.github.com>
This commit is contained in:
@@ -370,13 +370,14 @@ struct FloatingDockContainerPrivate
|
||||
eDragState DraggingState = DraggingInactive;
|
||||
QPoint DragStartMousePosition;
|
||||
CDockContainerWidget *DropContainer = nullptr;
|
||||
CDockAreaWidget *SingleDockArea = nullptr;
|
||||
QPoint DragStartPos;
|
||||
bool Hiding = false;
|
||||
bool AutoHideChildren = true;
|
||||
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
|
||||
QWidget* MouseEventHandler = nullptr;
|
||||
CFloatingWidgetTitleBar* TitleBar = nullptr;
|
||||
CDockAreaWidget *SingleDockArea = nullptr;
|
||||
QPoint DragStartPos;
|
||||
bool Hiding = false;
|
||||
bool AutoHideChildren = true;
|
||||
bool HideContentOnNextHide = false;
|
||||
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
|
||||
QWidget* MouseEventHandler = nullptr;
|
||||
CFloatingWidgetTitleBar* TitleBar = nullptr;
|
||||
bool IsResizing = false;
|
||||
bool MousePressed = false;
|
||||
#endif
|
||||
@@ -927,11 +928,11 @@ bool CFloatingDockContainer::nativeEvent(const QByteArray &eventType, void *mess
|
||||
|
||||
|
||||
//============================================================================
|
||||
void CFloatingDockContainer::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
ADS_PRINT("CFloatingDockContainer closeEvent");
|
||||
d->setState(DraggingInactive);
|
||||
event->ignore();
|
||||
void CFloatingDockContainer::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
ADS_PRINT("CFloatingDockContainer closeEvent");
|
||||
d->setState(DraggingInactive);
|
||||
event->ignore();
|
||||
if (!isClosable())
|
||||
{
|
||||
return;
|
||||
@@ -959,37 +960,55 @@ void CFloatingDockContainer::closeEvent(QCloseEvent *event)
|
||||
return;
|
||||
}
|
||||
|
||||
// New bug (QWebEngineView reload side effect):
|
||||
// when a WebEngine-based dock is tabified into a floating container, the
|
||||
// embedded native/web process can trigger delayed hide/show cycles on the
|
||||
// floating window. If every non-spontaneous hide propagates to
|
||||
// DockWidget->toggleView(false), unrelated tabs are marked closed and seem
|
||||
// to "disappear". We therefore arm HideContentOnNextHide only for the
|
||||
// explicit close path.
|
||||
d->HideContentOnNextHide = true;
|
||||
|
||||
// In Qt version after 5.9.2 there seems to be a bug that causes the
|
||||
// QWidget::event() function to not receive any NonClientArea mouse
|
||||
// events anymore after a close/show cycle. The bug is reported here:
|
||||
// https://bugreports.qt.io/browse/QTBUG-73295
|
||||
// The following code is a workaround for Qt versions > 5.9.2 that seems
|
||||
// to work
|
||||
// Starting from Qt version 5.12.2 this seems to work again. But
|
||||
// now the QEvent::NonClientAreaMouseButtonPress function returns always
|
||||
// Qt::RightButton even if the left button was pressed
|
||||
this->hide();
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
void CFloatingDockContainer::hideEvent(QHideEvent *event)
|
||||
{
|
||||
Super::hideEvent(event);
|
||||
if (event->spontaneous())
|
||||
{
|
||||
return;
|
||||
}
|
||||
// Starting from Qt version 5.12.2 this seems to work again. But
|
||||
// now the QEvent::NonClientAreaMouseButtonPress function returns always
|
||||
// Qt::RightButton even if the left button was pressed
|
||||
this->hide();
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
void CFloatingDockContainer::hideEvent(QHideEvent *event)
|
||||
{
|
||||
Super::hideEvent(event);
|
||||
if (event->spontaneous())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Prevent toogleView() events during restore state
|
||||
if (d->DockManager->isRestoringState())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ( d->AutoHideChildren )
|
||||
{
|
||||
d->Hiding = true;
|
||||
for ( auto DockArea : d->DockContainer->openedDockAreas() )
|
||||
if (d->DockManager->isRestoringState())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Only a close operation should propagate hide->toggleView(false) to
|
||||
// child dock widgets. Generic hide/show cycles (e.g. from platform or
|
||||
// embedded native content) must not change dock open/closed state.
|
||||
if (!d->HideContentOnNextHide)
|
||||
{
|
||||
return;
|
||||
}
|
||||
d->HideContentOnNextHide = false;
|
||||
|
||||
if ( d->AutoHideChildren )
|
||||
{
|
||||
d->Hiding = true;
|
||||
for ( auto DockArea : d->DockContainer->openedDockAreas() )
|
||||
{
|
||||
for ( auto DockWidget : DockArea->openedDockWidgets() )
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user