[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#569539: The culprit *is* xterm source, misc.c:817



  Looking at how xkbbell achieves the beep I found it does:

(in xkbutils/xkbbell.c)
 204         else                    ok=  XkbBell(dpy,win,volume,nameAtom);

Now, xterm has this code:

 811 void
 812 xtermBell(XtermWidget xw, int which, int percent)
 813 {
 814     TScreen *screen = TScreenOf(xw);
 815 #if defined(HAVE_XKB_BELL_EXT)
 816     Atom tony = AtomBell(xw, which);
 817     if (tony != None) {
 818         XkbBell(screen->display, VShellWindow, percent, tony);
 819     } else
 820 #endif
 821         XBell(screen->display, percent);
 822 }

On checking, HAVE_XKB_BELL_EXT is indeed set.  However AtomBell() is
returning 'None'.  But wait a moment, looking back at xkbbell it
defaults this to 'None' as well:

 43 static  Atom             nameAtom = None;

and the only way that changes is if it passes this test:

198     if (bellName!=NULL)
199         nameAtom = XInternAtom(dpy,bellName,0);

which it doesn't unless you specify a bell with 'xkbbell <bellname>'.
So with just 'xkbbell' working this means that passing a nameAtom of
'None' to XkbBell() is perfectly fine, so why is xterm deciding it's a
bad thing ?

  Thus just commenting out lines 817 and 819 causes xterm beeping to
start working again.  Obviously you'd actually want to make it something
more like:

 811 void
 812 xtermBell(XtermWidget xw, int which, int percent)
 813 {
 814     TScreen *screen = TScreenOf(xw);
 815 #if defined(HAVE_XKB_BELL_EXT)
 816     Atom tony = AtomBell(xw, which);
 817         XkbBell(screen->display, VShellWindow, percent, tony);
 818 #else
 819         XBell(screen->display, percent);
 820 #endif
 821 }

So that you only issue one of XkbBell() or XBell().  Note AtomBell()
always sets its return value to a default of 'None', so there shouldn't
be a need for a NULL pointer check or anysuch there.
  I may be wrong about not wanting to issue both, X11 experts can check
that.

XkbBell(3) has nothing to say about the Atom name 'None' being special,
but it does say it can be NULL (but not what happens if it is).  It does
also state:

       If  a  compatible  keyboard  extension  isn't  present in the X server,
       XkbBell calls XBell with the specified display and percent, and returns
       False.  Otherwise,  XkbBell calls XkbDeviceBell with the specified disâ??
       play, window, percent, and name,  a  device_spec  of  XkbUseCoreKbd,  a
       bell_class of XkbDfltXIClass, and a bell_id of XkbDfltXIId, and returns
       True.

which seems to mean that my change as above to not try both XkbBell()
and XBell() is correct, as the former will fall back to the latter if
needs be anyway.

-- 
- Athanasius = Athanasius(at)miggy.org / http://www.miggy.org/
                  Finger athan(at)fysh.org for PGP key
	   "And it's me who is my enemy. Me who beats me up.
Me who makes the monsters. Me who strips my confidence." Paula Cole - ME



Reply to: