From 3c7e5e47b892f03e9ab57704966f7c7325b169e2 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 25 Nov 2014 13:16:51 +0800 Subject: [PATCH] mac: Implement window state events --- atom/browser/native_window_mac.mm | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/atom/browser/native_window_mac.mm b/atom/browser/native_window_mac.mm index 18827e91bccb..accd24d01efc 100644 --- a/atom/browser/native_window_mac.mm +++ b/atom/browser/native_window_mac.mm @@ -81,11 +81,36 @@ static const CGFloat kAtomWindowCornerRadius = 4.0; shell_->ClipWebView(); } +- (void)windowDidMiniaturize:(NSNotification*)notification { + shell_->NotifyWindowMinimize(); +} + +- (void)windowDidDeminiaturize:(NSNotification*)notification { + shell_->NotifyWindowRestore(); +} + +- (BOOL)windowShouldZoom:(NSWindow*)window toFrame:(NSRect)newFrame { + // Cocoa doen't have concept of maximize/unmaximize, so wee need to emulate + // them by calculating size change when zooming. + if (newFrame.size.width < [window frame].size.width || + newFrame.size.height < [window frame].size.height) + shell_->NotifyWindowUnmaximize(); + else + shell_->NotifyWindowMaximize(); + return YES; +} + +- (void)windowDidEnterFullScreen:(NSNotification*)notification { + shell_->NotifyWindowEnterFullScreen(); +} + - (void)windowDidExitFullScreen:(NSNotification*)notification { if (!shell_->has_frame()) { NSWindow* window = shell_->GetNativeWindow(); [[window standardWindowButton:NSWindowFullScreenButton] setHidden:YES]; } + + shell_->NotifyWindowLeaveFullScreen(); } - (void)windowWillClose:(NSNotification*)notification {