mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-03-30 21:05:56 -05:00
impr: Hide window on macOS when close button is pressed
This commit is contained in:
@@ -856,4 +856,11 @@ namespace hex {
|
||||
return ImAlphaBlendColors(a.value(), b.value());
|
||||
}
|
||||
|
||||
extern "C" void macOSCloseButtonPressed() {
|
||||
auto windowHandle = ImHexApi::System::getMainWindowHandle();
|
||||
|
||||
glfwHideWindow(windowHandle);
|
||||
glfwIconifyWindow(windowHandle);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -48,6 +48,17 @@
|
||||
return [[NSScreen mainScreen] backingScaleFactor];
|
||||
}
|
||||
|
||||
void macOSCloseButtonPressed(void);
|
||||
|
||||
@interface CloseButtonHandler : NSObject
|
||||
@end
|
||||
|
||||
@implementation CloseButtonHandler
|
||||
- (void)pressed:(id)sender {
|
||||
macOSCloseButtonPressed();
|
||||
}
|
||||
@end
|
||||
|
||||
void setupMacosWindowStyle(GLFWwindow *window, bool borderlessWindowMode) {
|
||||
NSWindow* cocoaWindow = glfwGetCocoaWindow(window);
|
||||
|
||||
@@ -61,6 +72,10 @@
|
||||
[cocoaWindow setHasShadow:YES];
|
||||
[cocoaWindow setBackgroundColor:[NSColor colorWithWhite: 0 alpha: 0.001f]];
|
||||
}
|
||||
|
||||
NSButton *closeButton = [cocoaWindow standardWindowButton:NSWindowCloseButton];
|
||||
[closeButton setAction:@selector(pressed:)];
|
||||
[closeButton setTarget:[CloseButtonHandler alloc]];
|
||||
}
|
||||
|
||||
bool isMacosFullScreenModeEnabled(GLFWwindow *window) {
|
||||
|
||||
Reference in New Issue
Block a user