fix focusOut behavior for config windows

pull/5/head
Michail Vourlakos 6 years ago
parent 366f2783f2
commit 3ac5ebffeb

@ -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();
}
}

@ -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<PrimaryConfigView *>(m_parent);
if (parent && !parent->sticker() && !parent->isActive()) {
if (!m_latteView->containsMouse() && parent && !parent->sticker() && !parent->isActive()) {
parent->hideConfigWindow();
}
}

@ -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<ViewPart::PrimaryConfigView *>(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;

@ -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};

Loading…
Cancel
Save