fix(battlenet): stop Battle.net's pages playing videos on the CPU (#2195)

This commit is contained in:
MaxsTechReview authored and GitHub committed 2026-11-06 20:39:37 -05:00
1 parent a552f1e293
commit 0b4bc827e7
2 files changed
+79 -6

No files matched your search

@@ -31,6 +31,9 @@ WALLPAPER_DIR = ("users", "steamuser", "AppData", "Local", "DroidDeck")
DESKTOP_KEY = "[Control Panel\\\\Desktop]"
COLORS_KEY = "[Control Panel\\\\Colors]"
WALLPAPER_EDGE = (4, 6, 11)
USER_PREFERENCES = "UserPreferencesMask"
WINE_USER_PREFERENCES = bytes((0x10, 0x00, 0x00, 0x80, 0x12, 0x00, 0x00, 0x00))
CLIENT_AREA_ANIMATION = (4, 0x02)
WALLPAPER_MAX = (1280, 720)
FEX_REQUEST = "battlenet-fex.request"
FEX_RESULT = "battlenet-fex.result"
@@ -331,24 +334,47 @@ def reg_dword(reg, key, name, number):
return reg_line(reg, key, name, '"%s"=dword:%08x' % (name, number))
def reg_line(reg, key, name, line):
try:
with open(reg, encoding="utf-8", errors="replace") as f:
rows = f.read().splitlines()
except OSError:
return False
def reg_read(reg, key, name):
with open(reg, encoding="utf-8", errors="replace") as f:
rows = f.read().splitlines()
inside, last = False, None
for row in rows:
if row.startswith("["):
inside = row.startswith(key + " ") or row == key
elif inside and row.startswith('"%s"=' % name):
last = row
return last
def reg_line(reg, key, name, line):
try:
last = reg_read(reg, key, name)
except OSError:
return False
if last != line:
with open(reg, "a", encoding="utf-8") as out:
out.write("\n%s %d\n%s\n" % (key, int(time.time()), line))
return True
def still_pages(root):
reg = os.path.join(prefix(root), "pfx", "user.reg")
if not os.path.isfile(reg):
return False
row = reg_read(reg, DESKTOP_KEY, USER_PREFERENCES)
found = re.fullmatch(r'"%s"=hex:([0-9a-fA-F]{2}(?:,[0-9a-fA-F]{2})*)' % USER_PREFERENCES, row or "")
mask = bytearray(bytes.fromhex(found.group(1).replace(",", "")) if found else WINE_USER_PREFERENCES)
at, bit = CLIENT_AREA_ANIMATION
if len(mask) <= at or not mask[at] & bit:
return False
mask[at] &= ~bit
if wine_processes(os.path.join(prefix(root), "pfx")):
say("Battle.net's prefix is in use; Windows animations go off the next time it starts on its own")
return False
reg_line(reg, DESKTOP_KEY, USER_PREFERENCES, '"%s"=hex:%s' % (USER_PREFERENCES, ",".join("%02x" % b for b in mask)))
return True
def desktop_size():
width, height = os.environ.get("BL_WIDTH", ""), os.environ.get("BL_HEIGHT", "")
if width.isdigit() and height.isdigit() and 0 < int(width) <= 7680 and 0 < int(height) <= 4320:
@@ -515,6 +541,11 @@ def configure(root, library=None):
dpi(root)
except OSError as error:
say("Battle.net's desktop scale not set: %s" % error)
try:
if still_pages(root):
say("Battle.net's desktop: Windows animations off, so its pages do not play videos the CPU has to draw")
except OSError as error:
say("Battle.net's desktop animations not set: %s" % error)
wow_settings(root)
if change == "first":
say("wrote Battle.net's first config: hardware acceleration off, streaming off, closing itself as it launches a game, "