@@ -482,23 +482,24 @@ bool CAutoHideDockContainer::eventFilter(QObject* watched, QEvent* event)
482
482
}
483
483
else if (event->type () == QEvent::MouseButtonPress)
484
484
{
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
490
487
auto widget = qobject_cast<QWidget*>(watched);
491
- bool IsContainer = false ;
492
- while (widget)
488
+ if (widget && widget->window () != this ->window ())
493
489
{
494
- if (widget == Container)
495
- {
496
- IsContainer = true ;
497
- }
498
- widget = widget->parentWidget ();
490
+ collapseView (true );
491
+ return Super::eventFilter (watched, event);
499
492
}
500
493
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))
502
503
{
503
504
return Super::eventFilter (watched, event);
504
505
}
@@ -507,9 +508,7 @@ bool CAutoHideDockContainer::eventFilter(QObject* watched, QEvent* event)
507
508
// If the click is inside of this auto hide container, then we can also
508
509
// ignore the event, because the auto hide overlay should not get collapsed if
509
510
// 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);
513
512
if (rect ().contains (pos))
514
513
{
515
514
return Super::eventFilter (watched, event);
0 commit comments