From 740fd0b2b66f2996e2d878e6b209e3ac16caaf91 Mon Sep 17 00:00:00 2001 From: deepin-ci-robot Date: Wed, 13 May 2026 07:32:39 +0000 Subject: [PATCH] sync: from linuxdeepin/dde-session-shell Synchronize source files from linuxdeepin/dde-session-shell. Source-pull-request: https://github.com/linuxdeepin/dde-session-shell/pull/67 --- CMakeLists.txt | 24 +++++++++------------- files/snipe/scripts/lightdm-deepin-greeter | 7 +++++++ src/app/greeter-display-setting.cpp | 15 ++++++++++++-- 3 files changed, 30 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8832348eb..1fdcafc39 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -384,19 +384,15 @@ if (DISABLE_DSS_SNIPE) ) endif() -if (DISABLE_DSS_SNIPE) - add_executable(greeter-display-setting - src/app/greeter-display-setting.cpp - ) +add_executable(greeter-display-setting + src/app/greeter-display-setting.cpp +) - target_link_libraries(greeter-display-setting - ${Qt_LIBS} - ${XCB_EWMH_LIBRARIES} - ${DtkCore_LIBRARIES} - ${Qt5X11Extras_LIBRARIES} - ${Qt5DBus_LIBRARIES} - ) -endif () +target_link_libraries(greeter-display-setting + ${Qt_LIBS} + ${XCB_EWMH_LIBRARIES} + Dtk${DTK_VERSION_MAJOR}::Core +) if (DISABLE_DSS_SNIPE) add_subdirectory(lighter-greeter) @@ -407,7 +403,6 @@ add_subdirectory(src/pam-inhibit-autologin) if (DISABLE_DSS_SNIPE) # bin - install(TARGETS dde-lock lightdm-deepin-greeter greeter-display-setting DESTINATION ${CMAKE_INSTALL_BINDIR}) install(PROGRAMS files/deepin-greeter DESTINATION ${CMAKE_INSTALL_BINDIR}) # install x files @@ -425,13 +420,14 @@ if (DISABLE_DSS_SNIPE) install(PROGRAMS files/wayland/lightdm-deepin-greeter-wayland DESTINATION ${CMAKE_INSTALL_DATADIR}/dde-session-shell/greeters.d/wayland) install(FILES files/wayland/lightdm-deepin-greeter-wayland.desktop DESTINATION ${CMAKE_INSTALL_DATADIR}/xgreeters/) else () # snipe - install(TARGETS dde-lock lightdm-deepin-greeter DESTINATION ${CMAKE_INSTALL_BINDIR}) install(PROGRAMS files/snipe/deepin-greeter DESTINATION ${CMAKE_INSTALL_BINDIR}) file(GLOB SCRIPTS files/snipe/scripts/*) install(PROGRAMS ${SCRIPTS} DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/deepin/greeters.d) endif () +install(TARGETS dde-lock lightdm-deepin-greeter greeter-display-setting DESTINATION ${CMAKE_INSTALL_BINDIR}) + # 指定greeter,优先级最低,允许被其他应用以更高的配置文件覆盖 install(FILES files/50-deepin.conf DESTINATION ${CMAKE_INSTALL_DATADIR}/lightdm/lightdm.conf.d) install(PROGRAMS files/pre-greeter DESTINATION ${CMAKE_INSTALL_DATADIR}/dde-session-shell/greeters.d) diff --git a/files/snipe/scripts/lightdm-deepin-greeter b/files/snipe/scripts/lightdm-deepin-greeter index 0c138b97f..721be88b2 100755 --- a/files/snipe/scripts/lightdm-deepin-greeter +++ b/files/snipe/scripts/lightdm-deepin-greeter @@ -6,6 +6,13 @@ fi xsettingsd_conf="/etc/lightdm/deepin/xsettingsd.conf" if [ -e $xsettingsd_conf ]; then xsettingsd -c $xsettingsd_conf & +else + # xsettingsd.conf 不存在时,通过 greeter-display-setting 设置 QT 缩放环境变量 + greeter_display_setting_path="/usr/bin/greeter-display-setting" + if [ -f $greeter_display_setting_path ]; then + scale_env=$(/usr/bin/greeter-display-setting | tail -1) + export $scale_env + fi fi # 判断是否有脚本需要在greeter之前调用。与更新相关功能 diff --git a/src/app/greeter-display-setting.cpp b/src/app/greeter-display-setting.cpp index 881d7eb52..56a32f855 100644 --- a/src/app/greeter-display-setting.cpp +++ b/src/app/greeter-display-setting.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2015 - 2022 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2015 - 2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later #include "constants.h" @@ -278,7 +278,12 @@ double getScaleFormConfig() } static void setQtScaleFactorEnv() { - const double scaleFactor = IsWayland ? getScaleFormConfig() : getScaleFactor(); + double scaleFactor = 0.0; +#ifdef ENABLE_DSS_SNIPE + scaleFactor = getScaleFactor(); +#else + scaleFactor = IsWayland ? getScaleFormConfig() : getScaleFactor(); +#endif qDebug() << "Final scale factor: " << scaleFactor; if (scaleFactor > 0.0) { std::cout << QString("QT_SCALE_FACTOR="+QByteArray::number(scaleFactor)).toStdString().c_str() << std::endl; @@ -291,9 +296,15 @@ int main(int argc, char* argv[]) { // x11下,dxcb设置Qt::AA_EnableHighDpiScaling属性后,平台插件会处理缩放,不需要再主动设置QT_SCALE_FACTOR,否则会导致缩放系数相乘,得出错误的qApp->devicePixelRatio() // wayland下,dwayland平台插件不会处理缩放,需要手动设置QT_SCALE_FACTOR +#ifdef ENABLE_DSS_SNIPE + if (!IsWayland) { + setQtScaleFactorEnv(); + } +#else if (IsWayland) { setQtScaleFactorEnv(); } +#endif return 0; }