feat: Allow switching off borderless window mode
This commit is contained in:
parent
daf4e5cad6
commit
5cfcca0bc4
@ -12,7 +12,7 @@
|
||||
bool isMacosFullScreenModeEnabled(GLFWwindow *window);
|
||||
float getBackingScaleFactor();
|
||||
|
||||
void setupMacosWindowStyle(GLFWwindow *window);
|
||||
void setupMacosWindowStyle(GLFWwindow *window, bool borderlessWindowMode);
|
||||
|
||||
}
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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() {
|
||||
|
@ -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))
|
||||
|
@ -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",
|
||||
|
@ -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",
|
||||
|
@ -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<Widgets::Checkbox>("hex.builtin.setting.interface", "hex.builtin.setting.interface.window", "hex.builtin.setting.interface.multi_windows", MultiWindowSupportEnabledDefault).requiresRestart();
|
||||
|
||||
#if !defined(OS_WEB)
|
||||
ContentRegistry::Settings::add<Widgets::Checkbox>("hex.builtin.setting.interface", "hex.builtin.setting.interface.window", "hex.builtin.setting.interface.native_window_decorations", !getDefaultBorderlessWindowMode()).requiresRestart();
|
||||
#endif
|
||||
|
||||
ContentRegistry::Settings::add<Widgets::Checkbox>("hex.builtin.setting.interface", "hex.builtin.setting.interface.window", "hex.builtin.setting.interface.restore_window_pos", false);
|
||||
|
||||
ContentRegistry::Settings::add<Widgets::ColorPicker>("hex.builtin.setting.hex_editor", "", "hex.builtin.setting.hex_editor.highlight_color", ImColor(0x80, 0x80, 0xC0, 0x60));
|
||||
ContentRegistry::Settings::add<Widgets::Checkbox>("hex.builtin.setting.hex_editor", "", "hex.builtin.setting.hex_editor.sync_scrolling", false);
|
||||
ContentRegistry::Settings::add<Widgets::SliderInteger>("hex.builtin.setting.hex_editor", "", "hex.builtin.setting.hex_editor.byte_padding", 0, 0, 50);
|
||||
ContentRegistry::Settings::add<Widgets::SliderInteger>("hex.builtin.setting.hex_editor", "", "hex.builtin.setting.hex_editor.char_padding", 0, 0, 50);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/* Fonts */
|
||||
{
|
||||
|
||||
ContentRegistry::Settings::add<Widgets::Checkbox>("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<bool>("hex.builtin.setting.interface", "hex.builtin.setting.interface.native_window_decorations", !getDefaultBorderlessWindowMode());
|
||||
ImHexApi::System::impl::setBorderlessWindowMode(borderlessWindowMode);
|
||||
}
|
||||
|
||||
static void loadFolderSettings() {
|
||||
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -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())
|
||||
|
@ -121,6 +121,5 @@ IMHEX_PLUGIN_SETUP("Built-in", "WerWolv", "Default ImHex functionality") {
|
||||
addToolbarItems();
|
||||
addGlobalUIItems();
|
||||
|
||||
handleBorderlessWindowMode();
|
||||
setupOutOfBoxExperience();
|
||||
}
|
||||
|
@ -35,11 +35,7 @@ static void detectSystemTheme() {
|
||||
auto error = RegQueryValueEx(hkey, "AppsUseLightTheme", nullptr, nullptr, reinterpret_cast<LPBYTE>(&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<bool>("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();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user