Repository: pygame/pygame

Issue #2118: Fullscreen in 2.0.0.dev12 Not Working on XUbuntu 20.04 with GeForce MX250
Created: 2020-09-26T09:00:10Z
I cannot get fullscreen mode to work on my XUbuntu 20.04 laptop with a GeForce MX250 graphics card.


When starting in fullscreen mode, I get a black screen that I cannot alt-tab out of. The program seems to be running but it does not seem to be getting any input from the mouse or keyboard.


When switching to fullscreen mode from a window, the display disappears and often the window button disappears from the task bar. As above the program seems to keep running but does not seem to receive any input from the mouse or keyboard. If the window button is visible, it is sometimes possible to press it and get a black screen as above.


I discovered this problem when testing 2.0.0.dev12 with GearHead Caramel (https://github.com/jwvhewitt/gearhead-caramel). The example program setmodescale.py and other demos have the same issues. The programs run correctly on my wife's Windows desktop computer, so it's probably something about this laptop which is causing the problem.
Edit: This problem only appears to happen when the SCALED flag is used. Example programs that don't use SCALED run properly.

Duplicate issue #2348: pygame 2.0 fullscreen mode with OpenGL doesn't work properly
Created: 2020-11-21T16:12:29Z
Environment
Should be an absolutely bog-standard setup:

Ubuntu 20.04.1 LTS, pygame 2.0.0 (SDL 2.0.12, python 3.8.5) installed using PIP
standard Ubuntu GNOME 3 session, either on X.org 1.20.8 or Wayland
Intel(R) HD Graphics 520 (SKL GT2), Mesa 20.0.8

Current behavior
Even the simplest pygame program using OpenGL does not work properly in fullscreen mode.
"Desktop fullscreen" mode (using (0,0) in pygame.display.set_mode) shows very funky behavior:

on X.org:

A non-fullscreen window is created.
The window contents are black; the rendered content occasionally flashes for a few frames at a time.
Input focus cycles between the pygame window and the previously active window multiple times per second, making it unpredictable where keystrokes go to.
The mouse cursor position is repeatedly reset to the pygame window center.
gnome-shell floods the syslog with the message "STACK_OP_ADD: window 0x3400015 (pygame win) already in stack".


on Wayland:

The screen briefly becomes black, but the pygame window disappears immediately and can't be reactivated. It flashes into foreground again when the program is terminated with ^C or a signal.
Mouse motion becomes very jerky (like ~5 fps).
The syslog is flooded with the same message as on X.org, but with additional "Cannot grant Xwayland grab to surface <hex.ID>" messages added in.



Fullscreen mode with explicit resolution selection crashes with an X error, and the resolution is not restored after that (but that seems to be an issue of upstream SDL).
In windowed mode, everything runs fine.
Expected behavior
The program is run fullscreen without any glitches.
The same program run with pygame 1.9.6 (SDL 1.2.15) works flawlessly.
The equivalent C code, linked directly against SDL 2.0.10, works flawlessly too (using SDL_WINDOW_FULLSCREEN_DESKTOP).
Screenshots
I captured a video of the effect: https://www.emphy.de/~mfie/foo/pygame2_fail.mp4
Steps to reproduce / test code
Install pygame 2.0.0 and PyOpenGL (any vesion) and run this test program:
#!/usr/bin/env python
import math
import pygame
from OpenGL.GL import *

if __name__ == "__main__":
    pygame.init()
    pygame.display.set_mode((0,0), pygame.OPENGL | pygame.FULLSCREEN)
    #pygame.display.set_mode((800,600), pygame.OPENGL)  # this works just fine

    while True:
        ev = pygame.event.poll()
        if ev and (ev.type == pygame.KEYDOWN) \
              and (ev.key in (pygame.K_q, pygame.K_ESCAPE)):
            break
        t = pygame.time.get_ticks() * 0.001
        glClearColor(0.4, 0.6, 0.8, 1.0)
        glClear(GL_COLOR_BUFFER_BIT)
        glBegin(GL_TRIANGLES)
        glVertex2f(math.sin(t+0.0), math.cos(t+0.0))
        glVertex2f(math.sin(t+2.1), math.cos(t+2.1))
        glVertex2f(math.sin(t+4.2), math.cos(t+4.2))
        glEnd()
        pygame.display.flip()

    pygame.quit()

Closing comment (2020-11-24T22:48:01Z): Kajott's solution works for me. It must be the same as #2118
Strangely, compiling pygame2dev1 didn't fix this, but building with the Steam RT or replacing libSDL2.so does.