Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions examples/window_example/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ int main() {
// Create a new window (automatically registered)
std::shared_ptr<Window> window_ptr = std::make_shared<Window>();
window_ptr->SetTitle("Window Example");
window_ptr->SetTitleBarStyle(nativeapi::TitleBarStyle::Hidden);
window_ptr->SetSize({800, 600}, false);
window_ptr->SetMinimumSize({400, 300});
window_ptr->SetMaximumSize({1920, 1080});
Expand Down
36 changes: 35 additions & 1 deletion src/platform/macos/window_macos.mm
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,40 @@
// Key for associated objects (used by both window_macos.mm and window_manager_macos.mm)
const void* kWindowIdKey = &kWindowIdKey;

@interface NativeAPIWindow : NSWindow
@end

@implementation NativeAPIWindow

- (void)mouseUp:(NSEvent*)event {
if (event.clickCount == 2) {
if ((self.styleMask & NSWindowStyleMaskFullSizeContentView) &&
self.titlebarAppearsTransparent) {
NSPoint locationInWindow = [event locationInWindow];
NSRect contentLayoutRect = [self contentLayoutRect];
NSRect windowFrame = [[self contentView] frame];

NSRect titleBarRect = NSMakeRect(
contentLayoutRect.origin.x, contentLayoutRect.origin.y + contentLayoutRect.size.height,
contentLayoutRect.size.width, windowFrame.size.height - contentLayoutRect.size.height);

if (NSPointInRect(locationInWindow, titleBarRect)) {
NSString* action =
[[NSUserDefaults standardUserDefaults] stringForKey:@"AppleActionOnDoubleClick"];
if ([action isEqualToString:@"Minimize"]) {
[self miniaturize:nil];
} else {
[self performZoom:nil];
}
return;
}
}
}
[super mouseUp:event];
}

@end

namespace nativeapi {

// Private implementation class
Expand Down Expand Up @@ -39,7 +73,7 @@
if (native_window == nullptr) {
// Create new platform object
id = IdAllocator::Allocate<Window>();
ns_window = [[NSWindow alloc] init];
ns_window = [[NativeAPIWindow alloc] init];
ns_window.styleMask = NSWindowStyleMaskResizable | NSWindowStyleMaskTitled |
NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable;
// Store the ID as associated object
Expand Down