Skip to content

Commit 07d0bdc

Browse files
Improved CAutoHideDockContainer::eventFilter function to collapse the auto hide widget if someone clicks into another window
1 parent 5caa5db commit 07d0bdc

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

src/AutoHideDockContainer.cpp

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -482,23 +482,24 @@ bool CAutoHideDockContainer::eventFilter(QObject* watched, QEvent* event)
482482
}
483483
else if (event->type() == QEvent::MouseButtonPress)
484484
{
485-
auto Container = dockContainer();
486-
// First we check, if the mouse button press is inside the container
487-
// widget. If it is not, i.e. if someone resizes the main window or
488-
// clicks into the application menu or toolbar, then we ignore the
489-
// event
485+
// If the user clicked into another window, then we collapse the
486+
// auto hide widget
490487
auto widget = qobject_cast<QWidget*>(watched);
491-
bool IsContainer = false;
492-
while (widget)
488+
if (widget && widget->window() != this->window())
493489
{
494-
if (widget == Container)
495-
{
496-
IsContainer = true;
497-
}
498-
widget = widget->parentWidget();
490+
collapseView(true);
491+
return Super::eventFilter(watched, event);
499492
}
500493

501-
if (!IsContainer)
494+
// We check, if the mouse button press is inside the container
495+
// widget. If it is not, i.e. if someone resizes the main window or
496+
// clicks into the application menu or toolbar, then we ignore the
497+
// event
498+
auto Container = dockContainer();
499+
QMouseEvent* me = static_cast<QMouseEvent*>(event);
500+
auto GlobalPos = internal::globalPositionOf(me);
501+
auto pos = Container->mapFromGlobal(GlobalPos);
502+
if (!Container->rect().contains(pos))
502503
{
503504
return Super::eventFilter(watched, event);
504505
}
@@ -507,9 +508,7 @@ bool CAutoHideDockContainer::eventFilter(QObject* watched, QEvent* event)
507508
// If the click is inside of this auto hide container, then we can also
508509
// ignore the event, because the auto hide overlay should not get collapsed if
509510
// user works in it
510-
QMouseEvent* me = static_cast<QMouseEvent*>(event);
511-
auto GlobalPos = internal::globalPositionOf(me);
512-
auto pos = mapFromGlobal(GlobalPos);
511+
pos = mapFromGlobal(GlobalPos);
513512
if (rect().contains(pos))
514513
{
515514
return Super::eventFilter(watched, event);

0 commit comments

Comments
 (0)