diff options
Diffstat (limited to 'xW')
-rw-r--r-- | xW/CMakeLists.txt | 12 | ||||
-rw-r--r-- | xW/xW-resources.h | 1 | ||||
-rw-r--r-- | xW/xW.cpp | 14 | ||||
-rw-r--r-- | xW/xW.rc | 1 |
4 files changed, 22 insertions, 6 deletions
diff --git a/xW/CMakeLists.txt b/xW/CMakeLists.txt index 7af0e31..dc3e5c9 100644 --- a/xW/CMakeLists.txt +++ b/xW/CMakeLists.txt @@ -59,6 +59,13 @@ function (icon_for_win32 ico pngs pngs_raw) COMMENT "Generating Windows program icon" VERBATIM) endfunction () +# Produce a beep sample +find_program (sox_EXECUTABLE sox ${find_program_REQUIRE}) +add_custom_command (OUTPUT beep.wav + COMMAND ${sox_EXECUTABLE} -b 16 -Dr 44100 -n beep.wav + synth 0.1 0 25 triangle 800 vol 0.5 fade t 0 -0 0.005 pad 0 0.05 + COMMENT "Generating a beep sample" VERBATIM) + # Rasterize SVG icons set (icon_ico_list) foreach (icon xW xW-highlighted) @@ -76,7 +83,8 @@ foreach (icon xW xW-highlighted) list (APPEND icon_ico_list ${icon_ico}) endforeach () -set_property (SOURCE xW.rc APPEND PROPERTY OBJECT_DEPENDS ${icon_ico_list}) +set_property (SOURCE xW.rc + APPEND PROPERTY OBJECT_DEPENDS ${icon_ico_list} beep.wav) # Build the main executable and link it set (root "${PROJECT_SOURCE_DIR}/..") @@ -97,7 +105,7 @@ add_custom_target (xC-proto DEPENDS ${PROJECT_BINARY_DIR}/xC-proto.cpp) add_executable (xW WIN32 xW.cpp xW.rc xW.manifest ${project_config} ${root}/liberty/tools/lxdrgen-cpp-win32.cpp) -target_link_libraries (xW comctl32 ws2_32) +target_link_libraries (xW comctl32 ws2_32 winmm) add_dependencies (xW xC-proto) # At least with MinGW, this is a fully independent portable executable diff --git a/xW/xW-resources.h b/xW/xW-resources.h index 47568b0..55d5590 100644 --- a/xW/xW-resources.h +++ b/xW/xW-resources.h @@ -1,5 +1,6 @@ #define IDI_ICON 1 #define IDI_HIGHLIGHTED 2 +#define IDR_BEEP 3 #define IDA_ACCELERATORS 10 // Named after input_add_functions() in xC. @@ -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. } @@ -12,6 +12,7 @@ CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "xW.manifest" IDI_ICON ICON "xW.ico" IDI_HIGHLIGHTED ICON "xW-highlighted.ico" +IDR_BEEP WAVE "beep.wav" IDA_ACCELERATORS ACCELERATORS BEGIN |