From 78a2d99de130cc8e6adc18c5d7a987c5c8b2d2b3 Mon Sep 17 00:00:00 2001 From: FRAU KOUJIRO Date: Tue, 15 Apr 2014 17:09:47 -0700 Subject: cocoa: sync inputContext inside EventsResponder --- osdep/macosx_events.m | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'osdep/macosx_events.m') diff --git a/osdep/macosx_events.m b/osdep/macosx_events.m index 7a525f7dd5..c8da555fa1 100644 --- a/osdep/macosx_events.m +++ b/osdep/macosx_events.m @@ -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) -- cgit v1.2.3