Fixed the on top issue with the game window, it should not pop up when alt tabbing to some other programs now.
This commit is contained in:
@@ -972,6 +972,11 @@ class _X11:
|
||||
"""Raise the mapped game client and give it keyboard focus."""
|
||||
|
||||
self.library.XMapRaised(self.display, window)
|
||||
self.restore_input_focus(window)
|
||||
|
||||
def restore_input_focus(self, window: int) -> None:
|
||||
"""Give a mapped client keyboard focus without raising its host window."""
|
||||
|
||||
self.library.XSetInputFocus(
|
||||
self.display,
|
||||
window,
|
||||
@@ -1437,6 +1442,27 @@ def _repair_game_window_focus(mapper: _X11, window: int) -> bool:
|
||||
return False
|
||||
|
||||
|
||||
def _repair_gamescope_game_window_focus(mapper: _X11, window: int) -> bool:
|
||||
"""Restore nested focus without asking the desktop to activate Gamescope."""
|
||||
|
||||
try:
|
||||
if mapper.window_is_focused(window):
|
||||
return True
|
||||
except Exception:
|
||||
return False
|
||||
try:
|
||||
mapper.restore_input_focus(window)
|
||||
return mapper.window_is_focused(window)
|
||||
except Exception as exc:
|
||||
print(
|
||||
f"Warning: could not restore nested game input focus ({exc}); "
|
||||
"continuing normally",
|
||||
file=sys.stderr,
|
||||
flush=True,
|
||||
)
|
||||
return False
|
||||
|
||||
|
||||
def _enable_game_window_scaling(mapper: _X11, window: int) -> bool:
|
||||
"""Enable confirmed resize/maximize actions without risking game startup."""
|
||||
|
||||
@@ -1572,7 +1598,7 @@ def _maintain_gamescope_game_window_focus(
|
||||
now = time.monotonic()
|
||||
if now < next_focus_repair_at:
|
||||
continue
|
||||
_repair_game_window_focus(mapper, window)
|
||||
_repair_gamescope_game_window_focus(mapper, window)
|
||||
next_focus_repair_at = (
|
||||
time.monotonic() + GAMESCOPE_FOCUS_REPAIR_INTERVAL_SECONDS
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user