summaryrefslogtreecommitdiffstats
path: root/osdep/macosx_application_objc.h
diff options
context:
space:
mode:
authorStefano Pigozzi <stefano.pigozzi@gmail.com>2013-02-23 18:28:22 +0100
committerStefano Pigozzi <stefano.pigozzi@gmail.com>2013-05-12 15:27:54 +0200
commitafdc9c4ae2e69a9ced6c3c6580df19edfedea36a (patch)
tree552186adca34cd6c1b6fb89656badde9e140a297 /osdep/macosx_application_objc.h
parent6a2a8880e92442a70696cac217773f1078023084 (diff)
downloadmpv-afdc9c4ae2e69a9ced6c3c6580df19edfedea36a.tar.bz2
mpv-afdc9c4ae2e69a9ced6c3c6580df19edfedea36a.tar.xz
OSX: use native Cocoa's event loop
Schedule mpv's playloop as a high frequency timer inside the main Cocoa event loop. This has the benefit to allow accessing menus as well as resizing the window without the playback being blocked and allows to remove countless hacks from the code that involved manually pumping the event loop as well simulating manually some of the Cocoa default behaviours. A huge improvement consists in removing NSApplicationLoad. This is a C function defined in the Cocoa header and implements a minimal OSX application under ther hood so that you can use the Cocoa GUI toolkit from C/C++ without having to respect the Cocoa standards in terms of application initialization. This was bad because the behaviour implemented by NSApplicationLoad was hard to customize and had several gotchas especially in the menu department. mpv was changed to be just a nib-less application. All the Cocoa part is still generated in code but the event handling is now not dissimilar to what is present in a stock Mac application. As a part of reviewing the initialization process, I also removed all of `osdep/macosx_finder_args`. The useful parts of the code were moved to `osdep/macosx_appication` which has the broaded responsibility of managing the full lifecycle of the Cocoa application. By consequence the `--enable-macosx-finder` configure switch was killed as well, as this feature is always enabled. Another change the users will notice is that when using a bundle the `--quiet` option will be inserted much earlier in the initializaion process. This results in mpv not spamming mpv.log anymore with all the initialization outputs.
Diffstat (limited to 'osdep/macosx_application_objc.h')
-rw-r--r--osdep/macosx_application_objc.h40
1 files changed, 40 insertions, 0 deletions
diff --git a/osdep/macosx_application_objc.h b/osdep/macosx_application_objc.h
new file mode 100644
index 0000000000..340b2a9b1c
--- /dev/null
+++ b/osdep/macosx_application_objc.h
@@ -0,0 +1,40 @@
+/*
+ * This file is part of mpv.
+ *
+ * mpv is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * mpv is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with mpv; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#import <Cocoa/Cocoa.h>
+#include "osdep/macosx_application.h"
+
+@interface Application : NSObject<NSApplicationDelegate>
+- (void)initialize_menu;
+- (void)registerSelector:(SEL)selector forKey:(MPMenuKey)key;
+- (void)call_callback;
+- (void)schedule_timer;
+- (void)stopPlayback;
+
+@property(nonatomic, assign) play_loop_callback callback;
+@property(nonatomic, assign) should_stop_callback shouldStopPlayback;
+@property(nonatomic, assign) void *context;
+@property(nonatomic, assign) struct input_ctx *inputContext;
+@property(nonatomic, assign) struct mp_fifo *keyFIFO;
+@property(nonatomic, retain) NSTimer *callbackTimer;
+@property(nonatomic, retain) NSMutableDictionary *menuItems;
+@property(nonatomic, retain) NSArray *files;
+@property(nonatomic, retain) NSMutableArray *argumentsList;
+@property(nonatomic, assign) BOOL willStopOnOpenEvent;
+@end
+