Skip to content

fix(wlroots): connected check#1210

Merged
MistEO merged 2 commits intoMaaXYZ:mainfrom
litwak913:wlr-fix
Mar 18, 2026
Merged

fix(wlroots): connected check#1210
MistEO merged 2 commits intoMaaXYZ:mainfrom
litwak913:wlr-fix

Conversation

@litwak913
Copy link
Copy Markdown
Contributor

@litwak913 litwak913 commented Mar 15, 2026

增加对 WlRoots 控制器连接的额外检查。

Summary by Sourcery

收紧对 Wayland wlroots 客户端连接的处理方式,并基于受跟踪的连接状态来控制各类操作。

Bug 修复:

  • 确保 Wayland 客户端只在设备准备成功后才将自身标记为已连接,并在关闭时重置该状态。
  • 防止在 Wayland 客户端未连接时执行屏幕捕获、指针、键盘、文本输入和缓冲区相关操作。
  • 在 Wayland 客户端已经断开连接时,避免执行缓冲区清理/销毁相关工作。

增强项:

  • 引入显式的 connected_ 标志,并将其作为连接状态的唯一可信来源,而不是从 display 指针中推断状态。
  • 重新组织 WaylandClient 的公共 API 声明,将其划分为更清晰的初始化、缓冲区以及工具(utility)部分。
Original summary in English

Summary by Sourcery

Tighten Wayland wlroots client connection handling and gate operations on a tracked connection state.

Bug Fixes:

  • Ensure Wayland client marks itself connected only after successful device preparation and resets the state on close.
  • Prevent screencapture, pointer, keyboard, text input, and buffer operations from running when the Wayland client is not connected.
  • Avoid buffer teardown work when the Wayland client is already disconnected.

Enhancements:

  • Introduce an explicit connected_ flag and use it as the single source of truth for connection status instead of inferring it from the display pointer.
  • Reorganize WaylandClient public API declarations into clearer initialization, buffer, and utility sections.

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - 我给出了一些高层次的反馈:

  • 现在 connected_ 已经成为 connected() 的唯一“真实来源”,请再次检查所有创建/销毁 Wayland 连接的代码路径(例如析构函数、open 中的错误路径、bind_protocol/prepare_device 失败的情况),确保 connected_ 始终与实际连接状态保持同步,并且在 display_ 和相关资源已经被销毁时,不会仍然保持为 true
  • 请考虑 close_buffer()!connected_ 时是否真的应该是 no‑op(空操作);如果该函数可能在 connected_ 被切换为 false 后、但缓冲区仍然存在的析构/清理阶段被调用,那么这个新增加的保护条件可能会跳过必要的清理,从而导致资源泄漏或处于不一致的状态。
给 AI Agent 的提示
Please address the comments from this code review:

## Overall Comments
- Now that `connected_` is the source of truth for `connected()`, double‑check all code paths that create/destroy the Wayland connection (e.g., destructor, error paths in `open`, failures in `bind_protocol`/`prepare_device`) to ensure `connected_` is kept in sync with the actual connection state and cannot remain `true` when `display_` and related resources are already torn down.
- Consider whether `close_buffer()` should really be a no‑op when `!connected_`; if this function might be called during teardown after `connected_` is flipped to `false` but while a buffer still exists, this new guard could skip necessary cleanup and leak or leave resources in an inconsistent state.

Sourcery 对开源项目是免费的——如果你觉得我们的评审对你有帮助,欢迎分享 ✨
帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈改进之后的评审。
Original comment in English

Hey - I've left some high level feedback:

  • Now that connected_ is the source of truth for connected(), double‑check all code paths that create/destroy the Wayland connection (e.g., destructor, error paths in open, failures in bind_protocol/prepare_device) to ensure connected_ is kept in sync with the actual connection state and cannot remain true when display_ and related resources are already torn down.
  • Consider whether close_buffer() should really be a no‑op when !connected_; if this function might be called during teardown after connected_ is flipped to false but while a buffer still exists, this new guard could skip necessary cleanup and leak or leave resources in an inconsistent state.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Now that `connected_` is the source of truth for `connected()`, double‑check all code paths that create/destroy the Wayland connection (e.g., destructor, error paths in `open`, failures in `bind_protocol`/`prepare_device`) to ensure `connected_` is kept in sync with the actual connection state and cannot remain `true` when `display_` and related resources are already torn down.
- Consider whether `close_buffer()` should really be a no‑op when `!connected_`; if this function might be called during teardown after `connected_` is flipped to `false` but while a buffer still exists, this new guard could skip necessary cleanup and leak or leave resources in an inconsistent state.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@MistEO MistEO merged commit aa24839 into MaaXYZ:main Mar 18, 2026
19 checks passed
@litwak913 litwak913 deleted the wlr-fix branch March 21, 2026 16:26
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