fix: Battle.net scales its windows to large desktops instead of opening tiny on high-resolution screens (#1832)

This commit is contained in:
MaxsTechReview authored and GitHub committed 2026-10-30 13:58:44 -04:00
1 parent 9a1334b73b
commit 8f7cdb7106
2 files changed
+43 -1

No files matched your search

@@ -322,7 +322,14 @@ def wallpaper_bmp(width, height):
def reg_value(reg, key, name, value):
line = '"%s"="%s"' % (name, value.replace("\\", "\\\\").replace('"', '\\"'))
return reg_line(reg, key, name, '"%s"="%s"' % (name, value.replace("\\", "\\\\").replace('"', '\\"')))
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()
@@ -347,6 +354,16 @@ def desktop_size():
return 1280, 720
def desktop_dpi():
width, height = desktop_size()
return 96 * max(4, int(min(width / 1920.0, height / 1080.0) * 4)) // 4
def dpi(root):
reg = os.path.join(prefix(root), "pfx", "user.reg")
return os.path.isfile(reg) and reg_dword(reg, DESKTOP_KEY, "LogPixels", desktop_dpi())
def wallpaper(root):
width, height = desktop_size()
shrink = min(1.0, WALLPAPER_MAX[0] / width, WALLPAPER_MAX[1] / height)
@@ -492,6 +509,10 @@ def configure(root, library=None):
wallpaper(root)
except OSError as error:
say("Battle.net's desktop wallpaper not set: %s" % error)
try:
dpi(root)
except OSError as error:
say("Battle.net's desktop scale 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, "
+21
View File
@@ -896,6 +896,27 @@ class LaunchTest(Harness):
self.assertEqual(image.read_bytes(), b"BM1152x720")
self.assertIn('"WallpaperStyle"="2"', (pfx / "user.reg").read_text())
def test_a_large_desktop_scales_battle_net_to_fit_it(self):
sizes = {("1280", "720"): 96, ("1920", "1080"): 96, ("2400", "1504"): 120, ("2448", "1848"): 120,
("1080", "2400"): 96, ("3840", "2160"): 192, ("2560", "1600"): 120}
for (width, height), want in sizes.items():
with mock.patch.dict(os.environ, {"BL_WIDTH": width, "BL_HEIGHT": height}):
self.assertEqual(BNET["desktop_dpi"](), want, (width, height))
def test_battle_nets_desktop_scale_is_written_once_and_follows_the_size(self):
self.install()
pfx = Path(self.root) / ("steamapps/compatdata/%s/pfx" % BNET["APP_ID"])
(pfx / "user.reg").write_text('WINE REGISTRY Version 2\n\n[Control Panel\\\\Desktop] 1\n"LogPixels"=dword:00000060\n')
with mock.patch.dict(os.environ, {"BL_WIDTH": "1280", "BL_HEIGHT": "720"}):
self.assertTrue(BNET["dpi"](self.root))
self.assertEqual((pfx / "user.reg").read_text().count("LogPixels"), 1)
with mock.patch.dict(os.environ, {"BL_WIDTH": "2448", "BL_HEIGHT": "1848"}):
self.assertTrue(BNET["dpi"](self.root))
self.assertTrue(BNET["dpi"](self.root))
reg = (pfx / "user.reg").read_text()
self.assertEqual(reg.count('"LogPixels"=dword:00000078'), 1)
self.assertTrue(reg.rstrip().endswith('"LogPixels"=dword:00000078'))
def test_an_open_battle_net_is_handed_the_game(self):
self.install()
up = self.clients()