Skip to content

Commit

Permalink
fix in window for xmonad with SDL2 (commaai#23786)
Browse files Browse the repository at this point in the history
  • Loading branch information
geohot authored and budney committed Mar 27, 2022
1 parent b21d839 commit 2c7418e
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions common/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 2c7418e

Please sign in to comment.