3 Star 0 Fork 6

src-openEuler/kiran-session-guard

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0015-fix-cursor-incorrect-scaling-cursor-size.patch 4.78 KB
一键复制 编辑 原始数据 按行查看 历史
liubuguiii 提交于 2024-04-09 17:11 . sync 2.5.1-11
From 3d55d3e81a2de1b91994473695b2bffa27c47b1b Mon Sep 17 00:00:00 2001
From: liuxinhao <liuxinhao@kylinsec.com.cn>
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 <QtMath>
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
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/src-openeuler/kiran-session-guard.git
git@gitee.com:src-openeuler/kiran-session-guard.git
src-openeuler
kiran-session-guard
kiran-session-guard
master

搜索帮助