diff --git a/CMakeLists.txt b/CMakeLists.txt index cd5f19f8c62492d20573e9c5e0ae7f74e5e45d71..d97a85524f6223cd48d303e514a4334beadfe2a5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,4 +36,7 @@ configure_file( install(FILES ${CMAKE_CURRENT_BINARY_DIR}/xdg-desktop-portal-gxde.service DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/systemd/user/") install(FILES ${CMAKE_CURRENT_BINARY_DIR}/org.freedesktop.impl.portal.desktop.gxde.service DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/dbus-1/services") install(FILES ${CMAKE_CURRENT_LIST_DIR}/misc/gxde.portal DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/xdg-desktop-portal/portals/") -install(FILES ${CMAKE_CURRENT_LIST_DIR}/misc/gxde-portals.conf DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/xdg-desktop-portal/") +install(FILES + ${CMAKE_CURRENT_LIST_DIR}/misc/deepin-portals.conf + ${CMAKE_CURRENT_LIST_DIR}/misc/gxde-portals.conf + DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/xdg-desktop-portal/") diff --git a/debian/changelog b/debian/changelog index f3ecc9e3587b26d81b7863083ec9dfc5a4fb9ea7..a3f1911f0bbe532647722d8ed2d5b2f767dc8d8e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +xdg-desktop-portal-gxde (1.2.2-gxde1) unstable; urgency=medium + + * 修复了Wayland下由于传入平台为dcb导致的崩溃 + + -- CharOfString Thu, 20 Aug 2026 22:49:52 +0800 + xdg-desktop-portal-gxde (1.2.1-gxde1) unstable; urgency=medium * 修复了Wayland下由于Treeland personal manager v1下因为协议签名变化导致的崩溃(现在协议跟随DTK6而不是自行生成) diff --git a/misc/deepin-portals.conf b/misc/deepin-portals.conf new file mode 100644 index 0000000000000000000000000000000000000000..3a2e55740af2257b3d84529c81f2f7c3e825db25 --- /dev/null +++ b/misc/deepin-portals.conf @@ -0,0 +1,2 @@ +[preferred] +default=gxde diff --git a/misc/gxde-portals.conf b/misc/gxde-portals.conf index 69b81b78629cd02f053428630fe9e8f530f519e4..3a2e55740af2257b3d84529c81f2f7c3e825db25 100644 --- a/misc/gxde-portals.conf +++ b/misc/gxde-portals.conf @@ -1,2 +1,2 @@ [preferred] -default=dde +default=gxde diff --git a/misc/gxde.portal b/misc/gxde.portal index 74ff9c06b0737c324beee59c4201799d282cd32c..dfe460c208536a7005d82156c949f956564376f5 100644 --- a/misc/gxde.portal +++ b/misc/gxde.portal @@ -1,4 +1,4 @@ [portal] DBusName=org.freedesktop.impl.portal.desktop.gxde -Interfaces=org.freedesktop.impl.portal.Screenshot;org.freedesktop.impl.portal.Notification;org.freedesktop.impl.portal.FileChooser;org.freedesktop.impl.portal.Wallpaper;org.freedesktop.impl.portal.ScreenCast;org.freedesktop.impl.portal.RemoteDesktop;org.freedesktop.impl.portal.Access;org.freedesktop.impl.portal.Settings +Interfaces=org.freedesktop.impl.portal.Screenshot;org.freedesktop.impl.portal.Notification;org.freedesktop.impl.portal.FileChooser;org.freedesktop.impl.portal.Wallpaper;org.freedesktop.impl.portal.ScreenCast;org.freedesktop.impl.portal.Access;org.freedesktop.impl.portal.Settings UseIn=Deepin diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b3440a19eb51034651cf7c33c97b1c9af08c05b0..f260fd7a1d89c0c1e90c3f0ade518e314adc4cb4 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -27,6 +27,7 @@ qt6_add_dbus_interface(NotificationInterface set(SRC ${NotificationInterface} xdg-desktop-portal-gxde.cpp + sessiontype.h ddesktopportal.h ddesktopportal.cpp screenshot.h diff --git a/src/sessiontype.h b/src/sessiontype.h new file mode 100644 index 0000000000000000000000000000000000000000..881ac663d7f99dd781eb641ea5651f50023731d7 --- /dev/null +++ b/src/sessiontype.h @@ -0,0 +1,27 @@ +// SPDX-FileCopyrightText: 2026 CharOfString +// +// SPDX-License-Identifier: LGPL-3.0-or-later + +#pragma once + +#include +#include + +namespace PortalSession { + +inline bool isWayland() { + const QByteArray sessionType = qgetenv("XDG_SESSION_TYPE").toLower(); + if (!sessionType.isEmpty()) { + return sessionType == QByteArrayLiteral("wayland"); + } + + return !qEnvironmentVariableIsEmpty("WAYLAND_DISPLAY"); +} + +inline void selectQpaPlatform() { + if (isWayland()) { + qputenv("QT_QPA_PLATFORM", QByteArrayLiteral("wayland")); + } +} + +} // namespace PortalSession diff --git a/src/wayland/portalwaylandcontext.cpp b/src/wayland/portalwaylandcontext.cpp index 65b7dd7c5d3e0b08659a5c75d40c346d1014032d..6ec23810cec603306e18d973bb93b7f4373287fd 100644 --- a/src/wayland/portalwaylandcontext.cpp +++ b/src/wayland/portalwaylandcontext.cpp @@ -7,6 +7,9 @@ #include "screencastportal.h" #include "filechooser.h" #include "wallpaper.h" +#include "notification.h" +#include "access.h" +#include "settings.h" #include #include @@ -22,6 +25,9 @@ PortalWaylandContext::PortalWaylandContext(QObject *parent) , m_screenCopyManager(new ScreenCopyManager(this)) , m_treelandCaptureManager(new TreeLandCaptureManager(this)) , m_fileChooser(new FileChooserPortal(this)) + , m_notification(new NotificationPortal(this)) + , m_access(new AccessPortal(this)) + , m_settings(new SettingsPortal(this)) { new ScreenshotPortalWayland(this); new ScreencastPortalWayland(this); diff --git a/src/wayland/portalwaylandcontext.h b/src/wayland/portalwaylandcontext.h index 1961edcea480bb0acd126268645ec4957022e6c1..c3fdfe9249114d103a69266d3cb8b8a3395fae7d 100644 --- a/src/wayland/portalwaylandcontext.h +++ b/src/wayland/portalwaylandcontext.h @@ -11,6 +11,9 @@ #include class FileChooserPortal; +class NotificationPortal; +class AccessPortal; +class SettingsPortal; class PortalWaylandContext : public QObject, public QDBusContext { @@ -25,4 +28,7 @@ private: ScreenCopyManager *m_screenCopyManager; TreeLandCaptureManager *m_treelandCaptureManager; FileChooserPortal *m_fileChooser; + NotificationPortal *m_notification; + AccessPortal *m_access; + SettingsPortal *m_settings; }; diff --git a/src/xdg-desktop-portal-gxde.cpp b/src/xdg-desktop-portal-gxde.cpp index dc87e1aabcdf78610e8f0acef45cb762b7fb36ed..7daf0cd8531040b156e813b26d1506a634ff0e23 100644 --- a/src/xdg-desktop-portal-gxde.cpp +++ b/src/xdg-desktop-portal-gxde.cpp @@ -4,6 +4,7 @@ #include "ddesktopportal.h" #include "filechooser.h" +#include "sessiontype.h" #include "wayland/portalwaylandcontext.h" #include "wayland/toplevelmodel.h" #include "wayland/restoredata.h" @@ -20,7 +21,8 @@ Q_LOGGING_CATEGORY(XdgDesktopDDE, "xdg-dde") inline static bool onWayland() { - return QGuiApplication::platformName() == "wayland"; + return QGuiApplication::platformName().contains(QLatin1String("wayland"), + Qt::CaseInsensitive); } int main(int argc, char *argv[]) @@ -30,6 +32,8 @@ int main(int argc, char *argv[]) // qputenv("WAYLAND_DEBUG", "1"); qDBusRegisterMetaType(); qDBusRegisterMetaType(); + + PortalSession::selectQpaPlatform(); #if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) /* Disable X11 session management As XdgDesktopPortal is a QGuiApplication it connects to our X session manager. diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 1bbff408c06a0760d15e21e3f7b3dc5014abe38e..48ffe0ab94579aba97698b8d1463d6e4f94af08e 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -20,3 +20,17 @@ add_test(NAME settings-dbus-metatype COMMAND test-settings-dbus-metatype) set_tests_properties(settings-dbus-metatype PROPERTIES ENVIRONMENT "QT_QPA_PLATFORM=offscreen" ) + +add_executable(test-sessiontype + test_sessiontype.cpp +) + +target_include_directories(test-sessiontype PRIVATE + ${CMAKE_SOURCE_DIR}/src +) + +target_link_libraries(test-sessiontype PRIVATE + Qt6::Core +) + +add_test(NAME sessiontype COMMAND test-sessiontype) diff --git a/tests/test_sessiontype.cpp b/tests/test_sessiontype.cpp new file mode 100644 index 0000000000000000000000000000000000000000..92e3365cf61c857bcdc0bcc2397d42f05f415a7e --- /dev/null +++ b/tests/test_sessiontype.cpp @@ -0,0 +1,49 @@ +// SPDX-FileCopyrightText: 2026 2026 CharOfString +// +// SPDX-License-Identifier: LGPL-3.0-or-later + +#include "sessiontype.h" + +#include + +namespace { + +bool expectPlatform(const char *scenario, const QByteArray &expected) { + PortalSession::selectQpaPlatform(); + const QByteArray actual = qgetenv("QT_QPA_PLATFORM"); + if (actual == expected) { + return true; + } + + return false; +} + +} // namespace + +int main() { + qputenv("XDG_SESSION_TYPE", "wayland"); + qunsetenv("WAYLAND_DISPLAY"); + qputenv("QT_QPA_PLATFORM", "dxcb;xcb;dwayland;wayland"); + if (!expectPlatform("Wayland session", "wayland")) { + return 1; + } + + qputenv("XDG_SESSION_TYPE", "x11"); + qputenv("WAYLAND_DISPLAY", "wayland-0"); + qputenv("QT_QPA_PLATFORM", "dxcb;xcb"); + if (!expectPlatform("X11 session", "dxcb;xcb")) { + return 1; + } + + qunsetenv("XDG_SESSION_TYPE"); + qputenv("WAYLAND_DISPLAY", "wayland-0"); + qputenv("QT_QPA_PLATFORM", "xcb;wayland"); + if (!expectPlatform("Wayland display fallback", "wayland")) { + return 1; + } + + qunsetenv("XDG_SESSION_TYPE"); + qunsetenv("WAYLAND_DISPLAY"); + qputenv("QT_QPA_PLATFORM", "offscreen"); + return expectPlatform("Unknown session", "offscreen") ? 0 : 1; +}