diff --git a/lib/libimhex/include/hex/helpers/utils_macos.hpp b/lib/libimhex/include/hex/helpers/utils_macos.hpp index fc1a5045c..8aab9e5a8 100644 --- a/lib/libimhex/include/hex/helpers/utils_macos.hpp +++ b/lib/libimhex/include/hex/helpers/utils_macos.hpp @@ -12,7 +12,7 @@ bool isMacosFullScreenModeEnabled(GLFWwindow *window); float getBackingScaleFactor(); - void setupMacosWindowStyle(GLFWwindow *window); + void setupMacosWindowStyle(GLFWwindow *window, bool borderlessWindowMode); } diff --git a/lib/libimhex/source/helpers/utils_macos.m b/lib/libimhex/source/helpers/utils_macos.m index d1c97bd70..9b0c6c295 100644 --- a/lib/libimhex/source/helpers/utils_macos.m +++ b/lib/libimhex/source/helpers/utils_macos.m @@ -44,16 +44,19 @@ return [[NSScreen mainScreen] backingScaleFactor]; } - void setupMacosWindowStyle(GLFWwindow *window) { + void setupMacosWindowStyle(GLFWwindow *window, bool borderlessWindowMode) { NSWindow* cocoaWindow = glfwGetCocoaWindow(window); cocoaWindow.titleVisibility = NSWindowTitleHidden; - cocoaWindow.titlebarAppearsTransparent = YES; - cocoaWindow.styleMask |= NSWindowStyleMaskFullSizeContentView; - [cocoaWindow setOpaque:NO]; - [cocoaWindow setHasShadow:YES]; - [cocoaWindow setBackgroundColor:[NSColor colorWithWhite: 0 alpha: 0.001f]]; + if (borderlessWindowMode) { + cocoaWindow.titlebarAppearsTransparent = YES; + cocoaWindow.styleMask |= NSWindowStyleMaskFullSizeContentView; + + [cocoaWindow setOpaque:NO]; + [cocoaWindow setHasShadow:YES]; + [cocoaWindow setBackgroundColor:[NSColor colorWithWhite: 0 alpha: 0.001f]]; + } } bool isMacosFullScreenModeEnabled(GLFWwindow *window) { diff --git a/main/gui/source/window/macos_window.cpp b/main/gui/source/window/macos_window.cpp index 904eda012..1db3971fd 100644 --- a/main/gui/source/window/macos_window.cpp +++ b/main/gui/source/window/macos_window.cpp @@ -41,8 +41,6 @@ namespace hex { } void Window::setupNativeWindow() { - ImHexApi::System::impl::setBorderlessWindowMode(true); - bool themeFollowSystem = ImHexApi::System::usesSystemThemeDetection(); EventOSThemeChanged::subscribe(this, [themeFollowSystem] { if (!themeFollowSystem) return; @@ -63,7 +61,7 @@ namespace hex { } }); - setupMacosWindowStyle(m_window); + setupMacosWindowStyle(m_window, ImHexApi::System::isBorderlessWindowModeEnabled()); } void Window::beginNativeWindowFrame() { diff --git a/main/gui/source/window/win_window.cpp b/main/gui/source/window/win_window.cpp index aa4f62756..14bc249dc 100644 --- a/main/gui/source/window/win_window.cpp +++ b/main/gui/source/window/win_window.cpp @@ -296,8 +296,6 @@ namespace hex { log::impl::redirectToFile(); } - ImHexApi::System::impl::setBorderlessWindowMode(true); - // Add plugin library folders to dll search path for (const auto &path : hex::fs::getDefaultPaths(fs::ImHexPath::Libraries)) { if (std::fs::exists(path)) diff --git a/plugins/builtin/romfs/lang/de_DE.json b/plugins/builtin/romfs/lang/de_DE.json index 7bb7568a5..596cae8ce 100644 --- a/plugins/builtin/romfs/lang/de_DE.json +++ b/plugins/builtin/romfs/lang/de_DE.json @@ -482,6 +482,7 @@ "hex.builtin.setting.imhex": "ImHex", "hex.builtin.setting.imhex.recent_files": "Zuletzt geƶffnete Dateien", "hex.builtin.setting.interface": "Aussehen", + "hex.builtin.setting.interface.native_window_decorations": "Benutze OS Fensterdekorationen", "hex.builtin.setting.interface.color": "Farbdesign", "hex.builtin.setting.interface.crisp_scaling": "Gestochen scharfe Skallierung aktivieren", "hex.builtin.setting.interface.fps": "FPS Limit", diff --git a/plugins/builtin/romfs/lang/en_US.json b/plugins/builtin/romfs/lang/en_US.json index 9991b5fbd..0b947094b 100644 --- a/plugins/builtin/romfs/lang/en_US.json +++ b/plugins/builtin/romfs/lang/en_US.json @@ -469,6 +469,7 @@ "hex.builtin.setting.imhex.recent_files": "Recent Files", "hex.builtin.setting.interface": "Interface", "hex.builtin.setting.interface.always_show_provider_tabs": "Always show Provider Tabs", + "hex.builtin.setting.interface.native_window_decorations": "Use OS Window decorations", "hex.builtin.setting.interface.color": "Color theme", "hex.builtin.setting.interface.crisp_scaling": "Enable crisp scaling", "hex.builtin.setting.interface.fps": "FPS Limit", diff --git a/plugins/builtin/source/content/settings_entries.cpp b/plugins/builtin/source/content/settings_entries.cpp index 25ae3bd69..ac3d652df 100644 --- a/plugins/builtin/source/content/settings_entries.cpp +++ b/plugins/builtin/source/content/settings_entries.cpp @@ -601,6 +601,28 @@ namespace hex::plugin::builtin { i32 m_currIndex = 0; }; + + bool getDefaultBorderlessWindowMode() { + bool result = false; + + #if defined (OS_WINDOWS) || defined(OS_MACOS) + result = true; + #endif + + // 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 + if (ImHexApi::System::isBorderlessWindowModeEnabled()) { + const bool isIntelGPU = hex::containsIgnoreCase(ImHexApi::System::getGPUVendor(), "Intel"); + + result = !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"); + } + + return result; + } + } void registerSettings() { @@ -686,17 +708,23 @@ namespace hex::plugin::builtin { #endif ContentRegistry::Settings::add("hex.builtin.setting.interface", "hex.builtin.setting.interface.window", "hex.builtin.setting.interface.multi_windows", MultiWindowSupportEnabledDefault).requiresRestart(); + + #if !defined(OS_WEB) + ContentRegistry::Settings::add("hex.builtin.setting.interface", "hex.builtin.setting.interface.window", "hex.builtin.setting.interface.native_window_decorations", !getDefaultBorderlessWindowMode()).requiresRestart(); + #endif + ContentRegistry::Settings::add("hex.builtin.setting.interface", "hex.builtin.setting.interface.window", "hex.builtin.setting.interface.restore_window_pos", false); ContentRegistry::Settings::add("hex.builtin.setting.hex_editor", "", "hex.builtin.setting.hex_editor.highlight_color", ImColor(0x80, 0x80, 0xC0, 0x60)); ContentRegistry::Settings::add("hex.builtin.setting.hex_editor", "", "hex.builtin.setting.hex_editor.sync_scrolling", false); ContentRegistry::Settings::add("hex.builtin.setting.hex_editor", "", "hex.builtin.setting.hex_editor.byte_padding", 0, 0, 50); ContentRegistry::Settings::add("hex.builtin.setting.hex_editor", "", "hex.builtin.setting.hex_editor.char_padding", 0, 0, 50); + + } /* Fonts */ { - ContentRegistry::Settings::add("hex.builtin.setting.font", "hex.builtin.setting.font.glyphs", "hex.builtin.setting.font.load_all_unicode_chars", false) .requiresRestart(); @@ -823,6 +851,9 @@ namespace hex::plugin::builtin { ImHexApi::System::enableSystemThemeDetection(false); ThemeManager::changeTheme(theme); } + + auto borderlessWindowMode = !ContentRegistry::Settings::read("hex.builtin.setting.interface", "hex.builtin.setting.interface.native_window_decorations", !getDefaultBorderlessWindowMode()); + ImHexApi::System::impl::setBorderlessWindowMode(borderlessWindowMode); } static void loadFolderSettings() { diff --git a/plugins/builtin/source/content/ui_items.cpp b/plugins/builtin/source/content/ui_items.cpp index 67d53404c..bb49c23b8 100644 --- a/plugins/builtin/source/content/ui_items.cpp +++ b/plugins/builtin/source/content/ui_items.cpp @@ -425,17 +425,4 @@ namespace hex::plugin::builtin { ContentRegistry::Interface::addMenuItemToToolbar("hex.builtin.menu.edit.bookmark.create", ImGuiCustomCol_ToolbarGreen); } - void handleBorderlessWindowMode() { - // 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 - if (ImHexApi::System::isBorderlessWindowModeEnabled()) { - bool isIntelGPU = hex::containsIgnoreCase(ImHexApi::System::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"); - } - } - } \ No newline at end of file diff --git a/plugins/builtin/source/content/workspaces.cpp b/plugins/builtin/source/content/workspaces.cpp index 580c3759a..d78315cb0 100644 --- a/plugins/builtin/source/content/workspaces.cpp +++ b/plugins/builtin/source/content/workspaces.cpp @@ -7,6 +7,8 @@ namespace hex::plugin::builtin { void loadWorkspaces() { + WorkspaceManager::reset(); + for (const auto &defaultPath : fs::getDefaultPaths(fs::ImHexPath::Workspaces)) { for (const auto &entry : std::fs::directory_iterator(defaultPath)) { if (!entry.is_regular_file()) diff --git a/plugins/builtin/source/plugin_builtin.cpp b/plugins/builtin/source/plugin_builtin.cpp index 97d0bba27..69115e3e2 100644 --- a/plugins/builtin/source/plugin_builtin.cpp +++ b/plugins/builtin/source/plugin_builtin.cpp @@ -121,6 +121,5 @@ IMHEX_PLUGIN_SETUP("Built-in", "WerWolv", "Default ImHex functionality") { addToolbarItems(); addGlobalUIItems(); - handleBorderlessWindowMode(); setupOutOfBoxExperience(); } diff --git a/plugins/windows/source/plugin_windows.cpp b/plugins/windows/source/plugin_windows.cpp index 6a4790c1b..b50e76fbd 100644 --- a/plugins/windows/source/plugin_windows.cpp +++ b/plugins/windows/source/plugin_windows.cpp @@ -35,11 +35,7 @@ static void detectSystemTheme() { auto error = RegQueryValueEx(hkey, "AppsUseLightTheme", nullptr, nullptr, reinterpret_cast(&value), &size); if (error == ERROR_SUCCESS) { RequestChangeTheme::post(value == 0 ? "Dark" : "Light"); - } else { - ImHexApi::System::impl::setBorderlessWindowMode(false); } - } else { - ImHexApi::System::impl::setBorderlessWindowMode(false); } }); @@ -51,13 +47,6 @@ static void detectSystemTheme() { }); } -static void checkBorderlessWindowOverride() { - bool borderlessWindowForced = ContentRegistry::Settings::read("hex.builtin.setting.interface", "hex.builtin.setting.interface.force_borderless_window_mode", false); - - if (borderlessWindowForced) - ImHexApi::System::impl::setBorderlessWindowMode(true); -} - IMHEX_PLUGIN_SETUP("Windows", "WerWolv", "Windows-only features") { using namespace hex::plugin::windows; @@ -71,5 +60,4 @@ IMHEX_PLUGIN_SETUP("Windows", "WerWolv", "Windows-only features") { registerSettings(); detectSystemTheme(); - checkBorderlessWindowOverride(); }