Skip to content
Merged
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
3 changes: 2 additions & 1 deletion debian/dde-session-shell.install
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ etc
usr/bin
usr/share/applications
usr/share/deepin-debug-config
usr/share/dsg
usr/share/dsg/configs/org.deepin.dde.lightdm-deepin-greeter/org.deepin.dde.lightdm-deepin-greeter.json
usr/share/dsg/configs/org.deepin.dde.lock/org.deepin.dde.lock.json
usr/share/glib-2.0
usr/share/xgreeters
usr/share/dbus-1
Expand Down
1,012 changes: 659 additions & 353 deletions docs/development-guide.md

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion src/app/dde-lock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,9 @@ int main(int argc, char *argv[])
});

DLogManager::setLogFormat("%{time}{yyyy-MM-dd, HH:mm:ss.zzz} [%{type:-7}] [ %{function:-35} %{line}] %{message}\n");
#ifdef QT_DEBUG
DLogManager::registerConsoleAppender();
DLogManager::registerFileAppender();
#endif
DLogManager::registerJournalAppender();

QCommandLineParser cmdParser;
Expand Down Expand Up @@ -203,6 +204,7 @@ int main(int argc, char *argv[])
QObject::connect(WarningContent::instance(), &WarningContent::requestLockFrameHide, [model] {
model->setVisible(false);
});
QObject::connect(LockContent::instance(), &LockContent::requestLockStateChange, worker, &LockWorker::setLocked);

auto createFrame = [&](QPointer<QScreen> screen, int count) -> QWidget* {
LockFrame *lockFrame = new LockFrame(model);
Expand Down
67 changes: 67 additions & 0 deletions src/app/greeter-display-setting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,65 @@
return maxScale;
}

static QStringList getScaleList()
{
qDebug() << "Get scale list";
Display *display = XOpenDisplay(nullptr);
if (!display) {
qWarning() << "Display is null";
return QStringList{};
}

XRRScreenResources *resources = XRRGetScreenResourcesCurrent(display, DefaultRootWindow(display));
if (!resources) {
resources = XRRGetScreenResources(display, DefaultRootWindow(display));
qCWarning(DDE_SHELL) << "Get current XRR screen resources failed, instead of getting XRR screen resources, resources: " << resources;
}

static const float MinScreenWidth = 1024.0f;
static const float MinScreenHeight = 768.0f;
static const QStringList tvstring = {"1.0", "1.25", "1.5", "1.75", "2.0", "2.25", "2.5", "2.75", "3.0"};
QStringList fscaleList;

if (resources) {
for (int i = 0; i < resources->noutput; i++) {
XRROutputInfo* outputInfo = XRRGetOutputInfo(display, resources, resources->outputs[i]);
if (outputInfo->crtc == 0 || outputInfo->mm_width == 0)
continue;

XRRCrtcInfo *crtInfo = XRRGetCrtcInfo(display, resources, outputInfo->crtc);

Check warning on line 137 in src/app/greeter-display-setting.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Variable 'crtInfo' can be declared as pointer to const
if (crtInfo == nullptr)
continue;

auto maxWScale = crtInfo->width / MinScreenWidth;
auto maxHScale = crtInfo->height / MinScreenHeight;
auto maxScale = maxWScale < maxHScale ? maxWScale : maxHScale;
maxScale = maxScale < 3.0f ? maxScale : 3.0f;
if (fscaleList.isEmpty()) {
for (int idx = 0; idx * 0.25f + 1.0f <= maxScale; ++idx) {
fscaleList << tvstring[idx];
}
qDebug() << "First screen scale list:" << fscaleList;
} else {
QStringList tmpList;
for (int idx = 0; idx * 0.25f + 1.0f <= maxScale; ++idx) {
tmpList << tvstring[idx];
}
qDebug() << "Current screen scale list:" << tmpList;
// fscaleList、tmpList两者取交集
for (const auto &scale : fscaleList) {
if (!tmpList.contains(scale))
fscaleList.removeAll(scale);
}
}
}
} else {
qCWarning(DDE_SHELL) << "Get scale factor failed, please check X11 Extension";
}

return fscaleList;
}

static double getScaleFactor() {
Display *display = XOpenDisplay(nullptr);
double scaleFactor = 0.0;
Expand Down Expand Up @@ -199,6 +258,14 @@
qDebug() << "Scale factor from system display config: " << scaleFactor;
if(scaleFactor == 0.0) {
scaleFactor = defaultScaleFactor;
} else {
// 处理关机期间从高分屏换到低分屏的场景
const auto &scales = getScaleList();
qDebug() << "Scales:" << scales;
if (!scales.isEmpty() && !scales.contains(QString::number(scaleFactor, 'f', 2).replace("00", "0"))) {
qInfo() << "Scale factor is not in scales, use default scale factor";
scaleFactor = defaultScaleFactor;
}
}
return scaleFactor;
} else {
Expand Down
174 changes: 99 additions & 75 deletions src/dde-lock/lockworker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,27 +190,39 @@ void LockWorker::initConnections()
const bool sleepLock = isSleepLock();
#endif
qCInfo(DDE_SHELL) << "Lock screen when system wakes up: " << sleepLock << ", is visible:" << m_model->visible();

FullScreenBackground::setContent(LockContent::instance());
m_model->setCurrentContentType(SessionBaseModel::LockContent);

if (isSleep) {
endAuthentication(m_account, AT_All);
destroyAuthentication(m_account);
checkSystemWakeupTimer->start();
doSuspendTime = QDateTime::currentDateTime();
} else {
// 非黑屏mode
m_model->setIsBlackMode(isSleep);

// 如果待机唤醒后需要密码则创建验证
if(m_login1SessionSelf->active() && sleepLock)
createAuthentication(m_model->currentUser()->name());
}
if (!m_model->visible() && sleepLock) {
m_model->setIsBlackMode(isSleep);
m_model->setVisible(true);
}
m_model->setIsBlackMode(true);
// 休眠时按需拉起锁屏,注意此时是被动响应休眠
if (sleepLock && m_login1SessionSelf->active()) {
// 仅sleepLock配置开启时执行
m_model->setCurrentModeState(SessionBaseModel::ModeStatus::PasswordMode);
setLocked(true);
m_model->setVisible(true);

if (!isSleep && !sleepLock) {
//待机唤醒后检查是否需要密码,若不需要密码直接隐藏锁定界面
m_model->setVisible(false);
qCInfo(DDE_SHELL) << "locked for sleepLock config";
}
} else {
SessionBaseModel::ModeStatus status = m_model->currentModeState();
if (isLocked() || (m_model->isNoPasswordLogin() && (status == SessionBaseModel::ModeStatus::PowerMode || status == SessionBaseModel::ModeStatus::PasswordMode))) {
// 唤醒时如果处于lock状态,重置认证
if (m_login1SessionSelf->active()) {
endAuthentication(m_account, AT_All);
destroyAuthentication(m_account);
createAuthentication(m_model->currentUser()->name());
}
} else {
// 处理其他流程设置的可见状态
m_model->setVisible(false);
}
// 避免在电源选项处理中设置密码模式,会导致唤醒后闪锁屏
m_model->setCurrentModeState(SessionBaseModel::ModeStatus::PasswordMode);
m_model->setIsBlackMode(false);
}
emit m_model->prepareForSleep(isSleep);
});
Expand Down Expand Up @@ -286,40 +298,50 @@ void LockWorker::initConnections()

void LockWorker::initData()
{
/* com.deepin.daemon.Accounts */
m_model->updateUserList(m_accountsInter->userList());
m_model->updateLoginedUserList(m_loginedInter->userList());

m_model->setUserlistVisible(valueByQSettings<bool>("", "userlist", true));
/* com.deepin.udcp.iam */
QDBusInterface ifc(DSS_DBUS::udcpIamService, DSS_DBUS::udcpIamPath, DSS_DBUS::udcpIamService, QDBusConnection::systemBus(), this);
const bool allowShowCustomUser = (!m_model->userlistVisible()) || valueByQSettings<bool>("", "loginPromptInput", false) ||
ifc.property("Enable").toBool() || checkIsADDomain();
m_model->setAllowShowCustomUser(allowShowCustomUser);

/* init server user or custom user */
if (DSysInfo::deepinType() == DSysInfo::DeepinServer || m_model->allowShowCustomUser()) {
std::shared_ptr<User> user(new User());
m_model->setIsServerModel(DSysInfo::deepinType() == DSysInfo::DeepinServer);
m_model->addUser(user);
}
auto list = m_accountsInter->userList();
if (!list.isEmpty()) {
/* com.deepin.daemon.Accounts */
m_model->updateUserList(m_accountsInter->userList());
m_model->updateLoginedUserList(m_loginedInter->userList());

m_model->setUserlistVisible(valueByQSettings<bool>("", "userlist", true));
/* com.deepin.udcp.iam */
QDBusInterface ifc(DSS_DBUS::udcpIamService, DSS_DBUS::udcpIamPath, DSS_DBUS::udcpIamService, QDBusConnection::systemBus(), this);
const bool allowShowCustomUser = (!m_model->userlistVisible()) || valueByQSettings<bool>("", "loginPromptInput", false) ||
ifc.property("Enable").toBool() || checkIsADDomain();
m_model->setAllowShowCustomUser(allowShowCustomUser);

/* init server user or custom user */
if (DSysInfo::deepinType() == DSysInfo::DeepinServer || m_model->allowShowCustomUser()) {
std::shared_ptr<User> user(new User());
m_model->setIsServerModel(DSysInfo::deepinType() == DSysInfo::DeepinServer);
m_model->addUser(user);
}

/* com.deepin.dde.LockService */
std::shared_ptr<User> user_ptr = m_model->findUserByUid(getuid());
if (user_ptr.get()) {
m_model->updateCurrentUser(user_ptr);
const QString &userJson = m_lockInter->CurrentUser();
QJsonParseError jsonParseError;
const QJsonDocument userDoc = QJsonDocument::fromJson(userJson.toUtf8(), &jsonParseError);
if (jsonParseError.error != QJsonParseError::NoError || userDoc.isEmpty()) {
qCWarning(DDE_SHELL) << "Failed to obtain current user information from lock service!";
/* com.deepin.dde.LockService */
std::shared_ptr<User> user_ptr = m_model->findUserByUid(getuid());
if (user_ptr.get()) {
m_model->updateCurrentUser(user_ptr);
const QString &userJson = m_lockInter->CurrentUser();
QJsonParseError jsonParseError;
const QJsonDocument userDoc = QJsonDocument::fromJson(userJson.toUtf8(), &jsonParseError);
if (jsonParseError.error != QJsonParseError::NoError || userDoc.isEmpty()) {
qCWarning(DDE_SHELL) << "Failed to obtain current user information from lock service!";
} else {
const QJsonObject userObj = userDoc.object();
m_model->currentUser()->setLastAuthType(AUTH_TYPE_CAST(userObj["AuthType"].toInt()));
m_model->currentUser()->setLastCustomAuth(userObj["LastCustomAuth"].toString());
}
} else {
const QJsonObject userObj = userDoc.object();
m_model->currentUser()->setLastAuthType(AUTH_TYPE_CAST(userObj["AuthType"].toInt()));
m_model->currentUser()->setLastCustomAuth(userObj["LastCustomAuth"].toString());
m_model->updateCurrentUser(m_lockInter->CurrentUser());
}
} else {
m_model->updateCurrentUser(m_lockInter->CurrentUser());
qCWarning(DDE_SHELL) << "dbus com.deepin.daemon.Accounts userList is empty, use ...";

std::shared_ptr<User> user(new User());
m_model->addUser(user);
m_model->updateCurrentUser(user);
m_model->setAllowShowCustomUser(true);
}

/* com.deepin.daemon.Authenticate */
Expand All @@ -343,6 +365,8 @@ void LockWorker::initConfiguration()
m_model->setAllowShowUserSwitchButton(getDconfigValue("switchUser", Ondemand).toInt() == AuthInterface::Ondemand);
#endif

m_model->setGsCheckpwd(isCheckPwdBeforeRebootOrShut());

checkPowerInfo();
}

Expand Down Expand Up @@ -490,7 +514,6 @@ void LockWorker::doPowerAction(const SessionBaseModel::PowerAction action)
case SessionBaseModel::PowerAction::RequireSuspend:
{
m_model->setIsBlackMode(true);
m_model->setCurrentModeState(SessionBaseModel::ModeStatus::PasswordMode);

int delayTime = 500;
#ifndef ENABLE_DSS_SNIPE
Expand Down Expand Up @@ -520,7 +543,6 @@ void LockWorker::doPowerAction(const SessionBaseModel::PowerAction action)
case SessionBaseModel::PowerAction::RequireHibernate:
{
m_model->setIsBlackMode(true);
m_model->setCurrentModeState(SessionBaseModel::ModeStatus::PasswordMode);

int delayTime = 500;
#ifndef ENABLE_DSS_SNIPE
Expand Down Expand Up @@ -549,42 +571,44 @@ void LockWorker::doPowerAction(const SessionBaseModel::PowerAction action)
}
}
break;
case SessionBaseModel::PowerAction::RequireRestart:
case SessionBaseModel::PowerAction::RequireRestart: {
m_model->setShutdownMode(true);
auto gsCheckPwd = m_model->gsCheckpwd();
if (!isLocked() || m_model->currentModeState() == SessionBaseModel::ModeStatus::ShutDownMode || !gsCheckPwd) {
m_sessionManagerInter->RequestReboot();
} else {
createAuthentication(m_account);
m_model->setCurrentModeState(SessionBaseModel::ModeStatus::ConfirmPasswordMode);
}

QTimer::singleShot(350, this, [=] {
if (!isLocked() || m_model->currentModeState() == SessionBaseModel::ModeStatus::ShutDownMode || !isCheckPwdBeforeRebootOrShut()) {
m_sessionManagerInter->RequestReboot();
} else {
createAuthentication(m_account);
m_model->setCurrentModeState(SessionBaseModel::ModeStatus::ConfirmPasswordMode);
}

if (m_model->visibleShutdownWhenRebootOrShutdown()) {
return;
}
if (m_model->visibleShutdownWhenRebootOrShutdown()) {
return;
}

if (!gsCheckPwd)
m_model->setVisible(false);
});

return;
case SessionBaseModel::PowerAction::RequireShutdown:
}
case SessionBaseModel::PowerAction::RequireShutdown: {
m_model->setShutdownMode(true);
auto gsCheckPwd = m_model->gsCheckpwd();
if (!isLocked() || m_model->currentModeState() == SessionBaseModel::ModeStatus::ShutDownMode || !gsCheckPwd) {
m_sessionManagerInter->RequestShutdown();
} else {
createAuthentication(m_account);
m_model->setCurrentModeState(SessionBaseModel::ModeStatus::ConfirmPasswordMode);
}

QTimer::singleShot(350, this, [=] {
if (!isLocked() || m_model->currentModeState() == SessionBaseModel::ModeStatus::ShutDownMode || !isCheckPwdBeforeRebootOrShut()) {
m_sessionManagerInter->RequestShutdown();
} else {
createAuthentication(m_account);
m_model->setCurrentModeState(SessionBaseModel::ModeStatus::ConfirmPasswordMode);
}

if (m_model->visibleShutdownWhenRebootOrShutdown()) {
return;
}
if (m_model->visibleShutdownWhenRebootOrShutdown()) {
return;
}

if (!gsCheckPwd)
m_model->setVisible(false);
});

return;
}
case SessionBaseModel::PowerAction::RequireLock:
m_model->setCurrentModeState(SessionBaseModel::ModeStatus::PasswordMode);
createAuthentication(m_model->currentUser()->name());
Expand Down
2 changes: 1 addition & 1 deletion src/dde-lock/lockworker.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public slots:

void onNoPasswordLoginChanged(const QString &account, bool noPassword);
void sendExtraInfo(const QString &account, AuthCommon::AuthType authType, const QString &info);
void setLocked(const bool locked);

private:
void initConnections();
Expand All @@ -76,7 +77,6 @@ public slots:

void doPowerAction(const SessionBaseModel::PowerAction action);
void setCurrentUser(const std::shared_ptr<User> user);
void setLocked(const bool locked);

// lock
void lockServiceEvent(quint32 eventType, quint32 pid, const QString &username, const QString &message);
Expand Down
Loading
Loading