fix: improve web runtime resolution and restore x11vnc ncache
This commit is contained in:
@@ -71,15 +71,35 @@ def _sanitize_resolution(width: int | None, height: int | None) -> tuple[int, in
|
||||
def apply_resolution(width: int | None, height: int | None) -> tuple[int, int]:
|
||||
safe_w, safe_h = _sanitize_resolution(width, height)
|
||||
# Best effort: Xvfb usually exposes RandR and accepts xrandr -s.
|
||||
applied = False
|
||||
try:
|
||||
subprocess.run( # noqa: S603
|
||||
result = subprocess.run( # noqa: S603
|
||||
["xrandr", "-display", DISPLAY, "-s", f"{safe_w}x{safe_h}"],
|
||||
check=False,
|
||||
stdout=subprocess.DEVNULL,
|
||||
stderr=subprocess.DEVNULL,
|
||||
)
|
||||
applied = result.returncode == 0
|
||||
except Exception:
|
||||
pass
|
||||
applied = False
|
||||
|
||||
if not applied:
|
||||
# Fallback to default geometry if requested mode is unsupported.
|
||||
try:
|
||||
fallback_w, fallback_h = [int(x) for x in CHROME_WINDOW_SIZE.split(",", 1)]
|
||||
except Exception:
|
||||
fallback_w, fallback_h = 1920, 1080
|
||||
safe_w, safe_h = _sanitize_resolution(fallback_w, fallback_h)
|
||||
try:
|
||||
subprocess.run( # noqa: S603
|
||||
["xrandr", "-display", DISPLAY, "-s", f"{safe_w}x{safe_h}"],
|
||||
check=False,
|
||||
stdout=subprocess.DEVNULL,
|
||||
stderr=subprocess.DEVNULL,
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
_state["resolution"] = f"{safe_w},{safe_h}"
|
||||
return safe_w, safe_h
|
||||
|
||||
|
||||
Reference in New Issue
Block a user