summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--DOCS/man/options.rst5
-rw-r--r--input/input.c7
-rw-r--r--osdep/macosx_events.h2
-rw-r--r--osdep/macosx_events.m29
-rw-r--r--player/client.c3
5 files changed, 35 insertions, 11 deletions
diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst
index 09e5b0b520..1c49d6754a 100644
--- a/DOCS/man/options.rst
+++ b/DOCS/man/options.rst
@@ -2228,6 +2228,11 @@ Input
(This option was renamed from ``--input-x11-keyboard``.)
+``--input-app-events=<yes|no>``
+ (OS X only)
+ Enable/disable application wide keyboard events so that keyboard shortcuts
+ can be processed without a window. Enabled by default (except for libmpv).
+
OSD
---
diff --git a/input/input.c b/input/input.c
index 35377251d1..439a0cf4fa 100644
--- a/input/input.c
+++ b/input/input.c
@@ -173,6 +173,7 @@ struct input_opts {
int use_alt_gr;
int use_appleremote;
int use_media_keys;
+ int use_app_events;
int default_bindings;
int enable_mouse_movements;
int vo_key_input;
@@ -204,6 +205,7 @@ const struct m_sub_options input_config = {
#if HAVE_COCOA
OPT_FLAG("appleremote", use_appleremote, CONF_GLOBAL),
OPT_FLAG("media-keys", use_media_keys, CONF_GLOBAL),
+ OPT_FLAG("app-events", use_app_events, CONF_GLOBAL),
#endif
{0}
},
@@ -219,6 +221,7 @@ const struct m_sub_options input_config = {
#if HAVE_COCOA
.use_appleremote = 1,
.use_media_keys = 1,
+ .use_app_events = 1,
#endif
.default_bindings = 1,
.vo_key_input = 1,
@@ -1276,6 +1279,10 @@ void mp_input_load(struct input_ctx *ictx)
}
#if HAVE_COCOA
+ if (input_conf->use_app_events) {
+ cocoa_start_event_monitor();
+ }
+
if (input_conf->use_appleremote) {
cocoa_init_apple_remote();
ictx->using_ar = true;
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(), ^{
diff --git a/player/client.c b/player/client.c
index ff94c517a6..c0b73977d3 100644
--- a/player/client.c
+++ b/player/client.c
@@ -405,8 +405,9 @@ mpv_handle *mpv_create(void)
mpv_set_option_string(ctx, "input-default-bindings", "no");
mpv_set_option_string(ctx, "input-vo-keyboard", "no");
mpv_set_option_string(ctx, "input-lirc", "no");
- mpv_set_option_string(ctx, "input-media-keys", "no");
mpv_set_option_string(ctx, "input-appleremote", "no");
+ mpv_set_option_string(ctx, "input-media-keys", "no");
+ mpv_set_option_string(ctx, "input-app-events", "no");
} else {
mp_destroy(mpctx);
}