diff --git a/source/window/win_window.cpp b/source/window/win_window.cpp index 187d638db..781e7904b 100644 --- a/source/window/win_window.cpp +++ b/source/window/win_window.cpp @@ -26,6 +26,7 @@ static LONG_PTR oldWndProc; static float titleBarHeight; static ImGuiMouseCursor mouseCursorIcon; + static BOOL compositionEnabled = false; static bool isTaskbarAutoHideEnabled(UINT edge, RECT monitor) { APPBARDATA data = { .cbSize = sizeof(APPBARDATA), .uEdge = edge, .rc = monitor }; @@ -156,6 +157,11 @@ break; } + case WM_NCACTIVATE: + case WM_NCPAINT: + { + return DefWindowProc(hwnd, uMsg, wParam, lParam); + } default: break; } @@ -182,11 +188,14 @@ oldWndProc = ::SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)windowProc); - MARGINS borderless = {1,1,1,1}; + MARGINS borderless = { 1, 1, 1, 1 }; ::DwmExtendFrameIntoClientArea(hwnd, &borderless); + DWORD attribute = DWMNCRP_ENABLED; + ::DwmSetWindowAttribute(hwnd, DWMWA_NCRENDERING_POLICY, &attribute, sizeof(attribute)); + ::SetWindowPos(hwnd, nullptr, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED | SWP_ASYNCWINDOWPOS | SWP_NOSIZE | SWP_NOMOVE); - ::SetWindowLong(hwnd, GWL_STYLE, GetWindowLong(hwnd, GWL_STYLE) | WS_POPUP | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_CAPTION | WS_SYSMENU); + ::SetWindowLong(hwnd, GWL_STYLE, GetWindowLong(hwnd, GWL_STYLE) | WS_OVERLAPPEDWINDOW); bool themeFollowSystem = ContentRegistry::Settings::getSetting("hex.builtin.setting.interface", "hex.builtin.setting.interface.color") == 0; EventManager::subscribe(this, [themeFollowSystem]{ diff --git a/source/window/window.cpp b/source/window/window.cpp index 4956eacc9..bf0598c15 100644 --- a/source/window/window.cpp +++ b/source/window/window.cpp @@ -84,6 +84,7 @@ namespace hex { this->initGLFW(); this->initImGui(); + this->setupNativeWindow(); EventManager::subscribe(this, [this]() { { @@ -707,6 +708,8 @@ namespace hex { glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); + glfwWindowHint(GLFW_DECORATED, GLFW_FALSE); + glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE); this->m_windowTitle = "ImHex"; this->m_window = glfwCreateWindow(1280 * SharedData::globalScale, 720 * SharedData::globalScale, this->m_windowTitle.c_str(), nullptr, nullptr); @@ -719,7 +722,19 @@ namespace hex { glfwMakeContextCurrent(this->m_window); glfwSwapInterval(1); - this->setupNativeWindow(); + GLFWmonitor *monitor = glfwGetPrimaryMonitor(); + if (monitor != nullptr) { + const GLFWvidmode *mode = glfwGetVideoMode(monitor); + if (mode != nullptr) { + int monitorX, monitorY; + glfwGetMonitorPos(monitor, &monitorX, &monitorY); + + int windowWidth, windowHeight; + glfwGetWindowSize(this->m_window, &windowWidth, &windowHeight); + + glfwSetWindowPos(this->m_window, monitorX + (mode->width - windowWidth) / 2, monitorY + (mode->height - windowHeight) / 2); + } + } { int x = 0, y = 0; @@ -819,6 +834,8 @@ namespace hex { }); glfwSetWindowSizeLimits(this->m_window, 720 * SharedData::globalScale, 480 * SharedData::globalScale, GLFW_DONT_CARE, GLFW_DONT_CARE); + + glfwShowWindow(this->m_window); } void Window::initImGui() {