Skip to content

Restore focus to editor after sending do-file#21

Open
iglhaut wants to merge 1 commit intoacarril:masterfrom
iglhaut:restore-editor-focus
Open

Restore focus to editor after sending do-file#21
iglhaut wants to merge 1 commit intoacarril:masterfrom
iglhaut:restore-editor-focus

Conversation

@iglhaut
Copy link

@iglhaut iglhaut commented Apr 27, 2025

Restore editor focus after sending do-file on Ubuntu 24.04.2 LTS

Problem:
After upgrading to Ubuntu 24.04.2 LTS, Stata’s window ( xstata-mp) ignores synthetic keystrokes sent directly via xdotool --window, so code no longer executes in the background.

Solution:

  1. Save the ID of the currently active window.
  2. Activate (focus) the Stata window so it reliably receives keystrokes.
  3. Send the do "<tempfile>" command.
  4. Restore focus to the original window.

This ensures Sublime-to-Stata workflows continue uninterrupted under the stricter input-event handling in Ubuntu 24.04.2 LTS.

Comment:
I think this change is unfortunate, and StataLinux used to work much nicer before. I am not exactly sure what causes the problem in the first place. A brief search revealed potential related problems but I do not possess the skills to get to the bottom of this. This fix makes it possible for me to keep working with StataLinux, but in case someone has the ability to restore the original way the package used to send code from Sublime to Stata in the background, that would be great.

Saves the previously active window ID, activates Stata to ensure it receives keystrokes, then restores focus to the editor so your workflow isn’t interrupted.
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.

1 participant