From 80c26f85f56773feb63c74fa1ec3e1d060d92c2c Mon Sep 17 00:00:00 2001 From: allelomorph Date: Thu, 14 Aug 2025 22:25:13 +0000 Subject: [PATCH] disable use of X11 extension MIT-SHM when using remote X server(#8956) - alternative solution to #8956, but does not address original request for cleaner exit on Xlib error --- src/video/x11/SDL_x11framebuffer.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/video/x11/SDL_x11framebuffer.c b/src/video/x11/SDL_x11framebuffer.c index 2bfdc74acac4d..2dae12535d22b 100644 --- a/src/video/x11/SDL_x11framebuffer.c +++ b/src/video/x11/SDL_x11framebuffer.c @@ -42,6 +42,16 @@ static int shm_errhandler(Display *d, XErrorEvent *e) static SDL_bool have_mitshm(Display *dpy) { /* Only use shared memory on local X servers */ + /* Given that Windows 10 and 11 now offer use of OpenSSH, checking for a + SSH_TTY value (man ssh(1)) is potentially an OS-agnostic means of + detecting a common case of using a remote X server: when accessing via + X11 forwarding over `ssh -X`. */ + /* (Linux-specific alternative: checking if XDG_SESSION_TYPE == "tty" (see + man pam_systemd(8))) */ + const char *ssh_tty = SDL_getenv("SSH_TTY"); + if (ssh_tty != NULL && SDL_strlen(ssh_tty) > 0) { + return SDL_FALSE; + } return X11_XShmQueryExtension(dpy) ? SDL_X11_HAVE_SHM : SDL_FALSE; }