Skip to content

Conversation

@wjyrich
Copy link
Contributor

@wjyrich wjyrich commented Jul 28, 2025

  1. Added setKeyboardFocus method to PluginSurface class to handle keyboard focus via Wayland seat
  2. Exposed the method as Q_INVOKABLE for QML access
  3. Implemented focus handling in ShellSurfaceItemProxy when hovered
  4. Includes necessary QWaylandSeat header for keyboard focus management
  5. This ensures proper keyboard input handling when interacting with plugin surfaces

feat: 为插件表面添加键盘焦点管理

  1. 在 PluginSurface 类中添加 setKeyboardFocus 方法,通过 Wayland seat 处 理键盘焦点
  2. 将方法暴露为 Q_INVOKABLE 以便 QML 访问
  3. 在 ShellSurfaceItemProxy 中实现悬停时的焦点处理
  4. 包含必要的 QWaylandSeat 头文件用于键盘焦点管理
  5. 确保与插件表面交互时能正确处理键盘输入

Pms: BUG-312795

Summary by Sourcery

Introduce keyboard focus management for plugin surfaces in the compositor and QML layer

New Features:

  • Add setKeyboardFocus method to PluginSurface to assign keyboard focus via the Wayland seat
  • Expose setKeyboardFocus as Q_INVOKABLE for QML access
  • Invoke setKeyboardFocus in ShellSurfaceItemProxy on hover to enable keyboard input

Enhancements:

  • Include QWaylandSeat header to support keyboard focus operations

@sourcery-ai
Copy link

sourcery-ai bot commented Jul 28, 2025

Reviewer's Guide

Implements keyboard focus management for plugin surfaces by adding a setKeyboardFocus API exposed to QML and triggering it on hover in the ShellSurfaceItemProxy to route keyboard input via the Wayland seat.

Sequence diagram for keyboard focus management on plugin surface hover

sequenceDiagram
    actor User
    participant ShellSurfaceItemProxy (QML)
    participant PluginSurface
    participant QWaylandSeat
    participant QWaylandSurface

    User->>ShellSurfaceItemProxy (QML): Hover over plugin surface
    ShellSurfaceItemProxy (QML)->>PluginSurface: setKeyboardFocus()
    PluginSurface->>QWaylandSeat: setKeyboardFocus(QWaylandSurface)
    QWaylandSeat-->>PluginSurface: Keyboard focus set
    PluginSurface-->>ShellSurfaceItemProxy (QML): (returns)
    ShellSurfaceItemProxy (QML)-->>User: (keyboard input now routed)
Loading

Class diagram for PluginSurface keyboard focus API

classDiagram
    class PluginSurface {
        +Q_INVOKABLE void setKeyboardFocus()
    }
    class QWaylandSeat {
        +void setKeyboardFocus(QWaylandSurface*)
    }
    PluginSurface --> QWaylandSeat : uses
    PluginSurface --> QWaylandSurface : uses
Loading

File-Level Changes

Change Details Files
Add keyboard focus management API in backend
  • Implement setKeyboardFocus method using Wayland seat
  • Expose setKeyboardFocus as Q_INVOKABLE for QML
  • Include QWaylandSeat header for focus management
panels/dock/pluginmanagerextension.cpp
panels/dock/pluginmanagerextension_p.h
Trigger keyboard focus on hover in QML
  • Handle hovered state change in ShellSurfaceItemProxy
  • Call shellSurface.setKeyboardFocus() when hovered
  • Add console log for focus invocation
panels/dock/tray/ShellSurfaceItemProxy.qml

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

Copy link

@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 @wjyrich - I've reviewed your changes and they look great!


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.

1. Added setKeyboardFocus method to PluginSurface class to handle
keyboard focus via Wayland seat
2. Exposed the method as Q_INVOKABLE for QML access
3. Implemented focus handling in ShellSurfaceItemProxy when hovered
4. Includes necessary QWaylandSeat header for keyboard focus management
5. This ensures proper keyboard input handling when interacting with
plugin surfaces

feat: 为插件表面添加键盘焦点管理

1. 在 PluginSurface 类中添加 setKeyboardFocus 方法,通过 Wayland seat 处
理键盘焦点
2. 将方法暴露为 Q_INVOKABLE 以便 QML 访问
3. 在 ShellSurfaceItemProxy 中实现悬停时的焦点处理
4. 包含必要的 QWaylandSeat 头文件用于键盘焦点管理
5. 确保与插件表面交互时能正确处理键盘输入

Pms: BUG-312795
@deepin-ci-robot
Copy link

deepin pr auto review

代码审查意见:

  1. 代码重复setupMouseFocusListener 函数中,Q_UNUSED(oldFocus); 可能是多余的,因为 oldFocus 参数在 lambda 表达式中没有被使用。

  2. 错误处理:在 setupMouseFocusListener 函数中,如果 newFocus 为空,则直接返回,但没有对 newFocus 为空的情况进行错误处理或日志记录,这可能会使得调试变得困难。

  3. 性能考虑:在 setupMouseFocusListener 函数中,每次鼠标焦点变化都会触发 lambda 表达式,如果这个信号频繁触发,可能会对性能产生影响。可以考虑添加一些防抖动或节流机制。

  4. 代码可读性:在 setupMouseFocusListener 函数中,lambda 表达式内的代码可以拆分成更小的函数,以提高代码的可读性和可维护性。

  5. 类型转换:在 setupMouseFocusListener 函数中,将 extensionContainer() 转换为 QWaylandCompositor * 时,应该添加类型检查,以防止类型转换失败。

  6. 日志记录:在 setupMouseFocusListener 函数中,qDebug()<<"setKeyboardFocus"; 可能不足以记录调试信息,建议使用更详细的日志记录,包括 newFocusoldFocus 的信息。

  7. 信号连接:在 setupMouseFocusListener 函数中,使用 lambda 表达式连接信号和槽时,应该使用 Qt::QueuedConnection,以确保槽函数在事件循环中执行,避免潜在的竞态条件。

  8. 头文件包含:在 pluginmanagerextension_p.h 中,#include <QtWaylandCompositor/QWaylandSeat> 可能是多余的,因为 QWaylandSeatpluginmanagerextension.cpp 中已经包含。

  9. 未使用的头文件:在 pluginmanagerextension.cpp 中,#include <QJsonParseError> 可能是多余的,因为 QJsonObjectQJsonParseError 没有在代码中使用。

  10. 未使用的变量:在 initialize 函数中,init(compositor->display(), 1); 的第二个参数 1 没有被使用,应该移除这个参数或者添加注释说明其用途。

综上所述,代码中存在一些潜在的问题,需要进一步优化和改进。

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 18202781743, wjyrich

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

@wjyrich
Copy link
Contributor Author

wjyrich commented Jul 29, 2025

/forcemerge

@deepin-bot
Copy link

deepin-bot bot commented Jul 29, 2025

This pr force merged! (status: behind)

@deepin-bot deepin-bot bot merged commit 0b43bc1 into linuxdeepin:master Jul 29, 2025
9 of 10 checks passed
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.

3 participants