]> git.sesse.net Git - vlc/blob - modules/gui/minimal_macosx/intf.m
Remove E_()
[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 #ifdef HAVE_CONFIG_H
34 # include "config.h"
35 #endif
36
37 #include <vlc/vlc.h>
38
39 #include <vlc_keys.h>
40
41 #include <vlc_input.h>
42
43 #import <intf.h>
44
45 /*****************************************************************************
46  * Local prototypes.
47  *****************************************************************************/
48 static void Run ( intf_thread_t *p_intf );
49
50 /*****************************************************************************
51  * OpenIntf: initialize interface
52  *****************************************************************************/
53 int OpenIntf ( vlc_object_t *p_this )
54 {
55     intf_thread_t *p_intf = (intf_thread_t*) p_this;
56
57     p_intf->p_sys = malloc( sizeof( intf_sys_t ) );
58     if( p_intf->p_sys == NULL )
59     {
60         return( 1 );
61     }
62
63     memset( p_intf->p_sys, 0, sizeof( *p_intf->p_sys ) );
64
65     p_intf->pf_run = Run;
66     p_intf->b_should_run_on_first_thread = true;
67
68     return VLC_SUCCESS;
69 }
70
71 /*****************************************************************************
72  * CloseIntf: destroy interface
73  *****************************************************************************/
74 void CloseIntf ( vlc_object_t *p_this )
75 {
76     intf_thread_t *p_intf = (intf_thread_t*) p_this;
77
78     free( p_intf->p_sys );
79 }
80
81 /* Dock Connection */
82 typedef struct CPSProcessSerNum
83 {
84         UInt32                lo;
85         UInt32                hi;
86 } CPSProcessSerNum;
87
88 extern OSErr    CPSGetCurrentProcess( CPSProcessSerNum *psn);
89 extern OSErr    CPSEnableForegroundOperation( CPSProcessSerNum *psn, UInt32 _arg2, UInt32 _arg3, UInt32 _arg4, UInt32 _arg5);
90 extern OSErr    CPSSetFrontProcess( CPSProcessSerNum *psn);
91
92 /*****************************************************************************
93  * Run: main loop
94  *****************************************************************************/
95 static void Run( intf_thread_t *p_intf )
96 {
97     sigset_t set;
98
99     /* Do it again - for some unknown reason, vlc_thread_create() often
100      * fails to go to real-time priority with the first launched thread
101      * (???) --Meuuh */
102     vlc_thread_set_priority( p_intf, VLC_THREAD_PRIORITY_LOW );
103
104     /* Make sure the "force quit" menu item does quit instantly.
105      * VLC overrides SIGTERM which is sent by the "force quit"
106      * menu item to make sure deamon mode quits gracefully, so
107      * we un-override SIGTERM here. */
108     sigemptyset( &set );
109     sigaddset( &set, SIGTERM );
110     pthread_sigmask( SIG_UNBLOCK, &set, NULL );
111     CPSProcessSerNum PSN;
112     NSAutoreleasePool   *pool = [[NSAutoreleasePool alloc] init];
113     [NSApplication sharedApplication];
114     if (!CPSGetCurrentProcess(&PSN))
115         if (!CPSEnableForegroundOperation(&PSN,0x03,0x3C,0x2C,0x1103))
116             if (!CPSSetFrontProcess(&PSN))
117                 [NSApplication sharedApplication];
118     [NSApp run];
119     [pool release];
120 }
121