From 7263bc7baa78fb8ed35fe9068964bcb12d9ee116 Mon Sep 17 00:00:00 2001 From: Albrecht Schlosser Date: Tue, 17 Mar 2026 15:58:59 +0100 Subject: [PATCH] Wayland: Fix crash in test/sudoku if ALSA soundlib is not available ... and the /hybrid/ FLTK lib is running under the Wayland backend. In this case X11 stuff must be disabled. Currently playing sounds under Wayland is only supported with the ALSA sound library. --- test/sudoku.cxx | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/test/sudoku.cxx b/test/sudoku.cxx index f6e78c170..c4f4e8a25 100644 --- a/test/sudoku.cxx +++ b/test/sudoku.cxx @@ -450,6 +450,12 @@ void SudokuSound::play(char note) { } else Beep(frequencies[note - 'A'], NOTE_DURATION); #elif defined(FLTK_USE_X11) + + // This program was compiled with X11 and potentially with Wayland backend + // (hybrid FLTK library). We can use ALSA for both (X11 and Wayland) or + // X11 sound stuff (below) if we're actually running under the X11 backend. + // Otherwise we can't play any sound. + # ifdef HAVE_ALSA_ASOUNDLIB_H if (handle) { // Use ALSA to play the sound... @@ -462,7 +468,13 @@ void SudokuSound::play(char note) { } # endif // HAVE_ALSA_ASOUNDLIB_H - // Just use standard X11 stuff... + // The ALSA sound library was not found: + // - backend X11: just use standard X11 stuff + // - backend Wayland: can't play sound (currently ?) + + if (!fl_x11_display()) // X11 configured but not active (using Wayland) + return; + XKeyboardState state; XKeyboardControl control;