Reworked some game window and gamescope methods for Cinnamon.

This commit is contained in:
2026-09-12 11:32:46 +02:00
parent 2cbb9315bf
commit f3059c334e
2 changed files with 101 additions and 36 deletions

View File

@@ -11,6 +11,7 @@ import select
import subprocess
import sys
import time
from collections import deque
from collections.abc import Collection, Iterable, Mapping, Sequence
from ..desktop_identity import (
@@ -322,10 +323,10 @@ class _X11:
def find_window_by_pid(self, expected_pid: int) -> int | None:
"""Find a top-level host window created by one native process."""
queue = self._root_windows()
queue = deque(self._root_windows())
visited: set[int] = set()
while queue and len(visited) < 4096:
window = queue.pop(0)
window = queue.popleft()
if window in visited:
continue
visited.add(window)
@@ -351,14 +352,17 @@ class _X11:
current_size,
increments,
)
self._replace_long_property(
window,
b"WM_NORMAL_HINTS",
b"WM_SIZE_HINTS",
updated,
)
self.library.XSync(self.display, 0)
confirmed = self._long_property(window, b"WM_NORMAL_HINTS", 18)
if updated == hints:
confirmed = hints
else:
self._replace_long_property(
window,
b"WM_NORMAL_HINTS",
b"WM_SIZE_HINTS",
updated,
)
self.library.XSync(self.display, 0)
confirmed = self._long_property(window, b"WM_NORMAL_HINTS", 18)
return bool(
confirmed
and len(confirmed) >= 17
@@ -369,18 +373,25 @@ class _X11:
def prefer_composited_presentation(self, window: int) -> bool:
"""Keep the host compositor active for this window at every size."""
preferred = (_NET_WM_BYPASS_COMPOSITOR_PREFER_COMPOSITING,)
if self._long_property(
window,
b"_NET_WM_BYPASS_COMPOSITOR",
1,
) == preferred:
return True
self._replace_long_property(
window,
b"_NET_WM_BYPASS_COMPOSITOR",
b"CARDINAL",
(_NET_WM_BYPASS_COMPOSITOR_PREFER_COMPOSITING,),
preferred,
)
self.library.XSync(self.display, 0)
return self._long_property(
window,
b"_NET_WM_BYPASS_COMPOSITOR",
1,
) == (_NET_WM_BYPASS_COMPOSITOR_PREFER_COMPOSITING,)
) == preferred
def _root_windows(self) -> list[int]:
root = self.library.XDefaultRootWindow(self.display)
@@ -720,9 +731,9 @@ class _X11:
Wine marks this game with identical current-size ``PMinSize`` and
``PMaxSize`` constraints and excludes resize/maximize from its Motif hints.
Remove only that exact fixed-size pair and preserve unrelated aspect,
increment, and geometry hints. Initial setup is retained only when the
window manager confirms resize plus both maximize actions. Event-driven
maintenance can skip the confirmation because support was already proven.
increment, and geometry hints. Callers can wait for the window manager to
confirm resize plus both maximize actions, or retain the safe client hints
while polling the manager-owned action property independently.
"""
current_size = self.window_size(window)