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
2 changes: 1 addition & 1 deletion configs/org.deepin.dde.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"visibility": "private"
},
"enableShortcutForLock":{
"value": ["Screenshot","Screen Recorder","Full screenshot"],
"value": ["Screenshot","Screen Recorder","Full screenshot","WLAN"],
"serial": 0,
"flags": [],
"name": "EnableShortcutForLock",
Expand Down
33 changes: 33 additions & 0 deletions files/wayland/lightdm-deepin-greeter-wayland
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,37 @@ if [ -x $display_daemon ]; then
fi


#在满足条件下,设置tapToClick=true
#解析dbus信息输出
dbus_values_get_strings(){
local input="$1"
echo "$input" | grep -oP 'string \K".*?"' | tr -d '"'
}
dbus_values_get_bool(){
local input="$1"
echo "$input" | grep -oP 'boolean \Ktrue|false' | awk '{print $1}'
}

#判断并设置设备属性
device_handle(){
local input="$1"
local dbus_touchpad=$(dbus-send --session --print-reply --dest=org.kde.KWin $input org.freedesktop.DBus.Properties.Get string:"org.kde.KWin.InputDevice" string:"touchpad")
local touchpad=$(dbus_values_get_bool "$dbus_touchpad")

if [ "$touchpad" = "true" ]; then
dbus-send --session --dest=org.kde.KWin "$input" org.freedesktop.DBus.Properties.Set string:"org.kde.KWin.InputDevice" string:"tapToClick" variant:boolean:true
fi
}

#获取设备列表
dbus_devices=$(dbus-send --session --print-reply --dest=org.kde.KWin /org/kde/KWin/InputDevice org.freedesktop.DBus.Properties.Get string:"org.kde.KWin.InputDeviceManager" string:"devicesSysNames")
devices_strings=$(dbus_values_get_strings "$dbus_devices")

#遍历设备列表
device_path="/org/kde/KWin/InputDevice/"
for dev in $devices_strings; do
path="${device_path}${dev}"
device_handle "$path"
done

/usr/share/dde-session-shell/greeters.d/launch-binary
38 changes: 37 additions & 1 deletion src/session-widgets/lockcontent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,14 @@ void LockContent::init(SessionBaseModel *model)
}

DConfigHelper::instance()->bind(this, SHOW_MEDIA_WIDGET, &LockContent::OnDConfigPropertyChanged);

QString kbLayout = getCurrentKBLayout();
if (!kbLayout.isEmpty() && !kbLayout.toLower().startsWith("us")) {
m_originalKBLayout = kbLayout;
qCInfo(DDE_SHELL) << "Original keyboard layout:" << m_originalKBLayout;
// 如果键盘布局有特殊设置,则切换到英文键盘布局,认证成功后恢复
setKBLayout("us");
}
}

void LockContent::initUI()
Expand Down Expand Up @@ -184,8 +192,13 @@ void LockContent::initConnections()
connect(m_model, &SessionBaseModel::userListChanged, this, &LockContent::onUserListChanged);
connect(m_model, &SessionBaseModel::userListLoginedChanged, this, &LockContent::onUserListChanged);
connect(m_model, &SessionBaseModel::authFinished, this, [this](bool successful) {
if (successful)
if (successful) {
setVisible(false);
if (!m_originalKBLayout.isEmpty()) {
// 切换回原来的键盘布局
setKBLayout(m_originalKBLayout);
}
}
restoreMode();
});
connect(m_model, &SessionBaseModel::MFAFlagChanged, this, [this](const bool isMFA) {
Expand Down Expand Up @@ -985,3 +998,26 @@ void LockContent::showShutdown()
m_model->setCurrentModeState(SessionBaseModel::ModeStatus::ShutDownMode);
m_model->setVisible(true);
}

QString LockContent::getCurrentKBLayout() const
{
QProcess p;
p.start("/usr/bin/setxkbmap", {"-query"});
p.waitForFinished();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (bug_risk): Add a timeout and error check to waitForFinished

Using waitForFinished() without a timeout can cause the process to hang if it stalls. Please use the timeout overload and check the process exit status and standard error to handle possible failures.


const QString output = QString::fromUtf8(p.readAllStandardOutput());
for (const QString &line : output.split('\n')) {
if (line.startsWith("layout:")) {
QString layout = line.section(':', 1).trimmed();
return layout;
}
}

return {};
}

void LockContent::setKBLayout(const QString &layout)
{
qCDebug(DDE_SHELL) << "Set keyboard layout: " << layout;
QProcess::execute("/usr/bin/setxkbmap", { layout});
}
4 changes: 4 additions & 0 deletions src/session-widgets/lockcontent.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ public slots:
void initFMAWidget();
void initUserListWidget();
void enableSystemShortcut(const QStringList &shortcuts, bool enabled, bool isPersistent);
QString getCurrentKBLayout() const;
void setKBLayout(const QString &layout);

protected:
SessionBaseModel *m_model = nullptr;
Expand Down Expand Up @@ -133,6 +135,8 @@ public slots:
bool m_MPRISEnable = false;
bool m_showMediaWidget = false;
bool m_hasResetPasswordDialog = false;

QString m_originalKBLayout;
};

#endif // LOCKCONTENT_H
27 changes: 23 additions & 4 deletions src/session-widgets/sessionbasemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
// SPDX-License-Identifier: GPL-3.0-or-later

#include "sessionbasemodel.h"
#include "dconfig_helper.h"

Check warning on line 6 in src/session-widgets/sessionbasemodel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "dconfig_helper.h" not found.
#include "dbus/dbusdisplaymanager.h"

Check warning on line 7 in src/session-widgets/sessionbasemodel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "dbus/dbusdisplaymanager.h" not found.

#include <DSysInfo>

Check warning on line 9 in src/session-widgets/sessionbasemodel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

#include <QDebug>

Check warning on line 10 in src/session-widgets/sessionbasemodel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

#include "dbusconstant.h"

Check warning on line 12 in src/session-widgets/sessionbasemodel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "dbusconstant.h" not found.
#include "dconfig_helper.h"

DCORE_USE_NAMESPACE

Expand Down Expand Up @@ -462,6 +462,22 @@
void SessionBaseModel::updateLoginedUserList(const QString &list)
{
qCDebug(DDE_SHELL) << "Logined user list: " << list;
// kwin崩溃时systemd中的sessions不会被remove掉,这里通过DisplayManager的session信息过滤一遍(临时解决方案)
QStringList loggedUserNameList;
DBusDisplayManager displayManager("org.freedesktop.DisplayManager", "/org/freedesktop/DisplayManager", QDBusConnection::systemBus());
const auto &sessions = displayManager.sessions();
for (const auto &session : sessions) {
const QString &sessionPath = session.path();
if (sessionPath.isEmpty())
continue;
QDBusInterface interface("org.freedesktop.DisplayManager", sessionPath, "org.freedesktop.DisplayManager.Session", QDBusConnection::systemBus());
if (interface.isValid()) {
const QString &userName = interface.property("UserName").toString();
if (!userName.isEmpty())
loggedUserNameList.append(userName);
}
}
qInfo(DDE_SHELL) << "Logined users from display manager: " << loggedUserNameList;

QList<QString> loginedUsersTmp = m_loginedUsers->keys();
QJsonParseError jsonParseError;
Expand All @@ -486,8 +502,11 @@
// 对于通过自定义窗口输入的账户(域账户), 此时账户还没添加进来,导致下面m_users->value(path)为空指针,调用会导致程序奔溃
// 因此在登录时,对于新增的账户,调用addUser先将账户添加进来,然后再去更新对应账户的登录状态
addUser(path);
m_loginedUsers->insert(path, m_users->value(path));
m_users->value(path)->updateLoginState(true);
auto user = m_users->value(path);
if (user->name().isEmpty() || loggedUserNameList.contains(user->name())) {
m_loginedUsers->insert(path, user);
user->updateLoginState(true);
}
} else {
loginedUsersTmp.removeAll(path);
}
Expand Down