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
21.58k stars 902 forks source link

Newly added sendshortcut dispatcher sometimes keeps sent mod key pressed after sending shortcut to application #6407

Closed yorororo closed 2 months ago

yorororo commented 5 months ago

Bug or Regression?

Bug

System Info and Version

System/Version info ```sh Hyprland, built from branch at commit ea2501d4556f84d3de86a4ae2f4b22a474555b9f (). Date: 2024-06-10 Tag: , commits: flags: (if any) System Information: System name: Linux Node name: laptop Release: 6.9.3 Version: #1-NixOS SMP PREEMPT_DYNAMIC Thu May 30 07:45:04 UTC 2024 GPU information: 01:00.0 VGA compatible controller [0300]: NVIDIA Corporation GA104 [Geforce RTX 3070 Ti Laptop GPU] [10de:24a0] (rev a1) (prog-if 00 [VGA controller]) 09:00.0 VGA compatible controller [0300]: Advanced Micro Devices, Inc. [AMD/ATI] Rembrandt [Radeon 680M] [1002:1681] (rev c8) (prog-if 00 [VGA controller]) os-release: ANSI_COLOR="1;34" BUG_REPORT_URL="https://github.com/NixOS/nixpkgs/issues" BUILD_ID="24.11.20240607.051f920" DOCUMENTATION_URL="https://nixos.org/learn.html" HOME_URL="https://nixos.org/" ID=nixos IMAGE_ID="" IMAGE_VERSION="" LOGO="nix-snowflake" NAME=NixOS PRETTY_NAME="NixOS 24.11 (Vicuña)" SUPPORT_URL="https://nixos.org/community.html" VERSION="24.11 (Vicuña)" VERSION_CODENAME="vicuña" VERSION_ID="24.11" plugins: hyprgrass by horriblename ver 0.6 ======Config-Start====== Config File: /home/user/.config/hypr/hyprland.conf: Read Succeeded exec-once = /nix/store/bnipzdfv788l7yvgn7k7s7gp76sd1zpz-dbus-1.14.10/bin/dbus-update-activation-environment --systemd DISPLAY HYPRLAND_INSTANCE_SIGNATURE WAYLAND_DISPLAY XDG_CURRENT_DESKTOP && systemctl --user stop hyprland-session.target && systemctl --user start hyprland-session.target plugin=/nix/store/9f1nc90a62zkj8q7a699rd2xfl7l8iyy-hyprgrass-0.6.0/lib/libhyprgrass.so $mainMod=SUPER $webMod=ALT animations { bezier=overshot, 0.13, 0.99, 0.29, 1.1 animation=windows, 1, 4, default, slide animation=border, 1, 10, default animation=fade, 1, 10, default animation=workspaces, 1, 4, default, slidefade enabled=1 } decoration { blur { enabled=0 new_optimizations=true passes=1 size=1 } col.shadow=0x33000000 col.shadow_inactive=0x22000000 drop_shadow=true rounding=15 shadow_range=100 shadow_render_power=5 } dwindle { force_split=0 no_gaps_when_only=1 pseudotile=true } general { apply_sens_to_raw=0 border_size=3 col.active_border=0xfff5c2e7 col.inactive_border=0xff45475a gaps_in=5 gaps_out=10 resize_on_border=true sensitivity=1.000000 } gestures { workspace_swipe=true workspace_swipe_fingers=4 } input { touchpad { natural_scroll=true } follow_mouse=true kb_layout=pl repeat_delay=250 repeat_rate=50 } misc { disable_hyprland_logo=true focus_on_activate=true vrr=1 } bind=$mainMod, Q, killactive, bind=$mainMod, F, fullscreen, bind=$mainMod, RETURN, exec, kitty bind=$mainMod, W, exec, firefox bind=$webMod, w, sendshortcut, control, t, bind=$webMod, q, sendshortcut, control, w, bind=$webMod, left, sendshortcut, control shift, tab, bind=$webMod, right, sendshortcut, control, tab, bind=$webMod, up, sendshortcut, control shift, tab, bind=$webMod, down, sendshortcut, control, tab, exec-once=swaylock & exec-once=dunst & exec-once=nm-applet & exec-once=polkit-kde-agent & exec-once=iio-hyprland eDP-1 & exec-once=ydotoold & monitor=eDP-1, 2560x1600@165, auto, 1 ======Config-End======== ```

Description

I am Hyperland user on NixOS (using flakes). I am using the newly added sendshortcut dispatcher as a way to rebind Firefox default keybindings for opening a new tab, closing the current tab and cycling through them.

For example, the default shortcut for opening a new tab in Firefox is CONTROL + T, and my respective Hyperland's bind config for that is bind=alt, w, sendshortcut, control, t,. It should work so that after pressing ALT + W, the new tab will open, and it does.

However, I have noticed that sometimes after using this bind, sent mod key (CONTROL in this case) remains pressed, and typing anything after using the bind performs other Firefox's key binds. For example, after using this bind, when the new tab opens with search bar focused, typing t will open another new tab (because of the Firefox's CONTROL + T open tab key bind), typing w will close the newly opened tab (because of the Firefox's CONTROL + W close tab key bind) etc. An interesting thing to note is that pressing the CONTROL key in this state resets this behavior, and the characters typed after that go to search bar (or other desired destination).

This bug makes using these binds (and this dispatcher) really annoying, because they can do unpredictable actions.

P.S. I am not sure what causes that, but given that before introducing this dispatcher I used ydotool for the same purpose, and its relative bind was bind=alt, w, execr, ydotool key 29:1 20:1 20:0 29:0 (key event sequence consisting of: pressing CONTROL, pressing T, releasing T, releasing CONTROL), I suppose the "releasing part" of CONTROL mod key sent by sendshortcut dispatcher sometimes does not reach Firefox (or any other application).

How to reproduce

Hyprland rev: ea2501d4556f84d3de86a4ae2f4b22a474555b9f nixpkgs rev: 051f920625ab5aabe37c920346e3e69d7d34400e Firefox version: Mozilla Firefox 126.0.1

Crash reports, logs, images, videos

No response

yorororo commented 5 months ago

@yungcxn @vaxerski

asiantuntija commented 4 months ago

I got the same issue with these two binds:

# Firefox tab scroll
bindr = SHIFT,mouse_up,sendshortcut,CTRL,left,^(firefox)$
bindr = SHIFT,mouse_down,sendshortcut,CTRL,right,^(firefox)$

They work fine if I go slow with the wheel, something like two clicks per second, but any faster, and mouse event gets sent with the CTRL, meaning the page gets rezised. If you go too slow on the other hand, then the mouse event gets sent as long as SHIFT is down, even though scroll isn't touched. This happens only with mouse_down and mouse_up, keycodes I tried worked just fine. This same behavior happens in other wayland programs as well.

darkwater commented 2 months ago

https://github.com/hyprwm/Hyprland/blob/92a0dd164e9cc74060b63abae67b0204b6b6074c/src/managers/KeybindManager.cpp#L2329

Is it because this sendKeyboardMods presses the modifiers, and they're never released

darkwater commented 2 months ago

Fixed by #7581, forgot to mention in PR oops