mirror of
https://github.com/mpv-player/mpv
synced 2025-01-03 05:22:23 +00:00
cocoa: sync inputContext inside EventsResponder
This commit is contained in:
parent
78a266d599
commit
78a2d99de1
@ -318,10 +318,7 @@ int cocoa_main(mpv_main_fn mpv_main, int argc, char *argv[])
|
||||
macosx_finder_args_preinit(&argc, &argv);
|
||||
pthread_create(&playback_thread_id, NULL, playback_thread, &ctx);
|
||||
|
||||
[_eventsResponder.input_ready lock];
|
||||
while (!_eventsResponder.inputContext)
|
||||
[_eventsResponder.input_ready wait];
|
||||
[_eventsResponder.input_ready unlock];
|
||||
[[EventsResponder sharedInstance] waitForInputContext];
|
||||
|
||||
cocoa_run_runloop();
|
||||
|
||||
@ -378,10 +375,7 @@ void cocoa_stop_runloop(void)
|
||||
|
||||
void cocoa_set_input_context(struct input_ctx *input_context)
|
||||
{
|
||||
[_eventsResponder.input_ready lock];
|
||||
_eventsResponder.inputContext = input_context;
|
||||
[_eventsResponder.input_ready signal];
|
||||
[_eventsResponder.input_ready unlock];
|
||||
[EventsResponder sharedInstance].inputContext = input_context;
|
||||
}
|
||||
|
||||
void cocoa_post_fake_event(void)
|
||||
|
@ -36,6 +36,8 @@
|
||||
|
||||
@interface EventsResponder ()
|
||||
{
|
||||
struct input_ctx *_inputContext;
|
||||
NSCondition *_input_ready;
|
||||
CFMachPortRef _mk_tap_port;
|
||||
HIDRemote *_remote;
|
||||
}
|
||||
@ -188,9 +190,6 @@ void cocoa_put_key_with_modifiers(int keycode, int modifiers)
|
||||
|
||||
@implementation EventsResponder
|
||||
|
||||
@synthesize inputContext = _input_context;
|
||||
@synthesize input_ready = _input_ready;
|
||||
|
||||
+ (EventsResponder *)sharedInstance
|
||||
{
|
||||
static EventsResponder *responder = nil;
|
||||
@ -220,6 +219,27 @@ void cocoa_put_key_with_modifiers(int keycode, int modifiers)
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)waitForInputContext
|
||||
{
|
||||
[_input_ready lock];
|
||||
while (!self.inputContext)
|
||||
[_input_ready wait];
|
||||
[_input_ready unlock];
|
||||
}
|
||||
|
||||
- (void)setInputContext:(struct input_ctx *)ctx;
|
||||
{
|
||||
[_input_ready lock];
|
||||
_inputContext = ctx;
|
||||
[_input_ready signal];
|
||||
[_input_ready unlock];
|
||||
}
|
||||
|
||||
- (struct input_ctx *)inputContext
|
||||
{
|
||||
return _inputContext;
|
||||
}
|
||||
|
||||
- (BOOL)useAltGr
|
||||
{
|
||||
if (self.inputContext)
|
||||
|
@ -27,7 +27,9 @@ struct input_ctx;
|
||||
|
||||
+ (EventsResponder *)sharedInstance;
|
||||
|
||||
/// Blocks until inputContext is present.
|
||||
- (void)waitForInputContext;
|
||||
|
||||
@property(nonatomic, assign) struct input_ctx *inputContext;
|
||||
@property(nonatomic, retain) NSCondition *input_ready;
|
||||
|
||||
@end
|
||||
|
Loading…
Reference in New Issue
Block a user