Skip to content

feat(layer-shell-extension): add compositor-driven dock resize protocol - #1393

Open
gugullll wants to merge 1 commit into
linuxdeepin:masterfrom
gugullll:fix/dock_change
Open

feat(layer-shell-extension): add compositor-driven dock resize protocol#1393
gugullll wants to merge 1 commit into
linuxdeepin:masterfrom
gugullll:fix/dock_change

Conversation

@gugullll

@gugullll gugullll commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Add the server side of the treeland-layer-shell-extension-unstable-v1 protocol, letting a layer-shell client (e.g. the dock) hand interactive resize over to the compositor. begin_resize validates seat/serial/edges and takes per-drag min/max size limits, which are enforced based on the dragged dimensions via a SeatSurfaceManager resize clamp. The moveResizeFinised signal now carries the surface so each extension object reacts only to its own surface.

新增layer-shell-extension私有协议服务端实现,dock可将resize交给合成器。 begin_resize校验seat/serial/edges,依赖SeatSurfaceManager的resize钳制 限制拖拽尺寸,moveResizeFinised信号携带surface以精准匹配对象。

Log: 新增层扩展对象协议,支持合成器驱动dock resize并限制尺寸
PMS: BUG-294673
Influence: 修复任务栏拖动时无法改变高度的问题,通过wayland私有协议将
resize交由合成器处理,并带min/max尺寸钳制,提升拖拽流畅度与一致性。

Summary by Sourcery

Enable compositor-driven, validated layer-surface resizing with configurable minimum and maximum dimensions.

New Features:

  • Add the compositor-side layer-shell extension protocol, allowing clients to delegate interactive layer-surface resizing to the compositor with per-drag size limits.

Bug Fixes:

  • Fix dock/taskbar resizing so its height can be changed during interactive dragging.

Enhancements:

  • Validate resize requests and correlate resize completion events with the affected surface.

Build:

  • Add the layer-shell-extension module and generate its Wayland server protocol bindings.

@sourcery-ai

sourcery-ai Bot commented Sep 11, 2026

Copy link
Copy Markdown

Reviewer's Guide

This PR introduces and registers a private layer-shell extension protocol that lets clients delegate interactive resizing to the compositor. Requests are validated against seat input serials, layer-surface state, anchors, and edges; accepted drags use the existing per-seat move/resize machinery with per-session size clamps, surface-specific completion handling, lifecycle cleanup, and dock-focused diagnostics.

Sequence diagram for compositor-driven layer-surface resize

sequenceDiagram
    participant Dock as Layer-shell client
    participant Manager as LayerShellExtensionManagerInterfaceV1
    participant Object as LayerShellExtensionObjectV1
    participant Container as RootSurfaceContainer
    participant Seat as SeatSurfaceManager

    Dock->>Manager: get_layer_shell_extension_object(surface)
    Manager-->>Dock: objectCreated
    Dock->>Object: begin_resize(seat, serial, edges, min_width, min_height, max_width, max_height)
    Object->>Object: wlr_seat_validate_pointer_grab_serial()
    Object->>Container: beginMoveResizeForSeat(seat, wrapper, qtEdges)
    Object->>Seat: setResizeClamp(minW, maxW, minH, maxH)
    Object-->>Dock: send_resizing(1)
    Seat->>Seat: applyResizeClamp(targetSize)
    Seat-->>Container: moveResizeChanged(surface)
    Container-->>Object: moveResizeFinised(surface)
    Object-->>Dock: send_resizing(0)
    Object->>Seat: clearResizeClamp()
Loading

File-Level Changes

Change Details Files
Add and register the compositor-side layer-shell extension protocol service.
  • Generate QtWayland server bindings for the private protocol.
  • Attach the manager during shell initialization and expose per-surface extension objects.
  • Track object and surface lifetimes, including cleanup when the underlying surface is destroyed.
src/modules/CMakeLists.txt
src/modules/layer-shell-extension/CMakeLists.txt
src/modules/layer-shell-extension/layershellextensionmanagerinterfacev1.h
src/modules/layer-shell-extension/layershellextensionmanagerinterfacev1.cpp
src/core/shellhandler.h
src/core/shellhandler.cpp
Implement validated compositor-driven resize requests for layer-shell surfaces.
  • Validate the seat resource, pointer serial, resize edges, layer-surface type/state, animation status, and anchor compatibility.
  • Start the standard per-seat move/resize path and report accepted or rejected protocol status.
  • Associate completion handling with the resized surface so unrelated move/resize completions do not end this object’s resize.
src/modules/layer-shell-extension/layershellextensionmanagerinterfacev1.cpp
src/core/rootsurfacecontainer.h
Add per-drag resize limit enforcement to seat surface management.
  • Store and clear per-seat min/max width and height constraints.
  • Clamp only dimensions corresponding to the active resize edges before applying the resized geometry.
  • Emit the resized surface with move/resize completion notifications and update related signal declarations.
src/surface/seatsurfacemanager.h
src/surface/seatsurfacemanager.cpp
Add dedicated dock logging for the new protocol implementation.
  • Declare and define the treeland.dock logging category.
  • Use the category for protocol validation, lifecycle, and resize diagnostics.
src/common/treelandlogging.h
src/common/treelandlogging.cpp

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨


#include <wayland-server.h>
#include <wlayersurface.h>
#include <wlr/types/wlr_seat.h>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

确认是否需要,如果需要,c头文件加 extern "C"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

改为了#include <wlr_all.h>

{
if (!surface) {
qCWarning(lcTlDock) << "get_object: NULL surface resource";
wl_resource_post_error(resource->handle, 0, "surface resource is NULL!");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

和 error_layer_shell_extension_exists 一样,协议加一个枚举表示这种错误

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Critical validation and include issues, resize state/lifecycle bugs, and missing protocol tests remain unresolved.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds a private layer-shell extension protocol for compositor-driven dock resizing with validation and min/max size limits.

Changes:

  • Adds and registers the layer-shell extension protocol.
  • Integrates per-seat resize clamping and surface-aware completion signals.
  • Adds protocol startup integration and dock logging.
File summaries
File Description
src/surface/seatsurfacemanager.h Adds resize clamp APIs and surface-aware signaling.
src/surface/seatsurfacemanager.cpp Applies resize limits and emits the affected surface.
src/modules/layer-shell-extension/layershellextensionmanagerinterfacev1.h Defines protocol manager and object interfaces.
src/modules/layer-shell-extension/layershellextensionmanagerinterfacev1.cpp Implements protocol validation, resizing, and lifecycle handling.
src/modules/layer-shell-extension/CMakeLists.txt Generates and builds protocol bindings.
src/modules/CMakeLists.txt Registers the new module.
src/core/shellhandler.h Stores the protocol manager.
src/core/shellhandler.cpp Attaches the protocol manager during startup.
src/core/rootsurfacecontainer.h Updates the resize completion signal.
src/common/treelandlogging.h Declares the dock logging category.
src/common/treelandlogging.cpp Defines the dock logging category.
Review details

Suppressed comments (4)

src/modules/layer-shell-extension/CMakeLists.txt:18

  • This new protocol path has no automated test target, although the repository provides a real compositor protocol-test framework and tests comparable private protocols such as treeland-prelaunch-splash-v2. The seat/serial/edge validation, per-seat min/max clamp, replacement of an active resize, and cleanup paths are stateful behaviors that can regress without detection. Add an integration test for an accepted resize plus rejected invalid requests and clamping/finish behavior.

这个新协议路径没有自动化测试目标,但仓库已经提供了真实合成器协议测试框架,并为类似的私有协议(例如 treeland-prelaunch-splash-v2)编写了测试。seat/serial/edge 校验、按 seat 的 min/max 钳制、替换已有 resize 以及清理路径都属于容易回归的状态行为。请增加集成测试,覆盖成功 resize、无效请求拒绝以及钳制和结束行为。

impl_treeland(
    NAME
        module_layer_shell_extension
    SOURCE
        layershellextensionmanagerinterfacev1.h
        layershellextensionmanagerinterfacev1.cpp
    INCLUDE
        $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
    LINK
        Qt6::Core
)

src/modules/layer-shell-extension/layershellextensionmanagerinterfacev1.cpp:379

  • When the client destroys this extension object during an active resize, the destructor only clears the clamp. The corresponding SeatSurfaceManager still retains the surface in its move/resize state, so pointer motion can continue resizing it after the protocol object is gone and no completion event is available. Destruction must cancel/end the matching compositor resize before releasing the object, with the resource/event ordering handled safely. / 客户端在拖动过程中销毁扩展对象时,析构函数只清除了钳制;对应的SeatSurfaceManager仍保留该surface的移动/缩放状态,因此协议对象销毁后指针移动仍可能继续改变尺寸,也无法再发送完成事件。销毁对象前必须结束或取消对应的合成器拖动,并安全处理资源与事件顺序。
    if (d->clampRegistered)
        d->clearClamp();

src/modules/layer-shell-extension/layershellextensionmanagerinterfacev1.cpp:257

  • This introduces a new protocol request with critical validation and stateful behavior—seat/serial/edge/anchor rejection, min/max clamping, and resize completion—but the PR adds no protocol test target. The repository already has dedicated automated targets under tests/protocols; please add coverage for accepted resize, invalid requests, clamping, and completion so these regressions are caught. / 这里新增了包含关键校验和有状态行为的协议请求,包括seat/serial/edge/anchor拒绝、最小/最大尺寸钳制和拖动完成,但PR没有增加协议测试目标。仓库在tests/protocols下已有专门的自动化测试目标;请补充成功拖动、无效请求、尺寸钳制和完成事件测试,以防止这些回归。
void LayerShellExtensionObjectV1Private::begin_resize(Resource *resource,

src/modules/layer-shell-extension/layershellextensionmanagerinterfacev1.cpp:310

  • The mask check accepts opposite edges such as top|bottom and left|right. SeatSurfaceManager::doMoveResize() applies the same delta to both opposite sides, so the corresponding dimension does not change even though the request is accepted and reported as resizing. Reject opposite edge pairs here as invalid. / 当前掩码校验会接受top|bottomleft|right等相对边组合,而SeatSurfaceManager::doMoveResize()会对相对两边应用相同位移,使对应尺寸实际上不变,但请求仍被接受并报告为拖动。应在此拒绝相对边组合。
    if (edges == 0 || (edges & ~kValidEdgeBits) != 0) {
        qCWarning(lcTlLayerShell) << "begin_resize REJECTED: bad edges =" << edges;
  • Files reviewed: 11/11 changed files
  • Comments generated: 4
  • Review effort level: Lite

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/modules/layer-shell-extension/layershellextensionmanagerinterfacev1.cpp Outdated
Comment thread src/modules/layer-shell-extension/layershellextensionmanagerinterfacev1.cpp Outdated
Comment thread src/modules/layer-shell-extension/layershellextensionmanagerinterfacev1.cpp Outdated
q->endResize();

if (isResource())
wl_resource_destroy(resource()->handle);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

理论上应该要等客户端调用destroy请求

@gugullll
gugullll force-pushed the fix/dock_change branch 2 times, most recently from 8fd88bb to e2c9069 Compare September 11, 2026 09:07
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: gugullll

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Critical resource-validation and surface-lifecycle issues remain, and protocol integration tests are missing.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details

Suppressed comments (2)

src/modules/layer-shell-extension/CMakeLists.txt:5

  • This introduces a new private Wayland protocol with validation, error events, and resize-clamp state, but no protocol integration test is added. The repository's protocol-test guidance requires a per-protocol C client/setup target (tests/protocols/README.md:19-39), and the existing tests/protocols/CMakeLists.txt registers comparable Treeland protocols. Add a real client test covering object/seat rejection, serial/edge validation, clamp limits, and the resizing completion event. 这里新增了带资源校验、错误事件和 resize 钳制状态的私有 Wayland 协议,但没有增加协议集成测试;仓库对其他 Treeland 协议均使用独立 C client/setup 测试。请补充覆盖对象/seat、serial/edge、min/max 钳制及完成事件的真实协议测试。
waylib_generate_qtwayland_server_protocol(libtreeland
    PROTOCOL ${TREELAND_PROTOCOLS_DATA_DIR}/treeland-layer-shell-extension-unstable-v1.xml
    BASENAME treeland-layer-shell-extension-unstable-v1

src/modules/layer-shell-extension/layershellextensionmanagerinterfacev1.cpp:391

  • The public wSurface() accessor has the same post-destruction path: onSurfaceDestroyed() clears nativeSurface, and calling this accessor then passes nullptr to the assertive wlr_surface_from_resource(). Return nullptr directly when d->nativeSurface is cleared. wSurface() 也存在相同的 surface 销毁后路径;当 nativeSurface 已清空时应直接返回 nullptr,不要调用会断言的转换函数。
    return WSurface::fromHandle(wlr_surface_from_resource(d->nativeSurface));
  • Files reviewed: 11/11 changed files
  • Comments generated: 5
  • Review effort level: Lite

{
Q_UNUSED(surface);

q->endResize();

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1

Comment on lines +182 to +185
if (auto *wlrSurface = wlr_surface_from_resource(surface)) {
m_surfaceDestroy.init(&wlrSurface->events.destroy,
this,
&LayerShellExtensionObjectV1Private::onSurfaceDestroyed);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

新增wl_resource_instance_of验证

const qreal effectiveMinH = validH ? minH : 0;
const qreal effectiveMaxH = validH ? maxH : 0;

auto *seatClient = wlr_seat_client_from_resource(seatResource);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

新增Q_ASSERT

return;
}

wlr_surface *origin = wlr_surface_from_resource(nativeSurface);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1

Comment on lines +311 to +314
// Edge must be a non-zero combination of valid edge bits
if (edges == 0 || (edges & ~kValidEdgeBits) != 0) {
qCWarning(lcTlLayerShell) << "begin_resize REJECTED: bad edges =" << edges;
send_resize_rejected(resource->handle, resize_error_bad_edges);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dde-shell已有

Add the server side of the treeland-layer-shell-extension-unstable-v1
protocol, letting a layer-shell client (e.g. the dock) hand interactive
resize over to the compositor. begin_resize validates seat/serial/edges
and takes per-drag min/max size limits, which are enforced based on the
dragged dimensions via a SeatSurfaceManager resize clamp. The
moveResizeFinised signal now carries the surface so each extension
object reacts only to its own surface.

新增layer-shell-extension私有协议服务端实现,dock可将resize交给合成器。
begin_resize校验seat/serial/edges,依赖SeatSurfaceManager的resize钳制
限制拖拽尺寸,moveResizeFinised信号携带surface以精准匹配对象。

Log: 新增层扩展对象协议,支持合成器驱动dock resize并限制尺寸
PMS: BUG-294673
Influence: 修复任务栏拖动时无法改变高度的问题,通过wayland私有协议将
resize交由合成器处理,并带min/max尺寸钳制,提升拖拽流畅度与一致性。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants