Hyprland icon indicating copy to clipboard operation
Hyprland copied to clipboard

Cannot type since new text-input-v3 with Fcitx PreferKeyEvent

Open JeffDess opened this issue 1 year ago • 35 comments

Hyprland Version

System/Version info
Hyprland, built from branch  at commit fe7b748eb668136dd0558b7c8279bfcd7ab4d759  (props: bump version to 0.39.1).
Date: Tue Apr 16 16:01:03 2024
Tag: v0.39.1, commits: 4460

flags: (if any)


System Information:
System name: Linux
Node name: archlinux
Release: 6.8.8-arch1-1
Version: #1 SMP PREEMPT_DYNAMIC Sun, 28 Apr 2024 15:59:47 +0000


GPU information:
01:00.0 VGA compatible controller [0300]: NVIDIA Corporation TU106M [GeForce RTX 2070 Mobile / Max-Q Refresh] [10de:1f14] (rev a1) (prog-if 00 [VGA controller])


os-release: NAME="Arch Linux"
PRETTY_NAME="Arch Linux"
ID=arch
BUILD_ID=rolling
ANSI_COLOR="38;2;23;147;209"
HOME_URL="https://archlinux.org/"
DOCUMENTATION_URL="https://wiki.archlinux.org/"
SUPPORT_URL="https://bbs.archlinux.org/"
BUG_REPORT_URL="https://gitlab.archlinux.org/groups/archlinux/-/issues"
PRIVACY_POLICY_URL="https://terms.archlinux.org/docs/privacy-policy/"
LOGO=archlinux-logo


plugins:



Bug or Regression?

Bug

Description

Hi! I updated my system yesterday night and today I am having issue when moving the focus from a window to another. After moving the focus, my I can type in the active window but most of the keystrokes wouldn't get through (arrow keys and backspace mostly).

If I open a terminal, then focus to a browser, then focus back to the terminal, I can see the text focus is on the browser address bar and some keys bindings, such as Ctrl+S would open a prompt to save the web page, even tough the active window is the terminal.

Additional observations:

  • Moving between terminal windows doesn't reproduce the issue.
  • Moving the focus back and forth between the same windows fixes the focus issue.
  • Opening a new window and closing it immediatly to return to the previous window also reassigns the focus correctly.

I am using Fcitx v5.1.9, killing this process resolves the issue.

I tried hyprland-git but it is even worse, I cannot type on any window except a terminal (Qt, GTK and Electron apps all fail to register keystrokes).

How to reproduce

  1. Launch Fcitx
  2. Launch a terminal such as Kitty.
  3. Move focus to a GTK app such as Firefox.
  4. Move focus back to the terminal.
  5. Tap "space" key, it should register
  6. Tab "backspace" key, it should not register.

Crash reports, logs, images, videos

No response

JeffDess avatar Apr 30 '24 17:04 JeffDess

jesus christ this is like the 7th dupe #5763

vaxerski avatar Apr 30 '24 17:04 vaxerski

I've read this issue before filing mine, I believed it was a different issue as the solution didn't work. Switching to hyprland-git doesn't solve this issue, quite the opposite, most windows are not registering the keyboard. I had to switch back to hyprland in order to get it working.

JeffDess avatar Apr 30 '24 17:04 JeffDess

if it's a regression bisect it

MightyPlaza avatar Apr 30 '24 17:04 MightyPlaza

well that's odd. Should've mentioned it. But yea, bisect please. See https://wiki.hyprland.org/Crashes-and-Bugs/#bisecting-an-issue

vaxerski avatar Apr 30 '24 17:04 vaxerski

Ok so I bissected all night and found the issue:

  • e87227e0 : Life is good, no issue whatsoever
  • 1d40af64 : Cannot type on any application outside terminal

On fcitx options, I have this :

~/.config/fcitx5/conf/waylandim.conf

# Forward key event instead of commiting text if it is not handled
PreferKeyEvent=False

When set to True, I can type normally. It's the default value and this is probably why most people don't have the issue.

However, the False value is needed as is fixes a lot of other issues with synthetic input (programmable keyboards).

JeffDess avatar May 01 '24 04:05 JeffDess

I am relabeling the issue since the focus bug seems resolved.

JeffDess avatar May 01 '24 04:05 JeffDess

can you try after 8bcccf9f0f0f69986e315d4288dfdbf119dd19db

vaxerski avatar May 01 '24 18:05 vaxerski

I built 56de72f3, unfortunately still unable to type on GUI applications.

JeffDess avatar May 02 '24 01:05 JeffDess

The PreferKeyEvent was introduced in this commit, if that can be of any help: https://github.com/fcitx/fcitx5/commit/fbf6651f2d3b866126ad208874f6c2dcdfcb55e3

JeffDess avatar May 02 '24 02:05 JeffDess

I'm having the similar issue, but not realized it's related to fcitx5 until then.

Here is my case:

terminal: foot gtk application: nautilus/firefox

  1. ~~with settings: follow_mouse = 2~~ same for follow_mouse = 1
  2. open a foot terminal and firefox side by side
  3. click foot, input some characters,
  4. click anywhere in firefox except for an input area like this comment box (and do not input any char)
  5. click back foot, input chars, the input gets passed to firefox page rather then foot

. If you input any chars in step 4 or click an input area in firefox, foot will get input in step 5 . If in step 5, you do not input chars, just click firefox and click foot back, then foot will get input for such a double switch.

Once I killed fcitx5, the input works well.

Hyprland, built from branch  at commit fe7b748eb668136dd0558b7c8279bfcd7ab4d759  (props: bump version to 0.39.1).
Date: Tue Apr 16 16:01:03 2024
Tag: v0.39.1, commits: 4460

flags: (if any)


System Information:
System name: Linux
Node name: rt
Release: 6.8.3-gskd
Version: #1 SMP PREEMPT_DYNAMIC Thu, 04 Apr 2024 10:17:48 +0000


GPU information: 
c7:00.0 VGA compatible controller [0300]: Advanced Micro Devices, Inc. [AMD/ATI] Phoenix1 [1002:15bf] (rev c2) (prog-if 00 [VGA controller])


os-release: NAME="Arch Linux"
PRETTY_NAME="Arch Linux"
ID=arch
BUILD_ID=rolling
ANSI_COLOR="38;2;23;147;209"
HOME_URL="https://archlinux.org/"
DOCUMENTATION_URL="https://wiki.archlinux.org/"
SUPPORT_URL="https://bbs.archlinux.org/"
BUG_REPORT_URL="https://gitlab.archlinux.org/groups/archlinux/-/issues"
PRIVACY_POLICY_URL="https://terms.archlinux.org/docs/privacy-policy/"
LOGO=archlinux-logo

rtgiskard avatar May 02 '24 13:05 rtgiskard

this is unrelated and fixed in git.

vaxerski avatar May 02 '24 14:05 vaxerski

@JeffDess I set the thing:

image

restarted fcitx5, and I can type normally in kitty. Anything else to repro?

vaxerski avatar May 02 '24 14:05 vaxerski

Yes terminal emulators work (kitty, foot...), GUI apps don't (GTK, Qt, Electron, etc). Firefox for instance doesn't work for me. Does it work for you?

If yes, are we testing with a similar setup?

Packages

local/fcitx5 5.1.9-1 (fcitx5-im)
    Next generation of fcitx
local/fcitx5-gtk 5.1.3-1 (fcitx5-im)
    Fcitx5 gtk im module and glib based dbus client library
local/fcitx5-qt 5.1.6-1 (fcitx5-im)
    Fcitx5 Qt Library (Qt5 & Qt6 integrations)

Environment

env = XDG_CURRENT_DESKTOP,Hyprland
env = XDG_SESSION_TYPE,wayland
env = XDG_SESSION_DESKTOP,Hyprland
env = CLUTTER_BACKEND,wayland
env = GDK_BACKEND,wayland,x11
env = QT_QPA_PLATFORM,wayland;xcb
env = QT_QPA_PLATFORMTHEME,qt5ct

env = XMODIFIERS,@im=fcitx
env = GTK_IM_MODULE,fcitx
env = QT_IM_MODULE,fcitx
env = SDL_IM_MODULE,fcitx5
env = XIM,fcitx
env = XIM_PROGRAM,fcitx

JeffDess avatar May 02 '24 15:05 JeffDess

You could also try to change your config with the fcitx5-configtool package to make sure. This option is available in Wayland Input Method Interface settings. It updates automatically without having to kill/spawn fcitx.

JeffDess avatar May 02 '24 16:05 JeffDess

I've just tested more things with a3ca016d :

  • Plugging keyboard with USB or using laptop built-in keyboard doesn't change anything, so I assume hardware/connection/latency is not in cause.
  • In Firefox, shorcuts like ctrl + key work.
  • In Firefox, if I paste text into address bar, I can move the cursor with arrow keys and delete characters with backspace. But letters, symbols, space and enter don't work.

Last observation is odd, the keys that work on GTK are precisely the keys that didn't work in terminal before the focus fix (arrow keys and backspace). Could there be an interaction with this fix and new text-input-v3 commit?

JeffDess avatar May 02 '24 16:05 JeffDess

I just updated to Gentoo's Hyprland version 0.39.1-r1 (commit fe7b748eb668136dd0558b7c8279bfcd7ab4d759) to fix the issue where the cursor would get stuck in Firefox. It's working, but I'm seeing similar behavior to @JeffDess.

One thing I've noticed though, is that GUI apps seem to work as long as I start fcitx5 after I open the app. If fcitx5 is already running when I open discord or firefox, then it doesn't work. Just restarting fcitx with the -r option doesn't work either, I actually need to kill fcitx, then restart it. JeffDess, do you see the same behavior?

arbyste avatar May 04 '24 02:05 arbyste

@arbyste it doesn't seem to make a difference when fcitx or the app is started, when fctix5 is running, I am having the problem.

JeffDess avatar May 06 '24 03:05 JeffDess

I also tested on Plasma and Qtile and the problem doesn't happen at all with the same version of Fcitx and all... looks to be Hyprland specific.

Also another issue I am having with post-e87227 commits, when I type into Anyrun, it closes after the first character typed.

JeffDess avatar May 06 '24 03:05 JeffDess

Also another issue I am having with post-e87227 commits, when I type into Anyrun, it closes after the first character typed.

That's an issue with the randr plugin. If you don't include it in the config, anyrun works.

fufexan avatar May 06 '24 12:05 fufexan

That's an issue with the randr plugin. If you don't include it in the config, anyrun works.

@fufexan Exactly, that's is solving the issue. But then can't use the plugin anymore :man_shrugging:

JeffDess avatar May 07 '24 02:05 JeffDess

Testing with 0c446ec tonight, even with no fcitx running, I am having more issues with synthetic inputs. For instance I use a macro to trigger scroll mode on my trackball and it doesn't work at all now. In order to work, it has to type numlock twice in 40ms (if I recall). Looking at wev's output, timings seem right, but no somehow it's not registering on apps.

[14:     wl_keyboard] key: serial: 4532; time: 1618410; key: 77; state: 1 (pressed)
                      sym: Num_Lock     (65407), utf8: ''
[14:     wl_keyboard] modifiers: serial: 0; group: 16
                      depressed: 00000010: Mod2
                      latched: 00000000
                      locked: 00000010: Mod2
[14:     wl_keyboard] key: serial: 4534; time: 1618410; key: 77; state: 0 (released)
                      sym: Num_Lock     (65407), utf8: ''
[14:     wl_keyboard] modifiers: serial: 0; group: 16
                      depressed: 00000000
                      latched: 00000000
                      locked: 00000010: Mod2
[14:     wl_keyboard] key: serial: 4536; time: 1618423; key: 77; state: 1 (pressed)
                      sym: Num_Lock     (65407), utf8: ''
[14:     wl_keyboard] modifiers: serial: 0; group: 16
                      depressed: 00000010: Mod2
                      latched: 00000000
                      locked: 00000010: Mod2
[14:     wl_keyboard] key: serial: 4538; time: 1618423; key: 77; state: 0 (released)
                      sym: Num_Lock     (65407), utf8: ''
[14:     wl_keyboard] modifiers: serial: 0; group: 0
                      depressed: 00000000
                      latched: 00000000
                      locked: 00000000

JeffDess avatar May 07 '24 02:05 JeffDess

That's an issue with the randr plugin. If you don't include it in the config, anyrun works.

@fufexan Exactly, that's is solving the issue. But then can't use the plugin anymore 🤷‍♂️

I'll try to make a patch for it if I get the time.

fufexan avatar May 07 '24 11:05 fufexan

Looking at wev's output, timings seem right, but no somehow it's not registering on apps.

uh-huh, that might not be a hyprland issue then? does it happen in e.g. sway?

vaxerski avatar May 07 '24 11:05 vaxerski

@vaxerski Works fine on Sway, Plasma, Qtile, or Hyprland pre- 1d40af6. I've compared with the wev output on e87227e and it is identical as far as I can tell, but the keypress is actually toggling scroll mode as intended.

JeffDess avatar May 07 '24 13:05 JeffDess

tried it again with ff this time and couldn't repro again. I'll need clear repro steps... maybe you're using a weird fcitx config?

vaxerski avatar May 07 '24 23:05 vaxerski

I have a hard time figuring out what could be the difference. My fcitx setup is pretty bland, I think I only ever changed that PreferKeyEvent setting. I am sharing my dotfiles and the repro steps as far as can tell:

  1. Clone and build latest version of Hyprland
  2. Install fcitx5, fcitx5-qt, fcitx5-gtk and fcitx5-configtool
  3. Launch config tool and, in Wayland Interface Options, uncheck Forward key event instead of commiting text if it is not handled (false) and save.
  4. Install kitty (I have 0.34.1)
  5. Install firefox (I use developper edition but that doesn't seem to matter)
  6. In hypr config, set exec-once = fcitx5 -r
  7. Exit session
  8. Open new Hyprland session
  9. Launch Kitty
  10. Try to type, any key should work.
  11. Close Kitty.
  12. Launch Firefox
  13. Try to type letters in address bar, no text should appear as you type.

I thinks that's pretty much it. I will also try it myself on another computer.

JeffDess avatar May 08 '24 02:05 JeffDess

Ok so I tried latest git commit on another computer and cannot reproduce in GUI apps. The scroll mode macro is broken on both computers tough.

I versioned the Hyprland config of both computers so I'll be able to compare easily. One major hardware difference is Nvidia GPU on the one I cannot type. Other than that there's not much difference, but we'll see what I can find.

I'll get back with more info when the comparison is done.

JeffDess avatar May 08 '24 03:05 JeffDess

Ok so, turns out fcitx was stuck to an old version I had built some time ago. I can now reproduce on both computers, with fctix 5.9 & 5.10, repro steps are mostly ok except the second computer has a slightly different behavior. If I close/open a bunch of windows I can sometimes regain type control. But opening kitty first, closing it, then reopening firefox will always lead to the bug. I will update the previous message with repro steps accordingly.

On the second computer, I also managed to lose type control in Kitty. Closing it then opening a new terminal solved it.

JeffDess avatar May 08 '24 12:05 JeffDess

can you check d7aed240db408259228bf09708986c82bdca23eb

vaxerski avatar May 09 '24 13:05 vaxerski

Sadly, no change. Can I provide any logs that could help?

JeffDess avatar May 10 '24 01:05 JeffDess