Skip to content

Pygame 2.0.2.dev2 -> NOFRAME and RESIZABLE flags not working when switching from fullscreen back to windowed mode #2711

@tank-king

Description

@tank-king

Environment:

  • Operating system Windows 10
  • Python version Python 3.9.5
  • SDL version SDL 2.0.16
  • PyGame version Pygame 2.0.2.dev2

Current behavior:

The NOFRAME and RESIZABLE flags do not work when switching from fullscreen mode back to windowed mode, and a non-resizable 'framed' window is set, but the SCALED flag works fine for all cases. This issue can be overriden when the window is set at least 2 times after reverting from fullscreen mode.

Expected behavior:

When window is switched to windowed mode from fullscreen to windowed mode with the NOFRAME or RESIZABLE flags (or both of them), then the window should have no title bar, and be resizable respectively.

Screenshots

Before fullscreen toggle:
image

In fullscreen mode:
image

Switching to windowed mode after fullscreen mode with NOFRAME flag:
image

Steps to reproduce:

  1. open command prompt or powershell
  2. pip install pygame==2.0.2.dev2
  3. press any key twice after running the example code

Test code

import pygame

pygame.init()

fullscreen = False
size = (1280, 720)

full_flags = pygame.FULLSCREEN | pygame.SCALED
normal_flags = pygame.NOFRAME | pygame.RESIZABLE | pygame.SCALED


def toggle_fullscreen(f):
    if f:
        return pygame.display.set_mode(size, full_flags)
    # pygame.display.set_mode(size, normal_flags)  # uncomment this to see issue being fixed as a workaround
    return pygame.display.set_mode(size, normal_flags)


screen = pygame.display.set_mode(size, normal_flags)

clock = pygame.time.Clock()

while True:
    screen.fill("purple")

    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            pygame.quit()
            raise SystemExit

        if event.type == pygame.KEYDOWN:
            fullscreen = not fullscreen
            screen = toggle_fullscreen(fullscreen)

    pygame.display.flip()
    clock.tick(144)  # framerate

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugdisplaypygame.displayreproducibleconfirmed that the issue can be replicated and there are instructions to reproduce the issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions