Skip to content

feat(linux): GTK4 focus-free write via widget click (GTK3 approach) - #1816

Merged
r33drichards merged 1 commit into
claude/lucid-lovelace-CMVuMfrom
feat/gtk4-widget-click-fix
Jun 3, 2026
Merged

feat(linux): GTK4 focus-free write via widget click (GTK3 approach)#1816
r33drichards merged 1 commit into
claude/lucid-lovelace-CMVuMfrom
feat/gtk4-widget-click-fix

Conversation

@r33drichards

Copy link
Copy Markdown
Collaborator

Summary

Truly focus-free GTK4 writes using widget-level click (proven GTK3 technique).

Problem

  • GTK4 AT-SPI bridge gates EditableText on focus
  • Need a focus-free solution

Solution - Widget Click (GTK3 Approach)

Applies the GTK3 technique from PR #1810 to GTK4:

  1. Find entry/text widget via AT-SPI Component interface
  2. Get screen coordinates via Component.GetExtents
  3. Translate to window-local coordinates
  4. Click widget center via X11 XSendEvent
  5. Type via X11 to the internally-focused widget

Key Insights

Widget-level focus without window activation (GTK3 and GTK4 share the same AT-SPI bridge behavior)
✅ Control terminal stays focused throughout
✅ No _NET_ACTIVE_WINDOW change
✅ No workspace switching
✅ Window remains unfocused, only widget gains internal focus

Works for Both GTK3 and GTK4

This fix works identically for both GTK3 (zenity) and GTK4 (GtkEntry) since they:

  • Use the same AT-SPI bridge architecture
  • Both gate EditableText on focus
  • Both respond to widget clicks for internal focus

Files Changed

  • platform-linux/src/atspi/native.rs (+120 lines, -25 lines)
    • Added entry_find_window_xid() helper
    • Added screen_to_window_coords() helper
    • Updated insert_text() with widget click fallback

Testing

nix build .#checks.x86_64-linux.cua-driver-linux-background-gui-gtk4

Expected: All assertions pass ✅ (read + write + focus unchanged)

Comparison

Directly mirrors GTK3 fix (PR #1810, commit 43a5d515) - proven and reliable approach.

GTK3 and GTK4's AT-SPI bridge gates EditableText on window/widget focus, so unfocused
background windows expose entry nodes in the tree (reads work) but not the
EditableText interface (writes fail). Qt6 exposes EditableText unconditionally.

This commit adds a GTK fallback: when insert_text finds an entry/text
role with Component bounds but no EditableText, it:
1. Gets the entry widget's screen coordinates via Component.GetExtents
2. Translates to window-local coords
3. Sends an X11 click to the entry's center to establish widget focus
4. Types via XSendEvent (now accepted by the internally-focused widget)

The window remains unfocused (control terminal keeps X focus), but the widget
receives and processes the keystrokes. This unblocks the gtk3 and gtk4 jobs in the
background-GUI test matrix.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Ignored Ignored Jun 2, 2026 11:58pm

Request Review

@coderabbitai

coderabbitai Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7fb4b446-dbf8-4487-abc1-8a45ff005032

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/gtk4-widget-click-fix

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

github-actions Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Linux visual regression artifacts

Matrix jobs now run independently. Download GIF artifacts from this workflow run:

  • cua-driver-linux-cursor-click-gif
  • cua-driver-linux-background-terminal-gif

Open workflow run and download artifacts

@r33drichards
r33drichards merged commit e923c10 into claude/lucid-lovelace-CMVuM Jun 3, 2026
19 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.

2 participants