Fixed keyboard / input issues with resizing.

This commit is contained in:
2026-09-06 21:52:07 +02:00
parent 0963ae34b9
commit 6eab4b961f
3 changed files with 58 additions and 8 deletions

View File

@@ -48,6 +48,7 @@ _NET_WM_STATE_REMOVE = 0
_NET_WM_STATE_SOURCE_APPLICATION = 1
_NET_WM_BYPASS_COMPOSITOR_PREFER_COMPOSITING = 2
WINDOW_FOCUS_REPAIR_INTERVAL_SECONDS = 1.0
GAMESCOPE_FOCUS_REPAIR_INTERVAL_SECONDS = 0.25
_P_MIN_SIZE = 1 << 4
_P_MAX_SIZE = 1 << 5
_P_RESIZE_INC = 1 << 6
@@ -1556,6 +1557,28 @@ def _maintain_game_window_focus(
return int(process.wait())
def _maintain_gamescope_game_window_focus(
mapper: _X11,
process: subprocess.Popen[bytes],
window: int,
) -> int:
"""Restore nested keyboard focus after host resize/maximize operations."""
next_focus_repair_at = (
time.monotonic() + GAMESCOPE_FOCUS_REPAIR_INTERVAL_SECONDS
)
while process.poll() is None:
time.sleep(GAMESCOPE_FOCUS_REPAIR_INTERVAL_SECONDS)
now = time.monotonic()
if now < next_focus_repair_at:
continue
_repair_game_window_focus(mapper, window)
next_focus_repair_at = (
time.monotonic() + GAMESCOPE_FOCUS_REPAIR_INTERVAL_SECONDS
)
return int(process.wait())
def _guard_game_window_startup(
mapper: _X11,
process: subprocess.Popen[bytes],
@@ -1732,7 +1755,11 @@ def run_game_window(
file=sys.stderr,
flush=True,
)
return int(process.wait())
return _maintain_gamescope_game_window_focus(
mapper,
process,
game_window,
)
_prepare_game_window(
mapper,
game_window,