X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/582c005495b54e9c107029b70a0ae9e8c892634c..260f3dec11d702a907fdaf5aaee143abb01d0eb2:/window.c diff --git a/window.c b/window.c index 4c4360c4..865ff805 100644 --- a/window.c +++ b/window.c @@ -1,6 +1,7 @@ #include #include #include +#include #ifndef AUTO_WINSOCK #ifdef WINSOCK_TWO #include @@ -2663,7 +2664,21 @@ void fatalbox(char *fmt, ...) { */ void beep(int mode) { 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); + lastbeep = now; } else if (mode == BELL_WAVEFILE) { if (!PlaySound(cfg.bell_wavefile, NULL, SND_ASYNC | SND_FILENAME)) { char buf[sizeof(cfg.bell_wavefile)+80];