fix: 修改获取屏幕区域缩放前分辨率的方式

在当前显示器设置了缩放因子的情况下,缩放前的分辨率是通过当前分辨率乘以缩放因子得到的,会有误差。改成了通过QScreen的handle()->geometry()函数能拿到缩放前的分辨率,和桌面获取分辨率保持一致

Log: 修复高分辨率屏幕设置缩放因子切换到低分辨率屏幕下桌面图标显示不全的bug
Bug: https://pms.uniontech.com/zentao/bug-view-87627.html
Change-Id: Ieddbae64fc13bd029b3dc818c7bc11fcc6c52462
This commit is contained in:
Dong Hualin 2021-07-21 21:33:08 +08:00
parent aeced57129
commit 33feba31e1

View File

@ -32,6 +32,7 @@
#include <QVariantAnimation>
#include <QX11Info>
#include <QDBusConnection>
#include <qpa/qplatformscreen.h>
const QString MonitorsSwitchTime = "monitorsSwitchTime";
const QString OnlyShowPrimary = "onlyShowPrimary";
@ -1377,10 +1378,8 @@ QRect MultiScreenWorker::getDockShowGeometry(const QString &screenName, const Po
for (auto s : DIS_INS->screens()) {
if (s->name() == screenName) {
QRect screenRect = s->geometry();
// 不能直接用screenRect乘缩放率因为那样会四舍五入得到的数值有误差桌面在判断当前显示器的时候得到的显示器错误引起桌面图标的显示错误
screenRect.setWidth(s->geometry().x() + int(s->geometry().width() * s->devicePixelRatio()));
screenRect.setHeight(s->geometry().y() + int(s->geometry().height() * s->devicePixelRatio()));
// 拿到当前显示器缩放之前的分辨率
QRect screenRect = s->handle()->geometry();
switch (pos) {
case Position::Top:
@ -1430,10 +1429,8 @@ QRect MultiScreenWorker::getDockHideGeometry(const QString &screenName, const Po
for (auto s : DIS_INS->screens()) {
if (s->name() == screenName) {
QRect screenRect = s->geometry();
// 不能直接用screenRect乘缩放率因为那样会四舍五入得到的数值有误差桌面在判断当前显示器的时候得到的显示器错误引起桌面图标的显示错误
screenRect.setWidth(s->geometry().x() + int(s->geometry().width() * s->devicePixelRatio()));
screenRect.setHeight(s->geometry().y() + int(s->geometry().height() * s->devicePixelRatio()));
// 拿到当前显示器缩放之前的分辨率
QRect screenRect = s->handle()->geometry();
switch (pos) {
case Position::Top: