diff --git a/src/core/lockscreen.cpp b/src/core/lockscreen.cpp index cfb75b0ff..c6291ea29 100644 --- a/src/core/lockscreen.cpp +++ b/src/core/lockscreen.cpp @@ -12,6 +12,10 @@ #include +#include + +#include + #ifdef EXT_SESSION_LOCK_V1 #include "rootsurfacecontainer.h" #include "surfacewrapper.h" @@ -100,6 +104,11 @@ void LockScreen::addOutput(Output *output) SurfaceContainer::addOutput(output); auto outputItem = output->outputItem(); connect(outputItem, &WOutputItem::geometryChanged, this, &LockScreen::repositionLoginView); + connect(output->output(), + &WOutput::enabledChanged, + this, + &LockScreen::onOutputEnabledChanged, + Qt::UniqueConnection); #if EXT_SESSION_LOCK_V1 connect(outputItem, &WOutputItem::geometryChanged, this, &LockScreen::onOutputGeometryChanged); @@ -117,6 +126,8 @@ void LockScreen::addOutput(Output *output) { output, std::unique_ptr(item, [](QQuickItem *item) { item->deleteLater(); }) }); + + repositionLoginView(); } bool LockScreen::isLocked() const @@ -131,6 +142,7 @@ void LockScreen::removeOutput(Output *output) SurfaceContainer::removeOutput(output); auto outputItem = output->outputItem(); disconnect(outputItem, &WOutputItem::geometryChanged, this, &LockScreen::repositionLoginView); + disconnect(output->output(), &WOutput::enabledChanged, this, &LockScreen::onOutputEnabledChanged); #if EXT_SESSION_LOCK_V1 disconnect(outputItem, @@ -238,9 +250,30 @@ void LockScreen::repositionLoginView() void LockScreen::onCursorPositionChanged() { - if (m_loginView) { - repositionLoginView(); + if (!m_loginView) { + if (isVisible()) { + createLoginView(); + } + return; } + repositionLoginView(); +} + +void LockScreen::onOutputEnabledChanged() +{ + auto *woutput = qobject_cast(sender()); + if (!woutput || !woutput->isEnabled()) { + return; + } + + if (!isVisible()) { + return; + } + + QTimer::singleShot(0, this, [this]() { + destroyLoginView(); + createLoginView(); + }); } #if EXT_SESSION_LOCK_V1 // ext_session_lock_v1 capabilities diff --git a/src/core/lockscreen.h b/src/core/lockscreen.h index 458989b49..f8839b8ce 100644 --- a/src/core/lockscreen.h +++ b/src/core/lockscreen.h @@ -74,6 +74,7 @@ private Q_SLOTS: void createLoginView(); void destroyLoginView(); void repositionLoginView(); + void onOutputEnabledChanged(); void onCursorPositionChanged(); Output *followerOutput() const; @@ -86,5 +87,5 @@ private Q_SLOTS: std::map>> m_fallbackItems; WSessionLock* m_sessionLock{ nullptr }; #endif - QQuickItem *m_loginView{ nullptr }; + QPointer m_loginView; };