Skip to content

Gaming input/focus issues on multi-monitor setup #3296

Description

@rykugur

The bug: sometimes after changing focus away from and back to a game I will encounter mouse and keyboard input issues. These issues are generally: input from mouse is sent to wrong location (if at all), followed by no input from keyboard nor mouse until I unfocus/refocus the game. This only seems to happen when I cross a monitor boundary.

Additional context:

I run multiple monitors, stacked on top of each other:

1x 35" ultrawide @ 175hz (bottom/primary - all games run here)
1x 35" ultrawide @ 144hz (top/secondary)

When gaming, I can switch between workspaces on the same monitor back and forth without issue. However, frequently when I switch between monitors, when I go back to re-focus my game, some very strange input issues happen.

This doesn't affect all games, but the two I'm playing right now it definitely does:

In Cyberpunk 2077, the cursor will not be visible except for at the very top/bottom of the screen. Sometimes I can click and the input will be somewhere else, but in general no input is accepted via mouse nor keyboard.
In EVE Online, my ship camera will spin wildly fast and I'll generally end up "under" my ship looking up. Sometimes I can click and the input will be somewhere else, but in general no input is accepted via mouse nor keyboard.

Other games I've noticed similar issues in: DOTA2, ARC Raiders.

The workaround I've found to get out of the "game is not accepting input" state is to press super+tab (which I have bound to overview), and then click the game window. Sometimes I have to do this twice, but once is usually enough.

I have found that I can reliably reproduce this bug if I:

  • Playing game
  • Move mouse to top monitor (depending on the game I might need to press esc to let my mouse escape the window, or press cmd+tab to select top monitor workspace)
  • Switch to a different workspace on top monitor, do something
  • Switch back to previous workspace on top monitor
  • Bring mouse down to bottom monitor

I'm unsure if it's related to VRR or not. I've tried with VRR on (also tried on-demand), and honestly don't notice a difference either way in performance nor this bug. I have noticed however that some games will suffer from performance drops after I re-focus them, and I'll need to do my overview trick above a couple times and the FPS will generally correct itself.

I've tried tailing journalctl while reproducing this and have not seen anything, but perhaps there's a verbose setting I'm unaware of.

Config
input {
    keyboard {
        xkb {
            layout "us"
            model ""
            rules ""
            variant ""
            options "fkeys:basic_13-24"
        }
        repeat-delay 200
        repeat-rate 60
        track-layout "global"
        numlock
    }
    touchpad {
        tap
        natural-scroll
    }
}
output "DP-1" {
    focus-at-startup
    transform "normal"
    position x=0 y=1440
    mode "3440x1440@174.963000"
    variable-refresh-rate on-demand=true
}
output "DP-2" {
    transform "normal"
    position x=0 y=0
    mode "3440x1440@144.000000"
}
screenshot-path "~/Pictures/Screenshots/Screenshot from %Y-%m-%d %H-%M-%S.png"
layout {
    gaps 16
    struts {
        left 0
        right 0
        top 0
        bottom 0
    }
    focus-ring { off; }
    border {
        width 4
        active-color "#89b4fa"
        inactive-color "#45475a"
    }
    default-column-width { proportion 0.666667; }
    preset-column-widths {
        proportion 0.250000
        proportion 0.333333
        proportion 0.500000
        proportion 0.666667
        proportion 0.750000
        proportion 1.000000
    }
    center-focused-column "never"
}
cursor {
    xcursor-theme "phinger-cursors-dark"
    xcursor-size 32
}
environment {
    "DMS_SCREENSHOT_EDITOR" "swappy"
    "QT_QPA_PLATFORM" "wayland"
    "XDG_CURRENT_DESKTOP" "Niri"
    "XDG_SESSION_DESKTOP" "Niri"
    "XDG_SESSION_TYPE" "wayland"
}
binds {
    Mod+0 { spawn "dms" "ipc" "call" "notepad" "toggle"; }
    Mod+Print repeat=false { spawn "dms" "screenshot" "--no-file"; }
    Mod+Return repeat=false { spawn "ghostty" "--gtk-single-instance=true"; }
    Mod+Shift+e { spawn "dms" "ipc" "call" "powermenu" "toggle"; }
    Mod+Shift+h { move-column-left-or-to-monitor-left; }
    Mod+Shift+j { move-window-down-or-to-workspace-down; }
    Mod+Shift+k { move-window-up-or-to-workspace-up; }
    Mod+Shift+l { move-column-right-or-to-monitor-right; }
    Mod+Shift+p { switch-preset-column-width-back; }
    Mod+Shift+v { spawn "dms" "ipc" "call" "clipboard" "toggle"; }
    Mod+Space { spawn "dms" "ipc" "call" "spotlight" "toggle"; }
    Mod+Tab cooldown-ms=250 { toggle-overview; }
    Mod+WheelScrollDown { focus-column-right; }
    Mod+WheelScrollUp { focus-column-left; }
    Mod+e repeat=false { spawn "nautilus" "--new-window"; }
    Mod+f repeat=false { spawn "/home/dusty/.nix-profile/bin/conditional-fullscreen.nu"; }
    Mod+g repeat=false { spawn "/home/dusty/.nix-profile/bin/eve-toggle.nu"; }
    Mod+h { focus-column-left-or-last; }
    Mod+j { focus-window-or-workspace-down; }
    Mod+k { focus-window-or-workspace-up; }
    Mod+l { focus-column-right-or-first; }
    Mod+o { show-hotkey-overlay; }
    Mod+p { switch-preset-column-width; }
    Mod+q repeat=false { spawn "/home/dusty/.nix-profile/bin/conditional-kill.nu"; }
    Mod+r { spawn "dms" "ipc" "call" "spotlight" "toggle"; }
    Mod+v repeat=false { toggle-window-floating; }
    Mod+w repeat=false { toggle-column-tabbed-display; }
    XF86AudioLowerVolume { spawn "dms" "ipc" "call" "audio" "decrement" "5"; }
    XF86AudioMute { spawn "dms" "ipc" "call" "audio" "mute"; }
    XF86AudioNext { spawn "dms" "ipc" "call" "mpris" "next"; }
    XF86AudioPause { spawn "dms" "ipc" "call" "mpris" "playPause"; }
    XF86AudioPlay { spawn "dms" "ipc" "call" "mpris" "playPause"; }
    XF86AudioPrev { spawn "dms" "ipc" "call" "mpris" "previous"; }
    XF86AudioRaiseVolume { spawn "dms" "ipc" "call" "audio" "increment" "5"; }
    XF86MonBrightnessDown { spawn "dms" "ipc" "call" "brightness" "decrement" "5"; }
    XF86MonBrightnessUp { spawn "dms" "ipc" "call" "brightness" "increment" "5"; }
    XF86Tools { spawn "dms" "ipc" "call" "audio" "micmute"; }
}
spawn-at-startup "dms" "run"
spawn-at-startup "1password"
spawn-at-startup "discord"
spawn-at-startup "steam"
spawn-at-startup "playerctld" "daemon"
spawn-at-startup "wl-paste" "--watch" "cliphist" "store"
spawn-at-startup "corectrl" "--minimize-systray"
spawn-sh-at-startup "ghostty --gtk-single-instance=true --quit-after-last-window-closed=false --initial-window=false"
window-rule {
    match app-id="1password"
    open-floating true
    block-out-from "screen-capture"
}
window-rule {
    draw-border-with-background false
    geometry-corner-radius 8.000000 8.000000 8.000000 8.000000
    clip-to-geometry true
}
window-rule {
    match app-id="com.mitchellh.ghostty"
    default-column-width { proportion 0.333333; }
}
window-rule {
    match app-id="discord"
    default-column-width { proportion 0.500000; }
}
window-rule {
    match app-id="steam" title="Friends List"
    default-column-width { proportion 0.333333; }
}
window-rule {
    match app-id="steam_app_8500" title="EVE Launcher"
    default-column-width { proportion 0.333333; }
}
window-rule {
    match app-id="steam_app_1903340" title="Clair Obscur: Expedition 33"
    open-fullscreen true
}
window-rule {
    match app-id="galculator"
    open-floating true
}
window-rule {
    match app-id="neovide"
    open-floating true
}
window-rule {
    match app-id="nemo"
    open-floating true
}
window-rule {
    match app-id="obsidian"
    open-floating true
}
window-rule {
    match app-id="opentrack"
    open-floating true
}
window-rule {
    match app-id="org.gnome.Nautilus"
    open-floating true
}
window-rule {
    match app-id="nemo"
    open-floating true
}
window-rule {
    match app-id="thunar"
    open-floating true
}
window-rule {
    match app-id="org.pulseaudio.pavucontrol"
    open-floating true
}
window-rule {
    match app-id="pavucontrol"
    open-floating true
}
window-rule {
    match app-id="ristretto"
    open-floating true
}
window-rule {
    match app-id="vlc"
    open-floating true
}
window-rule {
    match app-id="yad"
    open-floating true
}
window-rule {
    match app-id="zenity"
    open-floating true
}

xwayland-satellite is indeed installed and appears to be working:

~/.config/niri
✦ ❯ readlink /proc/(niri msg --json pick-window | jq .pid)/exe
/nix/store/vgzirc90qxi1hk1lpv4a2lm4c48d7zrk-xwayland-satellite-0.8/bin/.xwayland-satellite-wrapped

System Information

  • niri version: niri stable v25.08 (commit 01be0e6)
  • Distro: nixOS
  • GPU: AMD 9070 xt (Powercolor Reaper)
  • CPU: AMD Ryzen 9 5900x

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:inputKeyboard, mouse, touchpad, tablet, gestures, pointernot niri:xwayland-satellitexwayland-satellite issues

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions