From 1d6b02f304823e6bc79e9dab3d6d2ae031fbf146 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 9 Jun 2014 13:04:59 +0800 Subject: [PATCH] mac: Restore presentation options when leaving kiosk mode, fixes #272. --- atom/browser/native_window_mac.h | 3 +++ atom/browser/native_window_mac.mm | 9 +++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/atom/browser/native_window_mac.h b/atom/browser/native_window_mac.h index 5dc8aa6b8f6..3739517e78e 100644 --- a/atom/browser/native_window_mac.h +++ b/atom/browser/native_window_mac.h @@ -95,6 +95,9 @@ class NativeWindowMac : public NativeWindow { NSInteger attention_request_id_; // identifier from requestUserAttention + // The presentation options before entering kiosk mode. + NSApplicationPresentationOptions kiosk_options_; + // For system drag, the whole window is draggable and the non-draggable areas // have to been explicitly excluded. std::vector system_drag_exclude_areas_; diff --git a/atom/browser/native_window_mac.mm b/atom/browser/native_window_mac.mm index 634b052cb01..891764a8ad7 100644 --- a/atom/browser/native_window_mac.mm +++ b/atom/browser/native_window_mac.mm @@ -409,7 +409,8 @@ void NativeWindowMac::FlashFrame(bool flash) { } void NativeWindowMac::SetKiosk(bool kiosk) { - if (kiosk) { + if (kiosk && !is_kiosk_) { + kiosk_options_ = [NSApp currentSystemPresentationOptions]; NSApplicationPresentationOptions options = NSApplicationPresentationHideDock + NSApplicationPresentationHideMenuBar + @@ -421,10 +422,10 @@ void NativeWindowMac::SetKiosk(bool kiosk) { [NSApp setPresentationOptions:options]; is_kiosk_ = true; SetFullscreen(true); - } else { - [NSApp setPresentationOptions:[NSApp currentSystemPresentationOptions]]; - is_kiosk_ = false; + } else if (!kiosk && is_kiosk_) { + is_kiosk_ = false; SetFullscreen(false); + [NSApp setPresentationOptions:kiosk_options_]; } }