Glenn Maynard's patch (as adapted by Jacob) for taskbar flashing

when a bell occurs and the window is minimised.

[originally from svn r1123]
This commit is contained in:
Simon Tatham 2001-05-13 14:42:17 +00:00
Родитель 52a688abd1
Коммит 84e58edf9f
5 изменённых файлов: 81 добавлений и 7 удалений

Просмотреть файл

@ -272,6 +272,9 @@ typedef struct {
enum {
BELL_DISABLED, BELL_DEFAULT, BELL_VISUAL, BELL_WAVEFILE
} beep;
enum {
B_IND_DISABLED, B_IND_FLASH, B_IND_STEADY
} beep_ind;
int bellovl; /* bell overload protection active? */
int bellovl_n; /* number of bells to cause overload */
int bellovl_t; /* time interval for overload (seconds) */

Просмотреть файл

@ -110,6 +110,7 @@ void save_settings(char *section, int do_host, Config * cfg)
write_setting_i(sesskey, "CurType", cfg->cursor_type);
write_setting_i(sesskey, "BlinkCur", cfg->blink_cur);
write_setting_i(sesskey, "Beep", cfg->beep);
write_setting_i(sesskey, "BeepInd", cfg->beep_ind);
write_setting_s(sesskey, "BellWaveFile", cfg->bell_wavefile);
write_setting_i(sesskey, "BellOverload", cfg->bellovl);
write_setting_i(sesskey, "BellOverloadN", cfg->bellovl_n);
@ -273,6 +274,7 @@ void load_settings(char *section, int do_host, Config * cfg)
gppi(sesskey, "BlinkCur", 0, &cfg->blink_cur);
/* pedantic compiler tells me I can't use &cfg->beep as an int * :-) */
gppi(sesskey, "Beep", 1, &i); cfg->beep = i;
gppi(sesskey, "BeepInd", 0, &i); cfg->beep_ind = i;
gpps(sesskey, "BellWaveFile", "", cfg->bell_wavefile,
sizeof(cfg->bell_wavefile));
gppi(sesskey, "BellOverload", 1, &cfg->bellovl);

Просмотреть файл

@ -1142,11 +1142,9 @@ void term_out(void)
/*
* Perform an actual beep if we're not overloaded.
*/
if ((!cfg.bellovl || !beep_overloaded)
&& cfg.beep != 0) {
if (cfg.beep != 2)
beep(cfg.beep);
else if (cfg.beep == 2) {
if (!cfg.bellovl || !beep_overloaded) {
beep(cfg.beep);
if (cfg.beep == BELL_VISUAL) {
in_vbell = TRUE;
vbell_timeout = ticks + VBELL_TIMEOUT;
term_update();

Просмотреть файл

@ -328,6 +328,10 @@ enum { IDCX_ABOUT =
IDC_BELL_WAVESTATIC,
IDC_BELL_WAVEEDIT,
IDC_BELL_WAVEBROWSE,
IDC_B_IND_STATIC,
IDC_B_IND_DISABLED,
IDC_B_IND_FLASH,
IDC_B_IND_STEADY,
IDC_BELLOVL,
IDC_BELLOVLNSTATIC,
IDC_BELLOVLN,
@ -614,6 +618,11 @@ static void init_dlg_ctrls(HWND hwnd, int keepsess)
cfg.beep == BELL_WAVEFILE ? IDC_BELL_WAVEFILE :
cfg.beep ==
BELL_VISUAL ? IDC_BELL_VISUAL : IDC_BELL_DEFAULT);
CheckRadioButton(hwnd, IDC_B_IND_DISABLED, IDC_B_IND_STEADY,
cfg.beep_ind ==
B_IND_DISABLED ? IDC_B_IND_DISABLED : cfg.beep_ind ==
B_IND_FLASH ? IDC_B_IND_FLASH : cfg.beep_ind ==
B_IND_STEADY ? IDC_B_IND_STEADY : IDC_B_IND_DISABLED);
SetDlgItemText(hwnd, IDC_BELL_WAVEEDIT, cfg.bell_wavefile);
CheckDlgButton(hwnd, IDC_BELLOVL, cfg.bellovl);
SetDlgItemInt(hwnd, IDC_BELLOVLN, cfg.bellovl_n, FALSE);
@ -861,7 +870,7 @@ static void create_controls(HWND hwnd, int dlgtype, int panel)
}
if (panel == bellpanelstart) {
/* The Bell panel. Accelerators used: [acgo] bdsm wt */
/* The Bell panel. Accelerators used: [acgo] bdsm wit */
struct ctlpos cp;
ctlposinit(&cp, hwnd, 80, 3, 13);
bartitle(&cp, "Options controlling the terminal bell",
@ -876,6 +885,10 @@ static void create_controls(HWND hwnd, int dlgtype, int panel)
editbutton(&cp, "Custom sound file to play as a bell:",
IDC_BELL_WAVESTATIC, IDC_BELL_WAVEEDIT,
"Bro&wse...", IDC_BELL_WAVEBROWSE);
radioline(&cp, "Taskbar/caption &indication on bell:",
IDC_B_IND_STATIC, 3, "Disabled", IDC_B_IND_DISABLED,
"Flashing", IDC_B_IND_FLASH, "Steady", IDC_B_IND_STEADY,
NULL);
endbox(&cp);
beginbox(&cp, "Control the bell overload behaviour",
IDC_BOX_BELL2);
@ -1825,6 +1838,19 @@ static int GenericMainDlgProc(HWND hwnd, UINT msg,
cfg.beep = BELL_VISUAL;
}
break;
case IDC_B_IND_DISABLED:
case IDC_B_IND_FLASH:
case IDC_B_IND_STEADY:
if (HIWORD(wParam) == BN_CLICKED ||
HIWORD(wParam) == BN_DOUBLECLICKED) {
if (LOWORD(wParam) == IDC_B_IND_DISABLED)
cfg.beep_ind = B_IND_DISABLED;
if (LOWORD(wParam) == IDC_B_IND_FLASH)
cfg.beep_ind = B_IND_FLASH;
if (LOWORD(wParam) == IDC_B_IND_STEADY)
cfg.beep_ind = B_IND_STEADY;
}
break;
case IDC_BELL_WAVEBROWSE:
memset(&of, 0, sizeof(of));
#ifdef OPENFILENAME_SIZE_VERSION_400

Просмотреть файл

@ -77,6 +77,7 @@ static int pending_netevent = 0;
static WPARAM pend_netevent_wParam = 0;
static LPARAM pend_netevent_lParam = 0;
static void enact_pending_netevent(void);
static void flash_window(int mode);
static time_t last_movement = 0;
@ -644,11 +645,14 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
term_out();
term_update();
ShowCaret(hwnd);
flash_window(1); /* maintain */
if (in_vbell)
/* Hmm, term_update didn't want to do an update too soon ... */
timer_id = SetTimer(hwnd, 1, 50, NULL);
else if (!has_focus)
timer_id = SetTimer(hwnd, 1, 2000, NULL);
timer_id = SetTimer(hwnd, 1, 500, NULL);
else
timer_id = SetTimer(hwnd, 1, 100, NULL);
long_timer = 1;
@ -1643,6 +1647,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
has_focus = TRUE;
CreateCaret(hwnd, caretbm, font_width, font_height);
ShowCaret(hwnd);
flash_window(0); /* stop */
compose_state = 0;
term_out();
term_update();
@ -3238,6 +3243,42 @@ void fatalbox(char *fmt, ...)
exit(1);
}
/*
* Manage window caption / taskbar flashing, if enabled.
* 0 = stop, 1 = maintain, 2 = start
*/
static void flash_window(int mode)
{
static long last_flash = 0;
static int flashing = 0;
if ((mode == 0) || (cfg.beep_ind == B_IND_DISABLED)) {
/* stop */
if (flashing) {
FlashWindow(hwnd, FALSE);
flashing = 0;
}
} else if (mode == 2) {
/* start */
if (!flashing) {
last_flash = GetTickCount();
flashing = 1;
FlashWindow(hwnd, TRUE);
}
} else if ((mode == 1) && (cfg.beep_ind == B_IND_FLASH)) {
/* maintain */
if (flashing) {
long now = GetTickCount();
long fdiff = now - last_flash;
if (fdiff < 0 || fdiff > 450) {
last_flash = now;
FlashWindow(hwnd, TRUE); /* toggle */
}
}
}
}
/*
* Beep.
*/
@ -3272,4 +3313,8 @@ void beep(int mode)
cfg.beep = BELL_DEFAULT;
}
}
/* Otherwise, either visual bell or disabled; do nothing here */
if (!has_focus) {
flash_window(2); /* start */
}
}