]> git.sesse.net Git - vlc/blob - modules/gui/minimal_macosx/intf.m
Removes trailing spaces. Removes tabs.
[vlc] / modules / gui / minimal_macosx / intf.m
1 /*****************************************************************************
2  * intf.m: MacOS X interface module
3  *****************************************************************************
4  * Copyright (C) 2002-2007 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
8  *          Christophe Massiot <massiot@via.ecp.fr>
9  *          Derk-Jan Hartman <hartman at videolan.org>
10  *          Felix K\9fhne <fkuehne at videolan dot org>
11  *
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation; either version 2 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, write to the Free Software
24  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
25  *****************************************************************************/
26
27 /*****************************************************************************
28  * Preamble
29  *****************************************************************************/
30 #include <stdlib.h>                                      /* malloc(), free() */
31 #include <sys/param.h>                                    /* for MAXPATHLEN */
32 #include <string.h>
33 #include <vlc/vlc.h>
34
35 #include <vlc_keys.h>
36
37 #include <vlc_input.h>
38
39 #import <intf.h>
40
41 /*****************************************************************************
42  * Local prototypes.
43  *****************************************************************************/
44 static void Run ( intf_thread_t *p_intf );
45
46 /*****************************************************************************
47  * OpenIntf: initialize interface
48  *****************************************************************************/
49 int E_(OpenIntf) ( vlc_object_t *p_this )
50 {
51     intf_thread_t *p_intf = (intf_thread_t*) p_this;
52
53     p_intf->p_sys = malloc( sizeof( intf_sys_t ) );
54     if( p_intf->p_sys == NULL )
55     {
56         return( 1 );
57     }
58
59     memset( p_intf->p_sys, 0, sizeof( *p_intf->p_sys ) );
60
61     p_intf->pf_run = Run;
62
63     return VLC_SUCCESS;
64 }
65
66 /*****************************************************************************
67  * CloseIntf: destroy interface
68  *****************************************************************************/
69 void E_(CloseIntf) ( vlc_object_t *p_this )
70 {
71     intf_thread_t *p_intf = (intf_thread_t*) p_this;
72
73     free( p_intf->p_sys );
74 }
75
76 /* Dock Connection */
77 typedef struct CPSProcessSerNum
78 {
79         UInt32                lo;
80         UInt32                hi;
81 } CPSProcessSerNum;
82
83 extern OSErr    CPSGetCurrentProcess( CPSProcessSerNum *psn);
84 extern OSErr    CPSEnableForegroundOperation( CPSProcessSerNum *psn, UInt32 _arg2, UInt32 _arg3, UInt32 _arg4, UInt32 _arg5);
85 extern OSErr    CPSSetFrontProcess( CPSProcessSerNum *psn);
86
87 /*****************************************************************************
88  * Run: main loop
89  *****************************************************************************/
90 static void Run( intf_thread_t *p_intf )
91 {
92     sigset_t set;
93
94     /* Do it again - for some unknown reason, vlc_thread_create() often
95      * fails to go to real-time priority with the first launched thread
96      * (???) --Meuuh */
97     vlc_thread_set_priority( p_intf, VLC_THREAD_PRIORITY_LOW );
98
99     /* Make sure the "force quit" menu item does quit instantly.
100      * VLC overrides SIGTERM which is sent by the "force quit"
101      * menu item to make sure deamon mode quits gracefully, so
102      * we un-override SIGTERM here. */
103     sigemptyset( &set );
104     sigaddset( &set, SIGTERM );
105     pthread_sigmask( SIG_UNBLOCK, &set, NULL );
106     CPSProcessSerNum PSN;
107     NSAutoreleasePool   *pool = [[NSAutoreleasePool alloc] init];
108     [NSApplication sharedApplication];
109     if (!CPSGetCurrentProcess(&PSN))
110         if (!CPSEnableForegroundOperation(&PSN,0x03,0x3C,0x2C,0x1103))
111             if (!CPSSetFrontProcess(&PSN))
112                 [NSApplication sharedApplication];
113     [NSApp run];
114     [pool release];
115 }
116