Skip to content

fix(xwayland): stop per-motion X pointer warp causing stuck clicks - #1457

Closed
LFRon wants to merge 1 commit into
linuxdeepin:masterfrom
LFRon:fix/xwayland-click
Closed

LFRon wants to merge 1 commit into
linuxdeepin:masterfrom
LFRon:fix/xwayland-click

Conversation

@LFRon

@LFRon LFRon commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

问题详情: 分数缩放下Xwayland的Electron/Chromium应用鼠标点击有各种问题

Commit 5fe9fd7 ("fix(xwayland): sync cursor global position to X server") warped the X pointer to the cursor position through xcb_warp_pointer on XCB_NONE/screen->root on every WCursor::positionChanged. Treeland's underlying problem: any client-side XWarpPointer to the root is routed by Xwayland through xwl_cursor_warped_to() and xwl_seat_emulate_pointer_warp(), which creates a persistent zwp_locked_pointer_v1 lock whenever the target lands inside the focused X window. Treeland's PointerConstraintsManager then activates that lock, so WCursor::applyPointerConstraint() pins the cursor to the locked anchor and stops dispatching motion, while Xwayland switches the pointer to relative + fake positions instead of absolute coordinates. The result was the reported XWayland symptom: the cursor jumped back and clicks landed on stale coordinates, or left-click did not register at all. The warp also used logical cursor coordinates while Xwayland's root space is DPR scaled, so the position mismatched under HiDPI.

This commit removes the cursor-position sync entirely: the positionChanged hook, the warp helper and the seat-cursor watch are gone, so no movement triggers an X pointer warp and Xwayland no longer creates the spurious persistent lock. setSeat() keeps its null-safe seat argument.

当前问题:5fe9fd78f 在每次光标移动时通过 xcb_warp_pointer 把 X 指针 warp 到 屏幕 root。Xwayland 会把任何指向 root 的 XWarpPointer 交给
xwl_cursor_warped_to() / xwl_seat_emulate_pointer_warp(),只要目标落在当前 获得焦点的 X 窗口内,就会创建一个持久 zwp_locked_pointer_v1。treeland 的 PointerConstraintsManager 随后激活该锁,WCursor::applyPointerConstraint() 把 光标钉回锚点并停止派发移动,Xwayland 则改用相对增量加伪造位置、不再使用绝对
坐标,于是表现为光标回跳、点击落到旧坐标甚至左键点不下去;且 warp 用的是逻辑
坐标,而 Xwayland 的 root 空间按 DPR 放大,HiDPI 下坐标同样错位。
解决方式:完整移除该坐标同步机制(移动钩子、warp 辅助函数与 cursor 监听),
不再有任何移动触发 X 指针 warp,Xwayland 不再被诱导创建持久指针锁;
setSeat() 保留空安全参数。

Log: 移除光标移动时向 Xwayland 发送的 X 指针 warp,避免 Xwayland 创建持久指针锁,修复 X 应用点击错位/左键点不下去
Influence: Xwayland 不再随光标移动 warp X 指针;依赖 XQueryPointer 全局坐标的 X 窗口在指针位于原生 Wayland 表面上方时坐标可能不刷新(恢复到 5fe9fd7 之前的行为)。真实指针约束(游戏/远程桌面)路径不受影响。

Summary by Sourcery

Remove per-motion X pointer warping to restore reliable input handling in Xwayland applications.

Bug Fixes:

  • Stop warping the X pointer on every cursor movement to prevent Xwayland pointer locks that caused stuck clicks and incorrect pointer coordinates in Xwayland applications, particularly with fractional scaling.

Enhancements:

  • Remove the cursor-position synchronization and seat cursor monitoring that triggered X pointer warps while preserving null-safe seat assignment.

Commit 5fe9fd7 ("fix(xwayland): sync cursor global position to X
server") warped the X pointer to the cursor position through xcb_warp_pointer
on XCB_NONE/screen->root on every WCursor::positionChanged. Treeland's
underlying problem: any client-side XWarpPointer to the root is routed by
Xwayland through xwl_cursor_warped_to() and xwl_seat_emulate_pointer_warp(),
which creates a persistent zwp_locked_pointer_v1 lock whenever the target
lands inside the focused X window. Treeland's PointerConstraintsManager then
activates that lock, so WCursor::applyPointerConstraint() pins the cursor to
the locked anchor and stops dispatching motion, while Xwayland switches the
pointer to relative + fake positions instead of absolute coordinates. The
result was the reported XWayland symptom: the cursor jumped back and clicks
landed on stale coordinates, or left-click did not register at all. The warp
also used logical cursor coordinates while Xwayland's root space is DPR
scaled, so the position mismatched under HiDPI.

This commit removes the cursor-position sync entirely: the positionChanged
hook, the warp helper and the seat-cursor watch are gone, so no movement
triggers an X pointer warp and Xwayland no longer creates the spurious
persistent lock. setSeat() keeps its null-safe seat argument.

当前问题:5fe9fd78f 在每次光标移动时通过 xcb_warp_pointer 把 X 指针 warp 到
屏幕 root。Xwayland 会把任何指向 root 的 XWarpPointer 交给
xwl_cursor_warped_to() / xwl_seat_emulate_pointer_warp(),只要目标落在当前
获得焦点的 X 窗口内,就会创建一个持久 zwp_locked_pointer_v1。treeland 的
PointerConstraintsManager 随后激活该锁,WCursor::applyPointerConstraint() 把
光标钉回锚点并停止派发移动,Xwayland 则改用相对增量加伪造位置、不再使用绝对
坐标,于是表现为光标回跳、点击落到旧坐标甚至左键点不下去;且 warp 用的是逻辑
坐标,而 Xwayland 的 root 空间按 DPR 放大,HiDPI 下坐标同样错位。
解决方式:完整移除该坐标同步机制(移动钩子、warp 辅助函数与 cursor 监听),
不再有任何移动触发 X 指针 warp,Xwayland 不再被诱导创建持久指针锁;
setSeat() 保留空安全参数。

Log: 移除光标移动时向 Xwayland 发送的 X 指针 warp,避免 Xwayland 创建持久指针锁,修复 X 应用点击错位/左键点不下去
Influence: Xwayland 不再随光标移动 warp X 指针;依赖 XQueryPointer 全局坐标的 X 窗口在指针位于原生 Wayland 表面上方时坐标可能不刷新(恢复到 5fe9fd7 之前的行为)。真实指针约束(游戏/远程桌面)路径不受影响。
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: LFRon

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 Oct 5, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Removes the per-motion and initialization-time X pointer warps from WXWayland, eliminating the Xwayland pointer-lock side effect that caused stuck or misaligned clicks in scaled Electron/Chromium applications, while preserving null-safe seat setup and real pointer constraints.

Sequence diagram for removing XWayland pointer warps

sequenceDiagram
    participant Cursor
    participant WXWayland
    participant XWayland
    participant PointerConstraintsManager
    participant X11App

    Cursor->>WXWayland: positionChanged
    Note over WXWayland,XWayland: Removed: no xcb_warp_pointer call
    XWayland-->>X11App: Preserve normal pointer coordinates
    X11App-->>PointerConstraintsManager: No spurious persistent pointer lock
Loading

File-Level Changes

Change Details Files
Remove the per-motion X pointer warp and its cursor synchronization lifecycle.
  • Delete the cursor position change connection and related watch/sync helpers.
  • Stop installing cursor listeners or performing initial cursor warps during seat assignment and Xwayland readiness.
  • Keep seat propagation null-safe when calling wlr_xwayland_set_seat().
waylib/src/server/protocols/wxwayland.cpp
Prevent Xwayland-induced persistent pointer constraints and coordinate-related input failures.
  • Avoid routing every cursor movement through Xwayland's root-pointer warp path.
  • Restore behavior where X clients may not receive refreshed global coordinates over native Wayland surfaces, while leaving genuine pointer-constraint paths unaffected.
waylib/src/server/protocols/wxwayland.cpp

Possibly linked issues

  • #unknown: PR移除导致XWayland持久指针锁的逐次warp,直接修复该类全屏应用指针乱飘问题。

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-ci-robot

Copy link
Copy Markdown

Hi @LFRon. Thanks for your PR.

I'm waiting for a linuxdeepin member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@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 ✨

@zccrs

zccrs commented Oct 8, 2026

Copy link
Copy Markdown
Member

这整个实现机制都有些问题,我已经把之前 #1430 回退了。

@LFRon

LFRon commented Oct 8, 2026

Copy link
Copy Markdown
Contributor Author

好,那我关PR了

@LFRon LFRon closed this Oct 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants