mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-03-16 12:03:03 -05:00
Put back Robert de Bath's second level of bell overload tracking. It
had a useful purpose: when primary overload handling is disabled, it prevents MessageBeep calls overloading the program, because they don't cancel each other like async PlaySounds do. [originally from svn r1056]
This commit is contained in:
parent
559b00b90a
commit
abf6514f71
14
window.c
14
window.c
@ -2663,7 +2663,21 @@ void fatalbox(char *fmt, ...) {
|
|||||||
*/
|
*/
|
||||||
void beep(int mode) {
|
void beep(int mode) {
|
||||||
if (mode == BELL_DEFAULT) {
|
if (mode == BELL_DEFAULT) {
|
||||||
|
/*
|
||||||
|
* For MessageBeep style bells, we want to be careful of
|
||||||
|
* timing, because they don't have the nice property of
|
||||||
|
* PlaySound bells that each one cancels the previous
|
||||||
|
* active one. So we limit the rate to one per 50ms or so.
|
||||||
|
*/
|
||||||
|
static long lastbeep = 0;
|
||||||
|
long now, beepdiff;
|
||||||
|
|
||||||
|
now = GetTickCount();
|
||||||
|
beepdiff = now - lastbeep;
|
||||||
|
if (beepdiff >= 0 && beepdiff < 50)
|
||||||
|
return;
|
||||||
MessageBeep(MB_OK);
|
MessageBeep(MB_OK);
|
||||||
|
lastbeep = now;
|
||||||
} else if (mode == BELL_WAVEFILE) {
|
} else if (mode == BELL_WAVEFILE) {
|
||||||
if (!PlaySound(cfg.bell_wavefile, NULL, SND_ASYNC | SND_FILENAME)) {
|
if (!PlaySound(cfg.bell_wavefile, NULL, SND_ASYNC | SND_FILENAME)) {
|
||||||
char buf[sizeof(cfg.bell_wavefile)+80];
|
char buf[sizeof(cfg.bell_wavefile)+80];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user