Skip to content

Conversation

@asterwyx
Copy link
Contributor

@asterwyx asterwyx commented Dec 22, 2025

https://wayland.app/protocols/input-method-unstable-v2#zwp_input_method_v2:event:activate
https://github.com/hyprwm/Hyprland/blob/main/src/managers/input/TextInput.cpp#L233

Log: as title
Influence: input method
Signed-off-by: Yixue Wang wangyixue@uniontech.com

Summary by Sourcery

Bug Fixes:

  • Send surrounding text, text change cause, and content type events after input method activation when supported by the text input.

@deepin-ci-robot
Copy link

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

@sourcery-ai
Copy link

sourcery-ai bot commented Dec 22, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

When a text input gets enabled, the helper now sends all relevant input method state (surrounding text, text change cause, and content type) immediately after activation, if those features are available, before finalizing with a done event.

Sequence diagram for sending input method state after activate

sequenceDiagram
    participant TI as TextInput
    participant Helper as WInputMethodHelper
    participant IM as InputMethod

    TI->>Helper: handleTIEnabled()
    Helper->>IM: sendActivate()
    alt SurroundingText_feature_enabled
        Helper->>IM: sendSurroundingText(ti.surroundingText, ti.surroundingCursor, ti.surroundingAnchor)
    end
    Helper->>IM: sendTextChangeCause(ti.textChangeCause)
    alt ContentType_feature_enabled
        Helper->>IM: sendContentType(ti.contentHints.toInt, ti.contentPurpose)
    end
    Helper->>IM: sendDone()
Loading

File-Level Changes

Change Details Files
Send full input method state events immediately after activation when the text input is enabled, conditioned on supported features.
  • After calling the input method’s activate event, send surrounding text, cursor, and anchor if the text input advertises the SurroundingText feature
  • Always send the text change cause event following activation
  • Send content type (hints and purpose) if the text input supports the ContentType feature
  • Keep the done event as the final message to mark completion of the state update sequence
waylib/src/server/protocols/winputmethodhelper.cpp

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

@asterwyx asterwyx force-pushed the im-activate branch 2 times, most recently from f0a1511 to 69fe36e Compare December 29, 2025 10:21
@asterwyx asterwyx changed the title fix: send surrounding text and content type after activate fix: send events after activate if available Dec 29, 2025
@asterwyx asterwyx marked this pull request as ready for review December 29, 2025 10:25
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 - I've left some high level feedback:

  • Consider caching ti->features() in a local variable before the flag checks to avoid repeated calls and make the intent of feature-gated sends clearer.
  • If the protocol allows textChangeCause to be optional, you may want to guard im->sendTextChangeCause(ti->textChangeCause()) behind the corresponding feature flag (or version check) for consistency with the other conditional sends.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider caching `ti->features()` in a local variable before the flag checks to avoid repeated calls and make the intent of feature-gated sends clearer.
- If the protocol allows `textChangeCause` to be optional, you may want to guard `im->sendTextChangeCause(ti->textChangeCause())` behind the corresponding feature flag (or version check) for consistency with the other conditional sends.

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.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes the input method activation flow by sending necessary state information (surrounding text, text change cause, and content type) to the input method immediately after activation, as required by the Wayland input-method-unstable-v2 protocol specification.

Key changes:

  • Send surrounding text, text change cause, and content type events after input method activation when the corresponding features are supported by the text input

@zccrs zccrs merged commit 8df383a into linuxdeepin:master Dec 30, 2025
18 of 20 checks passed
@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: asterwyx, zccrs

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

@asterwyx asterwyx deleted the im-activate branch January 7, 2026 05:56
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