diff --git a/include/Mw/LowLevel/Cocoa.h b/include/Mw/LowLevel/Cocoa.h index 445af0e..bc65d96 100644 --- a/include/Mw/LowLevel/Cocoa.h +++ b/include/Mw/LowLevel/Cocoa.h @@ -110,6 +110,7 @@ NSCursor *cursor; MwBool pointerLocked; + MwBool mouseMoved; } + (MilskoCocoa *)newWithParent:(MwLL)parent diff --git a/src/backend/cocoa.m b/src/backend/cocoa.m index eeae856..8b96fe7 100644 --- a/src/backend/cocoa.m +++ b/src/backend/cocoa.m @@ -176,6 +176,21 @@ static NSPoint pointFlip(NSPoint point) { this->lastEvent = [this->application currentEvent]; [this eventProcess:this->lastEvent]; + if (this->_forceRender) { + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + NSEvent *event = [NSEvent otherEventWithType:NSApplicationDefined + location:NSMakePoint(0, 0) + modifierFlags:0 + timestamp:0 + windowNumber:0 + context:nil + subtype:0 + data1:0 + data2:0]; + [NSApp postEvent:event atStart:YES]; + [pool release]; + } + [[NSApplication sharedApplication] stop:nil]; } @@ -301,7 +316,7 @@ static NSPoint pointFlip(NSPoint point) { - (void)getNextEvent { [self sendClipboardEvent]; - if (self->pointerLocked && [self->window isMainWindow]) { + if (self->pointerLocked && [self->window isMainWindow] && self->lastEvent) { struct CGPoint pos; pos.x = [window frame].origin.x + [window frame].size.width / 2; pos.y = [window frame].origin.y + [window frame].size.height / 2; diff --git a/src/widget/opengl_cocoa.m b/src/widget/opengl_cocoa.m index 15c1198..503fe5e 100644 --- a/src/widget/opengl_cocoa.m +++ b/src/widget/opengl_cocoa.m @@ -9,7 +9,7 @@ @interface MacOpenGLWidget : NSObject { NSOpenGLPixelFormat *pixelFormat; NSOpenGLContext *glc; - MilskoCocoa * _win; + MilskoCocoa *_win; } - (MacOpenGLWidget *)initWithWindow:(MilskoCocoa *)w; @@ -31,8 +31,8 @@ static int create(MwWidget handle) { printf("%d %d\n", width, height); - handle->internal = [[MacOpenGLWidget alloc] - initWithWindow:handle->lowlevel->cocoa.real]; + handle->internal = + [[MacOpenGLWidget alloc] initWithWindow:handle->lowlevel->cocoa.real]; handle->lowlevel->common.copy_buffer = 0; MwSetDefault(handle); @@ -98,7 +98,6 @@ static void func_handler(MwWidget handle, const char *name, void *out, [self->glc makeCurrentContext]; }; - (void)swapBuffer { - [self->_win forceRender]; [self->glc flushBuffer]; }; - (void *)getProcAddressWithName:(const char *)name {