summaryrefslogtreecommitdiffstats
path: root/osdep/macosx_application.m
diff options
context:
space:
mode:
authorAkemi <der.richter@gmx.de>2017-02-25 21:56:59 +0100
committerAkemi <der.richter@gmx.de>2017-03-26 20:26:18 +0200
commitf8a223b7aca08491e22438df0f1ea233d602907c (patch)
tree4547edcf3b4f0ed7b37bdd1cdf42221328964dff /osdep/macosx_application.m
parentafbd657bb8e955accf8022c96e867973c1fb0a41 (diff)
downloadmpv-f8a223b7aca08491e22438df0f1ea233d602907c.tar.bz2
mpv-f8a223b7aca08491e22438df0f1ea233d602907c.tar.xz
osx: initial Touch Bar support
Diffstat (limited to 'osdep/macosx_application.m')
-rw-r--r--osdep/macosx_application.m46
1 files changed, 46 insertions, 0 deletions
diff --git a/osdep/macosx_application.m b/osdep/macosx_application.m
index d7cdf4b832..cccd60b4e2 100644
--- a/osdep/macosx_application.m
+++ b/osdep/macosx_application.m
@@ -17,10 +17,12 @@
#include <stdio.h>
#include <pthread.h>
+#include "config.h"
#include "mpv_talloc.h"
#include "common/msg.h"
#include "input/input.h"
+#include "player/client.h"
#import "osdep/macosx_application_objc.h"
#include "osdep/macosx_compat.h"
@@ -28,6 +30,10 @@
#include "osdep/threads.h"
#include "osdep/main-fn.h"
+#if HAVE_MACOS_TOUCHBAR
+#import "osdep/macosx_touchbar.h"
+#endif
+
#define MPV_PROTOCOL @"mpv://"
// Whether the NSApplication singleton was created. If this is false, we are
@@ -106,6 +112,38 @@ static void terminate_cocoa_application(void)
[super dealloc];
}
+#if HAVE_MACOS_TOUCHBAR
+- (NSTouchBar *)makeTouchBar
+{
+ TouchBar *tBar = [[TouchBar alloc] init];
+ [tBar setApp:self];
+ tBar.delegate = tBar;
+ tBar.customizationIdentifier = customID;
+ tBar.defaultItemIdentifiers = @[play, previousItem, nextItem, seekBar];
+ tBar.customizationAllowedItemIdentifiers = @[play, seekBar, previousItem,
+ nextItem, previousChapter, nextChapter, cycleAudio, cycleSubtitle,
+ currentPosition, timeLeft];
+ return tBar;
+}
+
+- (void)toggleTouchBarMenu
+{
+ [NSApp toggleTouchBarCustomizationPalette:self];
+}
+#endif
+
+- (void)processEvent:(struct mpv_event *)event
+{
+#if HAVE_MACOS_TOUCHBAR
+ [(TouchBar *)self.touchBar processEvent:event];
+#endif
+}
+
+- (void)queueCommand:(char *)cmd
+{
+ [_eventsResponder queueCommand:cmd];
+}
+
#define _R(P, T, E, K) \
{ \
NSMenuItem *tmp = [self menuItemWithParent:(P) title:(T) \
@@ -139,6 +177,13 @@ static void terminate_cocoa_application(void)
NSMenu *menu = [[NSMenu alloc] initWithTitle:@"Window"];
_R(menu, @"Minimize", @"m", MPM_MINIMIZE)
_R(menu, @"Zoom", @"z", MPM_ZOOM)
+
+#if HAVE_MACOS_TOUCHBAR
+ [menu addItem:[NSMenuItem separatorItem]];
+ [self menuItemWithParent:menu title:@"Customize Touch Bar…"
+ action:@selector(toggleTouchBarMenu) keyEquivalent: @""];
+#endif
+
return [menu autorelease];
}
@@ -322,6 +367,7 @@ int cocoa_main(int argc, char *argv[])
{
@autoreleasepool {
application_instantiated = true;
+ [[EventsResponder sharedInstance] setIsApplication:YES];
struct playback_thread_ctx ctx = {0};
ctx.argc = &argc;