Search code examples
pythonmacospygame

Why does a Pygame display with the pygame.FULLSCREEN flag affect other windows?


I just started learning how to use Pygame earlier this week. While messing around with it I discovered that if I make a fullscreen window and leave it open for about 10 seconds and close it, all the other windows I have open will shrink in size and my screen is at a lower resolution for a few seconds.

These things happen with this chunk of code:

import pygame

pygame.init()
pygame.display.set_mode((500, 500),
                        pygame.FULLSCREEN)

running = True
while running is True:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False

pygame.quit()

Why would this code change the state of my other windows and change my screen resolution temporarily?

I am working with Pygame 2.0.1 with Python 3.9.1 using PyCharm 2020.3.1 on macOS Big Sur 11.1.


Solution

  • Change

    pygame.display.set_mode((500, 500), pygame.FULLSCREEN)
    

    to

    pygame.display.set_mode((0, 0), pygame.FULLSCREEN)
    

    Pygame will automatically detect the screen size.