Fixed some issues and pushed last release.
This commit is contained in:
@@ -1708,6 +1708,8 @@ def _focus_game_window(
|
||||
focused = _repair_game_window_focus(mapper, window)
|
||||
else:
|
||||
# Host focus may have changed during the dashboard handoff delay.
|
||||
# The nested monitor owns startup mapping so it can defer that step
|
||||
# until the host becomes active and handle replacement login clients.
|
||||
focused = _repair_gamescope_game_window_focus(mapper, window)
|
||||
outcome = "focused" if focused else "focus_not_owned"
|
||||
except Exception as exc:
|
||||
@@ -1975,6 +1977,14 @@ def _resolve_gamescope_game_window(
|
||||
except Exception:
|
||||
return None
|
||||
if found is None:
|
||||
# A named GE startup client can exist before Gamescope gives it
|
||||
# WM_STATE. Keep following it while waiting for host focus instead of
|
||||
# permanently excluding it as if it were a destroyed login window.
|
||||
try:
|
||||
if mapper.window_state(window) is None and mapper.window_size(window) is not None:
|
||||
return window
|
||||
except Exception:
|
||||
pass
|
||||
return None
|
||||
replacement, title = found
|
||||
_apply_game_window_identity(mapper, replacement)
|
||||
@@ -2256,6 +2266,60 @@ def _maintain_game_window_focus(
|
||||
return int(process.wait())
|
||||
|
||||
|
||||
def _prepare_gamescope_startup_window(
|
||||
mapper: _X11,
|
||||
window: int,
|
||||
prepared_windows: set[int],
|
||||
*,
|
||||
diagnostics: WindowDiagnosticRecorder | None = None,
|
||||
) -> None:
|
||||
"""Map each new nested client once, deferring while its host is inactive."""
|
||||
|
||||
if window in prepared_windows:
|
||||
return
|
||||
try:
|
||||
if mapper.window_state(window) is not None:
|
||||
# A previously managed window losing WM_STATE later is a teardown,
|
||||
# not permission to map it again. Nested iconify recovery is separate.
|
||||
prepared_windows.add(window)
|
||||
return
|
||||
if not _gamescope_host_focus_is_allowed() or mapper.window_size(window) is None:
|
||||
return
|
||||
# Recheck state and host ownership after the X11 geometry round trip.
|
||||
if mapper.window_state(window) is not None:
|
||||
prepared_windows.add(window)
|
||||
return
|
||||
if not _gamescope_host_focus_is_allowed():
|
||||
return
|
||||
except Exception:
|
||||
return
|
||||
|
||||
# GE publishes its title before mapping the initial client. Mapping only
|
||||
# this nested window restores Gamescope's surface without resizing it or
|
||||
# activating a desktop window. Bound attempts even if the WM never replies.
|
||||
prepared_windows.add(window)
|
||||
try:
|
||||
mapper.map_window(window, borderless=False)
|
||||
if diagnostics is not None:
|
||||
diagnostics.record("nested_startup_window_mapped", window_id=window)
|
||||
deadline = time.monotonic() + WINDOW_STATE_CONFIRM_TIMEOUT_SECONDS
|
||||
while mapper.window_state(window) is None:
|
||||
remaining = deadline - time.monotonic()
|
||||
if remaining <= 0 or not _gamescope_host_focus_is_allowed():
|
||||
break
|
||||
time.sleep(min(WINDOW_CONFIRM_POLL_SECONDS, remaining))
|
||||
except Exception as exc:
|
||||
if diagnostics is not None:
|
||||
diagnostics.record(
|
||||
"nested_startup_mapping_failed", window_id=window,
|
||||
error_type=type(exc).__name__,
|
||||
)
|
||||
print(
|
||||
f"Warning: could not map the nested startup window ({exc}); continuing normally",
|
||||
file=sys.stderr, flush=True,
|
||||
)
|
||||
|
||||
|
||||
def _maintain_gamescope_game_window_focus(
|
||||
mapper: _X11,
|
||||
process: subprocess.Popen[bytes],
|
||||
@@ -2269,6 +2333,7 @@ def _maintain_gamescope_game_window_focus(
|
||||
|
||||
active_window: int = window
|
||||
retired_window_ids = set(existing_window_ids)
|
||||
prepared_windows: set[int] = set()
|
||||
next_focus_repair_at = (
|
||||
time.monotonic() + GAMESCOPE_FOCUS_REPAIR_INTERVAL_SECONDS
|
||||
)
|
||||
@@ -2301,6 +2366,9 @@ def _maintain_gamescope_game_window_focus(
|
||||
if resolved_window_id != active_window:
|
||||
retired_window_ids.add(active_window)
|
||||
active_window = resolved_window_id
|
||||
_prepare_gamescope_startup_window(
|
||||
mapper, active_window, prepared_windows, diagnostics=diagnostics,
|
||||
)
|
||||
if diagnostics is None:
|
||||
_repair_gamescope_game_window_focus(mapper, active_window)
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user