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

Some fullscreen XWayland games break keyboard when switching focus #7155

Open
nonetrix opened this issue Aug 2, 2024 · 15 comments
Open

Some fullscreen XWayland games break keyboard when switching focus #7155

nonetrix opened this issue Aug 2, 2024 · 15 comments
Labels
bug Something isn't working

Comments

@nonetrix
Copy link

nonetrix commented Aug 2, 2024

Regression?

Yes

System Info and Version

System/Version info
Hyprland, built from branch  at commit 4141e6755022edc19cd37cd7ad077a93b3bae5bd  ().
Date: 2024-08-02
Tag: , commits: 4141e6755022edc19cd37cd7ad077a93b3bae5bd

flags: (if any)


System Information:
System name: Linux
Node name: nixos
Release: 6.9.12
Version: #1-NixOS SMP PREEMPT_DYNAMIC Sat Jul 27 09:36:19 UTC 2024


GPU information: 
09:00.0 VGA compatible controller [0300]: Advanced Micro Devices, Inc. [AMD/ATI] Navi 21 [Radeon RX 6800/6800 XT / 6900 XT] [1002:73bf] (rev c3) (prog-if 00 [VGA controller])


os-release: ANSI_COLOR="1;34"
BUG_REPORT_URL="https://github.com/NixOS/nixpkgs/issues"
BUILD_ID="24.11.20240731.9f918d6"
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 (Vicuna)"
SUPPORT_URL="https://nixos.org/community.html"
VERSION="24.11 (Vicuna)"
VERSION_CODENAME=vicuna
VERSION_ID="24.11"


plugins:
  hyprsplit by shezdy ver 1.0

======Config-Start======


Config File: /home/noah/.config/hypr/hyprland.conf: Read Succeeded
exec-once = /nix/store/j8l2v22xypah1srykhwjlkgwwgdxnnpw-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/w68hm6fxxv37an1jz9x2zbk8d6zv35ka-hyprsplit-0.1/lib/libhyprsplit.so
$mod=SUPER
cursor {
  inactive_timeout=5
}

debug {
}

decoration {
  blur {
    brightness=0.700000
    enabled=true
  }
  blurls=bar-0
  blurls=bar-1
  blurls=rofi
  blurls=notifications0
  blurls=notifications1
  blurls=mpris
  col.shadow=rgba(1a1a1aaf)
  drop_shadow=true
  rounding=12
  shadow_offset=0, 40
  shadow_range=300
  shadow_render_power=4
  shadow_scale=0.900000
}

device {
  name=wacom-intuos-s-pen
}

dwindle {
  preserve_split=true
}

experimental {
  explicit_sync=1
}

general {
  border_size=2
  col.active_border=rgba(f38ba8ff)
  col.inactive_border=rgba(1e1e2eff)
  extend_border_grab_area=25
  gaps_in=5
  gaps_out=10
  resize_on_border=1
}

input {
  accel_profile=flat
  follow_mouse=1
  mouse_refocus=false
}

misc {
  disable_hyprland_logo=true
}
animation=layers, 1, 5, default, slide
bind=, XF86AudioPlay, exec, playerctl play-pause
bind=, XF86AudioNext, exec, playerctl next
bind=, XF86AudioPrev, exec, playerctl previous
bind=$mod, f11, exec, brightness-ctrl down
bind=$mod, f12, exec, brightness-ctrl up
bind=$mod SHIFT, f12, exec, brightness-ctrl full
bind=CTRL, Print, exec, satty-shot
bind=, Print, exec, hyprshot -m output -o ~/Pictures/Screenshots
bind=$mod, p, exec, wl-copy $(hyprpicker)
bind=$mod, h, movefocus, l
bind=$mod, l, movefocus, r
bind=$mod, k, movefocus, u
bind=$mod, j, movefocus, d
bind=$mod SHIFT, h, movewindow, l
bind=$mod SHIFT, l, movewindow, r
bind=$mod SHIFT, k, movewindow, u
bind=$mod SHIFT, j, movewindow, d
bind=$mod, slash, togglesplit
bind=$mod, mouse_down, split:workspace, e-1
bind=$mod, mouse_up, split:workspace, e+1
bind=alt, tab, exec, rofi -show window
bind=$mod, t, togglefloating
bind=$mod, c, killactive
bind=$mod, q, exec, shutdown-menu
bind=$mod, B, exec, firefox
bind=$mod, y, exec, kitty -e yazi
bind=alt, f4, exec, hyprctl kill
bind=$mod, Return, exec, kitty
bind=$mod, Space, exec, rofi -show drun
bind=$mod, E, exec, rofimoji
bind=$mod, a, exec, kitty -e ollama run mixtral
bind=$mod SHIFT, escape, exec, hyprlock
bind=$mod SHIFT, a, exec, llm-actions
bind=$mod, 1, split:workspace, 1
bind=$mod SHIFT, 1, split:movetoworkspace, 1
bind=$mod, 2, split:workspace, 2
bind=$mod SHIFT, 2, split:movetoworkspace, 2
bind=$mod, 3, split:workspace, 3
bind=$mod SHIFT, 3, split:movetoworkspace, 3
bind=$mod, 4, split:workspace, 4
bind=$mod SHIFT, 4, split:movetoworkspace, 4
bind=$mod, 5, split:workspace, 5
bind=$mod SHIFT, 5, split:movetoworkspace, 5
bind=$mod, 6, split:workspace, 6
bind=$mod SHIFT, 6, split:movetoworkspace, 6
bind=$mod, 7, split:workspace, 7
bind=$mod SHIFT, 7, split:movetoworkspace, 7
bind=$mod, 8, split:workspace, 8
bind=$mod SHIFT, 8, split:movetoworkspace, 8
bind=$mod, 9, split:workspace, 9
bind=$mod SHIFT, 9, split:movetoworkspace, 9
bind=$mod, 0, split:workspace, 10
bind=$mod SHIFT, 0, split:movetoworkspace, 10
binde=, XF86AudioRaiseVolume, exec, wpctl set-volume -l 1.4 @DEFAULT_AUDIO_SINK@ 1%+
binde=, XF86AudioLowerVolume, exec, wpctl set-volume -l 1.4 @DEFAULT_AUDIO_SINK@ 1%-
binde=$mod CTRL, l, resizeactive, 10 0
binde=$mod CTRL, h, resizeactive, -10 0
binde=$mod CTRL, k, resizeactive, 0 -10
binde=$mod CTRL, j, resizeactive, 0 10
bindm=$mod, mouse:272, movewindow
bindm=$mod, mouse:273, resizewindow
exec-once=ags
exec-once=fcitx5
exec-once=wpaperd
exec-once=mpv --no-video --volume=150 /nix/store/ag6v7p7x8ksxirkyqjl9xfsmhzr45w31-start.wav
exec-once=/nix/store/kgicsqdrmk7z1gs9fkzkvdzgayihi7dl-lxqt-policykit-2.0.0/bin/lxqt-policykit-agent
layerrule=ignorealpha, bar-0
layerrule=ignorealpha, bar-1
layerrule=ignorealpha, notifications0
layerrule=ignorealpha, notifications1
layerrule=ignorealpha, mpris
layerrule=ignorealpha, rofi
layerrule=noanim,selection
monitor=DP-2, 1920x1200, 1920x0, 1
monitor=DP-1, 1920x1080@165, 0x0, 1, vrr, 1 
windowrulev2=noanim, class:^(com.gabm.satty)$
windowrulev2=size 640 360, title:(Picture-in-Picture)
windowrulev2=pin, title:^(Picture-in-Picture)$
windowrulev2=move 1906 14, title:(Picture-in-Picture)
windowrulev2=float, title:^(Picture-in-Picture)$
windowrulev2=float, title:^(Authentication Required)$

======Config-End========

Description

When opening a game in full screen keyboard and mouse both work, but if you switch focus to another window with rofi -show window for example then switch back keyboard will be broken mouse only will work

How to reproduce

  1. Open game e.g. Quake 2 remaster
  2. Have key bind to run rofi -show window
  3. Switch to another window e.g. Firefox
  4. Switch back to game
  5. Suddenly keyboard doesn't work

Crash reports, logs, images, videos

No response

@nonetrix nonetrix added the bug Something isn't working label Aug 2, 2024
@BluewyDiamond
Copy link

i also have the same or something similar to this

this is what i remember
in my case my game loses keyboard focus in the following scenarios:

first scenario: when steam (xwayland window) is under my game (xwayland window)
solutions:

  • switching back to steam and then back to the game
  • unfullscreen the game and fullscreen it again
  • avoid having steam and the game in the same workspace (sometimes you rarely still lose keyboard focus on the game)

scenario 2: even when the game and steam are in different workspaces
solutions:

  • refocus steam and go back to the game

@nonetrix
Copy link
Author

nonetrix commented Aug 3, 2024

Same here and makes it worse that a lot of games I have to window then fullscreen or it's in a window with my bar is the way because of another bug #6568

@declspecl
Copy link

Does the video turn black when you regain focus onto the game window? If so, may be a duplicate of this issue #6966 which is fixed in the AUR package and will be fixed in stable in a few days, with 0.42 being merged in earlier today. More context onto the problem in this issue as well here #6375

@BluewyDiamond
Copy link

BluewyDiamond commented Aug 9, 2024

it is somewhat related to it while the main problems of the issue were fixed some edge cases like this one are left though it is not a very big deal since in my case i can recover by doing the steps i describe above

@soworksl2
Copy link

I am experiencing something similar with Pathologic 2.

I am using Wine 9.14 and Hyprland 0.41.2-3 from the Arch repo.

I am playing in fullscreen mode, and when I switch to another workspace and then come back, the game freezes. I have to close it with Ctrl-C in the terminal. However, when I reopen the game, I notice that it changes the configuration and automatically switches to window mode, but it works fine that way.

Another behavior I observe is that if the game is in window mode and I drag or resize the window, or simply change workspaces, the image does not freeze, but the keyboard stops working.

Also, in fullscreen mode, when I switch workspaces or drag the window, the Wine terminal outputs some messages instantly:

011c:fixme:wbemprox:wbem_services_CreateInstanceEnum unsupported flags 0x30
0140:fixme:toolhelp:CreateToolhelp32Snapshot Unimplemented: heap list snapshot
0140:fixme:toolhelp:Heap32ListFirst : stub
018c:fixme:d3d_shader:shader_sm4_read_dcl_resource Unhandled data type 0x6.
018c:fixme:d3d_shader:shader_sm4_read_dcl_resource Unhandled data type 0x6.
018c:fixme:d3d_shader:shader_sm4_read_dcl_resource Unhandled data type 0x6.
0188:fixme:d3d_shader:shader_sm4_read_dcl_resource Unhandled data type 0x6.
0188:fixme:d3d_shader:shader_sm4_read_dcl_resource Unhandled data type 0x6.
0188:fixme:d3d_shader:shader_sm4_read_dcl_resource Unhandled data type 0x6.
011c:fixme:dxgi:d3d11_swapchain_GetDesc Ignoring ScanlineOrdering and Scaling.
011c:fixme:dxgi:d3d11_swapchain_ResizeBuffers Ignoring flags 0x2.
011c:fixme:dwmapi:DwmGetWindowAttribute attribute 1 not implemented.
011c:fixme:dxgi:d3d11_swapchain_GetDesc Ignoring ScanlineOrdering and Scaling.
011c:fixme:dxgi:d3d11_swapchain_ResizeBuffers Ignoring flags 0x2.
011c:fixme:dxgi:d3d11_swapchain_GetDesc Ignoring ScanlineOrdering and Scaling.
011c:fixme:dxgi:d3d11_swapchain_ResizeBuffers Ignoring flags 0x2.

I hope this information is useful.

I suspect there are two problems here that need to be handled differently:

  1. Game freezes when changing workspaces: This issue is related to focus, as mentioned in XWayland game turns black after switching to another XWayland window. #6375.

    Probes or clues:

    • It only happens when changing focus.
    • In Windows, some games also switch from fullscreen to window mode on Alt+Tab, and I suspect they get minimized as well.
    • When the game loses focus, Wine automatically logs some fixme messages (see above).
  2. The keyboard stops working when the game window is manipulated in window mode.

    Probes or clues:

    • The game does not freeze, and the mouse works correctly.
    • The keyboard stops working when dragging, resizing the window, or changing workspaces.

More clues:

  • The game can switch from window mode to fullscreen and vice versa without any errors. It only occurs when Hyprland manipulates the window's attributes externally.

I hope this information can help to fix this bug. I am not experienced with Wayland or window managers, but I have some skills in C++. I would like to help find the bug, but I don’t even know where to start looking. In the meantime, I'm going to play some Pathologic 2 without messing with the windows XD, Sayonara baby.

@BluewyDiamond
Copy link

@soworksl2 if by game freezing you mean the game going black or something like that when changing workspaces the fix has been merged and available in the latest release 0.42

@soworksl2
Copy link

@BluewyDiamond it's not a black screen; it's just that the image gets frozen with the last frame of the game rendered.

@BluewyDiamond
Copy link

BluewyDiamond commented Aug 12, 2024

either way it sounds pretty much the same issue as the black window one but we wont really know until u try out the latest release 0.42 or -git version.

@nonetrix
Copy link
Author

@BluewyDiamond it's not a black screen; it's just that the image gets frozen with the last frame of the game rendered.

Could you try on older/newer kernel before 6.10 and compare?

@soworksl2
Copy link

either way it sounds pretty much the same issue as the black window one but we wont really know until u try out the latest release 0.42 or -git version.

@BluewyDiamond yes, I gonna make some time to install the 0.42 Hyprland version and test the game. probably at night.

Could you try on older/newer kernel before 6.10 and compare?

@nonetrix I don't think that would be very feasible for me. But anyway, why do you think this problem could be related to the Linux kernel?

@nonetrix
Copy link
Author

I have had issues in games where they just go crazy and flicker with black screen like mad in 6.10 then in older versions they just stutter sounded somewhat similar idk

@soworksl2
Copy link

@nonetrix By any chance, were you using Nvidia with the open-source graphics drivers (nouveau) or Intel?

I've experienced those kinds of problems, but I don't think it's very related because this issue follows a very repeatable pattern (when the game loses focus). Either way, we shouldn't dismiss your opinion, but something I can do that's more convenient for me is to test the game on other window managers first, like Sway, and see if the issues occur there.

@nonetrix
Copy link
Author

I am using AMD and it seems to be games using Kex engine specifically e.g. Doom 1 + Doom 2 or Quake 1 or 2 remastered

@soworksl2
Copy link

I have tried the game in sway, and apparently the keyboard does not work there either but changing the focus does not freeze the game.

@TAforever
Copy link

Same here and makes it worse that a lot of games I have to window then fullscreen or it's in a window with my bar is the way because of another bug #6568

#6568 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants