On 06/10/12 00:41, Johan R wrote: > After searching a bit i am pretty sure XBell will not generate > the required event (XkbBellNotify) which is required to get the > bell sound to a "sound card".
Both XBell() and XkbBell() are xlib calls that send messages to the X server (which may be a remote machine) to ring the bell on the workstation, and both can be redirected to the sound card. On one of the links in my last post, it mentioned this to get XBell() to send a sound to the soundcard: "xkbevd is a daemon that can execute specific commands on given X events. If I create the file ~/.xkb/xkbevd.cf with the contents 'Bell() shell "beep"' and run `xkbevd`, beep will be executed (making a beep) every time there's a system bell event. With this, I get both the PC speaker beep and the bell.ogg sound. [..]" I tried this myself and it worked; I have a centos 5 machine, and have never heard a beep from it before. But if I: xset b on xset b 100 ..then run xkbevd as described above: echo 'Bell() shell "aplay /usr/lib64/openoffice.org/basis3.1/share/gallery/sounds/laser.wav"' > /tmp/foo.cf xkbevd -cfg /tmp/foo.cf ..then when I run the FLTK "button" demo and press "beep", it plays the ogg sound, and scrolls messages from aplay executing. I could also jump over to a remote machine, set my DISPLAY variable to point to my local machine so that the demo opens on my box, press the 'beep' button and get the same sound results on my workstation. > the PulseAudio x11-bell works fine for other apps (e.g. hitting > backspace in an empty terminal). I don't know much about a pulseaudio config, but if it can be configured to listen to Xevents, I would think it could listen for system bell events from XBell() or XkbBell(). It sounds like a config issue where it's currently configured to listen for only XkbBell() events.. but I imagine if it can be configured for XBell() too, then that should work too. > I really think fltk should use XkbBell if available and only > fallback to XBell as they do in xterm (and probably most other apps) : I'd agree, though I'd defer to the other devs who are more familiar with X11. It's not clear (to me at least) why XkbBell() is any better at sound redirection. It just seems like the same function, just with a more flexible sound pallet (ie. different 'bell names' can be specified). Doing some research to see what other toolkits do, seems FLTK is consistent with wxwidgets and Qt; both use only XBell(). Only GTK tries both: *** WX WIDGETS (2.9.3) *** void wxBell() { // Use current setting for the bell XBell ((Display*) wxGetDisplay(), 0); } *** QT (current git) *** void QApplication::beep() { if (X11->display) XBell(X11->display, 0); else printf("\7"); // << what, no fflush(stdout)? -erco } *** GTK 3.2.2 *** static void gdk_x11_display_beep (GdkDisplay *display) { #ifdef HAVE_XKB XkbBell (GDK_DISPLAY_XDISPLAY (display), None, 0, None); #else XBell (GDK_DISPLAY_XDISPLAY (display), 0); #endif } *** FLTK (1.3.x) *** void fl_beep(int type) { [..X11..] switch (type) { case FL_BEEP_DEFAULT : case FL_BEEP_ERROR : if (!fl_display) fl_open_display(); XBell(fl_display, 100); break; default : if (!fl_display) fl_open_display(); XBell(fl_display, 50); break; } Although GTK is in the minority, they might also be more up to date on new trends in X11 than the other libs because they're perhaps closer to the linux community where change happens quickly. So perhaps we should do the #ifdef for using XkbBell() if available. Seems other platforms like Apple and Sun support this extension, so maybe we should too. Again, just doing research here. I suppose the devs would have to vote on it. The hardest thing to doing this would be to modify our configure script to check for it Xkb extensions. But seems to me you should be able to get XBell() to work as you like without having to change FLTK, which I think was part of your initial question: > Should fl_beep/XBell work? I think yes, if by 'work' when there's no PC speaker, that it play a sound. The xkbevd is one way, though perhaps there are others. > If not, any chance to improve fltk 1.3 to make fl_beep work ? I'm not sure FLTK needs to be changed for it to work, but we could ask the devs for a vote, assuming it really needs to be changed, and isn't just a config issue. _______________________________________________ fltk mailing list fltk@easysw.com http://lists.easysw.com/mailman/listinfo/fltk