当通过 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.
谁能告诉我这里到底发生了什么?
这是我的脚本:
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()
这是之前和之后的屏幕截图:
KDE 5.45.0
桌面的系统设置窗口没有运行 sdl 脚本,显示相关设置桌面 Effects>Translucency
。请注意窗口是半透明的,因为我在拍照时拖动了它。
相同,但运行了 sdl 脚本。请注意,尽管我用力拖动,窗口仍然顽固地不透明。
最佳答案
我也可以使用 Unity 在我的 Ubuntu 桌面上重现这个,所以这绝对不是你的 KDE 桌面的问题。我认为这是 pysdl2 中的一个错误,这个解决方案应该是一个临时的解决方法,直到它得到修复,但与此同时,您可以将它添加到您的 while 循环中:
window.get_surface()
关于python - 奇怪的 sdl 对无关窗口的副作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56053077/