Cocoa: User performSelectorOnMainLoop for render frames as well which means render frames work during modal loops
This commit is contained in:
parent
0dc6ac26c3
commit
fcb26e5dc7
@ -296,21 +296,20 @@ static GLFWbool initializeTIS(void)
|
|||||||
|
|
||||||
@interface GLFWApplication : NSApplication
|
@interface GLFWApplication : NSApplication
|
||||||
- (void)tick_callback;
|
- (void)tick_callback;
|
||||||
|
- (void)render_frame_received:(id)displayIDAsID;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
extern void dispatchCustomEvent(NSEvent *event);
|
|
||||||
|
|
||||||
@implementation GLFWApplication
|
@implementation GLFWApplication
|
||||||
- (void)sendEvent:(NSEvent *)event {
|
|
||||||
if (event.type == NSEventTypeApplicationDefined) {
|
|
||||||
dispatchCustomEvent(event);
|
|
||||||
} else [super sendEvent:event];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)tick_callback
|
- (void)tick_callback
|
||||||
{
|
{
|
||||||
_glfwDispatchTickCallback();
|
_glfwDispatchTickCallback();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)render_frame_received:(id)displayIDAsID
|
||||||
|
{
|
||||||
|
CGDirectDisplayID displayID = [(NSNumber*)displayIDAsID unsignedIntValue];
|
||||||
|
_glfwDispatchRenderFrame(displayID);
|
||||||
|
}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|||||||
@ -277,7 +277,9 @@ static CVReturn displayLinkCallback(
|
|||||||
}
|
}
|
||||||
[_glfw.ns.displayLinks.lock unlock];
|
[_glfw.ns.displayLinks.lock unlock];
|
||||||
if (notify) {
|
if (notify) {
|
||||||
_glfwCocoaPostEmptyEvent(RENDER_FRAME_REQUEST_EVENT_TYPE, displayID, true);
|
NSNumber *arg = [NSNumber numberWithUnsignedInt:displayID];
|
||||||
|
[NSApp performSelectorOnMainThread:@selector(render_frame_received:) withObject:arg waitUntilDone:NO];
|
||||||
|
[arg release];
|
||||||
}
|
}
|
||||||
return kCVReturnSuccess;
|
return kCVReturnSuccess;
|
||||||
}
|
}
|
||||||
|
|||||||
7
glfw/cocoa_platform.h
vendored
7
glfw/cocoa_platform.h
vendored
@ -36,12 +36,6 @@ typedef void* id;
|
|||||||
typedef void* CVDisplayLinkRef;
|
typedef void* CVDisplayLinkRef;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
EMPTY_EVENT_TYPE,
|
|
||||||
RENDER_FRAME_REQUEST_EVENT_TYPE,
|
|
||||||
} EventTypes;
|
|
||||||
|
|
||||||
|
|
||||||
typedef VkFlags VkMacOSSurfaceCreateFlagsMVK;
|
typedef VkFlags VkMacOSSurfaceCreateFlagsMVK;
|
||||||
typedef int (* GLFWcocoatextinputfilterfun)(int,int,unsigned int, unsigned long);
|
typedef int (* GLFWcocoatextinputfilterfun)(int,int,unsigned int, unsigned long);
|
||||||
typedef int (* GLFWapplicationshouldhandlereopenfun)(int);
|
typedef int (* GLFWapplicationshouldhandlereopenfun)(int);
|
||||||
@ -205,3 +199,4 @@ float _glfwTransformYNS(float y);
|
|||||||
void _glfwClearDisplayLinks();
|
void _glfwClearDisplayLinks();
|
||||||
void _glfwCocoaPostEmptyEvent(short subtype, long data1, bool at_start);
|
void _glfwCocoaPostEmptyEvent(short subtype, long data1, bool at_start);
|
||||||
void _glfwDispatchTickCallback();
|
void _glfwDispatchTickCallback();
|
||||||
|
void _glfwDispatchRenderFrame(CGDirectDisplayID);
|
||||||
|
|||||||
@ -1741,7 +1741,7 @@ void _glfwPlatformSetWindowOpacity(_GLFWwindow* window, float opacity)
|
|||||||
[window->ns.object setAlphaValue:opacity];
|
[window->ns.object setAlphaValue:opacity];
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline CGDirectDisplayID displayIDForWindow(_GLFWwindow *w) {
|
CGDirectDisplayID displayIDForWindow(_GLFWwindow *w) {
|
||||||
NSWindow *nw = w->ns.object;
|
NSWindow *nw = w->ns.object;
|
||||||
NSDictionary *dict = [nw.screen deviceDescription];
|
NSDictionary *dict = [nw.screen deviceDescription];
|
||||||
NSNumber *displayIDns = [dict objectForKey:@"NSScreenNumber"];
|
NSNumber *displayIDns = [dict objectForKey:@"NSScreenNumber"];
|
||||||
@ -1750,27 +1750,14 @@ static inline CGDirectDisplayID displayIDForWindow(_GLFWwindow *w) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
dispatchCustomEvent(NSEvent *event) {
|
_glfwDispatchRenderFrame(CGDirectDisplayID displayID) {
|
||||||
switch(event.subtype) {
|
_GLFWwindow *w = _glfw.windowListHead;
|
||||||
case RENDER_FRAME_REQUEST_EVENT_TYPE:
|
while (w) {
|
||||||
{
|
if (w->ns.renderFrameRequested && displayID == displayIDForWindow(w)) {
|
||||||
CGDirectDisplayID displayID = (CGDirectDisplayID)event.data1;
|
w->ns.renderFrameRequested = GLFW_FALSE;
|
||||||
_GLFWwindow *w = _glfw.windowListHead;
|
w->ns.renderFrameCallback((GLFWwindow*)w);
|
||||||
while (w) {
|
}
|
||||||
if (w->ns.renderFrameRequested && displayID == displayIDForWindow(w)) {
|
w = w->next;
|
||||||
w->ns.renderFrameRequested = GLFW_FALSE;
|
|
||||||
w->ns.renderFrameCallback((GLFWwindow*)w);
|
|
||||||
}
|
|
||||||
w = w->next;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EMPTY_EVENT_TYPE:
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user