From fcd1b8e0110182bbb53a5b9a2e797f6ec1e1657e Mon Sep 17 00:00:00 2001 From: Přemysl Eric Janouch
Date: Thu, 27 Jul 2023 16:05:32 +0200 Subject: xW: improve beeping This adds yet another build dependency, but it's better than the alternatives of handling it in code. --- xW/xW.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'xW/xW.cpp') diff --git a/xW/xW.cpp b/xW/xW.cpp index cbc5b30..a20b1d0 100644 --- a/xW/xW.cpp +++ b/xW/xW.cpp @@ -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. } -- cgit v1.2.3-70-g09d2