mirror of https://github.com/AxioDL/boo.git
Use recursive_mutex on AppKit API boundaries
This commit is contained in:
parent
a99bddc905
commit
98bf80a9b9
|
@ -139,7 +139,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
std::mutex m_callbackMutex;
|
||||
std::recursive_mutex m_callbackMutex;
|
||||
IWindowCallback* m_callback = nullptr;
|
||||
void waitForRetrace(IAudioVoiceEngine* voxEngine)
|
||||
{
|
||||
|
@ -223,7 +223,7 @@ public:
|
|||
|
||||
void _setCallback(IWindowCallback* cb)
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(m_callbackMutex);
|
||||
std::lock_guard<std::recursive_mutex> lk(m_callbackMutex);
|
||||
m_callback = cb;
|
||||
}
|
||||
|
||||
|
@ -382,7 +382,7 @@ public:
|
|||
|
||||
void _setCallback(IWindowCallback* cb)
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(m_callbackMutex);
|
||||
std::lock_guard<std::recursive_mutex> lk(m_callbackMutex);
|
||||
m_callback = cb;
|
||||
}
|
||||
|
||||
|
@ -484,7 +484,7 @@ IGraphicsContext* _GraphicsContextCocoaMetalNew(IGraphicsContext::EGraphicsAPI a
|
|||
|
||||
- (BOOL)hasMarkedText
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(booContext->m_callbackMutex);
|
||||
std::lock_guard<std::recursive_mutex> lk(booContext->m_callbackMutex);
|
||||
if (booContext->m_callback)
|
||||
{
|
||||
boo::ITextInputCallback* textCb = booContext->m_callback->getTextInputCallback();
|
||||
|
@ -496,7 +496,7 @@ IGraphicsContext* _GraphicsContextCocoaMetalNew(IGraphicsContext::EGraphicsAPI a
|
|||
|
||||
- (NSRange)markedRange
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(booContext->m_callbackMutex);
|
||||
std::lock_guard<std::recursive_mutex> lk(booContext->m_callbackMutex);
|
||||
if (booContext->m_callback)
|
||||
{
|
||||
boo::ITextInputCallback* textCb = booContext->m_callback->getTextInputCallback();
|
||||
|
@ -511,7 +511,7 @@ IGraphicsContext* _GraphicsContextCocoaMetalNew(IGraphicsContext::EGraphicsAPI a
|
|||
|
||||
- (NSRange)selectedRange
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(booContext->m_callbackMutex);
|
||||
std::lock_guard<std::recursive_mutex> lk(booContext->m_callbackMutex);
|
||||
if (booContext->m_callback)
|
||||
{
|
||||
boo::ITextInputCallback* textCb = booContext->m_callback->getTextInputCallback();
|
||||
|
@ -526,7 +526,7 @@ IGraphicsContext* _GraphicsContextCocoaMetalNew(IGraphicsContext::EGraphicsAPI a
|
|||
|
||||
- (void)setMarkedText:(id)aString selectedRange:(NSRange)selectedRange replacementRange:(NSRange)replacementRange
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(booContext->m_callbackMutex);
|
||||
std::lock_guard<std::recursive_mutex> lk(booContext->m_callbackMutex);
|
||||
if (booContext->m_callback)
|
||||
{
|
||||
boo::ITextInputCallback* textCb = booContext->m_callback->getTextInputCallback();
|
||||
|
@ -545,7 +545,7 @@ IGraphicsContext* _GraphicsContextCocoaMetalNew(IGraphicsContext::EGraphicsAPI a
|
|||
|
||||
- (void)unmarkText
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(booContext->m_callbackMutex);
|
||||
std::lock_guard<std::recursive_mutex> lk(booContext->m_callbackMutex);
|
||||
if (booContext->m_callback)
|
||||
{
|
||||
boo::ITextInputCallback* textCb = booContext->m_callback->getTextInputCallback();
|
||||
|
@ -568,7 +568,7 @@ IGraphicsContext* _GraphicsContextCocoaMetalNew(IGraphicsContext::EGraphicsAPI a
|
|||
|
||||
- (NSAttributedString*)attributedSubstringForProposedRange:(NSRange)aRange actualRange:(NSRangePointer)actualRange
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(booContext->m_callbackMutex);
|
||||
std::lock_guard<std::recursive_mutex> lk(booContext->m_callbackMutex);
|
||||
if (booContext->m_callback)
|
||||
{
|
||||
boo::ITextInputCallback* textCb = booContext->m_callback->getTextInputCallback();
|
||||
|
@ -590,7 +590,7 @@ IGraphicsContext* _GraphicsContextCocoaMetalNew(IGraphicsContext::EGraphicsAPI a
|
|||
|
||||
- (void)insertText:(id)aString replacementRange:(NSRange)replacementRange
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(booContext->m_callbackMutex);
|
||||
std::lock_guard<std::recursive_mutex> lk(booContext->m_callbackMutex);
|
||||
if (booContext->m_callback)
|
||||
{
|
||||
boo::ITextInputCallback* textCb = booContext->m_callback->getTextInputCallback();
|
||||
|
@ -608,7 +608,7 @@ IGraphicsContext* _GraphicsContextCocoaMetalNew(IGraphicsContext::EGraphicsAPI a
|
|||
|
||||
- (NSUInteger)characterIndexForPoint:(NSPoint)aPoint
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(booContext->m_callbackMutex);
|
||||
std::lock_guard<std::recursive_mutex> lk(booContext->m_callbackMutex);
|
||||
if (booContext->m_callback)
|
||||
{
|
||||
boo::ITextInputCallback* textCb = booContext->m_callback->getTextInputCallback();
|
||||
|
@ -627,7 +627,7 @@ IGraphicsContext* _GraphicsContextCocoaMetalNew(IGraphicsContext::EGraphicsAPI a
|
|||
|
||||
- (NSRect)firstRectForCharacterRange:(NSRange)aRange actualRange:(NSRangePointer)actualRange
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(booContext->m_callbackMutex);
|
||||
std::lock_guard<std::recursive_mutex> lk(booContext->m_callbackMutex);
|
||||
if (booContext->m_callback)
|
||||
{
|
||||
boo::ITextInputCallback* textCb = booContext->m_callback->getTextInputCallback();
|
||||
|
@ -678,7 +678,7 @@ static inline boo::EMouseButton getButton(NSEvent* event)
|
|||
|
||||
- (void)mouseDown:(NSEvent*)theEvent
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(booContext->m_callbackMutex);
|
||||
std::lock_guard<std::recursive_mutex> lk(booContext->m_callbackMutex);
|
||||
if (!booContext->m_callback)
|
||||
return;
|
||||
NSPoint liw = [parentView convertPoint:[theEvent locationInWindow] fromView:nil];
|
||||
|
@ -697,7 +697,7 @@ static inline boo::EMouseButton getButton(NSEvent* event)
|
|||
|
||||
- (void)mouseUp:(NSEvent*)theEvent
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(booContext->m_callbackMutex);
|
||||
std::lock_guard<std::recursive_mutex> lk(booContext->m_callbackMutex);
|
||||
if (!booContext->m_callback)
|
||||
return;
|
||||
NSPoint liw = [parentView convertPoint:[theEvent locationInWindow] fromView:nil];
|
||||
|
@ -716,7 +716,7 @@ static inline boo::EMouseButton getButton(NSEvent* event)
|
|||
|
||||
- (void)rightMouseDown:(NSEvent*)theEvent
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(booContext->m_callbackMutex);
|
||||
std::lock_guard<std::recursive_mutex> lk(booContext->m_callbackMutex);
|
||||
if (!booContext->m_callback)
|
||||
return;
|
||||
NSPoint liw = [parentView convertPoint:[theEvent locationInWindow] fromView:nil];
|
||||
|
@ -735,7 +735,7 @@ static inline boo::EMouseButton getButton(NSEvent* event)
|
|||
|
||||
- (void)rightMouseUp:(NSEvent*)theEvent
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(booContext->m_callbackMutex);
|
||||
std::lock_guard<std::recursive_mutex> lk(booContext->m_callbackMutex);
|
||||
if (!booContext->m_callback)
|
||||
return;
|
||||
NSPoint liw = [parentView convertPoint:[theEvent locationInWindow] fromView:nil];
|
||||
|
@ -754,7 +754,7 @@ static inline boo::EMouseButton getButton(NSEvent* event)
|
|||
|
||||
- (void)otherMouseDown:(NSEvent*)theEvent
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(booContext->m_callbackMutex);
|
||||
std::lock_guard<std::recursive_mutex> lk(booContext->m_callbackMutex);
|
||||
if (!booContext->m_callback)
|
||||
return;
|
||||
boo::EMouseButton button = getButton(theEvent);
|
||||
|
@ -775,7 +775,7 @@ static inline boo::EMouseButton getButton(NSEvent* event)
|
|||
|
||||
- (void)otherMouseUp:(NSEvent*)theEvent
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(booContext->m_callbackMutex);
|
||||
std::lock_guard<std::recursive_mutex> lk(booContext->m_callbackMutex);
|
||||
if (!booContext->m_callback)
|
||||
return;
|
||||
boo::EMouseButton button = getButton(theEvent);
|
||||
|
@ -796,7 +796,7 @@ static inline boo::EMouseButton getButton(NSEvent* event)
|
|||
|
||||
- (void)mouseMoved:(NSEvent*)theEvent
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(booContext->m_callbackMutex);
|
||||
std::lock_guard<std::recursive_mutex> lk(booContext->m_callbackMutex);
|
||||
if (!booContext->m_callback)
|
||||
return;
|
||||
NSPoint liw = [parentView convertPoint:[theEvent locationInWindow] fromView:nil];
|
||||
|
@ -832,7 +832,7 @@ static inline boo::EMouseButton getButton(NSEvent* event)
|
|||
|
||||
- (void)mouseEntered:(NSEvent*)theEvent
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(booContext->m_callbackMutex);
|
||||
std::lock_guard<std::recursive_mutex> lk(booContext->m_callbackMutex);
|
||||
if (!booContext->m_callback)
|
||||
return;
|
||||
NSPoint liw = [parentView convertPoint:[theEvent locationInWindow] fromView:nil];
|
||||
|
@ -849,7 +849,7 @@ static inline boo::EMouseButton getButton(NSEvent* event)
|
|||
|
||||
- (void)mouseExited:(NSEvent*)theEvent
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(booContext->m_callbackMutex);
|
||||
std::lock_guard<std::recursive_mutex> lk(booContext->m_callbackMutex);
|
||||
if (!booContext->m_callback)
|
||||
return;
|
||||
NSPoint liw = [parentView convertPoint:[theEvent locationInWindow] fromView:nil];
|
||||
|
@ -866,7 +866,7 @@ static inline boo::EMouseButton getButton(NSEvent* event)
|
|||
|
||||
- (void)scrollWheel:(NSEvent*)theEvent
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(booContext->m_callbackMutex);
|
||||
std::lock_guard<std::recursive_mutex> lk(booContext->m_callbackMutex);
|
||||
if (!booContext->m_callback)
|
||||
return;
|
||||
NSPoint liw = [parentView convertPoint:[theEvent locationInWindow] fromView:nil];
|
||||
|
@ -889,7 +889,7 @@ static inline boo::EMouseButton getButton(NSEvent* event)
|
|||
|
||||
- (void)touchesBeganWithEvent:(NSEvent*)event
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(booContext->m_callbackMutex);
|
||||
std::lock_guard<std::recursive_mutex> lk(booContext->m_callbackMutex);
|
||||
if (!booContext->m_callback)
|
||||
return;
|
||||
for (NSTouch* touch in [event touchesMatchingPhase:NSTouchPhaseBegan inView:nil])
|
||||
|
@ -905,7 +905,7 @@ static inline boo::EMouseButton getButton(NSEvent* event)
|
|||
|
||||
- (void)touchesEndedWithEvent:(NSEvent*)event
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(booContext->m_callbackMutex);
|
||||
std::lock_guard<std::recursive_mutex> lk(booContext->m_callbackMutex);
|
||||
if (!booContext->m_callback)
|
||||
return;
|
||||
for (NSTouch* touch in [event touchesMatchingPhase:NSTouchPhaseEnded inView:nil])
|
||||
|
@ -921,7 +921,7 @@ static inline boo::EMouseButton getButton(NSEvent* event)
|
|||
|
||||
- (void)touchesMovedWithEvent:(NSEvent*)event
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(booContext->m_callbackMutex);
|
||||
std::lock_guard<std::recursive_mutex> lk(booContext->m_callbackMutex);
|
||||
if (!booContext->m_callback)
|
||||
return;
|
||||
for (NSTouch* touch in [event touchesMatchingPhase:NSTouchPhaseMoved inView:nil])
|
||||
|
@ -937,7 +937,7 @@ static inline boo::EMouseButton getButton(NSEvent* event)
|
|||
|
||||
- (void)touchesCancelledWithEvent:(NSEvent*)event
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(booContext->m_callbackMutex);
|
||||
std::lock_guard<std::recursive_mutex> lk(booContext->m_callbackMutex);
|
||||
if (!booContext->m_callback)
|
||||
return;
|
||||
for (NSTouch* touch in [event touchesMatchingPhase:NSTouchPhaseCancelled inView:nil])
|
||||
|
@ -1061,7 +1061,7 @@ static boo::ESpecialKey translateKeycode(short code)
|
|||
|
||||
- (void)keyDown:(NSEvent*)theEvent
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(booContext->m_callbackMutex);
|
||||
std::lock_guard<std::recursive_mutex> lk(booContext->m_callbackMutex);
|
||||
if (!booContext->m_callback)
|
||||
return;
|
||||
boo::ESpecialKey special = translateKeycode(theEvent.keyCode);
|
||||
|
@ -1084,7 +1084,7 @@ static boo::ESpecialKey translateKeycode(short code)
|
|||
|
||||
- (void)keyUp:(NSEvent*)theEvent
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(booContext->m_callbackMutex);
|
||||
std::lock_guard<std::recursive_mutex> lk(booContext->m_callbackMutex);
|
||||
if (!booContext->m_callback)
|
||||
return;
|
||||
boo::ESpecialKey special = translateKeycode(theEvent.keyCode);
|
||||
|
@ -1105,7 +1105,7 @@ static boo::ESpecialKey translateKeycode(short code)
|
|||
|
||||
- (void)flagsChanged:(NSEvent*)theEvent
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(booContext->m_callbackMutex);
|
||||
std::lock_guard<std::recursive_mutex> lk(booContext->m_callbackMutex);
|
||||
if (!booContext->m_callback)
|
||||
return;
|
||||
NSUInteger modFlags = theEvent.modifierFlags;
|
||||
|
@ -1176,7 +1176,7 @@ static boo::ESpecialKey translateKeycode(short code)
|
|||
|
||||
- (void)reshape
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(resp->booContext->m_callbackMutex);
|
||||
std::lock_guard<std::recursive_mutex> lk(resp->booContext->m_callbackMutex);
|
||||
NSRect frame = [self convertRectToBacking:self.frame];
|
||||
boo::SWindowRect rect = {int(frame.origin.x), int(frame.origin.y),
|
||||
int(frame.size.width), int(frame.size.height)};
|
||||
|
@ -1253,7 +1253,7 @@ static boo::ESpecialKey translateKeycode(short code)
|
|||
|
||||
- (void)reshapeHandler
|
||||
{
|
||||
std::lock_guard<std::mutex> lk1(resp->booContext->m_callbackMutex);
|
||||
std::lock_guard<std::recursive_mutex> lk1(resp->booContext->m_callbackMutex);
|
||||
NSRect frame = [self convertRectToBacking:self.frame];
|
||||
boo::SWindowRect rect = {int(frame.origin.x), int(frame.origin.y),
|
||||
int(frame.size.width), int(frame.size.height)};
|
||||
|
|
Loading…
Reference in New Issue