From 707e9455f0a8ea070f20a70fef6cfcf61a6d68a7 Mon Sep 17 00:00:00 2001 From: Albrecht Schlosser Date: Tue, 17 Mar 2026 15:42:17 +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 | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/test/sudoku.cxx b/test/sudoku.cxx index c0d6bfd43..c4719dfe2 100644 --- a/test/sudoku.cxx +++ b/test/sudoku.cxx @@ -2,7 +2,7 @@ // Sudoku game using the Fast Light Tool Kit (FLTK). // // Copyright 2005-2018 by Michael Sweet. -// Copyright 2019-2021 by Bill Spitzak and others. +// Copyright 2019-2026 by Bill Spitzak and others. // // This library is free software. Distribution and use rights are outlined in // the file "COPYING" which should have been included with this file. If this @@ -462,6 +462,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... @@ -474,7 +480,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;