feat(layer-shell-extension): add compositor-driven dock resize protocol - #1393
feat(layer-shell-extension): add compositor-driven dock resize protocol#1393gugullll wants to merge 1 commit into
Conversation
Reviewer's GuideThis 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 resizesequenceDiagram
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()
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
|
||
| #include <wayland-server.h> | ||
| #include <wlayersurface.h> | ||
| #include <wlr/types/wlr_seat.h> |
There was a problem hiding this comment.
改为了#include <wlr_all.h>
4120d81 to
d927f17
Compare
| { | ||
| if (!surface) { | ||
| qCWarning(lcTlDock) << "get_object: NULL surface resource"; | ||
| wl_resource_post_error(resource->handle, 0, "surface resource is NULL!"); |
There was a problem hiding this comment.
和 error_layer_shell_extension_exists 一样,协议加一个枚举表示这种错误
There was a problem hiding this comment.
🟡 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
SeatSurfaceManagerstill 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|bottomandleft|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|bottom和left|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.
| q->endResize(); | ||
|
|
||
| if (isResource()) | ||
| wl_resource_destroy(resource()->handle); |
8fd88bb to
e2c9069
Compare
|
[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. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
There was a problem hiding this comment.
🟡 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 existingtests/protocols/CMakeLists.txtregisters comparable Treeland protocols. Add a real client test covering object/seat rejection, serial/edge validation, clamp limits, and theresizingcompletion 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()clearsnativeSurface, and calling this accessor then passesnullptrto the assertivewlr_surface_from_resource(). Returnnullptrdirectly whend->nativeSurfaceis 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(); |
| if (auto *wlrSurface = wlr_surface_from_resource(surface)) { | ||
| m_surfaceDestroy.init(&wlrSurface->events.destroy, | ||
| this, | ||
| &LayerShellExtensionObjectV1Private::onSurfaceDestroyed); |
There was a problem hiding this comment.
新增wl_resource_instance_of验证
| const qreal effectiveMinH = validH ? minH : 0; | ||
| const qreal effectiveMaxH = validH ? maxH : 0; | ||
|
|
||
| auto *seatClient = wlr_seat_client_from_resource(seatResource); |
| return; | ||
| } | ||
|
|
||
| wlr_surface *origin = wlr_surface_from_resource(nativeSurface); |
| // 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); |
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尺寸钳制,提升拖拽流畅度与一致性。
e2c9069 to
bb1f7c9
Compare
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:
Bug Fixes:
Enhancements:
Build: