From b92e0ca25b91b46290b710a4722a19e37893a383 Mon Sep 17 00:00:00 2001 From: liuxinhao Date: Tue, 9 Apr 2024 17:11:06 +0800 Subject: [PATCH] sync 2.5.1-11 --- ...legate-updateEditorGeometry-to-updat.patch | 4 +- ...ound-Add-login-background-setting-ti.patch | 4 +- ...-ci-Connect-to-internal-CI-processes.patch | 51 + ...g-Fix-some-static-code-scanning-issu.patch | 987 ++++++++++++++++++ ...ard-Add-detection-for-whether-to-ins.patch | 140 +++ ...cursor-incorrect-scaling-cursor-size.patch | 158 +++ ...x-untranslated-text-from-polkit-agen.patch | 146 +++ kiran-session-guard.spec | 65 +- 8 files changed, 1538 insertions(+), 17 deletions(-) create mode 100644 0012-feat-ci-Connect-to-internal-CI-processes.patch create mode 100644 0013-fix-code-scanning-Fix-some-static-code-scanning-issu.patch create mode 100644 0014-fix-virutalkeyboard-Add-detection-for-whether-to-ins.patch create mode 100644 0015-fix-cursor-incorrect-scaling-cursor-size.patch create mode 100644 0016-fix-polkit-ts-fix-untranslated-text-from-polkit-agen.patch diff --git a/0008-fix-styleditemdelegate-updateEditorGeometry-to-updat.patch b/0008-fix-styleditemdelegate-updateEditorGeometry-to-updat.patch index 7a0eed7..92f63e5 100644 --- a/0008-fix-styleditemdelegate-updateEditorGeometry-to-updat.patch +++ b/0008-fix-styleditemdelegate-updateEditorGeometry-to-updat.patch @@ -1,8 +1,8 @@ From 66d11ae4717a846e06a7fc85354993ba2e90ce0e Mon Sep 17 00:00:00 2001 From: liuxinhao Date: Thu, 26 Oct 2023 14:40:23 +0800 -Subject: [PATCH 08/10] fix(styleditemdelegate): updateEditorGeometry to update - the wrong size of ItemWidgets in QStyledItemDelegate +Subject: [PATCH] fix(styleditemdelegate): updateEditorGeometry to update the + wrong size of ItemWidgets in QStyledItemDelegate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit diff --git a/0011-fix-login-background-Add-login-background-setting-ti.patch b/0011-fix-login-background-Add-login-background-setting-ti.patch index cb64c99..ca9d5b6 100644 --- a/0011-fix-login-background-Add-login-background-setting-ti.patch +++ b/0011-fix-login-background-Add-login-background-setting-ti.patch @@ -1,4 +1,4 @@ -From a1615021c9e2c89558338108755420077e6658e1 Mon Sep 17 00:00:00 2001 +From dde040b63753a0f8e1b8e3a65dbdefc8d188224c Mon Sep 17 00:00:00 2001 From: liuxinhao Date: Thu, 18 Jan 2024 17:15:12 +0800 Subject: [PATCH] fix(login background): Add login background setting title @@ -159,5 +159,5 @@ index fbe76f5..5468e6f 100644 请确保两个选项之一被打开! -- -2.33.0 +2.27.0 diff --git a/0012-feat-ci-Connect-to-internal-CI-processes.patch b/0012-feat-ci-Connect-to-internal-CI-processes.patch new file mode 100644 index 0000000..68d0092 --- /dev/null +++ b/0012-feat-ci-Connect-to-internal-CI-processes.patch @@ -0,0 +1,51 @@ +From b97a40e3391511acd90848b18f526447f9196062 Mon Sep 17 00:00:00 2001 +From: liuxinhao +Date: Wed, 31 Jan 2024 09:29:47 +0800 +Subject: [PATCH 12/16] feat(ci): Connect to internal CI processes +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +- 接入内部CI流程 +--- + .gitlab-ci.yml | 25 ++++++++++++++++++------- + 1 file changed, 18 insertions(+), 7 deletions(-) + +diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml +index 18db367..da5af29 100644 +--- a/.gitlab-ci.yml ++++ b/.gitlab-ci.yml +@@ -1,12 +1,23 @@ + variables: + EXTRA_DNF_REPOS: | +- [KiranBase2.4] +- name=KiranBase2.4 ++ [Kiran2.6] ++ name=Kiran2.6 + gpgcheck=0 +- baseurl=http://192.168.120.71/kojifiles/repos/KY3.5-1-Kiran-base-2.4-build/latest/x86_64/ +- RPM_BUILD_REQUIRES: 'gcc-c++ cmake libXtst-devel libX11-devel libXrandr-devel libXcursor-devel libXfixes-devel glib2-devel lightdm-qt5-devel pam-devel qt5-qtbase-devel qt5-linguist qt5-qtx11extras-devel qt5-qtsvg-devel gsettings-qt-devel kiran-widgets-qt5-devel kiran-log-qt5-devel kiran-biometrics-devel kiran-authentication-service-devel kiran-cc-daemon-devel kiran-control-panel-devel kiran-qt5-integration-devel kiran-screensaver-devel' +- ++ baseurl=http://build.kylinsec.com.cn:82/KylinSec:/3.5.2:/Customize:/Kiran2.6/standard_x86_64/ ++ [KylinSec_3.5.2_Epol] ++ name=KylinSec 3.5.2 (standard_x86_64) ++ baseurl=http://build.kylinsec.com.cn:82/KylinSec:/3.5.2:/Epol/standard_x86_64/ ++ enabled=1 ++ gpgcheck=0 ++ [KylinSec_3.5.2_Mainline] ++ name=KylinSec 3.5.2 (standard_x86_64) ++ baseurl=http://build.kylinsec.com.cn:82/KylinSec:/3.5.2:/Mainline/standard_x86_64/ ++ gpgcheck=0 ++ gpgkey=http://build.kylinsec.com.cn:82/KylinSec:/3.5.2:/Mainline/standard_x86_64/repodata/repomd.xml.key ++ enabled=1 ++ RPM_BUILD_REQUIRES: 'cmake gcc-c++ libXtst-devel libX11-devel libXrandr-devel libXcursor-devel libXfixes-devel glib2-devel lightdm-qt5-devel pam-devel libxkbcommon-devel qt5-qtbase-devel qt5-linguist qt5-qtx11extras-devel qt5-qtsvg-devel gsettings-qt-devel kiran-widgets-qt5-devel kiran-log-qt5-devel kiran-authentication-service-devel kiran-cc-daemon-devel kiran-control-panel-devel kiran-qt5-integration-devel kiran-qdbusxml2cpp kiran-screensaver-devel polkit-qt5-1-devel' + include: +- - project: 'os/gitlab-ci' ++ - project: 'os/ks-devops' + ref: main +- file: '/cmake/cxx.gitlab-ci.yml' ++ file: '/entrypoint/develop/cmake.yml' ++ +-- +2.27.0 + diff --git a/0013-fix-code-scanning-Fix-some-static-code-scanning-issu.patch b/0013-fix-code-scanning-Fix-some-static-code-scanning-issu.patch new file mode 100644 index 0000000..827d57d --- /dev/null +++ b/0013-fix-code-scanning-Fix-some-static-code-scanning-issu.patch @@ -0,0 +1,987 @@ +From a076bff281bf7d8b3a5b6dc61f82a2e2cb25d23c Mon Sep 17 00:00:00 2001 +From: liuxinhao +Date: Wed, 31 Jan 2024 11:46:23 +0800 +Subject: [PATCH 13/16] fix(code scanning ): Fix some static code scanning + issues +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +- 修复一些代码静态扫描问题 +--- + lib/auth-proxy/auth-controller-i.h | 13 ++ + lib/common-widgets/auth-type-drawer.cpp | 15 ++- + lib/common-widgets/auth-type-drawer.h | 13 ++ + lib/common-widgets/auth-type-switcher.cpp | 17 ++- + ...m.kylinsec.Kiran.SystemDaemon.Accounts.xml | 8 -- + lib/login-frame/login-frame.cpp | 2 +- + lib/utils/keyboard-monitor.cpp | 69 ++++------ + lib/utils/scaling-helper.cpp | 125 ++++++++++-------- + lib/utils/virtual-keyboard.h | 4 +- + src/lightdm-greeter/common/prefs.cpp | 26 ++-- + src/lightdm-greeter/frame.cpp | 6 +- + .../kiran-cpanel-greeter/main.cpp | 13 ++ + .../kiran-cpanel-greeter/setting-window.cpp | 1 - + src/lightdm-greeter/term-signal-handler.cpp | 2 +- + .../widgets/disabledeselectlistwidget.cpp | 11 +- + src/lightdm-greeter/widgets/login-button.cpp | 7 +- + src/lightdm-greeter/widgets/user-info.h | 2 + + src/lightdm-greeter/widgets/user-list.cpp | 15 ++- + src/lightdm-greeter/widgets/user-list.h | 2 +- + src/polkit-agent/auth-polkit.h | 2 +- + src/polkit-agent/dialog.cpp | 2 +- + src/polkit-agent/moreinfo-button.cpp | 16 +-- + src/screensaver-dialog/auth-pam.h | 2 +- + .../checkpass-common/pam-message.cpp | 4 +- + src/screensaver-dialog/frame.cpp | 10 +- + src/screensaver-dialog/prefs.cpp | 12 +- + .../session-guard-checkpass/main.cpp | 30 +++-- + 27 files changed, 240 insertions(+), 189 deletions(-) + +diff --git a/lib/auth-proxy/auth-controller-i.h b/lib/auth-proxy/auth-controller-i.h +index 3340807..6f75241 100644 +--- a/lib/auth-proxy/auth-controller-i.h ++++ b/lib/auth-proxy/auth-controller-i.h +@@ -1,3 +1,16 @@ ++/** ++ * Copyright (c) 2020 ~ 2024 KylinSec Co., Ltd. ++ * kiran-session-guard is licensed under Mulan PSL v2. ++ * You can use this software according to the terms and conditions of the Mulan PSL v2. ++ * You may obtain a copy of Mulan PSL v2 at: ++ * http://license.coscl.org.cn/MulanPSL2 ++ * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, ++ * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, ++ * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. ++ * See the Mulan PSL v2 for more details. ++ * ++ * Author: liuxinhao ++ */ + #pragma once + #include + #include "auth-define.h" +diff --git a/lib/common-widgets/auth-type-drawer.cpp b/lib/common-widgets/auth-type-drawer.cpp +index bddc5e8..57109ee 100644 +--- a/lib/common-widgets/auth-type-drawer.cpp ++++ b/lib/common-widgets/auth-type-drawer.cpp +@@ -1,3 +1,16 @@ ++/** ++ * Copyright (c) 2020 ~ 2024 KylinSec Co., Ltd. ++ * kiran-session-guard is licensed under Mulan PSL v2. ++ * You can use this software according to the terms and conditions of the Mulan PSL v2. ++ * You may obtain a copy of Mulan PSL v2 at: ++ * http://license.coscl.org.cn/MulanPSL2 ++ * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, ++ * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, ++ * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. ++ * See the Mulan PSL v2 for more details. ++ * ++ * Author: liuxinhao ++ */ + #include "auth-type-drawer.h" + #include "style-palette.h" + +@@ -84,7 +97,7 @@ void AuthTypeDrawer::setAuthTypes(QList> authT + authButtonInfo.m_icon = icon; + m_buttonMap[authType] = authButtonInfo; + } +- ++ + updateValidSizeHint(); + + if (m_adjustColorToTheme) +diff --git a/lib/common-widgets/auth-type-drawer.h b/lib/common-widgets/auth-type-drawer.h +index 7095773..f6edb79 100644 +--- a/lib/common-widgets/auth-type-drawer.h ++++ b/lib/common-widgets/auth-type-drawer.h +@@ -1,3 +1,16 @@ ++/** ++ * Copyright (c) 2020 ~ 2024 KylinSec Co., Ltd. ++ * kiran-session-guard is licensed under Mulan PSL v2. ++ * You can use this software according to the terms and conditions of the Mulan PSL v2. ++ * You may obtain a copy of Mulan PSL v2 at: ++ * http://license.coscl.org.cn/MulanPSL2 ++ * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, ++ * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, ++ * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. ++ * See the Mulan PSL v2 for more details. ++ * ++ * Author: liuxinhao ++ */ + #pragma once + + #include +diff --git a/lib/common-widgets/auth-type-switcher.cpp b/lib/common-widgets/auth-type-switcher.cpp +index a1a4470..37ead7d 100644 +--- a/lib/common-widgets/auth-type-switcher.cpp ++++ b/lib/common-widgets/auth-type-switcher.cpp +@@ -1,3 +1,16 @@ ++/** ++ * Copyright (c) 2020 ~ 2024 KylinSec Co., Ltd. ++ * kiran-session-guard is licensed under Mulan PSL v2. ++ * You can use this software according to the terms and conditions of the Mulan PSL v2. ++ * You may obtain a copy of Mulan PSL v2 at: ++ * http://license.coscl.org.cn/MulanPSL2 ++ * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, ++ * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, ++ * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. ++ * See the Mulan PSL v2 for more details. ++ * ++ * Author: liuxinhao ++ */ + #include "auth-type-switcher.h" + #include + #include +@@ -21,9 +34,9 @@ AuthTypeSwitcher::AuthTypeSwitcher(AuthTypeDrawerExpandDirection direction, int + m_drawer = new AuthTypeDrawer(direction, radius, parent, this); + connect(m_drawer, &AuthTypeDrawer::authTypeClicked, this, &AuthTypeSwitcher::onAuthTypeChanged); + // clang-format off +- connect(m_drawer, &AuthTypeDrawer::expandedStatusChanged, [this](bool expaned){ ++ connect(m_drawer, &AuthTypeDrawer::expandedStatusChanged, [this](bool expaned){ + m_isExpanded = expaned; +- update(); ++ update(); + }); + // clang-format on + } +diff --git a/lib/dbus/com.kylinsec.Kiran.SystemDaemon.Accounts.xml b/lib/dbus/com.kylinsec.Kiran.SystemDaemon.Accounts.xml +index 2248466..f7cb8f8 100644 +--- a/lib/dbus/com.kylinsec.Kiran.SystemDaemon.Accounts.xml ++++ b/lib/dbus/com.kylinsec.Kiran.SystemDaemon.Accounts.xml +@@ -65,14 +65,6 @@ + + + +- +- + + The RSA public key. + +diff --git a/lib/login-frame/login-frame.cpp b/lib/login-frame/login-frame.cpp +index 1657296..67e54e5 100644 +--- a/lib/login-frame/login-frame.cpp ++++ b/lib/login-frame/login-frame.cpp +@@ -280,8 +280,8 @@ void LoginFrame::onShowPrmpt(const QString& text, PromptType type) + ui->edit->setPlaceHolderText(text); + m_editMode = EDIT_MODE_PROMPT_RESPOSE; + ui->edit->setEchoMode(type == PromptTypeSecret ? QLineEdit::Password : QLineEdit::Normal); +- /// FIXME:需要延时设置输入焦点到输入框,不然又会被置回UserItem + m_prompted = true; ++ /// NOTE:需要延时设置输入焦点到输入框,不然又会被置回UserItem + setEditFocus(200); + } + +diff --git a/lib/utils/keyboard-monitor.cpp b/lib/utils/keyboard-monitor.cpp +index 290d8e4..4b7e89e 100644 +--- a/lib/utils/keyboard-monitor.cpp ++++ b/lib/utils/keyboard-monitor.cpp +@@ -26,6 +26,7 @@ + + #include + #include ++#include + + namespace Kiran + { +@@ -36,61 +37,39 @@ int KeyboardMonitor::getXiMajorVersion(Display *display) + XExtensionVersion *version; + static int vers = -1; + +- if (vers != -1) return vers; +- +- version = XGetExtensionVersion(display, INAME); +- +- if (version && (version != (XExtensionVersion *)NoSuchExtension)) ++ if (vers != -1) + { +- vers = version->major_version; +- XFree(version); ++ return vers; + } + +- /* Announce our supported version so the server treats us correctly. */ +- if (vers >= XI_2_Major) ++ version = XGetExtensionVersion(display, INAME); ++ if (!version || (version == reinterpret_cast(NoSuchExtension))) + { +- const char *forced_version; +- int maj = 2, min = 2; +- +- forced_version = getenv("XINPUT_XI2_VERSION"); +- if (forced_version) +- { +- if (sscanf(forced_version, "%d.%d", &maj, &min) != 2) +- { +- fprintf(stderr, +- "Invalid format of XINPUT_XI2_VERSION " +- "environment variable. Need major.minor\n"); +- exit(1); +- } +- printf("Overriding XI2 version to: %d.%d\n", maj, min); +- } +- +- XIQueryVersion(display, &maj, &min); ++ vers = 0; ++ return vers; + } + ++ vers = version->major_version; ++ XFree(version); + return vers; + } + + void KeyboardMonitor::selectEvents(Display *display) + { +- XIEventMask m; +- m.deviceid = XIAllMasterDevices; +- m.mask_len = XIMaskLen(XI_LASTEVENT); +- m.mask = (unsigned char *)calloc(m.mask_len, sizeof(char)); +- +- XISetMask(m.mask, XI_RawKeyRelease); +- // XISetMask(m.mask, XI_RawKeyPress); +- // XISetMask(m.mask, XI_RawButtonPress); +- // XISetMask(m.mask, XI_RawButtonRelease); +- // XISetMask(m.mask, XI_RawMotion); +- // XISetMask(m.mask, XI_RawTouchBegin); +- // XISetMask(m.mask, XI_RawTouchUpdate); +- // XISetMask(m.mask, XI_RawTouchEnd); +- +- XISelectEvents(display, DefaultRootWindow(display), &m, 1); +- +- free(m.mask); +- XSync(display, False); ++ XIEventMask evmask; ++ unsigned char mask[XIMaskLen(XI_LASTEVENT)] = {0}; ++ ++ memset(&evmask, 0, sizeof(evmask)); ++ memset(mask, 0, sizeof(mask)); ++ ++ XISetMask(mask, XI_RawKeyRelease); ++ ++ evmask.deviceid = XIAllMasterDevices; ++ evmask.mask_len = sizeof(mask); ++ evmask.mask = mask; ++ ++ XISelectEvents(display, DefaultRootWindow(display), &evmask, 1); ++ XFlush(display); + } + + int KeyboardMonitor::listenXiEvent(Display *display) +@@ -118,7 +97,7 @@ int KeyboardMonitor::listenXiEvent(Display *display) + } + else if (sym == XKB_KEY_Num_Lock) + { +- emit numlockStatusChanged(isNumlockOn()); ++ emit this->numlockStatusChanged(isNumlockOn()); + } + break; + } +diff --git a/lib/utils/scaling-helper.cpp b/lib/utils/scaling-helper.cpp +index ed051d9..697744e 100644 +--- a/lib/utils/scaling-helper.cpp ++++ b/lib/utils/scaling-helper.cpp +@@ -36,8 +36,14 @@ void ScalingHelper::auto_calculate_screen_scaling() + std::list scaleFactors; + + display = XOpenDisplay(nullptr); +- resources = XRRGetScreenResourcesCurrent(display, DefaultRootWindow(display)); ++ if (!display) ++ { ++ KLOG_WARNING("auto_calculate_screen_scaling failed,set QT_AUTO_SCREEN_SCALE_FACTOR=1"); ++ qputenv("QT_AUTO_SCREEN_SCALE_FACTOR", "1"); ++ return; ++ } + ++ resources = XRRGetScreenResourcesCurrent(display, DefaultRootWindow(display)); + if (!resources) + { + KLOG_WARNING("XRRGetScreenResourcesCurrent failed,try XRRGetScreenResources"); +@@ -47,81 +53,86 @@ void ScalingHelper::auto_calculate_screen_scaling() + if (!resources) + { + KLOG_WARNING("get screen resources failed"); +- goto failed; ++ if (display) ++ { ++ XCloseDisplay(display); ++ } ++ KLOG_WARNING("auto_calculate_screen_scaling failed,set QT_AUTO_SCREEN_SCALE_FACTOR=1"); ++ qputenv("QT_AUTO_SCREEN_SCALE_FACTOR", "1"); ++ return; + } + +- if (resources) ++ for (int i = 0; i < resources->noutput; i++) + { +- for (int i = 0; i < resources->noutput; i++) ++ XRROutputInfo *outputInfo = XRRGetOutputInfo(display, resources, resources->outputs[i]); ++ if (!outputInfo) ++ { ++ KLOG_WARNING("get output info %d from resources failed", i); ++ continue; ++ } ++ else if ((outputInfo->crtc == 0) || (outputInfo->mm_width == 0)) + { +- XRROutputInfo *outputInfo = XRRGetOutputInfo(display, resources, resources->outputs[i]); +- if (outputInfo->crtc == 0 || outputInfo->mm_width == 0) +- { +- if (outputInfo != nullptr) +- { +- XRRFreeOutputInfo(outputInfo); +- } +- continue; +- } +- XRRCrtcInfo *crtInfo = XRRGetCrtcInfo(display, resources, outputInfo->crtc); +- if (crtInfo == nullptr) +- { +- XRRFreeOutputInfo(outputInfo); +- continue; +- } +- +- // 计算屏幕尺寸 +- qreal screenInch; +- screenInch = qSqrt(qPow(outputInfo->mm_width, 2.0) + qPow(outputInfo->mm_height, 2.0)) / qreal(25.4); +- +- // 计算ppi +- qreal hypotenusePixel = qSqrt(qPow(crtInfo->width, 2.0) + qPow(crtInfo->height, 2.0)); +- qreal ppi = hypotenusePixel / screenInch; +- +- KLOG_INFO() << "Screen:" << outputInfo->name; +- KLOG_INFO() << " physical size: " << outputInfo->mm_width << "x" << outputInfo->mm_height; +- KLOG_INFO() << " virtual size: " << crtInfo->width << crtInfo->height; +- KLOG_INFO() << " inch: " << screenInch; +- KLOG_INFO() << " ppi: " << ppi; +- +- double screen_scale_factor = 1.0; +- if (ppi >= 150 && ppi < 196) +- { +- screen_scale_factor = 1.5; +- } +- else if (ppi >= 196) +- { +- screen_scale_factor = 2.0; +- } +- else if (crtInfo->width >= 4096) +- { +- screen_scale_factor = 2.0; +- } +- scaleFactors.push_back(screen_scale_factor); +- XRRFreeCrtcInfo(crtInfo); ++ KLOG_WARNING("ignore crtc==0 or mm_width==0 output"); + XRRFreeOutputInfo(outputInfo); ++ continue; ++ } ++ ++ XRRCrtcInfo *crtInfo = XRRGetCrtcInfo(display, resources, outputInfo->crtc); ++ if (crtInfo == nullptr) ++ { ++ KLOG_WARNING("ignore crtcinfo==null output"); ++ XRRFreeOutputInfo(outputInfo); ++ continue; ++ } ++ ++ // 计算屏幕尺寸 ++ qreal screenInch; ++ screenInch = qSqrt(qPow(outputInfo->mm_width, 2.0) + qPow(outputInfo->mm_height, 2.0)) / qreal(25.4); ++ ++ // 计算ppi ++ qreal hypotenusePixel = qSqrt(qPow(crtInfo->width, 2.0) + qPow(crtInfo->height, 2.0)); ++ qreal ppi = hypotenusePixel / screenInch; ++ ++ KLOG_INFO() << "Screen:" << outputInfo->name; ++ KLOG_INFO() << " physical size: " << outputInfo->mm_width << "x" << outputInfo->mm_height; ++ KLOG_INFO() << " virtual size: " << crtInfo->width << crtInfo->height; ++ KLOG_INFO() << " inch: " << screenInch; ++ KLOG_INFO() << " ppi: " << ppi; ++ ++ double screen_scale_factor = 1.0; ++ if (ppi >= 150 && ppi < 196) ++ { ++ screen_scale_factor = 1.5; ++ } ++ else if (ppi >= 196) ++ { ++ screen_scale_factor = 2.0; ++ } ++ else if (crtInfo->width >= 4096) ++ { ++ screen_scale_factor = 2.0; + } +- XRRFreeScreenResources(resources); ++ scaleFactors.push_back(screen_scale_factor); ++ ++ XRRFreeCrtcInfo(crtInfo); ++ XRRFreeOutputInfo(outputInfo); + } ++ XRRFreeScreenResources(resources); + XCloseDisplay(display); ++ + if (scaleFactors.size()) + { + scaleFactors.sort(); + scale_factor = *scaleFactors.begin(); + } ++ + KLOG_INFO() << "QT_SCALE_FACTOR:" << scale_factor; + if (!qputenv("QT_SCALE_FACTOR", QString::number(scale_factor).toUtf8())) + { + KLOG_WARNING() << "set scale factor failed."; + } ++ + return; +-failed: +- if (display) +- { +- XCloseDisplay(display); +- } +- KLOG_WARNING("auto_calculate_screen_scaling failed,set QT_AUTO_SCREEN_SCALE_FACTOR=1"); +- qputenv("QT_AUTO_SCREEN_SCALE_FACTOR", "1"); + } + + } // namespace SessionGuard +diff --git a/lib/utils/virtual-keyboard.h b/lib/utils/virtual-keyboard.h +index 09bbc37..4670105 100644 +--- a/lib/utils/virtual-keyboard.h ++++ b/lib/utils/virtual-keyboard.h +@@ -44,8 +44,8 @@ private slots: + void slotReadyReadStandardOutput(); + + private: +- QWidget *m_keyboardWidget; +- QProcess *m_process; ++ QWidget *m_keyboardWidget = nullptr; ++ QProcess *m_process = nullptr; + QWidget *m_keyboardEmbed = nullptr; + }; + } // namespace SessionGuard +diff --git a/src/lightdm-greeter/common/prefs.cpp b/src/lightdm-greeter/common/prefs.cpp +index 91d7072..82891b4 100644 +--- a/src/lightdm-greeter/common/prefs.cpp ++++ b/src/lightdm-greeter/common/prefs.cpp +@@ -51,31 +51,31 @@ void Prefs::init() + /// common + settings.beginGroup("Common"); + +- auto hiddenSession = settings.value("hidden-sessions"); ++ auto hiddenSession = settings.value("hidden-sessions",""); + m_hiddenSessions = hiddenSession.toStringList(); + +- auto hiddenUsers = settings.value("hide-users"); +- m_hiddenUsers = hiddenUsers.toStringList(); ++ auto needHideUsers = settings.value("hide-users",""); ++ m_hiddenUsers = needHideUsers.toStringList(); + +- auto numlockInitState = settings.value("numlock-init-state"); +- m_numlockInitState = numlockInitState.toBool(); ++ auto numInitState = settings.value("numlock-init-state"); ++ m_numlockInitState = numInitState.toBool(); + + settings.endGroup(); + + /// power + settings.beginGroup("Power"); + +- auto canPowerOff = settings.value("can-poweroff"); +- m_canPowerOff = canPowerOff.toBool(); ++ auto powerOffEnable = settings.value("can-poweroff"); ++ m_canPowerOff = powerOffEnable.toBool(); + +- auto canReboot = settings.value("can-reboot"); +- m_canReboot = canReboot.toBool(); ++ auto rebootEnable = settings.value("can-reboot"); ++ m_canReboot = rebootEnable.toBool(); + +- auto canSuspend = settings.value("can-suspend"); +- m_canSuspend = canSuspend.toBool(); ++ auto suspendEnable = settings.value("can-suspend"); ++ m_canSuspend = suspendEnable.toBool(); + +- auto canHibernate = settings.value("can-hibernate"); +- m_canHibernate = canHibernate.toBool(); ++ auto hibernateEnable = settings.value("can-hibernate"); ++ m_canHibernate = hibernateEnable.toBool(); + } + + Prefs::~Prefs() +diff --git a/src/lightdm-greeter/frame.cpp b/src/lightdm-greeter/frame.cpp +index 3d8dada..e4afcb9 100644 +--- a/src/lightdm-greeter/frame.cpp ++++ b/src/lightdm-greeter/frame.cpp +@@ -110,7 +110,7 @@ void Frame::initMenus() + auto setMenuAttributes = [](QMenu* menu) + { + menu->setAttribute(Qt::WA_TranslucentBackground); // 透明必需 +- // FIXME:QMenu不能为窗口,只能为控件,不然透明效果依赖于窗口管理器混成特效与显卡 ++ // NOTE:QMenu不能为窗口,只能为控件,不然透明效果依赖于窗口管理器混成特效与显卡 + // 控件的话QMenu显示出来的话,不能点击其他区域隐藏窗口,需要手动隐藏 + menu->setWindowFlags(Qt::FramelessWindowHint | Qt::Widget); // 透明必需 + menu->setContentsMargins(0, 0, 0, 0); +@@ -165,7 +165,7 @@ void Frame::initUI() + { + resize(1024, 768); + +- /// FIXME:因弹出窗口不是作为新的窗口,而是作为一个控件,需要我们去做隐藏 ++ /// NOTE:因弹出窗口不是作为新的窗口,而是作为一个控件,需要我们去做隐藏 + /// 开始监听整个应用程序事件,在窗口点击事件中判断隐藏菜单 + qApp->installEventFilter(this); + +@@ -205,7 +205,7 @@ void Frame::initUI() + + // 初始化添加右下控件 + // 获取菜单弹出坐标,按钮和触发菜单右对齐 +- // FIXME: Qt在特定虚拟机环境下QMenu::popup传入正确的pos时,QMenu通过Pos找到screen,但screen的大小错误(为调整分辨率之前的分辨率) ++ // NOTE: Qt在特定虚拟机环境下QMenu::popup传入正确的pos时,QMenu通过Pos找到screen,但screen的大小错误(为调整分辨率之前的分辨率) + // 导致popup pos被修改成在错误的屏幕范围内 + auto getMenuPopupPos = [this](QMenu* menu, const QToolButton* triggerBtn) -> QPoint + { +diff --git a/src/lightdm-greeter/kiran-cpanel-greeter/main.cpp b/src/lightdm-greeter/kiran-cpanel-greeter/main.cpp +index eeffb39..96567b7 100644 +--- a/src/lightdm-greeter/kiran-cpanel-greeter/main.cpp ++++ b/src/lightdm-greeter/kiran-cpanel-greeter/main.cpp +@@ -1,3 +1,16 @@ ++/** ++ * Copyright (c) 2020 ~ 2024 KylinSec Co., Ltd. ++ * kiran-session-guard is licensed under Mulan PSL v2. ++ * You can use this software according to the terms and conditions of the Mulan PSL v2. ++ * You may obtain a copy of Mulan PSL v2 at: ++ * http://license.coscl.org.cn/MulanPSL2 ++ * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, ++ * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, ++ * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. ++ * See the Mulan PSL v2 for more details. ++ * ++ * Author: liuxinhao ++ */ + #include + + int main(int argc, char* argv[]) +diff --git a/src/lightdm-greeter/kiran-cpanel-greeter/setting-window.cpp b/src/lightdm-greeter/kiran-cpanel-greeter/setting-window.cpp +index 5c3fd15..45c9fb9 100644 +--- a/src/lightdm-greeter/kiran-cpanel-greeter/setting-window.cpp ++++ b/src/lightdm-greeter/kiran-cpanel-greeter/setting-window.cpp +@@ -435,7 +435,6 @@ void SettingWindow::initUserComboBox(QComboBox *combo) + iconFile.clear(); + } + }; +- QVector userInfoVector; + + QStringList users = UserManager::getCachedUsers(); + users.append("root"); +diff --git a/src/lightdm-greeter/term-signal-handler.cpp b/src/lightdm-greeter/term-signal-handler.cpp +index 5375d19..646c7e1 100644 +--- a/src/lightdm-greeter/term-signal-handler.cpp ++++ b/src/lightdm-greeter/term-signal-handler.cpp +@@ -22,7 +22,7 @@ + #include + #include + +-//FIXME:该种方式退出时,可能会有线程阻塞在xcb_wait_for_reply ++//TODO:该种方式退出时,可能会有线程阻塞在xcb_wait_for_reply + namespace Kiran + { + namespace SessionGuard +diff --git a/src/lightdm-greeter/widgets/disabledeselectlistwidget.cpp b/src/lightdm-greeter/widgets/disabledeselectlistwidget.cpp +index c2f0190..e6a7962 100644 +--- a/src/lightdm-greeter/widgets/disabledeselectlistwidget.cpp ++++ b/src/lightdm-greeter/widgets/disabledeselectlistwidget.cpp +@@ -31,24 +31,27 @@ DisableDeselectListWidget::DisableDeselectListWidget(QWidget *parent) + QItemSelectionModel::SelectionFlags + DisableDeselectListWidget::selectionCommand(const QModelIndex &index, const QEvent *event) const + { +- //FIXME:为了避免一些环境下会出现ItemFocus直接设置选中的情况 ++ // NOTE:为了避免一些环境下会出现ItemFocus直接设置选中的情况 + if (event == nullptr) + { + return QItemSelectionModel::NoUpdate; + } +- //禁用用户按住鼠标切换用户情况 ++ ++ // 禁用用户按住鼠标切换用户情况 + if (event->type() == QEvent::MouseMove) + { + return QItemSelectionModel::NoUpdate; + } +- if ((event != nullptr) && (event->type() == QEvent::MouseButtonPress)) ++ ++ if ((event->type() == QEvent::MouseButtonPress)) + { +- const QMouseEvent *mouseEvent = (QMouseEvent *)event; ++ const QMouseEvent *mouseEvent = static_cast(event); + if ((mouseEvent->modifiers() & Qt::ControlModifier) != 0) + { + return QItemSelectionModel::NoUpdate; + } + } ++ + return QListWidget::selectionCommand(index, event); + } + +diff --git a/src/lightdm-greeter/widgets/login-button.cpp b/src/lightdm-greeter/widgets/login-button.cpp +index 428f18d..63f9367 100644 +--- a/src/lightdm-greeter/widgets/login-button.cpp ++++ b/src/lightdm-greeter/widgets/login-button.cpp +@@ -24,9 +24,10 @@ namespace SessionGuard + { + namespace Greeter + { +-LoginButton::LoginButton(QWidget *parent) : QWidget(parent), +- ui(new Ui::LoginButton), +- m_pressed(false) ++LoginButton::LoginButton(QWidget *parent) ++ : QWidget(parent), ++ ui(new Ui::LoginButton), ++ m_pressed(false) + { + ui->setupUi(this); + ui->label_text->setText(tr("login")); +diff --git a/src/lightdm-greeter/widgets/user-info.h b/src/lightdm-greeter/widgets/user-info.h +index c7ca0d2..0aceaa8 100644 +--- a/src/lightdm-greeter/widgets/user-info.h ++++ b/src/lightdm-greeter/widgets/user-info.h +@@ -24,6 +24,8 @@ namespace Greeter + { + struct UserInfo + { ++ UserInfo():uid(0),hasMessage(false),loggedIn(false) ++ {}; + QString name; + QString realName; + QString session; +diff --git a/src/lightdm-greeter/widgets/user-list.cpp b/src/lightdm-greeter/widgets/user-list.cpp +index e59fa8b..1b9be4b 100644 +--- a/src/lightdm-greeter/widgets/user-list.cpp ++++ b/src/lightdm-greeter/widgets/user-list.cpp +@@ -281,8 +281,9 @@ QString UserList::getIconByUserName(const QString &userName) + UserInfo UserList::getUserInfoByUserName(const QString &userName) + { + UserInfo info; ++ int rowCout = m_filterModel.rowCount(QModelIndex()); + +- for (int i = 0; i < m_filterModel.rowCount(QModelIndex()); i++) ++ for (int i = 0; i < rowCout; i++) + { + UserInfo userInfo; + getUserInfoFromModel(i, userInfo); +@@ -339,10 +340,10 @@ void UserList::onModelRowsRemoved(const QModelIndex &parent, int first, int last + const QString userName = item->text(); + QListWidgetItem *removedItem = ui->userList->takeItem(i); + delete removedItem; +- emit userRemoved(userName); ++ emit this->userRemoved(userName); + } + int newCount = userCount(); +- emit userCountChanged(oldCount, newCount); ++ emit this->userCountChanged(oldCount, newCount); + updateGeometry(); + } + +@@ -359,7 +360,7 @@ void UserList::onModelRowsInserted(const QModelIndex &parent, int first, int las + KLOG_DEBUG() << "row inserted: " + << "cout[" << ui->userList->count() << "]"; + updateGeometry(); +- emit userCountChanged(oldCount, newCount); ++ emit this->userCountChanged(oldCount, newCount); + } + + void UserList::onAppFocusChanged(QWidget *oldFocus, QWidget *newFocus) +@@ -409,10 +410,10 @@ void UserList::onDataChanged(const QModelIndex &topLeft, + break; + } + }; +- int startRow = topLeft.row(); +- int endRow = topLeft.row(); + +- // FIXME: QLightdDM此处信号发出时roles为默认参数, 无法判断数据变化范围 ++ int startRow = topLeft.row(); ++ int endRow = bottomRight.row(); ++ // NOTE: QLightdDM此处信号发出时roles为默认参数, 无法判断数据变化范围 + // 检查图片更新,用户列表中的顺序可能和用户不一致 + for (int i = startRow; i <= endRow; i++) + { +diff --git a/src/lightdm-greeter/widgets/user-list.h b/src/lightdm-greeter/widgets/user-list.h +index e58b39c..32730cc 100644 +--- a/src/lightdm-greeter/widgets/user-list.h ++++ b/src/lightdm-greeter/widgets/user-list.h +@@ -64,7 +64,7 @@ private slots: + void onAppFocusChanged(QWidget* oldFocus,QWidget* newFocus); + void onDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector roles); + +-Q_SIGNALS: ++signals: + void userActivated(const UserInfo &userInfo); + void userCountChanged(int oldCount, int newCount); + void userRemoved(const QString &userName); +diff --git a/src/polkit-agent/auth-polkit.h b/src/polkit-agent/auth-polkit.h +index 063a964..2b3cb91 100644 +--- a/src/polkit-agent/auth-polkit.h ++++ b/src/polkit-agent/auth-polkit.h +@@ -59,7 +59,7 @@ private slots: + void handleSessionShowInfo(const QString& text); + + private: +- AuthControllerInterface* m_controllerInterface; ++ AuthControllerInterface* m_controllerInterface = nullptr; + QString m_cookie; + PolkitQt1::Agent::Session* m_session = nullptr; + PolkitQt1::Identity m_identity; +diff --git a/src/polkit-agent/dialog.cpp b/src/polkit-agent/dialog.cpp +index 6094a71..460e834 100644 +--- a/src/polkit-agent/dialog.cpp ++++ b/src/polkit-agent/dialog.cpp +@@ -247,7 +247,7 @@ void Dialog::onAuthComplete(bool success) + { + if (m_authController->isAuthenticated()) + { +- emit completed(true); ++ emit this->completed(true); + this->close(); + return; + } +diff --git a/src/polkit-agent/moreinfo-button.cpp b/src/polkit-agent/moreinfo-button.cpp +index 9415f11..babdac2 100644 +--- a/src/polkit-agent/moreinfo-button.cpp ++++ b/src/polkit-agent/moreinfo-button.cpp +@@ -27,17 +27,13 @@ namespace SessionGuard + namespace PolkitAgent + { + MoreInfoButton::MoreInfoButton(QWidget* parent) +- : QWidget(parent) ++ : QWidget(parent), ++ m_expandPix(style()->standardPixmap(QStyle::SP_ArrowUp)), ++ m_shrinkPix(style()->standardPixmap(QStyle::SP_ArrowRight)), ++ m_iconSize(QSize(16, 16)), ++ m_text(QString("more info")) + { +- m_shrinkPix = style()->standardPixmap(QStyle::SP_ArrowRight); +- m_expandPix = style()->standardPixmap(QStyle::SP_ArrowUp); +- +- m_iconSize = QSize(16, 16); +- +- // m_shrinkPix = m_shrinkPix.scaled(m_iconSize,Qt::KeepAspectRatio,Qt::SmoothTransformation); +- // m_expandPix = m_expandPix.scaled(m_iconSize,Qt::KeepAspectRatio,Qt::SmoothTransformation); +- +- setText("more info"); ++ setText(m_text); + } + + MoreInfoButton::~MoreInfoButton() +diff --git a/src/screensaver-dialog/auth-pam.h b/src/screensaver-dialog/auth-pam.h +index 210ad6f..99e0bb5 100644 +--- a/src/screensaver-dialog/auth-pam.h ++++ b/src/screensaver-dialog/auth-pam.h +@@ -60,7 +60,7 @@ private: + void handleChildExit(); + + private: +- AuthControllerInterface* m_interface; ++ AuthControllerInterface* m_interface = nullptr; + QString m_userName; + + bool m_isAuthenticated = false; +diff --git a/src/screensaver-dialog/checkpass-common/pam-message.cpp b/src/screensaver-dialog/checkpass-common/pam-message.cpp +index 3cd50f5..76fce7f 100644 +--- a/src/screensaver-dialog/checkpass-common/pam-message.cpp ++++ b/src/screensaver-dialog/checkpass-common/pam-message.cpp +@@ -43,12 +43,12 @@ bool kiran_pam_message_send(int fd, QJsonDocument& content) + QByteArray qByteArray = content.toJson(); + uint32_t contentLength = qByteArray.length(); + +- if (sendStream.writeRawData((const char*)&contentLength, sizeof(contentLength)) == -1) ++ if (sendStream.writeRawData(reinterpret_cast(&contentLength), sizeof(contentLength)) == -1) + { + return false; + } + +- if (sendStream.writeRawData((const char*)qByteArray.data(), qByteArray.length()) == -1) ++ if (sendStream.writeRawData(const_cast(qByteArray.data()), qByteArray.length()) == -1) + { + return false; + } +diff --git a/src/screensaver-dialog/frame.cpp b/src/screensaver-dialog/frame.cpp +index 590c19d..73f50dc 100644 +--- a/src/screensaver-dialog/frame.cpp ++++ b/src/screensaver-dialog/frame.cpp +@@ -50,9 +50,9 @@ Frame::Frame(Kiran::ScreenSaver::Interface* ksinterface, Power* power, QWidget* + m_power(power), + m_keyboard(nullptr), + m_ksInterface(ksinterface), ++ m_userName(UserManager::getCurrentUser()), + m_authProxy(nullptr) + { +- m_userName = UserManager::getCurrentUser(); + KLOG_DEBUG() << "locker create for" << m_userName; + initMenus(); + initUI(); +@@ -102,9 +102,9 @@ void Frame::initUI() + { + // 初始化添加右下控件 + // 获取菜单弹出坐标,按钮和触发菜单右对齐 +- // FIXME: Qt在特定虚拟机环境下QMenu::popup传入正确的pos时,QMenu通过Pos找到screen,但screen的大小错误(为调整分辨率之前的分辨率) ++ // NOTE: Qt在特定虚拟机环境下QMenu::popup传入正确的pos时,QMenu通过Pos找到screen,但screen的大小错误(为调整分辨率之前的分辨率) + // 导致popup pos被修改成在错误的屏幕范围内 +- auto getMenuPopupPos = [this](QMenu* menu, const QToolButton* triggerBtn) -> QPoint ++ auto getMenuPopupPos = [](QMenu* menu, const QToolButton* triggerBtn) -> QPoint + { + QSize menuSize = menu->actions().count() == 0 ? QSize(92, 10) : menu->sizeHint(); + QPoint btnRightTopPos = triggerBtn->mapToGlobal(QPoint(triggerBtn->width(), 0)); +@@ -137,7 +137,7 @@ void Frame::initUI() + }; + + // clang-format off +- m_btnSwitchToGreeter = createActionButton("btn_switchuser", tr("switch to greeter"), [](){ ++ m_btnSwitchToGreeter = createActionButton("btn_switchuser", tr("switch to greeter"), [](){ + KLOG_DEBUG() << "switch to greeter clicked"; + UserManager::switchToGreeter(); + }); +@@ -159,7 +159,7 @@ void Frame::initUI() + return; + } + QPoint pos = getMenuPopupPos(m_powerMenu,m_btnPower); +- m_powerMenu->popup(pos); ++ m_powerMenu->popup(pos); + }); + // clang-format on + +diff --git a/src/screensaver-dialog/prefs.cpp b/src/screensaver-dialog/prefs.cpp +index 2e12e91..65fb565 100644 +--- a/src/screensaver-dialog/prefs.cpp ++++ b/src/screensaver-dialog/prefs.cpp +@@ -33,14 +33,14 @@ void Prefs::init() + ///power + settings.beginGroup("Power"); + +- auto canPowerOff = settings.value("can-poweroff"); +- m_canPowerOff = canPowerOff.toBool(); ++ auto powerOffEnable = settings.value("can-poweroff"); ++ m_canPowerOff = powerOffEnable.toBool(); + +- auto canReboot = settings.value("can-reboot"); +- m_canReboot = canReboot.toBool(); ++ auto rebootEnable = settings.value("can-reboot"); ++ m_canReboot = rebootEnable.toBool(); + +- auto canSuspend = settings.value("can-suspend"); +- m_canSuspend = canSuspend.toBool(); ++ auto suspendEnable = settings.value("can-suspend"); ++ m_canSuspend = suspendEnable.toBool(); + } + + Prefs::~Prefs() +diff --git a/src/screensaver-dialog/session-guard-checkpass/main.cpp b/src/screensaver-dialog/session-guard-checkpass/main.cpp +index 9bad98d..30e8d91 100644 +--- a/src/screensaver-dialog/session-guard-checkpass/main.cpp ++++ b/src/screensaver-dialog/session-guard-checkpass/main.cpp +@@ -33,7 +33,7 @@ int conversation(int num_msg, const pam_message **msgs, pam_response **resp, voi + struct pam_response *reply = NULL; + char *username = nullptr; + +- reply = (struct pam_response *)calloc(num_msg, sizeof(*reply)); ++ reply = static_cast(calloc(num_msg, sizeof(pam_response))); + if (reply == nullptr) + { + KLOG_ERROR() << "can't malloc memory for replies,return PAM_CONV_ERR"; +@@ -56,14 +56,14 @@ int conversation(int num_msg, const pam_message **msgs, pam_response **resp, voi + + if (!kiran_pam_message_send_event(CHANNEL_WRITE, &event)) + { +- //发送消息失败 ++ // 发送消息失败 + KLOG_DEBUG() << "send pam message to parent process failed!"; + replyRet = PAM_CONV_ERR; + } + else + { + PamEvent *recvReply = nullptr; +- //接收消息失败 ++ // 接收消息失败 + if (!kiran_pam_message_recv_event(CHANNEL_READ, &recvReply)) + { + KLOG_ERROR() << "recv pam prompt reply failed"; +@@ -71,7 +71,7 @@ int conversation(int num_msg, const pam_message **msgs, pam_response **resp, voi + } + else + { +- //消息类型不正确 ++ // 消息类型不正确 + if (recvReply->type() != PamEvent::PromptReply) + { + KLOG_ERROR() << "recv event is not reply!"; +@@ -80,8 +80,8 @@ int conversation(int num_msg, const pam_message **msgs, pam_response **resp, voi + else + { + auto replyEvent = dynamic_cast(recvReply); +- //KLOG_DEBUG() << "recv prompt reply:" << replyEvent->result() << replyEvent->text(); +- //消息返回失败 ++ // KLOG_DEBUG() << "recv prompt reply:" << replyEvent->result() << replyEvent->text(); ++ // 消息返回失败 + if (!replyEvent->result()) + { + replyRet = PAM_CONV_ERR; +@@ -89,8 +89,10 @@ int conversation(int num_msg, const pam_message **msgs, pam_response **resp, voi + else + { + reply[i].resp_retcode = PAM_SUCCESS; +- reply[i].resp = (char *)calloc(1, replyEvent->text().length() + 1); +- strcpy(reply[i].resp, replyEvent->text().toStdString().c_str()); ++ reply[i].resp = static_cast(calloc(1, replyEvent->text().length() + 1)); ++ strncpy(reply[i].resp, ++ replyEvent->text().toStdString().c_str(), ++ replyEvent->text().length()); + } + } + } +@@ -103,7 +105,7 @@ int conversation(int num_msg, const pam_message **msgs, pam_response **resp, voi + MessageEvent messageEvent(msg->msg_style == PAM_ERROR_MSG, msg->msg); + if (!kiran_pam_message_send_event(CHANNEL_WRITE, &messageEvent)) + { +- //发送消息失败 ++ // 发送消息失败 + KLOG_DEBUG() << "send pam message to parent process failed!"; + replyRet = PAM_CONV_ERR; + } +@@ -141,7 +143,7 @@ int main(int argc, char *argv[]) + "kiran-screensaver-dialog", + "kiran-session-guard-checkpass"); + +- ///判断参数合法性 ++ /// 判断参数合法性 + if (argc != 3) + { + KLOG_ERROR() << "usage: pam-authproxy-checkpass READFD WRITEFD USERNAME"; +@@ -172,8 +174,8 @@ int main(int argc, char *argv[]) + return EXIT_FAILURE; + } + +- ///安全性 +- //可以参考lightdm session-child ++ /// 安全性 ++ // 可以参考lightdm session-child + /* Protect memory from being paged to disk, as we deal with passwords */ + mlockall(MCL_CURRENT | MCL_FUTURE); + +@@ -187,7 +189,7 @@ int main(int argc, char *argv[]) + << "\t write fd: " << CHANNEL_WRITE << "\n" + << "\t authproxy user name:" << userName; + +- ///开始pam认证 ++ /// 开始pam认证 + // clang-format off + struct pam_conv conv = { + .conv = &conversation, +@@ -201,7 +203,7 @@ int main(int argc, char *argv[]) + KLOG_WARNING() << "failed to start pam:" << pam_strerror(pamh, ret); + return EXIT_FAILURE; + } +- ++ + int authRes = PAM_SUCCESS; + authRes = pam_authenticate(pamh, 0); + const char *newUserName; +-- +2.27.0 + diff --git a/0014-fix-virutalkeyboard-Add-detection-for-whether-to-ins.patch b/0014-fix-virutalkeyboard-Add-detection-for-whether-to-ins.patch new file mode 100644 index 0000000..b392d34 --- /dev/null +++ b/0014-fix-virutalkeyboard-Add-detection-for-whether-to-ins.patch @@ -0,0 +1,140 @@ +From a76ad7de22f16efcad20236ec95dfa666ab3a8fa Mon Sep 17 00:00:00 2001 +From: liuxinhao +Date: Tue, 6 Feb 2024 10:14:07 +0800 +Subject: [PATCH 14/16] fix(virutalkeyboard): Add detection for whether to + install a virtual keyboard +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +- 新增对于是否安装虚拟键盘的检测 +--- + lib/utils/virtual-keyboard.cpp | 14 ++++++++++++++ + lib/utils/virtual-keyboard.h | 5 +++-- + src/lightdm-greeter/frame.cpp | 11 +++++++++-- + src/screensaver-dialog/frame.cpp | 9 ++++++++- + 4 files changed, 34 insertions(+), 5 deletions(-) + +diff --git a/lib/utils/virtual-keyboard.cpp b/lib/utils/virtual-keyboard.cpp +index 292740a..3e1e7dd 100644 +--- a/lib/utils/virtual-keyboard.cpp ++++ b/lib/utils/virtual-keyboard.cpp +@@ -22,6 +22,7 @@ + #include + #include + #include ++#include + + #define ONBOARD_LAYOUT "Compact" + #define ONBOARD_THEME "Blackboard" +@@ -61,10 +62,18 @@ VirtualKeyboard::~VirtualKeyboard() + + bool VirtualKeyboard::init(QWidget *parent) + { ++ if( !QFileInfo::exists("/usr/bin/onboard") ) ++ { ++ m_isSupported = false; ++ return false; ++ } ++ + if (m_keyboardWidget != nullptr) + { + return false; + } ++ ++ m_isSupported = true; + m_process = new QProcess(this); + connect(m_process, QOverload::of(&QProcess::finished), + this, &VirtualKeyboard::slot_finished); +@@ -98,6 +107,11 @@ bool VirtualKeyboard::init(QWidget *parent) + return true; + } + ++bool VirtualKeyboard::isSupported() ++{ ++ return m_isSupported; ++} ++ + bool VirtualKeyboard::isVisible() + { + if (m_keyboardWidget == nullptr) +diff --git a/lib/utils/virtual-keyboard.h b/lib/utils/virtual-keyboard.h +index 4670105..99bf405 100644 +--- a/lib/utils/virtual-keyboard.h ++++ b/lib/utils/virtual-keyboard.h +@@ -29,8 +29,9 @@ public: + ~VirtualKeyboard(); + + static VirtualKeyboard *instance(); +- + bool init(QWidget *parent = nullptr); ++ bool isSupported(); ++ + void hide(); + bool isVisible(); + void showAdjustSize(QWidget *parent = nullptr); +@@ -39,11 +40,11 @@ public: + + public slots: + void slot_finished(int exitCode, QProcess::ExitStatus exitStatus); +- + private slots: + void slotReadyReadStandardOutput(); + + private: ++ bool m_isSupported = false; + QWidget *m_keyboardWidget = nullptr; + QProcess *m_process = nullptr; + QWidget *m_keyboardEmbed = nullptr; +diff --git a/src/lightdm-greeter/frame.cpp b/src/lightdm-greeter/frame.cpp +index e4afcb9..085139a 100644 +--- a/src/lightdm-greeter/frame.cpp ++++ b/src/lightdm-greeter/frame.cpp +@@ -306,7 +306,14 @@ void Frame::initUI() + + rbBtnLayout->addItem(rbBtnLayoutItem); + rbBtnLayout->addWidget(m_btnSession, 1); +- rbBtnLayout->addWidget(m_btnKeyboard, 1); ++ if( VirtualKeyboard::instance()->isSupported() ) ++ { ++ rbBtnLayout->addWidget(m_btnKeyboard, 1); ++ } ++ else ++ { ++ m_btnKeyboard->setVisible(false); ++ } + rbBtnLayout->addWidget(m_btnPower, 1); + + setRightBottomWidget(rbBtnWidget); +@@ -316,7 +323,7 @@ void Frame::initAuth() + { + AuthLightdm* auth = new AuthLightdm(m_greeter); + LoginFrame::initAuth(auth); +- connect(m_greeter.data(),&QLightDM::Greeter::autologinTimerExpired,this,&Frame::onAutoLoginTimeout); ++ connect(m_greeter.data(), &QLightDM::Greeter::autologinTimerExpired, this, &Frame::onAutoLoginTimeout); + } + + void Frame::initConnection() +diff --git a/src/screensaver-dialog/frame.cpp b/src/screensaver-dialog/frame.cpp +index 73f50dc..04f0f30 100644 +--- a/src/screensaver-dialog/frame.cpp ++++ b/src/screensaver-dialog/frame.cpp +@@ -175,7 +175,14 @@ void Frame::initUI() + + rbBtnLayout->addItem(rbBtnLayoutItem); + rbBtnLayout->addWidget(m_btnSwitchToGreeter, 1); +- rbBtnLayout->addWidget(m_btnKeyboard, 1); ++ if( VirtualKeyboard::instance()->isSupported() ) ++ { ++ rbBtnLayout->addWidget(m_btnKeyboard, 1); ++ } ++ else ++ { ++ m_btnKeyboard->setVisible(false); ++ } + rbBtnLayout->addWidget(m_btnPower, 1); + setRightBottomWidget(rbBtnWidget); + +-- +2.27.0 + diff --git a/0015-fix-cursor-incorrect-scaling-cursor-size.patch b/0015-fix-cursor-incorrect-scaling-cursor-size.patch new file mode 100644 index 0000000..c3908ea --- /dev/null +++ b/0015-fix-cursor-incorrect-scaling-cursor-size.patch @@ -0,0 +1,158 @@ +From 3d55d3e81a2de1b91994473695b2bffa27c47b1b Mon Sep 17 00:00:00 2001 +From: liuxinhao +Date: Tue, 6 Feb 2024 13:45:31 +0800 +Subject: [PATCH 15/16] fix(cursor): incorrect scaling cursor size +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +- 错误的缩放光标大小 +--- + lib/utils/scaling-helper.cpp | 10 +++++----- + lib/utils/scaling-helper.h | 6 +++--- + src/lightdm-greeter/main.cpp | 22 +++++++++++++--------- + 3 files changed, 21 insertions(+), 17 deletions(-) + +diff --git a/lib/utils/scaling-helper.cpp b/lib/utils/scaling-helper.cpp +index 697744e..fcfd608 100644 +--- a/lib/utils/scaling-helper.cpp ++++ b/lib/utils/scaling-helper.cpp +@@ -23,12 +23,12 @@ namespace Kiran + { + namespace SessionGuard + { +-void ScalingHelper::set_scale_factor(double factor) ++void ScalingHelper::set_scale_factor(qreal factor) + { + qputenv("QT_SCALE_FACTOR", QString::number(factor).toUtf8()); + } + +-void ScalingHelper::auto_calculate_screen_scaling() ++qreal ScalingHelper::auto_calculate_screen_scaling() + { + Display *display = nullptr; + XRRScreenResources *resources = nullptr; +@@ -40,7 +40,7 @@ void ScalingHelper::auto_calculate_screen_scaling() + { + KLOG_WARNING("auto_calculate_screen_scaling failed,set QT_AUTO_SCREEN_SCALE_FACTOR=1"); + qputenv("QT_AUTO_SCREEN_SCALE_FACTOR", "1"); +- return; ++ return scale_factor; + } + + resources = XRRGetScreenResourcesCurrent(display, DefaultRootWindow(display)); +@@ -59,7 +59,7 @@ void ScalingHelper::auto_calculate_screen_scaling() + } + KLOG_WARNING("auto_calculate_screen_scaling failed,set QT_AUTO_SCREEN_SCALE_FACTOR=1"); + qputenv("QT_AUTO_SCREEN_SCALE_FACTOR", "1"); +- return; ++ return scale_factor; + } + + for (int i = 0; i < resources->noutput; i++) +@@ -132,7 +132,7 @@ void ScalingHelper::auto_calculate_screen_scaling() + KLOG_WARNING() << "set scale factor failed."; + } + +- return; ++ return scale_factor; + } + + } // namespace SessionGuard +diff --git a/lib/utils/scaling-helper.h b/lib/utils/scaling-helper.h +index 669fef1..1a3eb9b 100644 +--- a/lib/utils/scaling-helper.h ++++ b/lib/utils/scaling-helper.h +@@ -13,15 +13,15 @@ + */ + + #pragma once +- ++#include + namespace Kiran + { + namespace SessionGuard + { + namespace ScalingHelper + { +-void auto_calculate_screen_scaling(); +-void set_scale_factor(double factor); ++qreal auto_calculate_screen_scaling(); ++void set_scale_factor(qreal factor); + } // namespace ScalingHelper + + } // namespace SessionGuard +diff --git a/src/lightdm-greeter/main.cpp b/src/lightdm-greeter/main.cpp +index 61255ec..254911a 100644 +--- a/src/lightdm-greeter/main.cpp ++++ b/src/lightdm-greeter/main.cpp +@@ -31,20 +31,22 @@ using namespace ::Kiran::SessionGuard; + using namespace ::Kiran::SessionGuard::Greeter; + + // 根据配置项,调整缩放率 +-void adjustScaleFactor(Prefs* prefs) ++qreal adjustScaleFactor(Prefs* prefs) + { ++ qreal factor = 1.0; ++ + /// 设置缩放比 + switch (prefs->scale_mode()) + { + case GREETER_SCALING_MODE_AUTO: + { +- ScalingHelper::auto_calculate_screen_scaling(); ++ factor = ScalingHelper::auto_calculate_screen_scaling(); + break; + } + case GREETER_SCALING_MODE_MANUAL: + { +- double scaleFcator = prefs->scale_factor(); +- ScalingHelper::set_scale_factor(scaleFcator); ++ factor = prefs->scale_factor(); ++ ScalingHelper::set_scale_factor(factor); + break; + } + case GREETER_SCALING_MODE_DISABLE: +@@ -53,6 +55,8 @@ void adjustScaleFactor(Prefs* prefs) + KLOG_ERROR("enable-scaling: unsupported options %d", prefs->scale_mode()); + break; + } ++ ++ return factor; + } + + // 加载样式表 +@@ -91,12 +95,12 @@ bool loadTranslator() + } + + // 设置当前光标缩放,以及Root窗口光标避免开始会话到进入会话之中的空窗期光标错误显示 +-void setCursor(Prefs* prefs) ++void setCursor(qreal factor) + { + // 光标放大 +- if (!CursorHelper::setDefaultCursorSize(prefs->scale_factor())) ++ if (!CursorHelper::setDefaultCursorSize(factor)) + { +- KLOG_ERROR("set default cursor size for factor %d failed!", prefs->scale_factor()); ++ KLOG_ERROR("set default cursor size for factor %f failed!", factor); + } + + // 登录成功和进入桌面的间隔会显示根窗口,为了避免显示根窗口时光标显示为"X",需设置ROOT窗口光标 +@@ -121,12 +125,12 @@ int main(int argc, char* argv[]) + + Prefs::globalInit(); + auto prefs = Prefs::getInstance(); +- adjustScaleFactor(prefs); ++ qreal factor = adjustScaleFactor(prefs); + + QApplication app(argc, argv); + QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); + +- setCursor(prefs); ++ setCursor(factor); + loadTranslator(); + loadStyleSheet(); + +-- +2.27.0 + diff --git a/0016-fix-polkit-ts-fix-untranslated-text-from-polkit-agen.patch b/0016-fix-polkit-ts-fix-untranslated-text-from-polkit-agen.patch new file mode 100644 index 0000000..d1c1e1b --- /dev/null +++ b/0016-fix-polkit-ts-fix-untranslated-text-from-polkit-agen.patch @@ -0,0 +1,146 @@ +From a99db7807474f51454a0941d8ddbe272b6945050 Mon Sep 17 00:00:00 2001 +From: liuxinhao +Date: Tue, 6 Feb 2024 14:22:04 +0800 +Subject: [PATCH 16/16] fix(polkit ts): fix untranslated text from polkit-agent +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +- 修复kiran-polkit-agent中未翻译的文本 +--- + src/polkit-agent/dialog.cpp | 2 +- + src/polkit-agent/listener.cpp | 2 +- + translations/kiran-polkit-agent.zh_CN.ts | 39 ++++++++++++++++-------- + 3 files changed, 29 insertions(+), 14 deletions(-) + +diff --git a/src/polkit-agent/dialog.cpp b/src/polkit-agent/dialog.cpp +index 460e834..e7da7fe 100644 +--- a/src/polkit-agent/dialog.cpp ++++ b/src/polkit-agent/dialog.cpp +@@ -253,7 +253,7 @@ void Dialog::onAuthComplete(bool success) + } + else + { +- onAuthShowMessage("Authentication error", MessageTypeError); ++ onAuthShowMessage(tr("Authentication error"), MessageTypeError); + + ui->edit->lineEdit()->clear(); + ui->edit->setEnabled(false); +diff --git a/src/polkit-agent/listener.cpp b/src/polkit-agent/listener.cpp +index 7474329..8a79c0a 100644 +--- a/src/polkit-agent/listener.cpp ++++ b/src/polkit-agent/listener.cpp +@@ -147,7 +147,7 @@ void Listener::onAuthDialogCompleted(bool isSuccess) + { + if (!isSuccess) + { +- m_result->setError("Authentication Error"); ++ m_result->setError(tr("Authentication Error")); + } + m_inProcess = false; + +diff --git a/translations/kiran-polkit-agent.zh_CN.ts b/translations/kiran-polkit-agent.zh_CN.ts +index ae75cc2..452e955 100644 +--- a/translations/kiran-polkit-agent.zh_CN.ts ++++ b/translations/kiran-polkit-agent.zh_CN.ts +@@ -74,7 +74,7 @@ + + Kiran::SessionGuard::AuthController + +- ++ + Failed to authenticate + 认证失败 + +@@ -82,32 +82,32 @@ + + Kiran::SessionGuard::AuthTypeSwitcher + +- ++ + face auth + 人脸认证 + + +- ++ + finger auth + 人脸认证 + + +- ++ + password auth + 密码认证 + + +- ++ + finger vein auth + 指静脉认证 + + +- ++ + iris auth + 虹膜认证 + + +- ++ + ukey auth + UKey认证 + +@@ -120,29 +120,44 @@ + 认证 + + +- ++ + fingerprint auth + 指纹认证 + + +- ++ + face auth + 人脸认证 + + +- ++ + fingervein auth + 指静脉认证 + ++ ++ ++ iris auth ++ 虹膜认证 ++ ++ ++ ++ Authentication error ++ 认证错误 ++ + + + Kiran::SessionGuard::PolkitAgent::Listener + +- +- ++ ++ + Existing authentication is in progress, please try again later + 已存在正在进行的认证,请稍后再进行尝试 + ++ ++ ++ Authentication Error ++ 认证错误 ++ + + + Listener +-- +2.27.0 + diff --git a/kiran-session-guard.spec b/kiran-session-guard.spec index a028333..b7e703d 100644 --- a/kiran-session-guard.spec +++ b/kiran-session-guard.spec @@ -1,6 +1,13 @@ +%if "%{?ks_custom_name}" == "PG" || "%{?kylin_custom_name}" == "PG" + %global hidden_admin 1 + %global hideen_power_menu 1 +%endif + +%global show_virtual_keyboard 0 + Name: kiran-session-guard Version: 2.5.1 -Release: 9%{?dist} +Release: 11%{?dist} Summary: Kiran desktop environment login and lock screen dialog Summary(zh_CN): Kiran桌面环境登录和解锁框 @@ -18,8 +25,11 @@ Patch0008: 0008-fix-styleditemdelegate-updateEditorGeometry-to-updat.patch Patch0009: 0009-fix-autologin-timeout-Fix-issues-caused-by-automatic.patch Patch0010: 0010-fix-scale-Fix-the-issue-of-manual-scaling-not-taking.patch Patch0011: 0011-fix-login-background-Add-login-background-setting-ti.patch - -%define SHOW_VIRTUAL_KEYBOARD 0 +Patch0012: 0012-feat-ci-Connect-to-internal-CI-processes.patch +Patch0013: 0013-fix-code-scanning-Fix-some-static-code-scanning-issu.patch +Patch0014: 0014-fix-virutalkeyboard-Add-detection-for-whether-to-ins.patch +Patch0015: 0015-fix-cursor-incorrect-scaling-cursor-size.patch +Patch0016: 0016-fix-polkit-ts-fix-untranslated-text-from-polkit-agen.patch BuildRequires: cmake BuildRequires: gcc-c++ @@ -68,7 +78,7 @@ Requires: libXrandr Requires: libXcursor Requires: glib2 Requires: pam -%if %{SHOW_VIRTUAL_KEYBOARD} == 1 +%if 0%{show_virtual_keyboard} == 1 Requires: onboard %endif @@ -109,9 +119,18 @@ Kiran desktop environment polkit agent %build %{__mkdir} -p %{buildroot} %cmake -DBUILD_SHARED_LIBS:BOOL=OFF \ -%if %{SHOW_VIRTUAL_KEYBOARD} == 1 +%if 0%{?show_virtual_keyboard} -DSHOW_VIRTUAL_KEYBOARD=on \ %endif +%if 0%{?hidden_admin} +-DHIDDEN_USER=secadm,sysadm,audadm \ +%endif +%if 0%{?hideen_power_menu} +-DCAN_POWER_OFF=false \ +-DCAN_REBOOT=false \ +-DCAN_SUSPEND=false \ +-DCAN_HIBERNATE=false \ +%endif make %{?_smp_mflags} @@ -155,13 +174,33 @@ gtk-update-icon-cache -f /usr/share/icons/hicolor/ rm -rf %{buildroot} %changelog -* Thu Jan 18 2024 liuxinhao - 2.5.1-9 +* Wed Feb 21 2024 liuxinhao - 2.5.1-11 +- KYOS-B: Fix ci issues +- KYOS-B: Add virtual keyboard detection(#29712) +- KYOS-B: incorrect scaling cursor size(#29286) +- KYOS-B: fix untranslated text from polkit-agent(#29452) + +* Fri Jan 19 2024 liuxinhao - 2.5.1-10.kb2 +- KYOS-B: Adjust the relevant compilation macros in the spec file + +* Thu Jan 18 2024 liuxinhao - 2.5.1-9.kb1 +- KYOS-B: Add login background setting title(#25063) + +* Thu Jan 18 2024 liuxinhao - 2.5.1-8.kb2 +- rebuild for KiranUI-2.6-next + +* Thu Jan 18 2024 liuxinhao - 2.5.1-8.kb1 - KYOS-B: fix the issue of manual scaling not taking effect(#25011) - KYOS-B: fix issues caused by automatic login timeout(#25015) -- KYOS-B: add login background settings title(#25063) -* Thu Oct 26 2023 liuxinhao - 2.5.1-7.kb1 -- KYOS-B: fix updateEditorGeometry to update the wrong size of ItemWidgets in QStyledItemDelegate(#16513) +* Wed Dec 06 2023 liuxinhao - 2.5.1-7.kb2 +- rebuild for KiranUi-2.6-next + +* Wed Nov 29 2023 kpkg - 2.5.1-7.kb1 +- rebuild for KY3.4-5-GC-KiranUI-2.5 + +* Thu Oct 26 2023 liuxinhao - 2.5.1-7 +- KYOS-F: fix updateEditorGeometry to update the wrong size of ItemWidgets in QStyledItemDelegate(#16513) * Tue Sep 12 2023 yinhongchang - 2.5.1-6.kb1 - KYOS-F: fits the Qt5.9.7 interface(#15019) @@ -184,7 +223,7 @@ rm -rf %{buildroot} - KYOS-B: Remove the restriction on polkit-agent authentication errors(#I7961L) * Wed May 24 2023 liuxinhao - 2.5.1-1 -- KYOS-F: If the authentication fails, the re-authentication button is displayed.(#69229) +- KYOS-F: If the authentication fails, the re-authentication button is displayed.(#69229) - KYOS-B: Fixed an issue caused by selecting default desktop session(#69204,#69220) - KYOS-F: Supports UKey, Iris, and face authentication @@ -205,16 +244,16 @@ rm -rf %{buildroot} - KYOS-T: add some translation * Tue Apr 04 2023 liuxinhao - 2.5.0-1 -- KYOS-F: Supports the new biometric authentication framework and adds the authorization prompt box +- KYOS-F: Supports the new biometric authentication framework and adds the authorization prompt box * Fri Dec 09 2022 liuxinhao - 2.4.0-4 - KYOS-F: Fix the zombie process caused by waitpid reclaiming that the authentication process is not blocked after the command is invoked in the unlock box -- KYOS-F: unlock interface calls onboard, and the onboard process cycle is consistent with the unlock interface +- KYOS-F: unlock interface calls onboard, and the onboard process cycle is consistent with the unlock interface - KYOS-F: Use socket to notify SIGTERM signal, and process SIGTERM signal in the main thread to avoid abnormal exit - KYOS-F: Invoke virtual keyboard initialization during plug-in initialization * Fri Nov 18 2022 liuxinhao - 2.4.0-3 -- KYOS-F: fix the failure to update the drawing in time when setting the default avatar(#I61QHP) +- KYOS-F: fix the failure to update the drawing in time when setting the default avatar(#I61QHP) * Mon Nov 14 2022 liuxinhao - 2.4.0-2 - KYOS-F: fix PAM authorization bypass due to incorrect usage -- Gitee