Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 35 additions & 2 deletions src/core/lockscreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@
#include "common/treelandlogging.h"
#include "greeter/greeterproxy.h"

#include <woutputitem.h>

Check warning on line 13 in src/core/lockscreen.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <woutputitem.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.

#include <woutput.h>

Check warning on line 15 in src/core/lockscreen.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <woutput.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.

#include <QTimer>

Check warning on line 17 in src/core/lockscreen.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QTimer> not found. Please note: Cppcheck does not need standard library headers to get proper results.

#ifdef EXT_SESSION_LOCK_V1
#include "rootsurfacecontainer.h"
#include "surfacewrapper.h"

Check warning on line 21 in src/core/lockscreen.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "surfacewrapper.h" not found.

#include <wcursor.h>
#include <wsessionlock.h>
Expand Down Expand Up @@ -100,6 +104,11 @@
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);
Expand All @@ -117,6 +126,8 @@
{ output, std::unique_ptr<QQuickItem, void (*)(QQuickItem *)>(item, [](QQuickItem *item) {
item->deleteLater();
}) });

repositionLoginView();
}

bool LockScreen::isLocked() const
Expand All @@ -131,6 +142,7 @@
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,
Expand Down Expand Up @@ -238,9 +250,30 @@

void LockScreen::onCursorPositionChanged()
{
if (m_loginView) {
repositionLoginView();
if (!m_loginView) {
if (isVisible()) {
createLoginView();
}
return;
}
repositionLoginView();
}

void LockScreen::onOutputEnabledChanged()
{
auto *woutput = qobject_cast<WOutput *>(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
Expand Down
3 changes: 2 additions & 1 deletion src/core/lockscreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ private Q_SLOTS:
void createLoginView();
void destroyLoginView();
void repositionLoginView();
void onOutputEnabledChanged();
void onCursorPositionChanged();
Output *followerOutput() const;

Expand All @@ -86,5 +87,5 @@ private Q_SLOTS:
std::map<WOutputItem *, std::unique_ptr<QQuickItem, std::function<void(QQuickItem*)>>> m_fallbackItems;
WSessionLock* m_sessionLock{ nullptr };
#endif
QQuickItem *m_loginView{ nullptr };
QPointer<QQuickItem> m_loginView;
};
Loading