From facc014c717a2001a6695a5fce959c92710d4127 Mon Sep 17 00:00:00 2001 From: luhongxu Date: Wed, 16 Sep 2026 10:47:21 +0800 Subject: [PATCH] feat(dock): adapt to treeland-xwindow-control-unstable-v1 protocol set_xwindow_position_relative has been split from treeland-dde-shell-v1 into the standalone treeland-xwindow-control-unstable-v1 protocol in treeland-protocols (>=0.6.0, commit 7ba45e4). Changes: - Add TreeLandXWindowControl class (QWaylandClientExtensionTemplate + QtWayland::treeland_xwindow_control_v1) to bind the new global interface - Move setXWindowPositionRelative from TreeLandDDEShellManager to TreeLandXWindowControl; moveXEmbedWindow now calls the new interface - TreeLandDDEShellManager is retained for get_window_overlap_checker - Add treeland-xwindow-control-unstable-v1.xml to qt_generate_wayland_protocol_client_sources in panels/dock/CMakeLists.txt - Lock find_package(TreelandProtocols) to 0.6.0 - Update debian/control Build-Depends to treeland-protocols (>= 0.6.0) - Add isInitialized() guard in ~TreeLandXWindowControl before calling destroy() to avoid crash when compositor does not support the protocol Issue: DDE-320 --- debian/control | 2 +- panels/dock/CMakeLists.txt | 3 ++- panels/dock/waylanddockhelper.cpp | 27 +++++++++++++++++++++------ panels/dock/waylanddockhelper.h | 17 ++++++++++++++--- 4 files changed, 38 insertions(+), 11 deletions(-) diff --git a/debian/control b/debian/control index 2bf9d1520..27a16a495 100644 --- a/debian/control +++ b/debian/control @@ -40,7 +40,7 @@ Build-Depends: qt6-wayland-dev-tools, qt6-wayland-private-dev, systemd, - treeland-protocols (>> 0.5.9), + treeland-protocols (>= 0.6.0), wayland-protocols, Standards-Version: 4.6.2 Homepage: https://github.com/linuxdeepin/dde-shell diff --git a/panels/dock/CMakeLists.txt b/panels/dock/CMakeLists.txt index 80f756180..505876102 100644 --- a/panels/dock/CMakeLists.txt +++ b/panels/dock/CMakeLists.txt @@ -9,7 +9,7 @@ configure_file(environments.h.in environments.h @ONLY) find_package(PkgConfig REQUIRED) find_package(Qt${QT_VERSION_MAJOR} ${REQUIRED_QT_VERSION} COMPONENTS Core DBus Gui Qml WaylandCompositor Widgets WaylandClient) find_package(DdeTrayLoader REQUIRED) -find_package(TreelandProtocols REQUIRED) +find_package(TreelandProtocols 0.6.0 REQUIRED) pkg_check_modules(WaylandClient REQUIRED IMPORTED_TARGET wayland-client) file( @@ -62,6 +62,7 @@ qt_generate_wayland_protocol_client_sources(dockpanel FILES ${TREELAND_PROTOCOLS_DATA_DIR}/treeland-wallpaper-color-v1.xml ${TREELAND_PROTOCOLS_DATA_DIR}/treeland-dde-shell-v1.xml + ${TREELAND_PROTOCOLS_DATA_DIR}/treeland-xwindow-control-unstable-v1.xml ) target_link_libraries(dockpanel PRIVATE diff --git a/panels/dock/waylanddockhelper.cpp b/panels/dock/waylanddockhelper.cpp index 584483c73..0938abce7 100644 --- a/panels/dock/waylanddockhelper.cpp +++ b/panels/dock/waylanddockhelper.cpp @@ -9,7 +9,9 @@ #include "dockpanel.h" #include "layershell/dlayershellwindow.h" #include "qwayland-treeland-dde-shell-v1.h" +#include "qwayland-treeland-xwindow-control-unstable-v1.h" #include "wayland-treeland-dde-shell-v1-client-protocol.h" +#include "wayland-treeland-xwindow-control-unstable-v1-client-protocol.h" #include #include @@ -23,6 +25,7 @@ WaylandDockHelper::WaylandDockHelper(DockPanel *panel) , m_panel(panel) { m_ddeShellManager.reset(new TreeLandDDEShellManager()); + m_xwindowControl.reset(new TreeLandXWindowControl()); DS_NAMESPACE::DAppletBridge bridge("org.deepin.ds.dock.taskmanager"); if (auto applet = bridge.applet()) { connect(applet, SIGNAL(windowFullscreenChanged(bool)), this, SLOT(setCurrentActiveWindowFullscreened(bool))); @@ -177,14 +180,14 @@ bool WaylandDockHelper::moveXEmbedWindow(uint32_t wid, double dx, double dy, QQu } } - if (!m_ddeShellManager || !m_ddeShellManager->isActive() || !anchorSurface) { - qWarning() << "WaylandDockHelper::moveXEmbedWindow: not ready, manager active:" - << (m_ddeShellManager && m_ddeShellManager->isActive()) + if (!m_xwindowControl || !m_xwindowControl->isActive() || !anchorSurface) { + qWarning() << "WaylandDockHelper::moveXEmbedWindow: not ready, xwindow control active:" + << (m_xwindowControl && m_xwindowControl->isActive()) << "surface:" << (anchorSurface != nullptr); return false; } - struct wl_callback *cb = m_ddeShellManager->setXWindowPositionRelative(wid, anchorSurface, dx, dy); + struct wl_callback *cb = m_xwindowControl->setXWindowPositionRelative(wid, anchorSurface, dx, dy); // Register wl_callback listener — result arrives asynchronously if (!cb) { @@ -233,12 +236,24 @@ TreeLandDDEShellManager::TreeLandDDEShellManager() { } -struct ::wl_callback *TreeLandDDEShellManager::setXWindowPositionRelative(uint32_t wid, struct ::wl_surface *anchor, double dx, double dy) +TreeLandXWindowControl::TreeLandXWindowControl() + : QWaylandClientExtensionTemplate(treeland_xwindow_control_v1_interface.version) +{ +} + +TreeLandXWindowControl::~TreeLandXWindowControl() +{ + if (isInitialized()) { + destroy(); + } +} + +struct ::wl_callback *TreeLandXWindowControl::setXWindowPositionRelative(uint32_t wid, struct ::wl_surface *anchor, double dx, double dy) { if (!isActive()) { return nullptr; } - return QtWayland::treeland_dde_shell_manager_v1::set_xwindow_position_relative(wid, anchor, wl_fixed_from_double(dx), wl_fixed_from_double(dy)); + return QtWayland::treeland_xwindow_control_v1::set_xwindow_position_relative(wid, anchor, wl_fixed_from_double(dx), wl_fixed_from_double(dy)); } TreeLandWindowOverlapChecker::TreeLandWindowOverlapChecker(WaylandDockHelper *helper, struct ::treeland_window_overlap_checker *checker) diff --git a/panels/dock/waylanddockhelper.h b/panels/dock/waylanddockhelper.h index ff053173b..c341fcdb9 100644 --- a/panels/dock/waylanddockhelper.h +++ b/panels/dock/waylanddockhelper.h @@ -9,6 +9,7 @@ #include "qwayland-treeland-dde-shell-v1.h" #include "qwayland-treeland-wallpaper-color-v1.h" +#include "qwayland-treeland-xwindow-control-unstable-v1.h" #include #include @@ -19,6 +20,7 @@ namespace dock { class WallpaperColorManager; class TreeLandDockTriggerArea; class TreeLandDDEShellManager; +class TreeLandXWindowControl; class TreeLandWindowOverlapChecker; class WaylandDockHelper : public DockHelper @@ -61,6 +63,7 @@ protected Q_SLOTS: QScopedPointer m_wallpaperColorManager; QScopedPointer m_overlapChecker; QScopedPointer m_ddeShellManager; + QScopedPointer m_xwindowControl; struct ::wl_surface *m_dockWlSurface = nullptr; // Dock's wl_surface for XEmbed positioning }; @@ -86,9 +89,17 @@ class TreeLandDDEShellManager : public QWaylandClientExtensionTemplate, public QtWayland::treeland_xwindow_control_v1 +{ + Q_OBJECT + +public: + explicit TreeLandXWindowControl(); + + ~TreeLandXWindowControl() override; + struct ::wl_callback *setXWindowPositionRelative(uint32_t wid, struct ::wl_surface *anchor, double dx, double dy); };