Skip to content

refactor(linux): extract GTK3 pointer, touch and gesture handling - #194913

Draft
richyo-codes wants to merge 2 commits into
flutter:masterfrom
richyo-codes:pr/linux-gtk3-input-extraction-v2
Draft

richyo-codes wants to merge 2 commits into
flutter:masterfrom
richyo-codes:pr/linux-gtk3-input-extraction-v2

Conversation

@richyo-codes

@richyo-codes richyo-codes commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Summary

fl_view.cc currently mixes GTK3 pointer, scrolling, touch, and gesture handling with view lifecycle and rendering code. This PR moves those callbacks and their setup into fl_view_input_gtk3.cc, keeping the GTK3 event handling together and reducing overlap with future GTK4 changes.

The extraction preserves existing input behavior and the public API.

#194698

Changes

  • Move the existing input callbacks and helpers, event-box setup, signal connections, and zoom/rotation gesture creation into fl_view_input_gtk3.cc.
  • Call fl_view_input_gtk3_setup() at the original setup point in fl_view_init(), preserving initialization order.
  • Move the unchanged _FlView instance definition into the existing fl_view_private.h so both implementation files can access the view’s state.
  • Document setup timing and widget/gesture ownership, and add the new source file to the Linux build.

Callback logic, instance layout, and existing disposal responsibilities are preserved. Keyboard and focus handling remain in fl_view.cc.

Validation

  • Verified that all 21 extracted functions, the instance definition, and setup statements match the merge base.
  • Recompiled 146 Linux source/test translation units using the existing GTK3 build flags and Bullseye sysroot.
  • All 855 Linux tests pass.

Validation used cached engine dependencies; a fresh full-engine build with dependencies synchronized to the PR’s base was not performed.

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [AI contribution guidelines] and understand my responsibilities, or I am not using AI tools.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I signed the [CLA].
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant in-code documentation (doc comments with ///).
  • If this PR introduces a new feature or capability, I created and linked a website documentation issue or PR in [flutter/website] (or verified none is needed).
  • I added new tests to check the change I am making, or this PR is [test-exempt].
  • I followed the [breaking change policy] and added [Data Driven Fixes] where supported.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on [Discord].

If this change needs to override an active code freeze, provide a comment explaining why. The code freeze workflow can be overridden by code reviewers. See pinned issues for any active code freezes with guidance.

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

Move the existing event callbacks together with their signal connections,
event-box setup and gesture creation out of FlView. GTK4 uses a different
event API; separating the GTK3 adapters reduces overlap with view lifecycle
and rendering changes. Keyboard and focus handling remain in fl_view.cc.

Move the unchanged instance definition into the existing private header.
Document the setup timing and existing widget/gesture ownership. Preserve
input dispatch, initialization order, disposal and public API. This change
is independent of surface helpers and accessibility work and does not enable
GTK4.

Validation: all 21 extracted functions, the instance definition and setup
statements match the merge base. C++/GN formatting and diff checks pass.
Recompiled 146 Linux source/test translation units using the existing GTK3
build flags and Bullseye sysroot, then linked the GTK3 library and unit-test
executable against cached engine dependencies. All 855 Linux tests pass.
This is not a fresh full-engine build with baseline-synced dependencies.
@github-actions github-actions Bot added engine flutter/engine related. See also e: labels. platform-linux Building on or for Linux specifically a: desktop Running on desktop team-linux Owned by the Linux platform team labels Oct 21, 2026
Exercise event-box and gesture signals through FlView construction and assert events at the embedder boundary. Cover button/motion/release dispatch, multi-click filtering, scrolling, touch, combined zoom/rotation, and cancellation on broken grabs, grab changes, and unmap.

All eight new tests pass against the extraction and a pre-extraction view object. Removing the broken-grab connection makes the cancellation test fail. Related view/input suites pass 56 tests using the existing GTK3 configuration and cached engine dependencies; this is not a fresh full-engine build.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: desktop Running on desktop engine flutter/engine related. See also e: labels. platform-linux Building on or for Linux specifically team-linux Owned by the Linux platform team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant