Skip to content

Commit aec26e4

Browse files
committed
WinGUI now uses "threadless" beep handling. See commit c9c5f83.
The beep handling in WinGUI is now quite similar to that in the x11new port (compare the PDC_beep() functions in each). The code to actually omit the beep is entirely different, of course. This also fixes an overlooked bug in WinGUI : call napms() with a long time span, and text will not blink during the nap. Other ports handle this by breaking long naps into a series of short ones, calling PDC_check_for_blinking() in between.
1 parent daf559a commit aec26e4

1 file changed

Lines changed: 15 additions & 19 deletions

File tree

wingui/pdcutil.c

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,29 @@
33
#include "pdcwin.h"
44
#ifdef WIN32_LEAN_AND_MEAN
55
#include <mmsystem.h>
6-
#include <process.h>
76
#endif
87

9-
static volatile int _beep_count = 0;
10-
11-
static void beep_thread(LPVOID lpParameter)
8+
static void _raw_beep( void)
129
{
13-
INTENTIONALLY_UNUSED_PARAMETER( lpParameter);
14-
while( _beep_count)
15-
{
16-
if (!PlaySound((LPCTSTR) SND_ALIAS_SYSTEMDEFAULT, NULL, SND_ALIAS_ID))
17-
Beep(800, 200);
18-
_beep_count--;
19-
}
10+
flash( );
11+
if (!PlaySound((LPCTSTR) SND_ALIAS_SYSTEMDEFAULT, NULL, SND_ALIAS_ID))
12+
Beep(800, 200);
2013
}
2114

2215
void PDC_beep(void)
2316
{
24-
PDC_LOG(("PDC_beep() - called\n"));
17+
if( !SP->n_beeps_queued)
18+
{
19+
const long beep_interval = 400;
2520

26-
_beep_count++;
27-
#if (defined(_MSC_VER) && _MSC_VER < 1900) || defined( __TURBOC__)
28-
beep_thread( 0); /* Turbo C and old MSVC lack _beginthread */
29-
#else
30-
if( _beep_count == 1)
31-
_beginthread( beep_thread, 0, NULL);
32-
#endif
21+
_raw_beep( );
22+
SP->t_next_beep = PDC_millisecs( ) + beep_interval;
23+
}
24+
SP->n_beeps_queued++;
3325
}
3426

27+
void PDC_check_for_blinking( void);
28+
3529
void PDC_napms(int ms) /* 'ms' = milli, _not_ microseconds! */
3630
{
3731
/* RR: keep GUI window responsive while PDCurses sleeps */
@@ -43,6 +37,7 @@ void PDC_napms(int ms) /* 'ms' = milli, _not_ microseconds! */
4337
PDC_LOG(("PDC_napms() - called: ms=%d\n", ms));
4438

4539
/* Pump all pending messages from WIN32 to the window handler */
40+
PDC_check_for_blinking( );
4641
while( !PDC_bDone && curr_ms < milliseconds_sleep_limit )
4742
{
4843
const DWORD max_sleep_ms = 50; /* check msgs 20 times/second */
@@ -59,6 +54,7 @@ void PDC_napms(int ms) /* 'ms' = milli, _not_ microseconds! */
5954
sleep_millisecs = max_sleep_ms;
6055
Sleep( sleep_millisecs);
6156
curr_ms += sleep_millisecs;
57+
PDC_check_for_blinking( );
6258
}
6359
}
6460

0 commit comments

Comments
 (0)