diff --git a/src/spice2x/overlay/imgui/impl_spice.cpp b/src/spice2x/overlay/imgui/impl_spice.cpp index f4f03b5..09ac99e 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) 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); }