From fc08b3889541ea6ac8f9247e0a08bdbaf1fd6a7f Mon Sep 17 00:00:00 2001 From: YeShanShan Date: Fri, 5 Jan 2024 15:43:47 +0800 Subject: [PATCH] fix: existing wm titlebar It's unload dxcb platform plugin, and it's an change for qt, using `QDir().entryList()` to find plugin in qt6.2 before, and using `QDirIterator()` to find in qt6.2 after. QDir will sort result by name default, which is like `ls`, and QDirIterator doesn't sort result, which is like `ls -U`. now we fix it in application temporarily. Issue: https://github.com/linuxdeepin/developer-center/issues/6686 --- CMakeLists.txt | 1 + debian/control | 1 + main.cpp | 15 +++++++++++++++ 3 files changed, 17 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index d4d06d9e..df2b0d1a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -118,6 +118,7 @@ PRIVATE target_link_libraries(${BIN_NAME} PRIVATE ${DTK_NS}::Core ${DTK_NS}::Gui + Qt::GuiPrivate Qt::Qml Qt::Quick Qt::QuickControls2 diff --git a/debian/control b/debian/control index dca9976a..2b9e8c13 100644 --- a/debian/control +++ b/debian/control @@ -10,6 +10,7 @@ Build-Depends: # v-- to get systemduserunitdir from its pkg-config data systemd, qt6-base-dev, + qt6-base-private-dev, qt6-svg-dev, qt6-declarative-dev, qt6-tools-dev, diff --git a/main.cpp b/main.cpp index 36793a82..095aac6b 100644 --- a/main.cpp +++ b/main.cpp @@ -24,14 +24,29 @@ #include #include #include +#include DCORE_USE_NAMESPACE DGUI_USE_NAMESPACE +void tryUpdatePlatformPluginToDXcb() +{ + if (qEnvironmentVariableIsSet("WAYLAND_DISPLAY")) + return; + + const QByteArray dxcb = QByteArrayLiteral("dxcb"); + if (QPlatformIntegrationFactory::keys().contains(dxcb) && + qEnvironmentVariableIsEmpty("QT_QPA_PLATFORM")) { + qputenv("QT_QPA_PLATFORM", dxcb); + } +} + int main(int argc, char* argv[]) { // workaround for https://github.com/linuxdeepin/dtk/issues/115 qputenv("D_POPUP_MODE", "embed"); + // TODO qxcb maybe found firstly in qt6.4 later. + tryUpdatePlatformPluginToDXcb(); QGuiApplication app(argc, argv); #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)