hyprwm / Hyprland

Hyprland is an independent, highly customizable, dynamic tiling Wayland compositor that doesn't sacrifice on its looks.
https://hyprland.org
BSD 3-Clause "New" or "Revised" License
19.51k stars 818 forks source link

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

Closed JeffDess closed 2 days ago

JeffDess commented 4 months ago

Hyprland Version

System/Version info ```sh 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:

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

vaxerski commented 4 months ago

jesus christ this is like the 7th dupe #5763

JeffDess commented 4 months ago

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.

MightyPlaza commented 4 months ago

if it's a regression bisect it

vaxerski commented 4 months ago

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

JeffDess commented 4 months ago

Ok so I bissected all night and found the issue:

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 commented 4 months ago

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

vaxerski commented 4 months ago

can you try after 8bcccf9f0f0f69986e315d4288dfdbf119dd19db

JeffDess commented 4 months ago

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

JeffDess commented 4 months ago

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

rtgiskard commented 4 months ago

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
vaxerski commented 4 months ago

this is unrelated and fixed in git.

vaxerski commented 4 months ago

@JeffDess I set the thing:

image

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

JeffDess commented 4 months ago

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 commented 4 months ago

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 commented 4 months ago

I've just tested more things with a3ca016d :

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?

arbyste commented 4 months ago

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?

JeffDess commented 4 months ago

@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 commented 4 months ago

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.

fufexan commented 4 months ago

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.

JeffDess commented 4 months ago

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 commented 4 months ago

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
fufexan commented 4 months ago

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.

vaxerski commented 4 months ago

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?

JeffDess commented 4 months ago

@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.

vaxerski commented 4 months ago

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?

JeffDess commented 4 months ago

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 commented 4 months ago

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 commented 4 months ago

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.

vaxerski commented 3 months ago

can you check d7aed240db408259228bf09708986c82bdca23eb

JeffDess commented 3 months ago

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

vaxerski commented 3 months ago

You can try launching a simple app that exhibits the issue (the simpler the better) with WAYLAND_DEBUG=1 and saving the output (e.g. WAYLAND_DEBUG=1 kitty |& tee ./logs.txt) on both the bad commit and the good commit and attach both. Maybe I'll spot something off. (of course press your buttons while the app is open to gather the data xD)

fwiw, I've done all the steps you outlined and found a crash bug which I fixed shortly after, but after that my keys would register normally in firefox, chromium, kitty, etc.

JeffDess commented 3 months ago

Oh wait, I had a build error that I overlooked and was testing the wrong build. d7aed24 seems to have fixed it as far as I can tell! Thanks a lot! :tada:

The scroll mode with the double numlock macro is still broken. Do you prefer that I open a new issue about that one?

vaxerski commented 3 months ago

I dont mind either way, but please explain how your macro is supposed to work and which commit broke it

JeffDess commented 3 months ago

Yes, so I will investigate a little on my side and open a new issue when I have gathered all the info. Thanks!

JeffDess commented 3 months ago

Hi! While the bug where I could not type at all is gone, I am sorry to report that I can still reproduce the issue under very specific conditions (with 7ad9116d and Fcitx 5.1.9 & 5.1.10). The good news is I have STR 100% repro on two computers. It's pretty much what I have described before, but I have found the terminal needs to be the last window when it is closed. I have also tested more terminal emulators to make sure it wasn't linked to Kitty. Foot and Alacritty also reproduce the bug, while Konsole does not. Cannot reproduce in Sway either.

The annoying thing is, when it happens just before locking the computer (swaylock), it is not possible to enter password to unlock the system!

Here are the updated STR:

  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. In hypr config, set exec-once = fcitx5 -r
  5. Exit session
  6. Open new Hyprland session
  7. Launch a terminal (Kitty, Foot, Alacritty)
  8. Try to type, any key should work.
  9. Close the terminal. It must be the last window, no window should remain open at this point.
  10. Launch a non-terminal app (Firefox, Kate, Anyrun, etc.)
  11. Try to type letters, no text should appear as you type.
  12. Ctrl or GUI key combinations should all work (i.e. Ctrl+T to open a tab in a browser)
  13. Open a terminal
  14. With that new terminal window open, focus on the previously opened GUI app. The bug should have vanished, but it will happen again as long as the last closed window is the terminal.

Please let me know if you need any other details, hopefully you'll be able to reproduce easily. (my dotfiles)

ryan4yin commented 1 month ago

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

A workaround https://github.com/ryan4yin/nix-config/commit/5e9f98e56dce5685f4a72b77564aebd0d3a7891a

JeffDess commented 1 month ago

A workaround ryan4yin/nix-config@5e9f98e

Thanks @ryan4yin, I solved this issue by removing the randr plugin which I didn't use that much, but I'll keep that in mind if I want to enable it again.

sungyoonc commented 4 days ago

@JeffDess can you check if the latest -git fixed the issue?

JeffDess commented 2 days ago

Hi @sungyoonc, I just built with the latest and greatest:

> hyprctl version
Hyprland, built from branch main at commit 9b54342baa27d8de0460e1103ec4c3cc65592ed8  (Revert syncobj: wait for deadline instead of available).
Date: Tue Sep 3 08:47:34 2024
Tag: v0.42.0-113-g9b54342b, commits: 5182

So far it's everything seems to be working. I retested with the repro steps that I provided, but I have not encountered the bug.

Nice work, I appreciate it!