From 2c7418e5124e1f2e162062a284eb74d84cb53879 Mon Sep 17 00:00:00 2001 From: George Hotz <72895+geohot@users.noreply.github.com> Date: Thu, 17 Feb 2022 12:14:27 -0800 Subject: [PATCH] fix in window for xmonad with SDL2 (#23786) --- common/window.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/common/window.py b/common/window.py index 983dc439843539..ce1eecb8818442 100644 --- a/common/window.py +++ b/common/window.py @@ -11,11 +11,18 @@ def __init__(self, w, h, caption="window", double=False, halve=False): self.double = double self.halve = halve if self.double: - self.screen = pygame.display.set_mode((w*2, h*2)) + self.rw, self.rh = w*2, h*2 elif self.halve: - self.screen = pygame.display.set_mode((w//2, h//2)) + self.rw, self.rh = w//2, h//2 else: - self.screen = pygame.display.set_mode((w, h)) + self.rw, self.rh = w, h + self.screen = pygame.display.set_mode((self.rw, self.rh)) + pygame.display.flip() + + # hack for xmonad, it shrinks the window by 6 pixels after the display.flip + if self.screen.get_width() != self.rw: + self.screen = pygame.display.set_mode((self.rw+(self.rw-self.screen.get_width()), self.rh+(self.rh-self.screen.get_height()))) + pygame.display.flip() def draw(self, out): pygame.event.pump()