From 168084d6720a0573ba16cc5f2296f8e4c65bbe39 Mon Sep 17 00:00:00 2001 From: sp2xdev <127630192+sp2xdev@users.noreply.github.com> Date: Fri, 30 May 2025 22:21:03 -0700 Subject: [PATCH] update changelog --- src/spice2x/changelog.txt | 4 +++- src/spice2x/overlay/imgui/impl_spice.cpp | 17 +++++++++++++++-- src/spice2x/touch/touch.cpp | 12 +++++++++--- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/spice2x/changelog.txt b/src/spice2x/changelog.txt index 504fdec..57c5879 100644 --- a/src/spice2x/changelog.txt +++ b/src/spice2x/changelog.txt @@ -1,7 +1,9 @@ 05/31/2025 [spice2x] + IIDX: fix windowed subscreen not accepting mouse clicks when + overlay is active IIDX: tape LED over API - UI tweaks Option to make command line args take precedence + UI tweaks 05/09/2025 [spice2x] Check for window focus when processing input (-inputfocus) diff --git a/src/spice2x/overlay/imgui/impl_spice.cpp b/src/spice2x/overlay/imgui/impl_spice.cpp index f4f03b5..a09c384 100644 --- a/src/spice2x/overlay/imgui/impl_spice.cpp +++ b/src/spice2x/overlay/imgui/impl_spice.cpp @@ -12,6 +12,7 @@ #include "touch/touch.h" #include "util/logging.h" #include "util/utils.h" +#include "hooks/graphics/graphics.h" #if !defined(IMGUI_ENABLE_WIN32_DEFAULT_IME_FUNCTIONS) || \ !defined(IMGUI_DISABLE_DEFAULT_ALLOCATORS) || \ @@ -175,10 +176,22 @@ static void ImGui_ImplSpice_UpdateMousePos() { static_cast(pos.y / io.DisplaySize.y * window_size.y)); } + const auto active_window = ::GetForegroundWindow(); + + // if the main focus is a windowed subscreen, put the imgui cursor in a place that won't + // trigger any overlay, don't process anything else + const auto is_windowed_subscreen = + (GRAPHICS_IIDX_WSUB && active_window == TDJ_SUBSCREEN_WINDOW) || + (active_window == SDVX_SUBSCREEN_WINDOW); + if (is_windowed_subscreen) { + io.MousePos = ImVec2(-FLT_MAX, -FLT_MAX); + return; + } + // set mouse position io.MousePos = ImVec2(-FLT_MAX, -FLT_MAX); POINT pos; - if (HWND active_window = ::GetForegroundWindow()) { + if (active_window) { if (active_window == g_hWnd || ::IsChild(active_window, g_hWnd) || ::IsChild(g_hWnd, active_window) @@ -208,7 +221,7 @@ static void ImGui_ImplSpice_UpdateMousePos() { static size_t delay_touch = 0; static size_t delay_touch_target = 2; static DWORD last_touch_id = ~0u; - if (!touch_points.empty()) { + if (!touch_points.empty() && !is_windowed_subscreen) { // use the first touch point auto &tp = touch_points[0]; diff --git a/src/spice2x/touch/touch.cpp b/src/spice2x/touch/touch.cpp index fbea901..13f4172 100644 --- a/src/spice2x/touch/touch.cpp +++ b/src/spice2x/touch/touch.cpp @@ -240,8 +240,11 @@ static LRESULT CALLBACK SpiceTouchWndProc(HWND hWnd, UINT msg, WPARAM wParam, LP rawinput::touch::display_update(); } + const auto is_windowed_sub = + (GRAPHICS_IIDX_WSUB && hWnd == TDJ_SUBSCREEN_WINDOW) || (hWnd == SDVX_SUBSCREEN_WINDOW); + if (msg == WM_CLOSE) { - if ((GRAPHICS_IIDX_WSUB && hWnd == TDJ_SUBSCREEN_WINDOW) || (hWnd == SDVX_SUBSCREEN_WINDOW)) { + if (is_windowed_sub) { log_misc("touch", "ignore WM_CLOSE for subscreen window"); return false; } @@ -461,11 +464,14 @@ static LRESULT CALLBACK SpiceTouchWndProc(HWND hWnd, UINT msg, WPARAM wParam, LP }; // check if imgui is handling this mouse event - if (overlay::OVERLAY != nullptr && overlay::OVERLAY->get_active() && ImGui::GetIO().WantCaptureMouse) { + if (is_windowed_sub) { + // do nothing, don't let imgui hijack clicks on the sub window + result.action = ACTION_PASS; + + } else if (overlay::OVERLAY != nullptr && overlay::OVERLAY->get_active() && ImGui::GetIO().WantCaptureMouse) { result.action = ACTION_RETURN_DEFAULT; } else if (TOUCH_HANDLER != nullptr) { - // call touch handler TOUCH_HANDLER->handle_message(result, hWnd, msg, wParam, lParam); }