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 {
|
||||
public:
|
||||
#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 {
|
||||
const auto q = static_cast<TWidget*>(q_ptr);
|
||||
if (!q->testAttribute(Qt::WA_WState_Created)
|
||||
|
|
@ -31,20 +45,20 @@ public:
|
|||
if (const auto config = q->rhiConfig()) {
|
||||
return *config;
|
||||
}
|
||||
// We can't specify the widget here as q_evaluateRhiConfig is called
|
||||
// in QWidgetWindow constructor, while windowHandle is set right after
|
||||
// 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) {
|
||||
// fix flickering on GNOME
|
||||
if (WaylandGL) {
|
||||
return { QPlatformBackingStoreRhiConfig::OpenGL };
|
||||
}
|
||||
return QWidgetPrivate::rhiConfig();
|
||||
}
|
||||
#endif // Qt >= 6.4.0
|
||||
|
||||
private:
|
||||
static bool WaylandGL;
|
||||
};
|
||||
|
||||
bool TWidgetPrivate::WaylandGL = false;
|
||||
|
||||
TWidget::TWidget(QWidget *parent)
|
||||
: TWidgetHelper<QWidget>(*(new TWidgetPrivate), parent, {}) {
|
||||
[[maybe_unused]] static const auto Once = [] {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue