summaryrefslogtreecommitdiffstats
path: root/osdep
diff options
context:
space:
mode:
authorStefano Pigozzi <stefano.pigozzi@gmail.com>2014-10-09 21:23:54 +0200
committerStefano Pigozzi <stefano.pigozzi@gmail.com>2014-10-09 22:14:41 +0200
commitdba2b90d9a34055e98c9216bd305a5cb4fb01a3a (patch)
treeda5d649961ccc1ad9d3b812da24678b5433970a8 /osdep
parent58f62891fa99c8d4d0ebfc9c719134af753366e2 (diff)
downloadmpv-dba2b90d9a34055e98c9216bd305a5cb4fb01a3a.tar.bz2
mpv-dba2b90d9a34055e98c9216bd305a5cb4fb01a3a.tar.xz
libmpv/cocoa: don't start the event monitor
The event monitor is used to get keyboard events when there is no window, but since it is a global monitor to the current process, we don't want it in a library setting.
Diffstat (limited to 'osdep')
-rw-r--r--osdep/macosx_events.h2
-rw-r--r--osdep/macosx_events.m29
2 files changed, 21 insertions, 10 deletions
diff --git a/osdep/macosx_events.h b/osdep/macosx_events.h
index f3dfbdfea4..34d653c3de 100644
--- a/osdep/macosx_events.h
+++ b/osdep/macosx_events.h
@@ -26,6 +26,8 @@ struct input_ctx;
void cocoa_put_key(int keycode);
void cocoa_put_key_with_modifiers(int keycode, int modifiers);
+void cocoa_start_event_monitor(void);
+
void cocoa_init_apple_remote(void);
void cocoa_uninit_apple_remote(void);
diff --git a/osdep/macosx_events.m b/osdep/macosx_events.m
index 97ef93f405..71a9591134 100644
--- a/osdep/macosx_events.m
+++ b/osdep/macosx_events.m
@@ -45,6 +45,7 @@
- (BOOL)handleMediaKey:(NSEvent *)event;
- (NSEvent *)handleKey:(NSEvent *)event;
+- (void)startEventMonitor;
- (void)startAppleRemote;
- (void)stopAppleRemote;
- (void)startMediaKeys;
@@ -112,6 +113,11 @@ static int convert_key(unsigned key, unsigned charcode)
return charcode;
}
+void cocoa_start_event_monitor(void)
+{
+ [[EventsResponder sharedInstance] startEventMonitor];
+}
+
void cocoa_init_apple_remote(void)
{
[[EventsResponder sharedInstance] startAppleRemote];
@@ -211,16 +217,6 @@ void cocoa_set_input_context(struct input_ctx *input_context)
self = [super init];
if (self) {
_input_ready = [NSCondition new];
-
- [NSEvent addLocalMonitorForEventsMatchingMask:NSKeyDownMask|NSKeyUpMask
- handler:^(NSEvent *event) {
- BOOL equivalent = [[NSApp mainMenu] performKeyEquivalent:event];
- if (equivalent) {
- return (NSEvent *)nil;
- } else {
- return [self handleKey:event];
- }
- }];
}
return self;
}
@@ -254,6 +250,19 @@ void cocoa_set_input_context(struct input_ctx *input_context)
return YES;
}
+- (void)startEventMonitor
+{
+ [NSEvent addLocalMonitorForEventsMatchingMask:NSKeyDownMask|NSKeyUpMask
+ handler:^(NSEvent *event) {
+ BOOL equivalent = [[NSApp mainMenu] performKeyEquivalent:event];
+ if (equivalent) {
+ return (NSEvent *)nil;
+ } else {
+ return [self handleKey:event];
+ }
+ }];
+}
+
- (void)startAppleRemote
{
dispatch_async(dispatch_get_main_queue(), ^{