1/*****************************************************************************
2 * VLCMinimalVoutWindow.m: macOS minimal vout window
3 *****************************************************************************
4 * Copyright (C) 2007-2017 VLC authors and VideoLAN
5 * $Id: bd58f7d6e1c9eb019c0fe2a16d01dc23fc61ff50 $
6 *
7 * Authors: Pierre d'Herbemont <pdherbemont # videolan.org>
8 *          Felix Paul Kühne <fkuehne at videolan dot org>
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU Lesser General Public License as published by
12 * the Free Software Foundation; either version 2.1 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public License
21 * along with this program; if not, write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
24
25/*****************************************************************************
26 * Preamble
27 *****************************************************************************/
28
29#import "VLCMinimalVoutWindow.h"
30#import "misc.h"
31
32#import <Cocoa/Cocoa.h>
33
34@implementation VLCMinimalVoutWindow
35- (id)initWithContentRect:(NSRect)contentRect
36{
37    if( self = [super initWithContentRect:contentRect
38                                styleMask:NSBorderlessWindowMask
39                                  backing:NSBackingStoreBuffered
40                                    defer:NO])
41    {
42        initialFrame = contentRect;
43        [self setBackgroundColor:[NSColor blackColor]];
44        [self setHasShadow:YES];
45        [self setMovableByWindowBackground:YES];
46        [self center];
47    }
48    return self;
49}
50
51- (void)enterFullscreen
52{
53    NSScreen *screen = [self screen];
54
55    initialFrame = [self frame];
56    [self setFrame:[[self screen] frame] display:YES animate:YES];
57
58    NSApplicationPresentationOptions presentationOpts = [NSApp presentationOptions];
59    if ([screen hasMenuBar])
60        presentationOpts |= NSApplicationPresentationAutoHideMenuBar;
61    if ([screen hasMenuBar] || [screen hasDock])
62        presentationOpts |= NSApplicationPresentationAutoHideDock;
63    [NSApp setPresentationOptions:presentationOpts];
64}
65
66- (void)leaveFullscreen
67{
68    [NSApp setPresentationOptions: NSApplicationPresentationDefault];
69    [self setFrame:initialFrame display:YES animate:YES];
70}
71
72@end
73