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.
This commit is contained in:
Albrecht Schlosser 2026-03-17 15:58:59 +01:00
parent cc03f5dc95
commit 7263bc7baa

View File

@ -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;