Wayland: Detect SSD by querying compositor

Much more reliable than checking environment variables. Does
add ~1ms to startup time on Wayland.
This commit is contained in:
Kovid Goyal
2019-06-05 10:37:57 +05:30
parent 98d7fc9f39
commit 303711ab8d
2 changed files with 55 additions and 9 deletions

View File

@@ -137,16 +137,29 @@ def detect_if_wayland_ok():
return False
if 'KITTY_DISABLE_WAYLAND' in os.environ:
return False
if not os.path.exists(glfw_path('wayland')):
wayland = glfw_path('wayland')
if not os.path.exists(wayland):
return False
cd = os.environ.get('XDG_CURRENT_DESKTOP')
if cd:
cd = frozenset(cd.split(':'))
if 'GNOME' in cd:
# GNOME does not support xdg-decorations
# https://gitlab.gnome.org/GNOME/mutter/issues/217
return False
return True
# GNOME does not support xdg-decorations
# https://gitlab.gnome.org/GNOME/mutter/issues/217
import ctypes
lib = ctypes.CDLL(wayland)
check = lib.glfwWaylandCheckForServerSideDecorations
check.restype = ctypes.c_char_p
check.argtypes = ()
try:
ans = bytes(check())
except Exception:
return False
if ans == b'NO':
print(
'Your Wayland compositor does not support server side window decorations,'
' disabling Wayland. You can force Wayland support using the'
' linux_display_server option in kitty.conf'
' See https://drewdevault.com/2018/01/27/Sway-and-client-side-decorations.html'
' for more information.',
file=sys.stderr)
return ans == b'YES'
def is_wayland(opts=None):