-
Notifications
You must be signed in to change notification settings - Fork 727
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mouse movement control sequences leak to terminal at app shutdown #4418
Comments
We found the following entries in the FAQ which you may find helpful:
Feel free to close this issue if you found an answer in the FAQ. Otherwise, please give us a little time to review. This is an automated reply, generated by FAQtory |
I took a shot at diagnosing this issue, and the issue disappears if we modify the shutdown sequence of the input thread to loop a few times more to drain the mouse movement sequences out from the input descriptor: class LinuxDriver(Driver):
...
def run_input_thread(self) -> None:
...
countdown = 3
try:
with open("/tmp/textual_out", "a") as f:
while not self.exit_event.is_set() or countdown > 0:
selector_events = selector.select(0.1)
for _selector_key, mask in selector_events:
if mask & EVENT_READ:
rdd = read(fileno, 1024)
unicode_data = decode(rdd, final=self.exit_event.is_set())
for event in feed(unicode_data):
self.process_event(event)
if self.exit_event.is_set():
print(
f"Exit event set, countdown: {countdown}, data: {rdd if mask & EVENT_READ else None}",
file=f,
)
termios.tcflush(fileno, termios.TCIFLUSH)
rdd = ""
countdown -= 1
finally:
selector.close() I'm getting the following output in
so it looks like new mouse movement control sequences may appear on the linux driver's terminal file descriptor, even though the control sequence for disabling mouse support is already sent by |
This issue does seem specific to certain terminal emulators, at least from running quick tests with:
|
FWIW I couldn't reproduce it with kitty on macOS. |
@davep How about with macOS Terminal (just for confirmation as not one I'm able to check)? |
Didn't test with anything else; I'll try and remember to have a look the next time I'm at a machine. |
I've also now tested with Xfce Terminal which shows the same issue, which makes me wonder if perhaps specific to VTE-based terminal emulators? (Though this wouldn't explain issues with macOS terminals.) |
for more macOS terminal emulators: |
I can't seem to reproduce it at all with the latest Textual (on macOS). |
Actually, I did manage to reproduce it after a few attempt on Hyper. This should help me track it down! |
If the user is moving the mouse while the textual application exits, terminal control sequences from the mouse movement may leak from the application and get into the terminal.
This happens on all terminals I have tested: gnome-terminal and Terminator on Ubuntu Linux, and the Terminal on macOS. The issue can be easily reproduced using the examples from the textual repository. Here's a reproduction with
five_by_five.py
, where I pressq
on the keyboard while moving the mouse around the terminal:control-seq-leak-2024-04-15_10.56.24.mp4
Please find the diagnostics output below:
textual diagnose output
The text was updated successfully, but these errors were encountered: