Skip to content
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

Receiving Keyboard signals when switching focus in window managers #2864

Open
shvmsaini opened this issue Jun 20, 2023 · 7 comments · May be fixed by #2964
Open

Receiving Keyboard signals when switching focus in window managers #2864

shvmsaini opened this issue Jun 20, 2023 · 7 comments · May be fixed by #2964

Comments

@shvmsaini
Copy link

Whenever I open ranger inside my terminal and when I switch focus to/from ranger it receives signals. I have tried different window managers and with different terminals but it is still the case.

The problem doesn't occur when I open ranger as separate process with kitty -e ranger but only when I do ranger inside terminal.

Runtime Environment

  • Operating system and version: Arch linux 6.1.34-1-lts
  • Terminal emulator and version: kitty 0.28.1 and alacritty 0.12.1 (5fdfd47f)
  • Python version: 3.11.3 (main, Jun 5 2023, 09:32:32) [GCC 13.1.1 20230429]
  • Ranger version/commit: ranger 1.9.3
  • Locale: en_US.UTF-8

Current Behavior

Receives signals when switching focus.

Expected Behavior

Should not receive signals.

Context

Possible Solutions

Steps to reproduce

  1. Open ranger inside terminal
  2. Switch focus to and from ranger to other windows
  3. ranger is now in rename mode and is receiving signals when switching focus

output2

@toonn
Copy link
Member

toonn commented Jun 20, 2023

Ranger has no control over what keystrokes it gets sent. We need to figure out why it's getting the keystrokes and whether we can detect conditions where it shouldn't process keystrokes it receives.

@shvmsaini
Copy link
Author

Someone posted about the same issue on reddit.

@dionisos2
Copy link

I have the same problem, I tried with a very old version of ranger, and it does the same.
I am also on Arch Linux (6.3.7-arch1-1).

@dionisos2
Copy link

dionisos2 commented Jun 22, 2023

@dionisos2
Copy link

Some temporary fix :

  1. Install https://github.com/archlinux-downgrade/downgrade
  2. sudo downgrade ncurses lib32-ncurses
  3. Downgrade to 6.4-1

@toonn
Copy link
Member

toonn commented Jun 23, 2023

@dionisos2, thank you for the sleuthing! This sounds like a bug in Ncurses then. Please (anyone) ping when the upstream bug is fixed, I'll hold off on closing this issue until then so anyone following this for Ranger specifically gets a ping then.

krobelus added a commit to krobelus/ranger that referenced this issue Apr 6, 2024
Terminals can be asked to report focus events with

        print("\x1b[?1004h")

For some reason, our use of curses sends a sequence like that (not
exactly that one, but it contains "1004", you can observe it by
running ranger inside "script").

Then the terminal will send ^[[I and ^[[O for "focus in" and "focus
out" events respectively.  This is quite annoying. The proper way
to deal with these is to map them ourselves in all modes (to a nop,
or optionally add some UI feedback).

I do not know how to do that, so turn it off altogether with the
corresponding "l" sequence.

Fixes ranger#2864
@krobelus krobelus linked a pull request Apr 6, 2024 that will close this issue
@abrac
Copy link

abrac commented Apr 24, 2024

We need have @krobelus' commit merged.

A temporary workaround is to run Ranger in tmux, and adding set-option -g focus-events off in ~/.tmux.conf. This will configure tmux to ignore focus events.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants