refactor: Review-Funde umgesetzt (Notify-Parsing, Flatpak-Schritte, Asserts, Kanshi-Polling, Appmenu-Quoting, Layer-5-Cache)
This commit is contained in:
1 parent
c5a0fcd35c
commit
8def9724d6
10 files changed
+70
-17
No files matched your search
@@ -51,7 +51,7 @@ from pathlib import Path
|
||||
|
||||
MARKER = "# kanshi-autoconfig: managed"
|
||||
CONFIG_PATH = Path.home() / ".config" / "kanshi" / "config"
|
||||
POLL_INTERVAL = 5
|
||||
POLL_INTERVAL = 10
|
||||
|
||||
|
||||
_VM_CACHE = None
|
||||
@@ -79,12 +79,24 @@ def norm_rate(value):
|
||||
|
||||
|
||||
def choose_mode(modes, current, in_vm):
|
||||
"""Modus waehlen: VM-Heuristik, sonst preferred, sonst current/erster."""
|
||||
"""Modus waehlen: VM-Heuristik (hoechste Aufloesung, bevorzugt ~60 Hz),
|
||||
sonst preferred, sonst current/erster."""
|
||||
if in_vm:
|
||||
# In VMs meldet die Firmware oft einen Kleinstmodus als preferred.
|
||||
# Daher die Aufloesung mit den meisten Pixeln waehlen; bei Gleichstand
|
||||
# die Bildwiederholrate nahe 60 Hz.
|
||||
best = None
|
||||
best_key = None
|
||||
for m in modes:
|
||||
w = m.get("width") or 0
|
||||
h = m.get("height") or 0
|
||||
rate = norm_rate(m.get("refresh") or m.get("rate")) or 0
|
||||
if m.get("width") == 1920 and m.get("height") == 1080 and round(rate) == 60:
|
||||
return m
|
||||
key = (w * h, -abs(rate - 60) if rate else 0)
|
||||
if best_key is None or key > best_key:
|
||||
best_key = key
|
||||
best = m
|
||||
if best is not None:
|
||||
return best
|
||||
for m in modes:
|
||||
if m.get("preferred"):
|
||||
return m
|
||||
|
||||
Reference in new issue
Block a user