From 3ac5ebffebecb45c3836737068c7237d614a2d85 Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Fri, 8 Mar 2019 16:14:34 +0200 Subject: [PATCH] fix focusOut behavior for config windows --- app/view/settings/primaryconfigview.cpp | 3 ++- app/view/settings/secondaryconfigview.cpp | 12 +----------- app/view/view.cpp | 14 +++++++++----- app/view/view.h | 3 +++ 4 files changed, 15 insertions(+), 17 deletions(-) diff --git a/app/view/settings/primaryconfigview.cpp b/app/view/settings/primaryconfigview.cpp index e792fb25d..6f6ec1abb 100644 --- a/app/view/settings/primaryconfigview.cpp +++ b/app/view/settings/primaryconfigview.cpp @@ -347,7 +347,8 @@ void PrimaryConfigView::focusOutEvent(QFocusEvent *ev) return; } - if (!m_blockFocusLost && (!m_secConfigView || (m_secConfigView && !m_secConfigView->isActive()))) { + if (!m_blockFocusLost && !m_latteView->containsMouse() + && (!m_secConfigView || (m_secConfigView && !m_secConfigView->isActive()))) { hideConfigWindow(); } } diff --git a/app/view/settings/secondaryconfigview.cpp b/app/view/settings/secondaryconfigview.cpp index db965cc2d..5e625e447 100644 --- a/app/view/settings/secondaryconfigview.cpp +++ b/app/view/settings/secondaryconfigview.cpp @@ -65,16 +65,6 @@ SecondaryConfigView::SecondaryConfigView(Latte::View *view, QWindow *parent) m_screenSyncTimer.setSingleShot(true); m_screenSyncTimer.setInterval(100); - connect(this, &QQuickView::activeChanged, this, [this]() { - if (isActive() && m_parent) { - //! forward activation to primary config window - //! look at view::cpp -> QEvent::Enter event - //! in order for config windows to become on top - //! properly when the mouse enters the parent view - m_parent->requestActivate(); - } - }); - connections << connect(&m_screenSyncTimer, &QTimer::timeout, this, [this]() { setScreen(m_latteView->screen()); setFlags(wFlags()); @@ -293,7 +283,7 @@ void SecondaryConfigView::focusOutEvent(QFocusEvent *ev) const auto parent = qobject_cast(m_parent); - if (parent && !parent->sticker() && !parent->isActive()) { + if (!m_latteView->containsMouse() && parent && !parent->sticker() && !parent->isActive()) { parent->hideConfigWindow(); } } diff --git a/app/view/view.cpp b/app/view/view.cpp index 1ffd8cd4a..9ae6e66e6 100644 --- a/app/view/view.cpp +++ b/app/view/view.cpp @@ -466,6 +466,11 @@ void View::setAlternativesIsShown(bool show) emit alternativesIsShownChanged(); } +bool View::containsMouse() const +{ + return m_containsMouse; +} + bool View::contextMenuIsShown() const { if (!m_contextMenu) { @@ -960,23 +965,22 @@ bool View::event(QEvent *e) switch (e->type()) { case QEvent::Enter: + m_containsMouse = true; if (m_configView && containment()->isUserConfiguring() ) { ViewPart::PrimaryConfigView *configView = qobject_cast(m_configView); if (configView) { + configView->requestActivate(); + if (configView->secondaryWindow()) { - //! avoid focus-out race between secondary and primary config windows - //! when the secondary window becomes active it will activate - //! the primary config window configView->secondaryWindow()->requestActivate(); - } else { - configView->requestActivate(); } } } break; case QEvent::Leave: + m_containsMouse = false; engine()->trimComponentCache(); break; diff --git a/app/view/view.h b/app/view/view.h index bd75ffb8f..6dd489456 100644 --- a/app/view/view.h +++ b/app/view/view.h @@ -127,6 +127,8 @@ public: bool behaveAsPlasmaPanel() const; void setBehaveAsPlasmaPanel(bool behavior); + bool containsMouse() const; + bool contextMenuIsShown() const; bool byPassWM() const; @@ -271,6 +273,7 @@ private: bool m_alternativesIsShown{false}; bool m_behaveAsPlasmaPanel{false}; bool m_byPassWM{true}; + bool m_containsMouse{false}; bool m_inDelete{false}; bool m_inEditMode{false}; bool m_isPreferredForShortcuts{false};