Skip to content

sway, in terminal characters printed if focus switched immediately #5379

Open
@vvrein

Description

Hi!
Recently I've wrote about problems with newlines printed in terminal, after swaymsg focus left executed.
Video: https://tort.icu/bin/raw/k55mtgkq.mp4
#4975 (comment)

But @RedSoxFan said that

I thought we already sent key release events on focus change.
#4975 (comment)

So this gave me the idea that newlines is not related to the sway itself.

First part - zsh's preexec,precmd

Further investigations resolved this question for a half:
The problem is in zsh's add-zsh-hook -Uz preexec command.
This command adds possibility to execute command before execution command in prompt.

When I commented out all lines with
add-zsh-hook -Uz preexec
or
add-zsh-hook -Uz precmd
or
any sourced files with preexec|precmd in it
like
source /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh

-- problem gone.

But, when I have tried to record this behaviour, with and w/o preexec|precmd in .zshrc - I've found that with wf-recorder running newlines are always printed...

Second part - congestion

Further investigations makes me a little confused...

Without swaymsg

The first one -- I was able to reproduce this behavior without issuing swaymsg command at all.
The second one -- I was able to reproduce this behavior in bash, while I thinked that this is only zsh related issue.

Reproducing steps

I've typed: imv &
Then bring imv to foreground -- fg, which, after pressing Enter, spawns imv window and switches focus immediately to it.
Then I wait some time, press q, which get me back to previous window, where fg was typed.

zsh

zsh imv terminal listing
12:53:29 S 0 vrein@tokk:~
| imv &
[1] 68131
12:53:33 S 1 vrein@tokk:~
| Reading paths from stdin...
[1]  + suspended (tty input)  imv
12:53:33 S 1 vrein@tokk:~
| fg
[1]  + continued  imv


12:53:38 S 0 vrein@tokk:~
| imv &
[1] 68184
12:53:42 S 1 vrein@tokk:~
| Reading paths from stdin...
[1]  + suspended (tty input)  imv
12:53:42 S 1 vrein@tokk:~
| fg
[1]  + continued  imv


















12:53:43 S 0 vrein@tokk:~

White-spaces here was typed while imv window was focused.

bash

Reproducing of this behavior in bash
with such setup:

  • sudo cpupower frequency-set -g powersave
  • stress -c 12 (all my threads)
  • wf-recorder -f dummy-vf.mp4

wf-recorder somehow loads my pc more, so newlines printed behavior occurs more often

bash imv terminal listing
13:16:04 S 0 vrein@tokk:~
| bash
13:16:07 S 0 vrein@tokk:~
| imv &
[1] 69951
13:16:09 S 1 vrein@tokk:~
| Reading paths from stdin...

[1]+  Stopped                 imv
13:16:10 S 1 vrein@tokk:~
| fg
imv
13:16:12 S 0 vrein@tokk:~
|
13:16:12 S 0 vrein@tokk:~
| imv &
[1] 70025
13:16:19 S 1 vrein@tokk:~
| Reading paths from stdin...

[1]+  Stopped                 imv
13:16:20 S 1 vrein@tokk:~
| fg
imv
13:16:22 S 0 vrein@tokk:~
| imv &
[1] 70125
13:16:33 S 1 vrein@tokk:~
| Reading paths from stdin...

[1]+  Stopped                 imv
13:16:34 S 1 vrein@tokk:~
| fg
imv























































13:16:36 S 0 vrein@tokk:~
|
13:16:36 S 0 vrein@tokk:~
|
13:16:36 S 0 vrein@tokk:~
|
13:16:36 S 0 vrein@tokk:~
|
13:16:36 S 0 vrein@tokk:~

Here you can see, that several attempts was needed to reproduce this.

Thoughts

Aaaand so, main consistent pattern is:
The more

  • bells and whistles in shell is configured
  • more pc loaded

the more consistent this glitch is

And I wasn't able to reproduce this with shell started like this:

  • bash --norc
  • env ZDOTDIR='' zsh

So I think, main problem is in immediately focus switching, after Enter have been pressed
so key release

  • does not sent?
  • delayed sent until focus back?
  • sent to newly focused window?
  • shell is too busy for accepting it?

But I still do not understand what kind of problem it is, and whose it is.

I can bring log of env WAYLAND_DEBUG=1 <terminal> a little later, if needed.

My setup

$ swaymsg -t get_version
sway version 1.4-2a2dd580 (May 23 2020, branch 'master')

$ lsmod | grep nvidia | wc -l
0

$ grep 'model name' -m 1 /proc/cpuinfo
model name	: AMD Ryzen 5 3600 6-Core Processor

$ lspci | grep VGA
08:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Lexa PRO [Radeon 540/540X/550/550X / RX 540X/550/550X] (rev c7)

Activity

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

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions