15

When playing with sdl2 via pysdl2 I noticed this strange side-effect where once the sdl script runs unrelated windows which would normally become translucent when moved do now stay opaque.

I wouldn't mind all that much if it weren't for the nagging feeling that this indicates that I'm doing something fundamentally wrong.

Anyone able to enlighten me as to what the heck is going on here?

Here is my script:

import sdl2
import sdl2.ext as se
import time

def main():
    k = 2
    event_buffer = (k * sdl2.SDL_Event)()
    se.init()
    window = se.Window("what the ?", size=(400, 300))
    window.show()
    while True:
        window.refresh()
        time.sleep(0.01)
        sdl2.SDL_PumpEvents()
        sdl2.SDL_PeepEvents(event_buffer, k, sdl2.SDL_GETEVENT,
                            sdl2.SDL_FIRSTEVENT, sdl2.SDL_LASTEVENT)
        for event in event_buffer:
            if not event.type:
                continue
            elif event.type == sdl2.SDL_QUIT:
                se.quit()
                break
            else:
                pass
            event.type = 0
        else:
            continue
        break

if __name__ == '__main__':
    main()

And here are a before and an after screen grab:

before

The System Settings window of my KDE 5.45.0 desktop without the sdl script running, showing the relevant setting Desktop Effects>Translucency. Notice how the window is translucent because I'm dragging it while taking the picture.

after

The same but with the sdl script running. Notice how the window despite my vigorously dragging it stays stubbornly opaque.

Paul Panzer
  • 47,318
  • 2
  • 37
  • 82
  • 1
    Can you repro on a new, clean user account? – genpfault May 12 '19 at 17:42
  • 3
    @genpfault Just did. Fresh user account on a different computer (same OS). Same observation. – Paul Panzer May 12 '19 at 19:42
  • What sort of KDE session, X11 or Wayland? Python version? pysdl2 version? Underlying SDL2 version? – genpfault May 12 '19 at 20:05
  • 1
    @genpfault It's Python 3.6.5 -- pysdl 0.9.6. sdl2 is 2.0.0 on one computer, 2.0.9 on the other. KDE session is I think X11 (there is a kwin_x11 process running and nothing containing the word wayland) – Paul Panzer May 12 '19 at 20:40
  • My guess is that due to your **sdl** script running in the background (I assume the new window in the second picture is the script) your entire desktop is constantly refreshing, causing the other windows to stay opaque – Arnav Poddar Jun 04 '19 at 00:37
  • 1
    Maybe related: I saw that with some SDL games, the kde effects get deactivated (and reactivated at game exit). – Giancarlo Jun 19 '19 at 14:18
  • @Giancarlo Maybe related, indeed. With some games but not with every game? – Paul Panzer Jun 19 '19 at 21:36
  • well, I didn't play *every* sdl game :D – Giancarlo Jun 20 '19 at 07:17

1 Answers1

1

I can also reproduce this in my Ubuntu desktop with Unity, so it's definitely not a problem of your KDE desktop. I think this is a bug in pysdl2 and this solution should be a temporary workaround until it gets fixed but in the meanwhile, you can just add this inside your while loop:

window.get_surface()

The issue is already reported here: https://github.com/marcusva/py-sdl2/issues/139

jacalvo
  • 606
  • 5
  • 14