无关窗口上奇怪的sdl副作用

时间:2019-05-09 06:02:19

标签: python sdl kde window-management pysdl2

通过pysdl2与sdl2一起玩时,我注意到了一个奇怪的副作用,即一旦sdl脚本运行了不相关的窗口,这些窗口通常在移动时会变成半透明,现在却保持不透明。

  

如果不是因为the的感觉,我不会那么介意   这表明我在做根本上是错误的事情。

有人能启发我这里发生了什么吗?

这是我的剧本:

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()

这是之前和之后的屏幕抓取:

before

我的KDE 5.45.0桌面的“系统设置”窗口没有运行 sdl 脚本,显示了相关设置“桌面Effects>Translucency”。请注意,该窗口是半透明的,因为我在拍照时将其拖动。

after

相同,但是正在运行 sdl 脚本。请注意,尽管我大力拖动窗口,但窗口仍然顽固不透明。

1 个答案:

答案 0 :(得分:0)

我也可以在Unity的Ubuntu桌面上重现它,因此KDE桌面绝对不是问题。我认为这是pysdl2中的错误,此解决方案应该是暂时的解决方法,直到它得到修复,但与此同时,您可以将其添加到while循环中:

window.get_surface()

此问题已在此处报告:https://github.com/marcusva/py-sdl2/issues/139