sys: Added setting to override borderless window mode even on Intel
This commit is contained in:
parent
f72e9700ab
commit
33a1e7f055
@ -112,6 +112,8 @@ namespace hex {
|
||||
void setGlobalScale(float scale);
|
||||
|
||||
void setProgramArguments(int argc, char **argv, char **envp);
|
||||
|
||||
void setBorderlessWindowMode(bool enabled);
|
||||
}
|
||||
|
||||
struct ProgramArguments {
|
||||
@ -131,6 +133,8 @@ namespace hex {
|
||||
ImVec2 getMainWindowSize();
|
||||
ImGuiID getMainDockSpaceId();
|
||||
|
||||
bool isBorderlessWindowModeEnabled();
|
||||
|
||||
std::map<std::string, std::string> &getInitArguments();
|
||||
|
||||
}
|
||||
|
@ -189,6 +189,11 @@ namespace hex {
|
||||
s_programArguments.envp = envp;
|
||||
}
|
||||
|
||||
static bool s_borderlessWindowMode;
|
||||
void setBorderlessWindowMode(bool enabled) {
|
||||
s_borderlessWindowMode = enabled;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -225,6 +230,10 @@ namespace hex {
|
||||
return impl::s_mainDockSpaceId;
|
||||
}
|
||||
|
||||
bool isBorderlessWindowModeEnabled() {
|
||||
return impl::s_borderlessWindowMode;
|
||||
}
|
||||
|
||||
std::map<std::string, std::string> &getInitArguments() {
|
||||
static std::map<std::string, std::string> initArgs;
|
||||
|
||||
|
@ -16,7 +16,7 @@ namespace hex {
|
||||
|
||||
class Window {
|
||||
public:
|
||||
Window(bool borderlessWindow);
|
||||
Window();
|
||||
~Window();
|
||||
|
||||
void loop();
|
||||
@ -52,8 +52,6 @@ namespace hex {
|
||||
|
||||
std::list<std::string> m_popupsToOpen;
|
||||
std::vector<int> m_pressedKeys;
|
||||
|
||||
bool m_useBorderlessWindow = false;
|
||||
};
|
||||
|
||||
}
|
@ -14,10 +14,9 @@ int main(int argc, char **argv, char **envp) {
|
||||
using namespace hex;
|
||||
ImHexApi::System::impl::setProgramArguments(argc, argv, envp);
|
||||
|
||||
bool useBorderlessWindow = false;
|
||||
|
||||
#if defined(OS_WINDOWS)
|
||||
useBorderlessWindow = true;
|
||||
ImHexApi::System::impl::setBorderlessWindowMode(true);
|
||||
#endif
|
||||
|
||||
// Initialization
|
||||
@ -28,13 +27,21 @@ int main(int argc, char **argv, char **envp) {
|
||||
|
||||
init::WindowSplash splashWindow;
|
||||
|
||||
// Intel's OpenGL driver has weird bugs that cause the drawn window to be offset to the bottom right.
|
||||
// This can be fixed by either using Mesa3D's OpenGL Software renderer or by simply disabling it.
|
||||
// If you want to try if it works anyways on your GPU, set the hex.builtin.setting.interface.force_borderless_window_mode setting to 1
|
||||
|
||||
bool isIntelGPU = hex::containsIgnoreCase(splashWindow.getGPUVendor(), "Intel");
|
||||
ImHexApi::System::impl::setBorderlessWindowMode(!isIntelGPU);
|
||||
|
||||
if (isIntelGPU)
|
||||
log::warn("Intel GPU detected! Intel's OpenGL driver has bugs that can cause issues when using ImHex. If you experience any rendering bugs, please try the Mesa3D Software Renderer");
|
||||
|
||||
for (const auto &[name, task] : init::getInitTasks())
|
||||
splashWindow.addStartupTask(name, task);
|
||||
|
||||
if (!splashWindow.loop())
|
||||
ImHexApi::System::getInitArguments().insert({ "tasks-failed", {} });
|
||||
|
||||
useBorderlessWindow = !hex::containsIgnoreCase(splashWindow.getGPUVendor(), "Intel");
|
||||
}
|
||||
|
||||
// Clean up
|
||||
@ -45,7 +52,7 @@ int main(int argc, char **argv, char **envp) {
|
||||
|
||||
// Main window
|
||||
{
|
||||
Window window(useBorderlessWindow);
|
||||
Window window;
|
||||
|
||||
if (argc == 1)
|
||||
; // No arguments provided
|
||||
|
@ -241,7 +241,7 @@ namespace hex {
|
||||
// Setup borderless window
|
||||
auto hwnd = glfwGetWin32Window(this->m_window);
|
||||
|
||||
if (this->m_useBorderlessWindow) {
|
||||
if (ImHexApi::System::isBorderlessWindowModeEnabled()) {
|
||||
g_oldWndProc = ::SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)windowProc);
|
||||
|
||||
MARGINS borderless = { 1, 1, 1, 1 };
|
||||
@ -300,7 +300,7 @@ namespace hex {
|
||||
}
|
||||
|
||||
void Window::drawTitleBar() {
|
||||
if (!this->m_useBorderlessWindow) return;
|
||||
if (!ImHexApi::System::isBorderlessWindowModeEnabled()) return;
|
||||
|
||||
auto buttonSize = ImVec2(g_titleBarHeight * 1.5F, g_titleBarHeight - 1);
|
||||
|
||||
|
@ -71,7 +71,7 @@ namespace hex {
|
||||
buf->append("\n");
|
||||
}
|
||||
|
||||
Window::Window(bool borderlessWindow) : m_useBorderlessWindow(borderlessWindow) {
|
||||
Window::Window() {
|
||||
{
|
||||
for (const auto &[argument, value] : ImHexApi::System::getInitArguments()) {
|
||||
if (argument == "no-plugins") {
|
||||
@ -289,7 +289,7 @@ namespace hex {
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f);
|
||||
if (ImGui::BeginMainMenuBar()) {
|
||||
|
||||
if (this->m_useBorderlessWindow) {
|
||||
if (ImHexApi::System::isBorderlessWindowModeEnabled()) {
|
||||
auto menuBarHeight = ImGui::GetCurrentWindow()->MenuBarHeight();
|
||||
ImGui::SetCursorPosX(5);
|
||||
ImGui::Image(this->m_logoTexture, ImVec2(menuBarHeight, menuBarHeight));
|
||||
@ -501,7 +501,7 @@ namespace hex {
|
||||
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
|
||||
#endif
|
||||
|
||||
glfwWindowHint(GLFW_DECORATED, this->m_useBorderlessWindow ? GL_FALSE : GL_TRUE);
|
||||
glfwWindowHint(GLFW_DECORATED, ImHexApi::System::isBorderlessWindowModeEnabled() ? GL_FALSE : GL_TRUE);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
|
||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||
|
@ -43,6 +43,13 @@ static void detectSystemTheme() {
|
||||
});
|
||||
}
|
||||
|
||||
static void checkBorderlessWindowOverride() {
|
||||
bool borderlessWindowForced = ContentRegistry::Settings::read("hex.builtin.setting.interface", "hex.builtin.setting.interface.force_borderless_window_mode", 0) != 0;
|
||||
|
||||
if (borderlessWindowForced)
|
||||
ImHexApi::System::impl::setBorderlessWindowMode(true);
|
||||
}
|
||||
|
||||
IMHEX_PLUGIN_SETUP("Windows", "WerWolv", "Windows-only features") {
|
||||
using namespace hex::plugin::windows;
|
||||
|
||||
@ -57,4 +64,5 @@ IMHEX_PLUGIN_SETUP("Windows", "WerWolv", "Windows-only features") {
|
||||
registerSettings();
|
||||
|
||||
detectSystemTheme();
|
||||
checkBorderlessWindowOverride();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user