]> git.sesse.net Git - vlc/blob - modules/gui/minimal_macosx/misc.m
ncurses: fix exit
[vlc] / modules / gui / minimal_macosx / misc.m
1 /*****************************************************************************
2  * misc.m: custom code
3  *****************************************************************************
4  * Copyright (C) 2012 VLC authors and VideoLAN
5  * $Id$
6  *
7  * Authors: Felix Paul Kühne <fkuehne at videolan dot org>
8  *          David Fuhrmann <david dot fuhrmann at googlemail dot com>
9  *          Pierre d'Herbemont <pdherbemont # videolan dot org>
10  *
11  * This program is free software; you can redistribute it and/or modify it
12  * under the terms of the GNU Lesser General Public License as published by
13  * the Free Software Foundation; either version 2.1 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Lesser General Public License for more details.
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * along with this program; if not, write to the Free Software Foundation,
23  * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
24  *****************************************************************************/
25
26 #import "misc.h"
27
28 @implementation NSScreen (VLCAdditions)
29
30 - (BOOL)hasMenuBar
31 {
32     return ([self displayID] == [[[NSScreen screens] objectAtIndex:0] displayID]);
33 }
34
35 - (BOOL)hasDock
36 {
37     NSRect screen_frame = [self frame];
38     NSRect screen_visible_frame = [self visibleFrame];
39     CGFloat f_menu_bar_thickness = [self hasMenuBar] ? [[NSStatusBar systemStatusBar] thickness] : 0.0;
40
41     BOOL b_found_dock = NO;
42     if (screen_visible_frame.size.width < screen_frame.size.width)
43         b_found_dock = YES;
44     else if (screen_visible_frame.size.height + f_menu_bar_thickness < screen_frame.size.height)
45         b_found_dock = YES;
46
47     return b_found_dock;
48 }
49
50 - (CGDirectDisplayID)displayID
51 {
52     return (CGDirectDisplayID)[[[self deviceDescription] objectForKey: @"NSScreenNumber"] intValue];
53 }
54
55 @end