diff --git a/client/displayservers/Wayland/wayland.c b/client/displayservers/Wayland/wayland.c index 2cfa8247..a8269ef8 100644 --- a/client/displayservers/Wayland/wayland.c +++ b/client/displayservers/Wayland/wayland.c @@ -22,6 +22,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA #include #include #include +#include #include #include @@ -254,6 +255,28 @@ static const struct wl_seat_listener seatListener = { .name = seatNameHandler, }; +static bool waylandEarlyInit(void) +{ + if (getenv("SDL_VIDEODRIVER") != NULL) + return true; + + int err = setenv("SDL_VIDEODRIVER", "wayland", 1); + if (err < 0) + { + DEBUG_ERROR("Unable to set the env variable SDL_VIDEODRIVER: %d", err); + return false; + } + DEBUG_INFO("SDL_VIDEODRIVER has been set to wayland"); + + // Request to receive EPIPE instead of SIGPIPE when one end of a pipe + // disconnects while a write is pending. This is useful to the Wayland + // clipboard backend, where an arbitrary application is on the other end of + // that pipe. + signal(SIGPIPE, SIG_IGN); + + return true; +} + static void waylandInit(SDL_SysWMinfo * info) { memset(&wm, 0, sizeof(wm)); @@ -711,6 +734,7 @@ static void waylandCBRelease(void) struct LG_DisplayServerOps LGDS_Wayland = { .subsystem = SDL_SYSWM_WAYLAND, + .earlyInit = waylandEarlyInit, .init = waylandInit, .startup = waylandStartup, .free = waylandFree, diff --git a/client/src/main.c b/client/src/main.c index 3c4beaf8..0c594cb3 100644 --- a/client/src/main.c +++ b/client/src/main.c @@ -1712,12 +1712,6 @@ static int lg_run(void) signal(SIGINT , int_handler); signal(SIGTERM, int_handler); - // Request to receive EPIPE instead of SIGPIPE when one end of a pipe - // disconnects while a write is pending. This is useful to the Wayland - // clipboard backend, where an arbitrary application is on the other end of - // that pipe. - signal(SIGPIPE, SIG_IGN); - // try map the shared memory if (!ivshmemOpen(&g_state.shm)) {