Enable highdpi downscale when rhiConfig evaluates to GL
This commit is contained in:
parent
b1d5c7c116
commit
16772f440f
1 changed files with 21 additions and 7 deletions
|
|
@ -21,6 +21,20 @@
|
||||||
class TWidgetPrivate : public QWidgetPrivate {
|
class TWidgetPrivate : public QWidgetPrivate {
|
||||||
public:
|
public:
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 4, 0)
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 4, 0)
|
||||||
|
TWidgetPrivate(int version = QObjectPrivateVersion)
|
||||||
|
: QWidgetPrivate(version) {
|
||||||
|
[[maybe_unused]] static const auto Once = [] {
|
||||||
|
if (::Platform::IsWayland()
|
||||||
|
&& Ui::GL::ChooseBackendDefault(
|
||||||
|
Ui::GL::CheckCapabilities(nullptr, true))
|
||||||
|
== Ui::GL::Backend::OpenGL) {
|
||||||
|
qApp->setProperty("_q_widgets_highdpi_downscale", true);
|
||||||
|
WaylandGL = true;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}();
|
||||||
|
}
|
||||||
|
|
||||||
QPlatformBackingStoreRhiConfig rhiConfig() const override {
|
QPlatformBackingStoreRhiConfig rhiConfig() const override {
|
||||||
const auto q = static_cast<TWidget*>(q_ptr);
|
const auto q = static_cast<TWidget*>(q_ptr);
|
||||||
if (!q->testAttribute(Qt::WA_WState_Created)
|
if (!q->testAttribute(Qt::WA_WState_Created)
|
||||||
|
|
@ -31,20 +45,20 @@ public:
|
||||||
if (const auto config = q->rhiConfig()) {
|
if (const auto config = q->rhiConfig()) {
|
||||||
return *config;
|
return *config;
|
||||||
}
|
}
|
||||||
// We can't specify the widget here as q_evaluateRhiConfig is called
|
// fix flickering on GNOME
|
||||||
// in QWidgetWindow constructor, while windowHandle is set right after
|
if (WaylandGL) {
|
||||||
// the constructor is completed
|
|
||||||
if (::Platform::IsWayland() // old versions of mutter produce flicker without OpenGL
|
|
||||||
&& Ui::GL::ChooseBackendDefault(
|
|
||||||
Ui::GL::CheckCapabilities(nullptr))
|
|
||||||
== Ui::GL::Backend::OpenGL) {
|
|
||||||
return { QPlatformBackingStoreRhiConfig::OpenGL };
|
return { QPlatformBackingStoreRhiConfig::OpenGL };
|
||||||
}
|
}
|
||||||
return QWidgetPrivate::rhiConfig();
|
return QWidgetPrivate::rhiConfig();
|
||||||
}
|
}
|
||||||
#endif // Qt >= 6.4.0
|
#endif // Qt >= 6.4.0
|
||||||
|
|
||||||
|
private:
|
||||||
|
static bool WaylandGL;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool TWidgetPrivate::WaylandGL = false;
|
||||||
|
|
||||||
TWidget::TWidget(QWidget *parent)
|
TWidget::TWidget(QWidget *parent)
|
||||||
: TWidgetHelper<QWidget>(*(new TWidgetPrivate), parent, {}) {
|
: TWidgetHelper<QWidget>(*(new TWidgetPrivate), parent, {}) {
|
||||||
[[maybe_unused]] static const auto Once = [] {
|
[[maybe_unused]] static const auto Once = [] {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue