xW: improve beeping

This adds yet another build dependency,
but it's better than the alternatives of handling it in code.
This commit is contained in:
2023-07-27 16:05:32 +02:00
parent 3d345987c3
commit fcd1b8e011
4 changed files with 22 additions and 6 deletions

View File

@@ -165,6 +165,14 @@ window_get_text(HWND hWnd)
return buffer;
}
static void
beep()
{
if (!PlaySound(MAKEINTRESOURCE(IDR_BEEP),
GetModuleHandle(NULL), SND_ASYNC | SND_RESOURCE))
Beep(800, 100);
}
// --- Networking --------------------------------------------------------------
static bool
@@ -785,8 +793,7 @@ relay_process_buffer_line(Buffer &b, Relay::EventData_BufferLine &m)
if (line->is_highlight || (!visible && !line->is_unimportant &&
b.kind == Relay::BufferKind::PRIVATE_MESSAGE)) {
// TODO(p): Avoid the PC speaker, which is also unreliable.
Beep(800, 100);
beep();
if (!visible) {
b.highlighted = true;
@@ -1261,9 +1268,8 @@ input_complete(const InputStamp &state, const std::wstring &error,
SendMessage(g.hwndInput, EM_REPLACESEL, TRUE, (LPARAM) insert.c_str());
}
// TODO(p): Avoid the PC speaker, which is also unreliable.
if (response->completions.size() != 1)
Beep(800, 100);
beep();
// TODO(p): Show all completion options.
}