1
0
mirror of synced 2025-01-18 17:14:13 +01:00

sys: Fixed resize cursors not appearing in non-borderless window mode

This commit is contained in:
WerWolv 2022-08-04 09:46:17 +02:00
parent de386a9927
commit be37228dc6
4 changed files with 24 additions and 4 deletions

View File

@ -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

View File

@ -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
}
}

View File

@ -22,6 +22,8 @@
#include <dwmapi.h>
#include <windowsx.h>
#include <imgui_impl_glfw.h>
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);
}

View File

@ -242,7 +242,7 @@ namespace hex::plugin::builtin {
return false;
}
std::array<float, 4> m_currColor;
std::array<float, 4> m_currColor = { 0 };
};