diff --git a/userspace/usr/comma/magic.py b/userspace/usr/comma/magic.py index 05d633a..26996c3 100755 --- a/userspace/usr/comma/magic.py +++ b/userspace/usr/comma/magic.py @@ -61,10 +61,7 @@ def power_screen(): except Exception: pass -def show_background(img): - tex = rl.load_texture_from_image(img) - rl.set_texture_filter(tex, rl.TextureFilter.TEXTURE_FILTER_BILINEAR) - pos = rl.Vector2((rl.get_screen_width() - tex.width)/2.0, (rl.get_screen_height() - tex.height)/2.0) +def show_background(tex, pos): rl.begin_drawing() rl.draw_texture(tex, int(pos.x), int(pos.y), rl.WHITE) rl.end_drawing() @@ -89,10 +86,14 @@ def main(): drm_master = os.open(DRM_DEVICE, os.O_RDWR | os.O_CLOEXEC) os.environ['DRM_FD'] = str(drm_master) - rl.init_window(0, 0, "") + rl.init_window(0, 0, "not weston") img = rl.load_image(BACKGROUND) rl.image_resize(img, rl.get_screen_width(), rl.get_screen_width()//2) - show_background(img) + tex = rl.load_texture_from_image(img) + rl.set_texture_filter(tex, rl.TextureFilter.TEXTURE_FILTER_BILINEAR) + pos = rl.Vector2((rl.get_screen_width() - tex.width)/2.0, (rl.get_screen_height() - tex.height)/2.0) + rl.unload_image(img) + show_background(tex, pos) try: os.unlink(SOCK_PATH) @@ -114,9 +115,7 @@ def main(): clients.discard(t) if not clients and need_background: need_background = False - rl.close_window() - rl.init_window(0, 0, "") - show_background(img) + show_background(tex, pos) try: client, _ = server.accept()