diff --git a/host/src/d3d11_window.cpp b/host/src/d3d11_window.cpp index eb6ced7..7456fc2 100644 --- a/host/src/d3d11_window.cpp +++ b/host/src/d3d11_window.cpp @@ -204,14 +204,10 @@ LRESULT CALLBACK D3D11Window::wnd_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARA self->resize_height_ = HIWORD(lparam); } return 0; - case WM_KEYDOWN: - // Spike convenience: Esc quits so we aren't stuck in a borderless window. - if (wparam == VK_ESCAPE) - { - PostQuitMessage(0); - } - return 0; case WM_DESTROY: + // Reached by the close button, Alt+F4 (DefWindowProc turns it into WM_CLOSE -> + // DestroyWindow), and our own teardown. Esc deliberately does NOT quit -- it's a + // common in-game key, so quitting is via the File -> Exit menu item or Alt+F4. PostQuitMessage(0); return 0; default: diff --git a/host/src/main.cpp b/host/src/main.cpp index 33e86dc..a8beaaf 100644 --- a/host/src/main.cpp +++ b/host/src/main.cpp @@ -241,6 +241,11 @@ int run() } coop::apply_layout_end_frame(); // clear the one-shot "Reset layout" force + if (ui.request_quit) // File -> Exit + { + break; + } + // Forward the host window's mouse/keyboard into the game (when the MKB // subsystem is on, we're focused, and ImGui isn't using the event). coop::forward_mkb_frame(injection, window.hwnd(), capture.mirroring(), capture.source_hooked()); diff --git a/host/src/ui/app_chrome.cpp b/host/src/ui/app_chrome.cpp index e03cce8..2eba7aa 100644 --- a/host/src/ui/app_chrome.cpp +++ b/host/src/ui/app_chrome.cpp @@ -169,6 +169,15 @@ float draw_main_menu_bar(UiState& ui, const FrameStats& stats) ImGui::TextUnformatted("CoopAllTheThings"); ImGui::Separator(); + if (ImGui::BeginMenu("File")) + { + if (ImGui::MenuItem("Exit", "Alt+F4")) + { + ui.request_quit = true; // the main loop sees this and stops + } + ImGui::EndMenu(); + } + if (ImGui::BeginMenu("View")) { ImGui::MenuItem("Controllers", nullptr, &ui.show_controllers); @@ -190,9 +199,9 @@ float draw_main_menu_bar(UiState& ui, const FrameStats& stats) if (ImGui::BeginMenu("Help")) { - ImGui::TextDisabled("F1 hide/show this overlay"); - ImGui::TextDisabled("F2 release/clip the operator cursor"); - ImGui::TextDisabled("Esc quit"); + ImGui::TextDisabled("F1 hide/show this overlay"); + ImGui::TextDisabled("F2 release/clip the operator cursor"); + ImGui::TextDisabled("Alt+F4 quit (or File -> Exit)"); ImGui::Separator(); ImGui::TextDisabled("This window is what Remote Play"); ImGui::TextDisabled("Together captures."); diff --git a/host/src/ui/app_chrome.hpp b/host/src/ui/app_chrome.hpp index e2208f6..22b579f 100644 --- a/host/src/ui/app_chrome.hpp +++ b/host/src/ui/app_chrome.hpp @@ -20,6 +20,7 @@ struct UiState bool show_audio = true; bool show_log = true; bool debug_details = false; // off = general status; on = full diagnostics + bool request_quit = false; // set by File -> Exit; the main loop reads it and stops }; // Persist the verbosity-affecting UI switches (currently the "Debug details" toggle)