Skip to content

Commit 6ac2a8b

Browse files
authored
GLFW Wayland Warning Suppression (#67)
fix(wayland): suppress GLFW window position warnings and init fontconfig if available (#65) Suppresses GLFW UserWarning related to window positioning on Wayland to reduce stdout clutter. Attempts to initialize fontconfig via ctypes if available, improving compatibility in Wayland environments.
1 parent f7d4bae commit 6ac2a8b

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

mujoco_toolbox/__init__.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,26 @@
3434
3535
""" # noqa: D205, D400, D415, W291
3636

37+
import os
38+
39+
if "WAYLAND_DISPLAY" in os.environ:
40+
# Suppress GLFWError window position warnings caused by Wayland.
41+
# Warning Source:
42+
# https://github.com/glfw/glfw/blob/master/src/wl_window.c#L2246-L2253
43+
# Reduces stdout clutter when using MuJoCo with Wayland
44+
from warnings import filterwarnings
45+
filterwarnings(
46+
"ignore",
47+
category=UserWarning,
48+
module="glfw",
49+
message=".*window position.*",
50+
)
51+
try:
52+
from ctypes import CDLL
53+
CDLL("libfontconfig.so.1").FcInit()
54+
except Exception:
55+
pass
56+
3757
from .assets import WORLD_ASSETS, glovebox
3858
from .builder import Builder
3959
from .controllers import (

0 commit comments

Comments
 (0)