Changeset View
Changeset View
Standalone View
Standalone View
ksldapp.cpp
Show All 22 Lines | |||||
23 | #include "ksldapp.h" | 23 | #include "ksldapp.h" | ||
24 | #include "interface.h" | 24 | #include "interface.h" | ||
25 | #include "globalaccel.h" | 25 | #include "globalaccel.h" | ||
26 | #include "x11locker.h" | 26 | #include "x11locker.h" | ||
27 | #include "waylandlocker.h" | 27 | #include "waylandlocker.h" | ||
28 | #include "logind.h" | 28 | #include "logind.h" | ||
29 | #include "kscreensaversettings.h" | 29 | #include "kscreensaversettings.h" | ||
30 | #include "powermanagement_inhibition.h" | 30 | #include "powermanagement_inhibition.h" | ||
31 | | ||||
32 | #include "kscreenlocker_logging.h" | ||||
31 | #include <config-kscreenlocker.h> | 33 | #include <config-kscreenlocker.h> | ||
34 | | ||||
32 | #include <config-X11.h> | 35 | #include <config-X11.h> | ||
33 | #include "waylandserver.h" | 36 | #include "waylandserver.h" | ||
34 | // KDE | 37 | // KDE | ||
35 | #include <KAuthorized> | 38 | #include <KAuthorized> | ||
36 | #include <KIdleTime> | 39 | #include <KIdleTime> | ||
37 | #include <KLocalizedString> | 40 | #include <KLocalizedString> | ||
38 | #include <KNotification> | 41 | #include <KNotification> | ||
39 | #include <KGlobalAccel> | 42 | #include <KGlobalAccel> | ||
▲ Show 20 Lines • Show All 118 Lines • ▼ Show 20 Line(s) | |||||
158 | void KSldApp::initialize() | 161 | void KSldApp::initialize() | ||
159 | { | 162 | { | ||
160 | if (m_isX11) { | 163 | if (m_isX11) { | ||
161 | initializeX11(); | 164 | initializeX11(); | ||
162 | } | 165 | } | ||
163 | 166 | | |||
164 | // Global keys | 167 | // Global keys | ||
165 | if (KAuthorized::authorizeAction(QStringLiteral("lock_screen"))) { | 168 | if (KAuthorized::authorizeAction(QStringLiteral("lock_screen"))) { | ||
166 | qDebug() << "Configuring Lock Action"; | 169 | qCDebug(KSCREENLOCKER) << "Configuring Lock Action"; | ||
167 | QAction *a = new QAction(this); | 170 | QAction *a = new QAction(this); | ||
168 | a->setObjectName(QStringLiteral("Lock Session")); | 171 | a->setObjectName(QStringLiteral("Lock Session")); | ||
169 | a->setProperty("componentName", QStringLiteral("ksmserver")); | 172 | a->setProperty("componentName", QStringLiteral("ksmserver")); | ||
170 | a->setText(i18n("Lock Session")); | 173 | a->setText(i18n("Lock Session")); | ||
171 | KGlobalAccel::self()->setGlobalShortcut(a, KScreenSaverSettings::defaultShortcuts()); | 174 | KGlobalAccel::self()->setGlobalShortcut(a, KScreenSaverSettings::defaultShortcuts()); | ||
172 | connect(a, &QAction::triggered, this, | 175 | connect(a, &QAction::triggered, this, | ||
173 | [this]() { | 176 | [this]() { | ||
174 | lock(EstablishLock::Immediate); | 177 | lock(EstablishLock::Immediate); | ||
Show All 28 Lines | |||||
203 | ); | 206 | ); | ||
204 | 207 | | |||
205 | m_lockProcess = new QProcess(); | 208 | m_lockProcess = new QProcess(); | ||
206 | m_lockProcess->setProcessChannelMode(QProcess::ForwardedErrorChannel); | 209 | m_lockProcess->setProcessChannelMode(QProcess::ForwardedErrorChannel); | ||
207 | m_lockProcess->setReadChannel(QProcess::StandardOutput); | 210 | m_lockProcess->setReadChannel(QProcess::StandardOutput); | ||
208 | auto finishedSignal = static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished); | 211 | auto finishedSignal = static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished); | ||
209 | connect(m_lockProcess, finishedSignal, this, | 212 | connect(m_lockProcess, finishedSignal, this, | ||
210 | [this](int exitCode, QProcess::ExitStatus exitStatus) { | 213 | [this](int exitCode, QProcess::ExitStatus exitStatus) { | ||
211 | qDebug() << "Greeter process exitted with status:" | 214 | qCDebug(KSCREENLOCKER) << "Greeter process exitted with status:" | ||
212 | << exitStatus << "exit code:" << exitCode; | 215 | << exitStatus << "exit code:" << exitCode; | ||
213 | 216 | | |||
214 | const bool regularExit = !exitCode && exitStatus == QProcess::NormalExit; | 217 | const bool regularExit = !exitCode && exitStatus == QProcess::NormalExit; | ||
215 | if (regularExit || s_graceTimeKill || s_logindExit) { | 218 | if (regularExit || s_graceTimeKill || s_logindExit) { | ||
216 | // unlock process finished successfully - we can remove the lock grab | 219 | // unlock process finished successfully - we can remove the lock grab | ||
217 | 220 | | |||
218 | if (regularExit) { | 221 | if (regularExit) { | ||
219 | qDebug() << "Unlocking now on regular exit."; | 222 | qCDebug(KSCREENLOCKER) << "Unlocking now on regular exit."; | ||
220 | } else if (s_graceTimeKill) { | 223 | } else if (s_graceTimeKill) { | ||
221 | qDebug() << "Unlocking anyway due to grace time."; | 224 | qCDebug(KSCREENLOCKER) << "Unlocking anyway due to grace time."; | ||
222 | } else { | 225 | } else { | ||
223 | Q_ASSERT(s_logindExit); | 226 | Q_ASSERT(s_logindExit); | ||
224 | qDebug() << "Unlocking anyway since forced through logind."; | 227 | qCDebug(KSCREENLOCKER) << "Unlocking anyway since forced through logind."; | ||
225 | } | 228 | } | ||
226 | 229 | | |||
227 | s_graceTimeKill = false; | 230 | s_graceTimeKill = false; | ||
228 | s_logindExit = false; | 231 | s_logindExit = false; | ||
229 | doUnlock(); | 232 | doUnlock(); | ||
230 | return; | 233 | return; | ||
231 | } | 234 | } | ||
232 | 235 | | |||
233 | qWarning() << "Greeter process exit unregular. Restarting lock."; | 236 | qCWarning(KSCREENLOCKER) << "Greeter process exit unregular. Restarting lock."; | ||
234 | 237 | | |||
235 | m_greeterCrashedCounter++; | 238 | m_greeterCrashedCounter++; | ||
236 | if (m_greeterCrashedCounter < 4) { | 239 | if (m_greeterCrashedCounter < 4) { | ||
237 | // Perhaps it crashed due to a graphics driver issue, force software rendering now | 240 | // Perhaps it crashed due to a graphics driver issue, force software rendering now | ||
238 | qDebug("Trying to lock again with software rendering (%d/4).", | 241 | qCDebug(KSCREENLOCKER, "Trying to lock again with software rendering (%d/4).", | ||
239 | m_greeterCrashedCounter); | 242 | m_greeterCrashedCounter); | ||
240 | setForceSoftwareRendering(true); | 243 | setForceSoftwareRendering(true); | ||
241 | startLockProcess(EstablishLock::Immediate); | 244 | startLockProcess(EstablishLock::Immediate); | ||
242 | } else if (m_lockWindow) { | 245 | } else if (m_lockWindow) { | ||
243 | qWarning("Everything else failed. Need to put Greeter in emergency mode."); | 246 | qCWarning(KSCREENLOCKER) | ||
247 | << "Everything else failed. Need to put Greeter in emergency mode."; | ||||
244 | m_lockWindow->emergencyShow(); | 248 | m_lockWindow->emergencyShow(); | ||
245 | } else { | 249 | } else { | ||
246 | qCritical("Greeter process exitted and we could in no way recover from that!"); | 250 | qCCritical(KSCREENLOCKER) | ||
251 | << "Greeter process exitted and we could in no way recover from that!"; | ||||
247 | } | 252 | } | ||
248 | } | 253 | } | ||
249 | ); | 254 | ); | ||
250 | connect(m_lockProcess, &QProcess::errorOccurred, this, | 255 | connect(m_lockProcess, &QProcess::errorOccurred, this, | ||
251 | [this](QProcess::ProcessError error) { | 256 | [this](QProcess::ProcessError error) { | ||
252 | if (error == QProcess::FailedToStart) { | 257 | if (error == QProcess::FailedToStart) { | ||
253 | qDebug() << "Greeter Process failed to start. Trying to directly unlock again."; | 258 | qCDebug(KSCREENLOCKER) << "Greeter Process failed to start. Trying to directly unlock again."; | ||
254 | doUnlock(); | 259 | doUnlock(); | ||
255 | m_waylandServer->stop(); | 260 | m_waylandServer->stop(); | ||
256 | qCritical() << "Greeter Process not available"; | 261 | qCCritical(KSCREENLOCKER) << "Greeter Process not available"; | ||
257 | } else { | 262 | } else { | ||
258 | qWarning() << "Greeter Process encountered an unhandled error:" << error; | 263 | qCWarning(KSCREENLOCKER) << "Greeter Process encountered an unhandled error:" << error; | ||
259 | } | 264 | } | ||
260 | } | 265 | } | ||
261 | ); | 266 | ); | ||
262 | m_lockedTimer.invalidate(); | 267 | m_lockedTimer.invalidate(); | ||
263 | m_graceTimer->setSingleShot(true); | 268 | m_graceTimer->setSingleShot(true); | ||
264 | connect(m_graceTimer, &QTimer::timeout, this, &KSldApp::endGraceTime); | 269 | connect(m_graceTimer, &QTimer::timeout, this, &KSldApp::endGraceTime); | ||
265 | // create our D-Bus interface | 270 | // create our D-Bus interface | ||
266 | new Interface(this); | 271 | new Interface(this); | ||
▲ Show 20 Lines • Show All 117 Lines • ▼ Show 20 Line(s) | 382 | if (lockState() != Unlocked) { | |||
384 | } | 389 | } | ||
385 | return; | 390 | return; | ||
386 | } | 391 | } | ||
387 | 392 | | |||
388 | if (attemptCount == 0) { | 393 | if (attemptCount == 0) { | ||
389 | emit aboutToLock(); | 394 | emit aboutToLock(); | ||
390 | } | 395 | } | ||
391 | 396 | | |||
392 | qDebug() << "lock called"; | 397 | qCDebug(KSCREENLOCKER) << "lock called"; | ||
393 | if (!establishGrab()) { | 398 | if (!establishGrab()) { | ||
394 | if (attemptCount < 3) { | 399 | if (attemptCount < 3) { | ||
395 | qWarning() << "Could not establish screen lock. Trying again in 10ms"; | 400 | qCWarning(KSCREENLOCKER) << "Could not establish screen lock. Trying again in 10ms"; | ||
396 | QTimer::singleShot(10, this, [=]() { | 401 | QTimer::singleShot(10, this, [=]() { | ||
397 | lock(establishLock, attemptCount+1); | 402 | lock(establishLock, attemptCount+1); | ||
398 | }); | 403 | }); | ||
399 | } else { | 404 | } else { | ||
400 | qCritical() << "Could not establish screen lock"; | 405 | qCCritical(KSCREENLOCKER) << "Could not establish screen lock"; | ||
401 | } | 406 | } | ||
402 | return; | 407 | return; | ||
403 | } | 408 | } | ||
404 | 409 | | |||
405 | KNotification::event(QStringLiteral("locked"), | 410 | KNotification::event(QStringLiteral("locked"), | ||
406 | i18n("Screen locked"), | 411 | i18n("Screen locked"), | ||
407 | QPixmap(), | 412 | QPixmap(), | ||
408 | nullptr, | 413 | nullptr, | ||
▲ Show 20 Lines • Show All 118 Lines • ▼ Show 20 Line(s) | 530 | int rv = XGrabPointer( QX11Info::display(), QX11Info::appRootWindow(), | |||
527 | None, CurrentTime ); | 532 | None, CurrentTime ); | ||
528 | #undef GRABEVENTS | 533 | #undef GRABEVENTS | ||
529 | 534 | | |||
530 | return (rv == GrabSuccess); | 535 | return (rv == GrabSuccess); | ||
531 | } | 536 | } | ||
532 | 537 | | |||
533 | void KSldApp::doUnlock() | 538 | void KSldApp::doUnlock() | ||
534 | { | 539 | { | ||
535 | qDebug() << "Grab Released"; | 540 | qCDebug(KSCREENLOCKER) << "Grab Released"; | ||
536 | if (m_isX11) { | 541 | if (m_isX11) { | ||
537 | xcb_connection_t *c = QX11Info::connection(); | 542 | xcb_connection_t *c = QX11Info::connection(); | ||
538 | xcb_ungrab_keyboard(c, XCB_CURRENT_TIME); | 543 | xcb_ungrab_keyboard(c, XCB_CURRENT_TIME); | ||
539 | xcb_ungrab_pointer(c, XCB_CURRENT_TIME); | 544 | xcb_ungrab_pointer(c, XCB_CURRENT_TIME); | ||
540 | xcb_flush(c); | 545 | xcb_flush(c); | ||
541 | #ifdef X11_Xinput_FOUND | 546 | #ifdef X11_Xinput_FOUND | ||
542 | if (m_hasXInput2) { | 547 | if (m_hasXInput2) { | ||
543 | // get all devices | 548 | // get all devices | ||
▲ Show 20 Lines • Show All 67 Lines • ▼ Show 20 Line(s) | 591 | { | |||
611 | } | 616 | } | ||
612 | if (m_forceSoftwareRendering) { | 617 | if (m_forceSoftwareRendering) { | ||
613 | env.insert(s_qtQuickBackend, QStringLiteral("software")); | 618 | env.insert(s_qtQuickBackend, QStringLiteral("software")); | ||
614 | } | 619 | } | ||
615 | 620 | | |||
616 | // start the Wayland server | 621 | // start the Wayland server | ||
617 | int fd = m_waylandServer->start(); | 622 | int fd = m_waylandServer->start(); | ||
618 | if (fd == -1) { | 623 | if (fd == -1) { | ||
619 | qWarning() << "Could not start the Wayland server."; | 624 | qCWarning(KSCREENLOCKER) << "Could not start the Wayland server."; | ||
620 | emit m_lockProcess->errorOccurred(QProcess::FailedToStart); | 625 | emit m_lockProcess->errorOccurred(QProcess::FailedToStart); | ||
621 | return; | 626 | return; | ||
622 | } | 627 | } | ||
623 | 628 | | |||
624 | args << QStringLiteral("--ksldfd"); | 629 | args << QStringLiteral("--ksldfd"); | ||
625 | args << QString::number(fd); | 630 | args << QString::number(fd); | ||
626 | 631 | | |||
627 | m_lockProcess->setProcessEnvironment(env); | 632 | m_lockProcess->setProcessEnvironment(env); | ||
▲ Show 20 Lines • Show All 139 Lines • Show Last 20 Lines |