Skip to content

Commit 2b56a88

Browse files
ilya-fedinjohn-preston
authored andcommitted
Work around GNOME returning wrong screen size without fractional scaling
1 parent d3107bf commit 2b56a88

File tree

1 file changed

+17
-30
lines changed

1 file changed

+17
-30
lines changed

qtwayland_6.6.1/0002-force-enable-fractional-scale.patch

Lines changed: 17 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -11,56 +11,44 @@ index a4f8757e..68938a4a 100644
1111
return scale;
1212
}
1313

14-
diff --git a/src/client/qwaylandintegration.cpp b/src/client/qwaylandintegration.cpp
15-
index 88a2fa7e..604ccff0 100644
16-
--- a/src/client/qwaylandintegration.cpp
17-
+++ b/src/client/qwaylandintegration.cpp
18-
@@ -36,6 +36,7 @@
19-
#include <QtGui/QOpenGLContext>
20-
#endif // QT_CONFIG(opengl)
21-
#include <QSocketNotifier>
22-
+#include <QTimer>
23-
24-
#include <qpa/qplatforminputcontextfactory_p.h>
25-
#include <qpa/qplatformaccessibility.h>
2614
diff --git a/src/client/qwaylandscreen.cpp b/src/client/qwaylandscreen.cpp
27-
index 7c4f1bdf..c4efe3d6 100644
15+
index 7c4f1bdf..e0afd4d5 100644
2816
--- a/src/client/qwaylandscreen.cpp
2917
+++ b/src/client/qwaylandscreen.cpp
30-
@@ -168,7 +168,7 @@ Qt::ScreenOrientation QWaylandScreen::orientation() const
18+
@@ -168,14 +168,16 @@ Qt::ScreenOrientation QWaylandScreen::orientation() const
3119
return m_orientation;
3220
}
3321

3422
-int QWaylandScreen::scale() const
3523
+qreal QWaylandScreen::scale() const
3624
{
37-
return mScale;
25+
- return mScale;
26+
+ return devicePixelRatio();
3827
}
39-
@@ -238,7 +238,8 @@ void QWaylandScreen::output_geometry(int32_t x, int32_t y,
4028

41-
void QWaylandScreen::output_scale(int32_t factor)
29+
qreal QWaylandScreen::devicePixelRatio() const
4230
{
43-
- mScale = factor;
44-
+ if (!zxdg_output_v1::isInitialized() || !mWaylandDisplay->fractionalScaleManager())
45-
+ mScale = factor;
31+
- return qreal(mScale);
32+
+ return (mWaylandDisplay->fractionalScaleManager() && std::fmod(mFractionalScale, qreal(1)) != 0)
33+
+ ? mFractionalScale
34+
+ : qreal(mScale);
4635
}
4736

48-
void QWaylandScreen::output_done()
49-
@@ -324,7 +325,12 @@ void QWaylandScreen::zxdg_output_v1_name(const QString &name)
37+
qreal QWaylandScreen::refreshRate() const
38+
@@ -324,7 +326,11 @@ void QWaylandScreen::zxdg_output_v1_name(const QString &name)
5039
void QWaylandScreen::updateXdgOutputProperties()
5140
{
5241
Q_ASSERT(zxdg_output_v1::isInitialized());
53-
+ if (mWaylandDisplay->fractionalScaleManager())
54-
+ mScale = (qreal(mGeometry.width()) / qreal(mXdgGeometry.width())
55-
+ + qreal(mGeometry.height()) / qreal(mXdgGeometry.height())) * qreal(0.5);
42+
+ mFractionalScale = (qreal(mGeometry.width()) / qreal(mXdgGeometry.width())
43+
+ + qreal(mGeometry.height()) / qreal(mXdgGeometry.height())) * qreal(0.5);
5644
+ const QDpi dpi = logicalDpi();
5745
QWindowSystemInterface::handleScreenGeometryChange(screen(), geometry(), geometry());
5846
+ QWindowSystemInterface::handleScreenLogicalDotsPerInchChange(screen(), dpi.first, dpi.second);
5947
}
6048

6149
} // namespace QtWaylandClient
6250
diff --git a/src/client/qwaylandscreen_p.h b/src/client/qwaylandscreen_p.h
63-
index 4499f0ee..10efc284 100644
51+
index 4499f0ee..f1e761e7 100644
6452
--- a/src/client/qwaylandscreen_p.h
6553
+++ b/src/client/qwaylandscreen_p.h
6654
@@ -63,7 +63,7 @@ public:
@@ -72,12 +60,11 @@ index 4499f0ee..10efc284 100644
7260
qreal devicePixelRatio() const override;
7361
qreal refreshRate() const override;
7462

75-
@@ -114,7 +114,7 @@ protected:
76-
QString mModel;
63+
@@ -115,6 +115,7 @@ protected:
7764
QRect mGeometry;
7865
QRect mXdgGeometry;
79-
- int mScale = 1;
80-
+ qreal mScale = 1;
66+
int mScale = 1;
67+
+ qreal mFractionalScale = 1;
8168
int mDepth = 32;
8269
int mRefreshRate = 60000;
8370
int mTransform = -1;

0 commit comments

Comments
 (0)