diff --git a/CMakeLists.txt b/CMakeLists.txt index f43150880..57760c619 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -60,6 +60,7 @@ endif() find_package(Dtk${DTK_VERSION_MAJOR} REQUIRED COMPONENTS Core Gui) find_package(ICU 74.2 REQUIRED COMPONENTS uc i18n io) find_package(WaylandProtocols REQUIRED) +find_package(TreelandProtocols 0.9.0 REQUIRED) find_package(PkgConfig REQUIRED) # Check if dde-api provides EventLogger (header-only) diff --git a/frame/CMakeLists.txt b/frame/CMakeLists.txt index b54909545..b2200e12b 100644 --- a/frame/CMakeLists.txt +++ b/frame/CMakeLists.txt @@ -28,6 +28,7 @@ set(PRIVATE_HEADERS private/appletproxy_p.h private/appletbridge_p.h private/dsqmlglobal_p.h + layershell/layershellextension_p.h layershell/qwaylandlayershellsurface_p.h layershell/qwaylandlayershellintegration_p.h wayland/xdgactivation_p.h @@ -68,6 +69,7 @@ add_library(dde-shell-frame SHARED appletitemmodel.cpp dsqmlglobal.cpp layershell/dlayershellwindow.cpp + layershell/layershellextension.cpp layershell/qwaylandlayershellsurface.cpp layershell/qwaylandlayershellintegration.cpp models/kextracolumnsproxymodel.cpp @@ -87,6 +89,7 @@ qt_generate_wayland_protocol_client_sources(dde-shell-frame FILES ${CMAKE_CURRENT_SOURCE_DIR}/layershell/protocol/wlr-layer-shell-unstable-v1.xml ${WaylandProtocols_DATADIR}/stable/xdg-shell/xdg-shell.xml ${WaylandProtocols_DATADIR}/staging/xdg-activation/xdg-activation-v1.xml + ${TREELAND_PROTOCOLS_DATA_DIR}/treeland-layer-shell-extension-unstable-v1.xml ) set_target_properties(dde-shell-frame PROPERTIES diff --git a/frame/layershell/dlayershellwindow.cpp b/frame/layershell/dlayershellwindow.cpp index df5af0f2d..7261b1eff 100644 --- a/frame/layershell/dlayershellwindow.cpp +++ b/frame/layershell/dlayershellwindow.cpp @@ -43,6 +43,7 @@ class DLayerShellWindowPrivate int preferredWidth = -1; int preferredHeight = -1; bool closeOnDismissed = true; + bool resizing = false; QRegion inputRegion; }; @@ -299,6 +300,19 @@ bool DLayerShellWindow::ensureWaylandShellIntegration() return waylandWindow->shellIntegration() == shellIntegration; } +bool DLayerShellWindow::isResizing() const +{ + return d->resizing; +} + +void DLayerShellWindow::setResizing(bool resizing) +{ + if (d->resizing == resizing) + return; + d->resizing = resizing; + Q_EMIT resizingChanged(); +} + DLayerShellWindow* DLayerShellWindow::get(QWindow* window) { auto dlayerShellWindow = s_map.value(window); diff --git a/frame/layershell/dlayershellwindow.h b/frame/layershell/dlayershellwindow.h index f36799e97..5579558a7 100644 --- a/frame/layershell/dlayershellwindow.h +++ b/frame/layershell/dlayershellwindow.h @@ -32,6 +32,7 @@ class DS_SHARE DLayerShellWindow : public QObject Q_PROPERTY(int preferredHeight READ preferredHeight WRITE setPreferredHeight RESET resetPreferredHeight NOTIFY geometryHintsChanged) Q_PROPERTY(QRegion inputRegion READ inputRegion WRITE setInputRegion RESET resetInputRegion NOTIFY inputRegionChanged) + Q_PROPERTY(bool resizing READ isResizing NOTIFY resizingChanged) Q_PROPERTY(bool closeOnDismissed READ closeOnDismissed WRITE setCloseOnDismissed) public: @@ -149,6 +150,9 @@ class DS_SHARE DLayerShellWindow : public QObject bool ensureWaylandShellIntegration(); + /** Whether a system resize is pending or active on this layer surface. */ + bool isResizing() const; + /** * Gets the LayerShell Window for a given Qt Window * Ownership is not transferred @@ -166,8 +170,14 @@ class DS_SHARE DLayerShellWindow : public QObject void scopeChanged(); void geometryHintsChanged(); void inputRegionChanged(); + void resizingChanged(); + // Final size in QWindow coordinates, delivered before resizing becomes false. + void resizeFinished(const QSize &size); private: + friend class QWaylandLayerShellSurface; + void setResizing(bool resizing); + DLayerShellWindow(QWindow* window); QScopedPointer d; }; diff --git a/frame/layershell/layershellextension.cpp b/frame/layershell/layershellextension.cpp new file mode 100644 index 000000000..151deabbd --- /dev/null +++ b/frame/layershell/layershellextension.cpp @@ -0,0 +1,55 @@ +// SPDX-FileCopyrightText: 2026 UnionTech Software Technology Co., Ltd. +// +// SPDX-License-Identifier: GPL-3.0-or-later + +#include "layershellextension_p.h" + +#include +#include + +DS_BEGIN_NAMESPACE + +TreeLandLayerShellExtensionManager::TreeLandLayerShellExtensionManager() + : QWaylandClientExtensionTemplate(1) +{ + initialize(); +} + +TreeLandLayerShellExtensionManager::~TreeLandLayerShellExtensionManager() +{ + if (isInitialized()) + destroy(); +} + +TreeLandLayerShellExtensionManager *TreeLandLayerShellExtensionManager::instance() +{ + static QPointer manager; + if (!manager) { + manager = new TreeLandLayerShellExtensionManager; + manager->setParent(qApp); + } + return manager; +} + +TreeLandLayerShellExtensionObject::TreeLandLayerShellExtensionObject(struct ::treeland_layer_shell_extension_object_v1 *object) + : QtWayland::treeland_layer_shell_extension_object_v1(object) +{ +} + +TreeLandLayerShellExtensionObject::~TreeLandLayerShellExtensionObject() +{ + if (isInitialized()) + destroy(); +} + +void TreeLandLayerShellExtensionObject::treeland_layer_shell_extension_object_v1_resizing(uint32_t resizing) +{ + Q_EMIT resizingChanged(resizing != 0); +} + +void TreeLandLayerShellExtensionObject::treeland_layer_shell_extension_object_v1_resize_rejected(uint32_t error) +{ + Q_EMIT resizeRejected(error); +} + +DS_END_NAMESPACE diff --git a/frame/layershell/layershellextension_p.h b/frame/layershell/layershellextension_p.h new file mode 100644 index 000000000..2a9e3f265 --- /dev/null +++ b/frame/layershell/layershellextension_p.h @@ -0,0 +1,43 @@ +// SPDX-FileCopyrightText: 2026 UnionTech Software Technology Co., Ltd. +// +// SPDX-License-Identifier: GPL-3.0-or-later + +#pragma once + +#include "dsglobal.h" +#include "qwayland-treeland-layer-shell-extension-unstable-v1.h" + +#include + +DS_BEGIN_NAMESPACE + +class TreeLandLayerShellExtensionManager : public QWaylandClientExtensionTemplate, + public QtWayland::treeland_layer_shell_extension_manager_v1 +{ + Q_OBJECT +public: + TreeLandLayerShellExtensionManager(); + ~TreeLandLayerShellExtensionManager() override; + + static TreeLandLayerShellExtensionManager *instance(); +}; + +// Owned by the layer shell surface, and destroyed before its wl_surface. +class TreeLandLayerShellExtensionObject : public QObject, + public QtWayland::treeland_layer_shell_extension_object_v1 +{ + Q_OBJECT +public: + explicit TreeLandLayerShellExtensionObject(struct ::treeland_layer_shell_extension_object_v1 *object); + ~TreeLandLayerShellExtensionObject() override; + +Q_SIGNALS: + void resizingChanged(bool resizing); + void resizeRejected(uint32_t error); + +protected: + void treeland_layer_shell_extension_object_v1_resizing(uint32_t resizing) override; + void treeland_layer_shell_extension_object_v1_resize_rejected(uint32_t error) override; +}; + +DS_END_NAMESPACE diff --git a/frame/layershell/qwaylandlayershellsurface.cpp b/frame/layershell/qwaylandlayershellsurface.cpp index 586160f4b..05292708c 100644 --- a/frame/layershell/qwaylandlayershellsurface.cpp +++ b/frame/layershell/qwaylandlayershellsurface.cpp @@ -5,12 +5,16 @@ #include "dsglobal.h" #include "dlayershellwindow.h" #include "qwaylandlayershellsurface_p.h" +#include "layershellextension_p.h" #include #include #include +#include +#include +#include #include #include #include @@ -63,6 +67,9 @@ QWaylandLayerShellSurface::QWaylandLayerShellSurface(QtWayland::zwlr_layer_shell QWaylandLayerShellSurface::~QWaylandLayerShellSurface() { + m_shellExtension.reset(); + if (m_dlayerShellWindow) + m_dlayerShellWindow->setResizing(false); destroy(); } @@ -173,7 +180,7 @@ void QWaylandLayerShellSurface::zwlr_layer_surface_v1_configure(uint32_t serial, if (!m_configured) { m_configured = true; - window()->resizeFromApplyConfigure(m_pendingSize); + applyConfigure(); #if QT_VERSION < QT_VERSION_CHECK(6, 7, 0) window()->handleExpose(QRect(QPoint(), m_pendingSize)); #elif QT_VERSION < QT_VERSION_CHECK(6, 9, 0) @@ -189,11 +196,87 @@ void QWaylandLayerShellSurface::zwlr_layer_surface_v1_configure(uint32_t serial, void QWaylandLayerShellSurface::applyConfigure() { + if (m_interactiveResize) { + // Keep layer layout in step with the size Qt is about to render. In + // particular, margin/exclusive-zone commits must not re-anchor the + // surface using its pre-drag size. Do not echo unchanged replies. + const QSize previousRequest = m_requestSize; + calcAndSetRequestSize(m_pendingSize); + if (m_requestSize != previousRequest) + trySetAnchorsAndSize(); + } + + QScopedValueRollback applyingConfigure(m_applyingConfigure, true); window()->resizeFromApplyConfigure(m_pendingSize); } +void QWaylandLayerShellSurface::finishResize() +{ + // An interactive resize can end before Qt applies its last configure. + // Adopt it before clients persist their size or restore geometry bindings. + if (m_interactiveResize && m_configured) { + calcAndSetRequestSize(m_pendingSize); + trySetAnchorsAndSize(); + Q_EMIT m_dlayerShellWindow->resizeFinished(QHighDpi::fromNativePixels(m_pendingSize, windowHandle())); + } + m_interactiveResize = false; + m_dlayerShellWindow->setResizing(false); +} + +bool QWaylandLayerShellSurface::resize(QtWaylandClient::QWaylandInputDevice *inputDevice, Qt::Edges edges) +{ + if (!inputDevice || !inputDevice->wl_seat() || !m_configured || m_dlayerShellWindow->isResizing()) + return false; + + auto *manager = TreeLandLayerShellExtensionManager::instance(); + if (!manager->isActive()) + return false; + + // Qt::Edge and the protocol's xdg_toplevel-compatible enum differ. + uint32_t protocolEdges = 0; + if (edges.testFlag(Qt::TopEdge)) + protocolEdges |= TreeLandLayerShellExtensionObject::resize_edge_top; + if (edges.testFlag(Qt::BottomEdge)) + protocolEdges |= TreeLandLayerShellExtensionObject::resize_edge_bottom; + if (edges.testFlag(Qt::LeftEdge)) + protocolEdges |= TreeLandLayerShellExtensionObject::resize_edge_left; + if (edges.testFlag(Qt::RightEdge)) + protocolEdges |= TreeLandLayerShellExtensionObject::resize_edge_right; + + if (!m_shellExtension) { + m_shellExtension.reset(new TreeLandLayerShellExtensionObject( + manager->get_layer_shell_extension_object(window()->wlSurface()))); + connect(m_shellExtension.get(), &TreeLandLayerShellExtensionObject::resizingChanged, this, [this](bool resizing) { + if (resizing) + m_interactiveResize = true; + else + finishResize(); + }); + connect(m_shellExtension.get(), &TreeLandLayerShellExtensionObject::resizeRejected, this, [this](uint32_t error) { + qCWarning(layershellsurface) << "Layer surface resize rejected:" << error; + finishResize(); + }); + } + + const QSize minSize = window()->windowMinimumSize(); + const QSize maxSize = window()->windowMaximumSize(); + m_shellExtension->begin_resize(inputDevice->wl_seat(), inputDevice->serial(), protocolEdges, + qMax(0, minSize.width()), qMax(0, minSize.height()), + maxSize.width() == QWINDOWSIZE_MAX ? 0 : qMax(0, maxSize.width()), + maxSize.height() == QWINDOWSIZE_MAX ? 0 : qMax(0, maxSize.height())); + // QWaylandWindow releases the client pointer grab after this returns. + // Keep clients in resize mode while waiting for acceptance or rejection. + m_dlayerShellWindow->setResizing(true); + return true; +} + void QWaylandLayerShellSurface::setWindowGeometry(const QRect &geometry) { + // Qt also calls this while applying a compositor configure. Echoing that + // size back can replace a newer client request and start a resize loop. + if (m_applyingConfigure) + return; + calcAndSetRequestSize(geometry.size()); trySetAnchorsAndSize(); } diff --git a/frame/layershell/qwaylandlayershellsurface_p.h b/frame/layershell/qwaylandlayershellsurface_p.h index c8e59cb37..6bebd550a 100644 --- a/frame/layershell/qwaylandlayershellsurface_p.h +++ b/frame/layershell/qwaylandlayershellsurface_p.h @@ -7,12 +7,15 @@ #include "dsglobal.h" #include "dlayershellwindow.h" +#include #include #include #include DS_BEGIN_NAMESPACE +class TreeLandLayerShellExtensionObject; + class QWaylandLayerShellSurface : public QtWaylandClient::QWaylandShellSurface, public QtWayland::zwlr_layer_surface_v1 { Q_OBJECT @@ -28,6 +31,7 @@ class QWaylandLayerShellSurface : public QtWaylandClient::QWaylandShellSurface, void applyConfigure() override; void setWindowGeometry(const QRect &geometry) override; void attachPopup(QWaylandShellSurface *popup) override; + bool resize(QtWaylandClient::QWaylandInputDevice *inputDevice, Qt::Edges edges) override; private: void zwlr_layer_surface_v1_configure(uint32_t serial, uint32_t width, uint32_t height) override; @@ -51,12 +55,16 @@ class QWaylandLayerShellSurface : public QtWaylandClient::QWaylandShellSurface, void recreateWindow(); void flushRecreate(); void scheduleRecreate(); + void finishResize(); - DLayerShellWindow* m_dlayerShellWindow; + QPointer m_dlayerShellWindow; + QScopedPointer m_shellExtension; QSize m_pendingSize; QSize m_requestSize; wl_output *m_output = nullptr; bool m_configured = false; + bool m_applyingConfigure = false; + bool m_interactiveResize = false; bool m_commitScheduled = false; bool m_recreateScheduled = false; }; diff --git a/panels/dock/CMakeLists.txt b/panels/dock/CMakeLists.txt index 961655389..b4f583396 100644 --- a/panels/dock/CMakeLists.txt +++ b/panels/dock/CMakeLists.txt @@ -9,7 +9,6 @@ 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 0.9.0 REQUIRED) pkg_check_modules(WaylandClient REQUIRED IMPORTED_TARGET wayland-client) file( @@ -26,8 +25,6 @@ file( dockhelper.cpp waylanddockhelper.h waylanddockhelper.cpp - layershellextension.h - layershellextension.cpp ) # Old dbus interface compatible @@ -66,7 +63,6 @@ qt_generate_wayland_protocol_client_sources(dockpanel ${TREELAND_PROTOCOLS_DATA_DIR}/treeland-foreign-toplevel-manager-unstable-v3.xml ${TREELAND_PROTOCOLS_DATA_DIR}/treeland-xwindow-control-unstable-v1.xml ${TREELAND_PROTOCOLS_DATA_DIR}/treeland-region-watch-unstable-v1.xml - ${TREELAND_PROTOCOLS_DATA_DIR}/treeland-layer-shell-extension-unstable-v1.xml ) target_link_libraries(dockpanel PRIVATE diff --git a/panels/dock/dockpanel.cpp b/panels/dock/dockpanel.cpp index 2049c6a15..92b8e8cdf 100644 --- a/panels/dock/dockpanel.cpp +++ b/panels/dock/dockpanel.cpp @@ -7,7 +7,6 @@ #include "dockadaptor.h" #include "docksettings.h" #include "layershell/dlayershellwindow.h" -#include "layershellextension.h" #include "panel.h" #include "pluginfactory.h" #include "waylanddockhelper.h" @@ -29,10 +28,7 @@ #include -#include -#include #include -#include #ifdef HAVE_DDE_API_EVENTLOGGER #include @@ -229,7 +225,6 @@ bool DockPanel::init() m_helper = new WaylandDockHelper(this); connect(static_cast(m_helper), &WaylandDockHelper::xembedWindowMoveResult, this, &DockPanel::xembedWindowMoveResult); - m_dockShellExtensionManager.reset(new TreeLandLayerShellExtensionManager()); // Fallback to DGuiApplicationHelper for theme color when wayland wallpaper color is not available. // TODO: remove this when initWallpaperColorManager is re-enabled QObject::connect(Dtk::Gui::DGuiApplicationHelper::instance(), &Dtk::Gui::DGuiApplicationHelper::themeTypeChanged, @@ -651,7 +646,6 @@ void DockPanel::setContextDragging(bool newContextDragging) bool DockPanel::isResizing() const { return m_isResizing; - } void DockPanel::setIsResizing(bool resizing) @@ -669,94 +663,6 @@ bool DockPanel::moveXEmbedWindow(uint32_t wid, double dx, double dy, QQuickWindo } return false; } - -bool DockPanel::beginResize() -{ - uint edges = 0; - int minW = 0, maxW = 0, minH = 0, maxH = 0; - switch (position()) { - case Position::Left: - edges = TreeLandLayerShellExtensionObject::resize_edge_right; - minW = MIN_DOCK_SIZE; - maxW = MAX_DOCK_SIZE; - break; - case Position::Right: - edges = TreeLandLayerShellExtensionObject::resize_edge_left; - minW = MIN_DOCK_SIZE; - maxW = MAX_DOCK_SIZE; - break; - case Position::Top: - edges = TreeLandLayerShellExtensionObject::resize_edge_bottom; - minH = MIN_DOCK_SIZE; - maxH = MAX_DOCK_SIZE; - break; - case Position::Bottom: - edges = TreeLandLayerShellExtensionObject::resize_edge_top; - minH = MIN_DOCK_SIZE; - maxH = MAX_DOCK_SIZE; - break; - default: - Q_UNREACHABLE(); - break; - } - - if (!m_dockShellExtensionManager) { - qCWarning(dockLog) << "beginResize: layer shell extension manager is null"; - return false; - } - - if (!m_dockShellExtensionManager->isActive()) { - qCWarning(dockLog) << "beginResize: layer shell extension manager inactive"; - return false; - } - - auto *w = window(); - if (!w) { - qCWarning(dockLog) << "beginResize: window is null"; - return false; - } - - auto *waylandWindow = dynamic_cast(w->handle()); - if (!waylandWindow) { - qCWarning(dockLog) << "beginResize: failed to get QWaylandWindow"; - return false; - } - - auto *surface = waylandWindow->wlSurface(); - - if (!surface) { - qCWarning(dockLog) << "beginResize: wl_surface is null"; - return false; - } - - auto *inputDevice = waylandWindow->display()->lastInputDevice(); - - if (!inputDevice) { - qCWarning(dockLog) << "beginResize: no last input device"; - return false; - } - - auto *dockSurface = m_dockShellExtensionManager->getLayerShellExtensionObject(surface); - - if (!dockSurface) { - qCWarning(dockLog) << "beginResize: failed to get layer shell extension object"; - return false; - } - if (m_dockShellExtensionObject) - return false; - m_dockShellExtensionObject = new TreeLandLayerShellExtensionObject(dockSurface, surface); - m_dockShellExtensionObject->setParent(this); - connect(m_dockShellExtensionObject, &TreeLandLayerShellExtensionObject::resizingChanged, this, [this](bool resizing) { - setIsResizing(resizing); - if (!resizing) { - m_dockShellExtensionObject->deleteLater(); - } - }); - - m_dockShellExtensionObject->beginResize(inputDevice->wl_seat(), inputDevice->serial(), edges, minW, minH, maxW, maxH); - inputDevice->handleEndDrag(); - return true; -} } #include "dockpanel.moc" diff --git a/panels/dock/dockpanel.h b/panels/dock/dockpanel.h index 1176f998b..b30ee734b 100644 --- a/panels/dock/dockpanel.h +++ b/panels/dock/dockpanel.h @@ -14,8 +14,6 @@ namespace dock { class DockHelper; -class TreeLandLayerShellExtensionManager; -class TreeLandLayerShellExtensionObject; class DockPanel : public DS_NAMESPACE::DPanel, public QDBusContext { @@ -107,8 +105,6 @@ class DockPanel : public DS_NAMESPACE::DPanel, public QDBusContext // anchorWindow: the window containing the plugin item (dock panel or popup window) Q_INVOKABLE bool moveXEmbedWindow(uint32_t wid, double dx, double dy, QQuickWindow *anchorWindow = nullptr); - Q_INVOKABLE bool beginResize(); - bool showInPrimary() const; void setShowInPrimary(bool newShowInPrimary); @@ -193,8 +189,6 @@ private Q_SLOTS: bool m_contextDragging; bool m_isResizing; QRect m_frontendWindowRect; - QScopedPointer m_dockShellExtensionManager; - QPointer m_dockShellExtensionObject; }; } diff --git a/panels/dock/layershellextension.cpp b/panels/dock/layershellextension.cpp deleted file mode 100644 index 4e475e0b3..000000000 --- a/panels/dock/layershellextension.cpp +++ /dev/null @@ -1,56 +0,0 @@ -// SPDX-FileCopyrightText: 2026 UnionTech Software Technology Co., Ltd. -// -// SPDX-License-Identifier: GPL-3.0-or-later - -#include "layershellextension.h" - -namespace dock -{ - -TreeLandLayerShellExtensionManager::TreeLandLayerShellExtensionManager() - : QWaylandClientExtensionTemplate(treeland_layer_shell_extension_manager_v1_interface.version) -{ -} - -struct ::treeland_layer_shell_extension_object_v1 *TreeLandLayerShellExtensionManager::getLayerShellExtensionObject(struct ::wl_surface *surface) -{ - return get_layer_shell_extension_object(surface); -} - -TreeLandLayerShellExtensionObject::TreeLandLayerShellExtensionObject(struct ::treeland_layer_shell_extension_object_v1 *object, - struct ::wl_surface *nativeSurface) - : QWaylandClientExtensionTemplate(treeland_layer_shell_extension_object_v1_interface.version) - , m_nativeSurface(nativeSurface) -{ - init(object); -} - -TreeLandLayerShellExtensionObject::~TreeLandLayerShellExtensionObject() -{ - if (object()) { - destroy(); - } -} - -struct ::wl_surface *TreeLandLayerShellExtensionObject::nativeSurface() const -{ - return m_nativeSurface; -} - -void TreeLandLayerShellExtensionObject::beginResize(struct ::wl_seat *seat, - uint32_t serial, - uint32_t edges, - int32_t minWidth, - int32_t minHeight, - int32_t maxWidth, - int32_t maxHeight) -{ - begin_resize(seat, serial, edges, minWidth, minHeight, maxWidth, maxHeight); -} - -void TreeLandLayerShellExtensionObject::treeland_layer_shell_extension_object_v1_resizing(uint32_t resizing) -{ - Q_EMIT resizingChanged(resizing != 0); -} - -} diff --git a/panels/dock/layershellextension.h b/panels/dock/layershellextension.h deleted file mode 100644 index 2d7850d29..000000000 --- a/panels/dock/layershellextension.h +++ /dev/null @@ -1,62 +0,0 @@ -// SPDX-FileCopyrightText: 2026 UnionTech Software Technology Co., Ltd. -// -// SPDX-License-Identifier: GPL-3.0-or-later - -#pragma once - -#include "qwayland-treeland-layer-shell-extension-unstable-v1.h" - -#include - -#include - -namespace dock -{ - -// Client wrapper for the treeland_layer_shell_extension_manager_v1 protocol global. -// Lets the dock opt in to compositor-driven interactive resize: the compositor -// owns the drag state machine and drives the surface size through the standard -// layer-surface configure events (see treeland-layer-shell-extension-unstable-v1.xml). -class TreeLandLayerShellExtensionManager : public QWaylandClientExtensionTemplate, - public QtWayland::treeland_layer_shell_extension_manager_v1 -{ - Q_OBJECT - -public: - explicit TreeLandLayerShellExtensionManager(); - - // Creates an interactive object for an existing wl_surface and returns the - // raw protocol object; the caller wraps it in a TreeLandLayerShellExtensionObject. - struct ::treeland_layer_shell_extension_object_v1 *getLayerShellExtensionObject(struct ::wl_surface *surface); -}; - -// Client wrapper for the treeland_layer_shell_extension_object_v1 protocol object bound -// to the layer surface. This is the single entry point for every interactive -// operation on a treeland layer-shell surface (resize today, move later). -class TreeLandLayerShellExtensionObject : public QWaylandClientExtensionTemplate, - public QtWayland::treeland_layer_shell_extension_object_v1 -{ - Q_OBJECT - -public: - explicit TreeLandLayerShellExtensionObject(struct ::treeland_layer_shell_extension_object_v1 *object, struct ::wl_surface *nativeSurface); - ~TreeLandLayerShellExtensionObject(); - - void beginResize(struct ::wl_seat *seat, uint32_t serial, uint32_t edges, int32_t minWidth, int32_t minHeight, int32_t maxWidth, int32_t maxHeight); - - // Returns the wl_surface this object was bound to. Does not validate - // lifetime; callers must compare it against the window's current surface - // and re-bind (a new object) when it changed, before issuing any request. - struct ::wl_surface *nativeSurface() const; - -Q_SIGNALS: - void resizingChanged(bool resizing); - -protected: - void treeland_layer_shell_extension_object_v1_resizing(uint32_t resizing) override; - -private: - struct ::wl_surface *m_nativeSurface = nullptr; -}; - -} diff --git a/panels/dock/package/main.qml b/panels/dock/package/main.qml index 1d677a44c..1bf055850 100644 --- a/panels/dock/package/main.qml +++ b/panels/dock/package/main.qml @@ -115,6 +115,10 @@ Window { : dockSize color: "transparent" flags: Qt.WindowDoesNotAcceptFocus + maximumHeight: useColumnLayout ? Screen.height : Dock.MAX_DOCK_SIZE + minimumHeight: useColumnLayout? Screen.height : Dock.MIN_DOCK_SIZE + maximumWidth: useColumnLayout ? Dock.MAX_DOCK_SIZE : Screen.width + minimumWidth: useColumnLayout ? Dock.MIN_DOCK_SIZE : Screen.width function blendColorAlpha(fallback) { var appearance = DS.applet("org.deepin.ds.dde-appearance") @@ -788,7 +792,12 @@ Window { Panel.requestClosePopup() if (dock.compositorDrivenResize) { - Panel.beginResize() + const edge = Panel.position === Dock.Top ? Qt.BottomEdge + : Panel.position === Dock.Bottom ? Qt.TopEdge + : Panel.position === Dock.Left ? Qt.RightEdge : Qt.LeftEdge + if (!dock.startSystemResize(edge)) + finishResize() + return } DS.grabMouse(Panel.rootObject, true) } @@ -838,12 +847,18 @@ Window { onReleased: function(mouse) { if (Panel.locked) return - if (dock.compositorDrivenResize && Applet.isResizing) return + if (dock.DLayerShellWindow.resizing) return finishResize() } + onCanceled: { + if (!dock.DLayerShellWindow.resizing) + finishResize() + } + function finishResize() { + if (!dock.isDragging) return dock.isDragging = false Applet.dockSize = dockSize itemIconSizeBase = dockItemMaxSize @@ -883,9 +898,12 @@ Window { } Connections { - target: Panel - function onIsResizingChanged(resizing) { - if (!resizing && dock.isDragging) { + target: dock.DLayerShellWindow + function onResizeFinished(size) { + Applet.dockSize = dock.useColumnLayout ? size.width : size.height + } + function onResizingChanged() { + if (!dock.DLayerShellWindow.resizing && dock.isDragging) { dragArea.finishResize() } } @@ -895,7 +913,7 @@ Window { target: dock enabled: dock.compositorDrivenResize // Wayland can apply animation geometry after the animation stops. - && dock.isDragging && Applet.isResizing + && dock.isDragging && dock.DLayerShellWindow.resizing && !hideShowAnimation.running && !dockAnimation.running function onWidthChanged() {