]> git.sesse.net Git - vlc/blob - modules/gui/minimal_macosx/VLCMinimalVoutWindow.m
minimal_macosX: relicense to LGPL
[vlc] / modules / gui / minimal_macosx / VLCMinimalVoutWindow.m
1 /*****************************************************************************
2  * VLCMinimalVoutWindow.m: MacOS X Minimal interface window
3  *****************************************************************************
4  * Copyright (C) 2007-2012 VLC authors and VideoLAN
5  * $Id$
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 it 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, Foundation, Foundation,
22  * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23  *****************************************************************************/
24
25 /*****************************************************************************
26  * Preamble
27  *****************************************************************************/
28 #import "intf.h"
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 styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO])
38     {
39         initialFrame = contentRect;
40         [self setBackgroundColor:[NSColor blackColor]];
41         [self setHasShadow:YES];
42         [self setMovableByWindowBackground: YES];
43         [self center];
44     }
45     return self;
46 }
47
48 - (void)enterFullscreen
49 {
50     NSScreen *screen = [self screen];
51
52     initialFrame = [self frame];
53     [self setFrame:[[self screen] frame] display:YES animate:YES];
54
55     NSApplicationPresentationOptions presentationOpts = [NSApp presentationOptions];
56     if ([screen hasMenuBar])
57         presentationOpts |= NSApplicationPresentationAutoHideMenuBar;
58     if ([screen hasMenuBar] || [screen hasDock])
59         presentationOpts |= NSApplicationPresentationAutoHideDock;
60     [NSApp setPresentationOptions:presentationOpts];
61 }
62
63 - (void)leaveFullscreen
64 {
65     [NSApp setPresentationOptions: NSApplicationPresentationDefault];
66     [self setFrame:initialFrame display:YES animate:YES];
67 }
68
69 @end