Skip to content

移除旧截图,引入 treeland-capture-snap - #1307

Draft
glyvut wants to merge 2 commits into
linuxdeepin:masterfrom
glyvut:s4
Draft

移除旧截图,引入 treeland-capture-snap #1307
glyvut wants to merge 2 commits into
linuxdeepin:masterfrom
glyvut:s4

Conversation

@glyvut

@glyvut glyvut commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

前置:linuxdeepin/treeland-protocols#87

Summary by Sourcery

Replace the legacy screen-capture selection system with the treeland-capture-snap protocol and a dedicated snap-capture example.

New Features:

  • Introduce the treeland-capture-snap Wayland protocol and compositor-side snap-region detection for selecting visible surfaces under the cursor.
  • Add a Qt example client that displays snap regions, optionally captures the full desktop as a background, and provides a selection confirmation UI.

Enhancements:

  • Replace the legacy capture module and selector layer with the capture-snap implementation.
  • Treat capture mask windows as fixed, full-desktop overlays that are excluded from snap detection and window management operations.

Build:

  • Update CMake targets, protocol generation, module names, and example installation for capture-snap.

Chores:

  • Remove the obsolete capture protocol implementation, QML selector, and test_capture example.

@deepin-ci-robot

Copy link
Copy Markdown

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: glyvut

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

@sourcery-ai

sourcery-ai Bot commented Aug 20, 2026

Copy link
Copy Markdown

Reviewer's Guide

Replace the old capture module and client demo with a new treeland-capture-snap protocol and snap-based capture flow, wiring compositor-side snap handling and mask window detection to a new demo client and server module.

Sequence diagram for treeland-capture-snap snap session flow

sequenceDiagram
    actor Client
    participant treeland_capture_snap_v1
    participant CaptureSnapV1
    participant WSeat
    participant WCursor
    participant SnapDetector

    Client->>treeland_capture_snap_v1: start
    treeland_capture_snap_v1->>CaptureSnapV1: startRequested
    CaptureSnapV1->>CaptureSnapV1: onStartRequested
    CaptureSnapV1->>SnapDetector: collect(m_renderWindow, m_captureMaskSurface)
    SnapDetector-->>CaptureSnapV1: snapshot (QList<QRectF>)
    CaptureSnapV1->>WSeat: seat()
    WSeat-->>CaptureSnapV1: WSeat*
    CaptureSnapV1->>WCursor: connect(positionChanged)

    WCursor-->>CaptureSnapV1: positionChanged
    CaptureSnapV1->>CaptureSnapV1: onCursorMoved
    CaptureSnapV1->>CaptureSnapV1: updateSnapRegion
    CaptureSnapV1->>SnapDetector: hitTest(cursorPos, m_snapshot)
    SnapDetector-->>CaptureSnapV1: QRectF region
    CaptureSnapV1->>CaptureSnapV1: sendSnapRegion(region)
    CaptureSnapV1-->>treeland_capture_snap_v1: sendSnapRegion(x, y, w, h)

    Client->>treeland_capture_snap_v1: stop
    treeland_capture_snap_v1->>CaptureSnapV1: stopRequested
    CaptureSnapV1->>CaptureSnapV1: onStopRequested / stopSnapping
Loading

Sequence diagram for capture mask tagging and integration with CaptureSnapV1

sequenceDiagram
    participant WXdgToplevelSurface
    participant ShellHandler
    participant SurfaceWrapper
    participant SurfaceContainer_capture
    participant CaptureSnapV1

    WXdgToplevelSurface-->>ShellHandler: tagChanged
    ShellHandler->>ShellHandler: applyIfTaggedSurface()
    ShellHandler->>ShellHandler: checkAndApplyPrivilegedOverlay(wrapperPtr)
    ShellHandler->>ShellHandler: m_imCandidatePanelManager->checkAndApplyIMCandidatePanel(wrapperPtr)
    alt tag == org.deepin.treeland.capture-mask and !wrapperPtr->isCaptureMask()
        ShellHandler->>ShellHandler: applyCaptureMask(wrapper)
        ShellHandler->>SurfaceWrapper: setSkipSwitcher(true), setSkipDockPreView(true), setSkipMutiTaskView(true)
        ShellHandler->>SurfaceWrapper: setNoTitleBar(true), setNoCornerRadius(true), setNoDecoration(true)
        ShellHandler->>SurfaceWrapper: disableWindowAnimation()
        ShellHandler->>SurfaceWrapper: setPositionAutomatic(false)
        ShellHandler->>SurfaceContainer_capture: addSurface(wrapper)
        ShellHandler->>SurfaceWrapper: setHasInitializeContainer(true)
        ShellHandler->>SurfaceWrapper: setZ(CaptureLayerZOrder)
        ShellHandler->>SurfaceWrapper: setCaptureMask(true)
        ShellHandler->>SurfaceWrapper: setNormalGeometry(desktopRect)
        ShellHandler->>SurfaceWrapper: resize(desktopRect.size())
        ShellHandler->>CaptureSnapV1: setCaptureMaskSurface(wrapper->surface())
    end
Loading

File-Level Changes

Change Details Files
Introduce a new test_snap_capture example client using treeland-capture-snap and ext-image-copy-capture, replacing the legacy test_capture example.
  • Remove the entire examples/test_capture directory and its CMake integration.
  • Add examples/test_snap_capture with CMake setup for Wayland/treeland protocols, QML UI, and main.cpp wiring a SnapController to the snap protocol client.
  • Implement ScreenCapture to capture the full canvas using ext-output-image-capture-source and ext-image-copy-capture.
  • Implement snapproxy (ToplevelTagManager, Snap, SnapController) to consume treeland-capture-snap events, tag the mask window via xdg-toplevel-tag, and expose snap region state to QML.
examples/CMakeLists.txt
examples/test_capture/*
examples/test_snap_capture/CMakeLists.txt
examples/test_snap_capture/Main.qml
examples/test_snap_capture/main.cpp
examples/test_snap_capture/screencapture.cpp
examples/test_snap_capture/screencapture.h
examples/test_snap_capture/snapproxy.cpp
examples/test_snap_capture/snapproxy.h
Replace the old capture module with a new capture-snap server module implementing treeland-capture-snap-unstable-v1, cursor-based snap region detection, and a dedicated capture mask layer.
  • Rename the capture module directory/CMake target to capture-snap, switch to treeland-capture-snap-unstable-v1 protocol code generation, and update module metadata (URI, output name, impl_treeland registration).
  • Implement snapv1impl server-side wrapper for treeland_capture_snap_v1, emitting Qt signals for start/stop and sending snap_region/failed events.
  • Implement SnapDetector to build a snapshot of visible surface and output rectangles and hit-test them against cursor position.
  • Implement CaptureSnapV1 as a WServerInterface global that manages a single active snap session, tracks cursor movement, computes snap regions from SnapDetector, and sends them to the client.
  • Attach CaptureSnapV1 in Helper::init, wiring it to the main WOutputRenderWindow and seat, and expose it to ShellHandler via setCaptureSnap().
src/modules/CMakeLists.txt
src/modules/capture/CMakeLists.txt (renamed to capture-snap/CMakeLists.txt)
src/modules/capture-snap/impl/snapv1impl.h
src/modules/capture-snap/impl/snapv1impl.cpp
src/modules/capture-snap/snapdetector.h
src/modules/capture-snap/snapdetector.cpp
src/modules/capture-snap/snaphandler.h
src/modules/capture-snap/snaphandler.cpp
src/seat/helper.cpp
src/seat/helper.h
Remove the old capture QML layer and CaptureManagerV1 wiring, and introduce compositor-side handling for capture mask windows using xdg-toplevel tags.
  • Delete CaptureSelectorLayer.qml and its registration in libtreeland QML module and QmlEngine, removing createCaptureSelector API and CaptureManagerV1 references.
  • Adjust RootSurfaceContainer::CaptureLayerZOrder to place capture masks above privileged overlays.
  • Extend ShellHandler with a capture container, a CaptureSnapV1 pointer, and applyCaptureMask logic to detect the org.deepin.treeland.capture-mask tag and configure the mask SurfaceWrapper (no decorations, fixed geometry over full desktop, moved to capture container, skip from switcher/dock/multitask).
  • Ensure capture mask positioning uses union of output geometries and informs CaptureSnapV1 about the mask surface.
  • Update SeatSurfaceManager and SurfaceWrapper so capture mask windows cannot be moved, resized, maximized, tiled, or fullscreened, and always show on all workspaces; add isCaptureMask property and related capability filtering.
  • Remove capture-related QML types and selector handling from Helper, and simplify keyboard event handling accordingly.
src/CMakeLists.txt
src/core/qml/CaptureSelectorLayer.qml
src/core/qmlengine.cpp
src/core/qmlengine.h
src/core/rootsurfacecontainer.h
src/core/shellhandler.cpp
src/core/shellhandler.h
src/seat/helper.cpp
src/seat/helper.h
src/surface/seatsurfacemanager.cpp
src/surface/surfacewrapper.cpp
src/surface/surfacewrapper.h
src/modules/capture/*
Minor build and comment adjustments to reflect capture-snap naming and z-order behavior.
  • Update top-level CMakeLists comment to refer to the capture-snap module.
  • Rename module output names, URIs, and impl_treeland NAME from capture to capture-snap.
  • Adjust CaptureLayerZOrder enum value to sit above privileged overlays.
  • Ensure the capture module no longer exports old protocol or QML types.
CMakeLists.txt
src/core/rootsurfacecontainer.h
src/modules/capture-snap/CMakeLists.txt

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

@deepin-bot

deepin-bot Bot commented Aug 21, 2026

Copy link
Copy Markdown

TAG Bot

New tag: 0.9.0
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #1312

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.

2 participants