diff --git a/lib/external/imgui/include/imgui_impl_glfw.h b/lib/external/imgui/include/imgui_impl_glfw.h index b96f3ee2c..b67f23a91 100644 --- a/lib/external/imgui/include/imgui_impl_glfw.h +++ b/lib/external/imgui/include/imgui_impl_glfw.h @@ -49,3 +49,7 @@ IMGUI_IMPL_API void ImGui_ImplGlfw_ScrollCallback(GLFWwindow* window, double IMGUI_IMPL_API void ImGui_ImplGlfw_KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods); IMGUI_IMPL_API void ImGui_ImplGlfw_CharCallback(GLFWwindow* window, unsigned int c); IMGUI_IMPL_API void ImGui_ImplGlfw_MonitorCallback(GLFWmonitor* monitor, int event); + +// IMHEX PATCH BEGIN +IMGUI_IMPL_API void ImGui_ImplGlfw_SetBorderlessWindowMode(bool enabled); +// IMHEX PATCH END diff --git a/lib/external/imgui/source/imgui_impl_glfw.cpp b/lib/external/imgui/source/imgui_impl_glfw.cpp index 9fb94e5ce..10178005c 100644 --- a/lib/external/imgui/source/imgui_impl_glfw.cpp +++ b/lib/external/imgui/source/imgui_impl_glfw.cpp @@ -128,6 +128,7 @@ struct ImGui_ImplGlfw_Data bool WantUpdateMonitors; #ifdef _WIN32 WNDPROC GlfwWndProc; + bool BorderlessWindow; // IMHEX PATCH #endif // Chain GLFW callbacks: our callbacks will call the user's previously installed callbacks, if any. @@ -495,6 +496,11 @@ void ImGui_ImplGlfw_MonitorCallback(GLFWmonitor*, int) bd->WantUpdateMonitors = true; } +void ImGui_ImplGlfw_SetBorderlessWindowMode(bool enabled) { + ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData(); + bd->BorderlessWindow = enabled; +} + void ImGui_ImplGlfw_InstallCallbacks(GLFWwindow* window) { ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData(); @@ -741,12 +747,12 @@ static void ImGui_ImplGlfw_UpdateMouseCursor() else { // IMHEX PATCH BEGIN - #ifndef _WIN32 + if (!bd->BorderlessWindow) { // Show OS mouse cursor // FIXME-PLATFORM: Unfocused windows seems to fail changing the mouse cursor with GLFW 3.2, but 3.3 works here. glfwSetCursor(window, bd->MouseCursors[imgui_cursor] ? bd->MouseCursors[imgui_cursor] : bd->MouseCursors[ImGuiMouseCursor_Arrow]); glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_NORMAL); - #endif + } // IMHEX PATCH END } } diff --git a/main/source/window/win_window.cpp b/main/source/window/win_window.cpp index 9944c0c32..343db63f3 100644 --- a/main/source/window/win_window.cpp +++ b/main/source/window/win_window.cpp @@ -22,6 +22,8 @@ #include #include + #include + namespace hex { static LONG_PTR g_oldWndProc; @@ -244,7 +246,12 @@ namespace hex { // Setup borderless window auto hwnd = glfwGetWin32Window(this->m_window); - if (ImHexApi::System::isBorderlessWindowModeEnabled()) { + bool borderlessWindowMode = ImHexApi::System::isBorderlessWindowModeEnabled(); + + ImGui_ImplGlfw_SetBorderlessWindowMode(borderlessWindowMode); + + + if (borderlessWindowMode) { g_oldWndProc = ::SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)windowProc); MARGINS borderless = { 1, 1, 1, 1 }; @@ -263,6 +270,9 @@ namespace hex { } void Window::endNativeWindowFrame() { + if (!ImHexApi::System::isBorderlessWindowModeEnabled()) + return; + if (g_mouseCursorIcon != ImGuiMouseCursor_None) { ImGui::SetMouseCursor(g_mouseCursorIcon); } diff --git a/plugins/builtin/source/content/data_visualizers.cpp b/plugins/builtin/source/content/data_visualizers.cpp index 3a8440997..28089b3c5 100644 --- a/plugins/builtin/source/content/data_visualizers.cpp +++ b/plugins/builtin/source/content/data_visualizers.cpp @@ -242,7 +242,7 @@ namespace hex::plugin::builtin { return false; } - std::array m_currColor; + std::array m_currColor = { 0 }; };