简体   繁体   English

对不相关的窗口产生奇怪的sdl副作用

[英]Strange sdl side-effect on unrelated windows

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. 当通过pysdl2玩sdl2时,我注意到这种奇怪的副作用,一旦sdl脚本运行不相关的窗口,通常在移动时变为半透明,现在保持不透明。

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: 这里有一个前后屏幕抓取:

之前

The System Settings window of my KDE 5.45.0 desktop without the sdl script running, showing the relevant setting Desktop Effects>Translucency . 我的KDE 5.45.0桌面的系统设置窗口没有运行sdl脚本,显示相关设置桌面Effects>Translucency Notice how the window is translucent because I'm dragging it while taking the picture. 请注意窗口是如何半透明的,因为我在拍照时拖动它。

后

The same but with the sdl script running. 同样但运行sdl脚本。 Notice how the window despite my vigorously dragging it stays stubbornly opaque. 请注意,尽管我大力拖动它,但窗户仍保持顽固不透明状态。

I can also reproduce this in my Ubuntu desktop with Unity, so it's definitely not a problem of your KDE desktop. 我也可以在我的Ubuntu桌面上使用Unity重现这一点,所以它肯定不是你的KDE桌面的问题。 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: 我认为这是pysdl2中的一个错误,这个解决方案应该是一个临时的解决方法,直到它得到修复,但与此同时,你可以在你的while循环中添加它:

window.get_surface()

The issue is already reported here: https://github.com/marcusva/py-sdl2/issues/139 这个问题已在此处报道: https//github.com/marcusva/py-sdl2/issues/139

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM