Skip to content

Commit

Permalink
lockscreenmanager: always listen to the session provider's lock signal (
Browse files Browse the repository at this point in the history
#79)

Previously, it only listened if "Lock screen before suspending" was
enabled.
  • Loading branch information
paulolieuthier authored Sep 23, 2016
1 parent 75169e6 commit 8a1c915
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 27 deletions.
39 changes: 22 additions & 17 deletions lxqt-session/src/lockscreenmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,8 @@ LockScreenManager::~LockScreenManager()
delete mProvider;
}

bool LockScreenManager::startup()
bool LockScreenManager::startup(bool lockBeforeSleep)
{
connect(&mScreenSaver, &LXQt::ScreenSaver::done,
&mLoop, &QEventLoop::quit);

mProvider = new LogindProvider;
if (!mProvider->isValid())
{
Expand All @@ -59,12 +56,25 @@ bool LockScreenManager::startup()
}
}

if (mProvider)
if (!mProvider)
{
qCDebug(SESSION) << "LockScreenManager:"
<< mProvider->metaObject()->className()
<< "will be used";
qCDebug(SESSION) << "LockScreenManager: no valid provider";
return false;
}

qCDebug(SESSION) << "LockScreenManager:"
<< mProvider->metaObject()->className()
<< "will be used";

connect(&mScreenSaver, &LXQt::ScreenSaver::done, &mLoop, &QEventLoop::quit);

connect(mProvider, &LockScreenProvider::lockRequested, [this] {
mScreenSaver.lockScreen();
mLoop.exec();
});

if (lockBeforeSleep)
{
connect(mProvider,
&LockScreenProvider::aboutToSleep,
[this] (bool beforeSleep)
Expand All @@ -81,17 +91,12 @@ bool LockScreenManager::startup()
mProvider->inhibit();
});

connect(mProvider, &LockScreenProvider::lockRequested, [this] {
mScreenSaver.lockScreen();
mLoop.exec();
});

return mProvider->inhibit();
if (!mProvider->inhibit())
qCDebug(SESSION) << "LockScreenManager:"
<< "could not inhibit session provider";
}
else
qCDebug(SESSION) << "LockScreenManager: no valid provider";

return false;
return true;
}

/*
Expand Down
2 changes: 1 addition & 1 deletion lxqt-session/src/lockscreenmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class LockScreenManager : public QObject
explicit LockScreenManager(QObject *parent = nullptr);
virtual ~LockScreenManager();

bool startup();
bool startup(bool lockBeforeSleep);

private:
LockScreenProvider *mProvider;
Expand Down
16 changes: 7 additions & 9 deletions lxqt-session/src/sessionapplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
#include <X11/XKBlib.h>

SessionApplication::SessionApplication(int& argc, char** argv) :
LXQt::Application(argc, argv)
LXQt::Application(argc, argv),
lockScreenManager(new LockScreenManager(this))
{
listenToUnixSignals({SIGINT, SIGTERM, SIGQUIT, SIGHUP});
char* winmanager = NULL;
Expand Down Expand Up @@ -104,14 +105,11 @@ bool SessionApplication::startup()
});
#endif

if (settings.value(QLatin1String("lock_screen_before_power_actions")).toBool())
{
lockScreenManager = new LockScreenManager(this);
if (lockScreenManager->startup())
qCDebug(SESSION) << "LockScreenManager started successfully";
else
qCWarning(SESSION) << "LockScreenManager couldn't start";
}
bool lockBeforeSleep = settings.value(QLatin1String("lock_screen_before_power_actions"), true).toBool();
if (lockScreenManager->startup(lockBeforeSleep))
qCDebug(SESSION) << "LockScreenManager started successfully";
else
qCWarning(SESSION) << "LockScreenManager couldn't start";

// launch module manager and autostart apps
modman->startup(settings);
Expand Down

0 comments on commit 8a1c915

Please sign in to comment.