diff --git a/src/backend/cocoa.m b/src/backend/cocoa.m index 6961a963..0f979b9d 100644 --- a/src/backend/cocoa.m +++ b/src/backend/cocoa.m @@ -330,6 +330,7 @@ static void recursive_dispatch_key_released(MwLL handle, int* k) { frame = localRectFlip(frame, parent->cocoa.real->view); [self->view setBounds:frame]; } + // [self->view setNeedsDisplay:true]; [self nudge]; }; - (void)setW:(int)w H:(int)h { @@ -359,10 +360,12 @@ static void recursive_dispatch_key_released(MwLL handle, int* k) { MwLL h = [self->handle pointer]; if(_forceRender) { MwLLDispatch(h, draw, NULL); + // [self->view setNeedsDisplay:true]; _forceRender = MwFALSE; } if(_eventsPending) { MwLLDispatch(h, draw, NULL); + // [self->view setNeedsDisplay:true]; _eventsPending = MwFALSE; } [self sendClipboardEvent]; @@ -440,6 +443,18 @@ static void recursive_dispatch_key_released(MwLL handle, int* k) { }; - (void)forceRender { self->_forceRender = MwTRUE; + // 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]; }; - (void)setCursor:(MwCursor*)image mask:(MwCursor*)mask { int y, x, ys, xs; @@ -654,19 +669,17 @@ static void recursive_dispatch_key_released(MwLL handle, int* k) { NSArray* subviews = [self subviews]; int i; - if(self->width != dirtyRect.size.width || self->height != dirtyRect.size.height) { - if(self->rep) { - [self->rep release]; - } - if(dirtyRect.size.width && dirtyRect.size.height) { - [self initRepAndContextWithWidth:dirtyRect.size.width - Height:dirtyRect.size.height]; - self->width = dirtyRect.size.width; - self->height = dirtyRect.size.height; - } else { - [pool release]; - return; - } + if(self->rep) { + [self->rep release]; + } + if(dirtyRect.size.width && dirtyRect.size.height) { + [self initRepAndContextWithWidth:dirtyRect.size.width + Height:dirtyRect.size.height]; + self->width = dirtyRect.size.width; + self->height = dirtyRect.size.height; + } else { + [pool release]; + return; } [self->rep drawInRect:[self bounds]]; @@ -980,6 +993,7 @@ static void recursive_dispatch_key_released(MwLL handle, int* k) { if([ptr isKindOfClass:[MilskoFakePointer class]]) { MwLL h = [(MilskoFakePointer*)ptr pointer]; MwLLDispatch(h, resize, NULL); + // MwLLDispatch(h, draw, NULL); } } return frameSize; @@ -1104,15 +1118,18 @@ static void MwLLColorUpdateImpl(MwLL handle, MwLLColor c, int r, int g, int b) { static void MwLLGetXYWHImpl(MwLL handle, int* x, int* y, unsigned int* w, unsigned int* height) { - [handle->cocoa.real getX:x Y:y W:w H:height]; + MilskoCocoa* h = handle->cocoa.real; + [h getX:x Y:y W:w H:height]; } static void MwLLSetXYImpl(MwLL handle, int x, int y) { - [handle->cocoa.real setX:x Y:y]; + MilskoCocoa* h = handle->cocoa.real; + [h setX:x Y:y]; } static void MwLLSetWHImpl(MwLL handle, int w, int height) { - [handle->cocoa.real setW:w H:height]; + MilskoCocoa* h = handle->cocoa.real; + [h setW:w H:height]; } static void MwLLFreeColorImpl(MwLLColor color) { @@ -1124,11 +1141,13 @@ static int MwLLPendingImpl(MwLL handle) { } static void MwLLNextEventImpl(MwLL handle) { - [handle->cocoa.real getNextEvent]; + MilskoCocoa* h = handle->cocoa.real; + [h getNextEvent]; } static void MwLLSetTitleImpl(MwLL handle, const char* title) { - [handle->cocoa.real setTitle:title]; + MilskoCocoa* h = handle->cocoa.real; + [h setTitle:title]; } static MwLLPixmap MwLLCreatePixmapImpl(MwLL handle, unsigned char* data, @@ -1151,63 +1170,77 @@ static MwLLPixmap MwLLCreatePixmapImpl(MwLL handle, unsigned char* data, } static void MwLLPixmapUpdateImpl(MwLLPixmap pixmap) { - [pixmap->cocoa.real updateWithData:pixmap->common.raw]; + MilskoCocoaPixmap* p = pixmap->cocoa.real; + [p updateWithData:pixmap->common.raw]; } static void MwLLDestroyPixmapImpl(MwLLPixmap pixmap) { - [pixmap->cocoa.real destroy]; - [pixmap->cocoa.real release]; + MilskoCocoaPixmap* p = pixmap->cocoa.real; + [p destroy]; + [p release]; free(pixmap); } static void MwLLDrawPixmapImpl(MwLL handle, MwRect* rect, MwLLPixmap pixmap) { - [handle->cocoa.real drawPixmap:pixmap rect:rect]; + MilskoCocoa* h = handle->cocoa.real; + [h drawPixmap:pixmap rect:rect]; MwLLForceRender(handle); } static void MwLLSetIconImpl(MwLL handle, MwLLPixmap pixmap) { - [handle->cocoa.real setIcon:pixmap]; + MilskoCocoa* h = handle->cocoa.real; + [h setIcon:pixmap]; } static void MwLLForceRenderImpl(MwLL handle) { - [handle->cocoa.real forceRender]; + MilskoCocoa* h = handle->cocoa.real; + [h forceRender]; } static void MwLLSetCursorImpl(MwLL handle, MwCursor* image, MwCursor* mask) { - [handle->cocoa.real setCursor:image mask:mask]; + MilskoCocoa* h = handle->cocoa.real; + [h setCursor:image mask:mask]; } static void MwLLDetachImpl(MwLL handle, MwPoint* point) { - [handle->cocoa.real detachWithPoint:point]; + MilskoCocoa* h = handle->cocoa.real; + [h detachWithPoint:point]; } static void MwLLShowImpl(MwLL handle, int show) { - [handle->cocoa.real show:show]; + MilskoCocoa* h = handle->cocoa.real; + [h show:show]; } static void MwLLMakePopupImpl(MwLL handle, MwLL parent) { - [handle->cocoa.real makePopupWithParent:parent]; + MilskoCocoa* h = handle->cocoa.real; + [h makePopupWithParent:parent]; } static void MwLLSetSizeHintsImpl(MwLL handle, int minx, int miny, int maxx, int maxy) { - [handle->cocoa.real setSizeHintsWithMinX:minx MinY:miny MaxX:maxx MaxY:maxy]; + MilskoCocoa* h = handle->cocoa.real; + [h setSizeHintsWithMinX:minx MinY:miny MaxX:maxx MaxY:maxy]; } static void MwLLMakeBorderlessImpl(MwLL handle, int toggle) { - [handle->cocoa.real makeBorderless:toggle]; + MilskoCocoa* h = handle->cocoa.real; + [h makeBorderless:toggle]; } static void MwLLFocusImpl(MwLL handle) { - [handle->cocoa.real focus]; + MilskoCocoa* h = handle->cocoa.real; + [h focus]; } static void MwLLGrabPointerImpl(MwLL handle, int toggle) { - [handle->cocoa.real grabPointer:toggle]; + MilskoCocoa* h = handle->cocoa.real; + [h grabPointer:toggle]; } static void MwLLSetClipboardImpl(MwLL handle, const char* text) { - [handle->cocoa.real setClipboard:text]; + MilskoCocoa* h = handle->cocoa.real; + [h setClipboard:text]; } static void MwLLGetClipboardImpl(MwLL handle) { @@ -1215,15 +1248,19 @@ static void MwLLGetClipboardImpl(MwLL handle) { } static void MwLLMakeToolWindowImpl(MwLL handle) { - [handle->cocoa.real makeToolWindow]; + + MilskoCocoa* h = handle->cocoa.real; + [h makeToolWindow]; } static void MwLLGetCursorCoordImpl(MwLL handle, MwPoint* point) { - [handle->cocoa.real getCursorCoord:point]; + MilskoCocoa* h = handle->cocoa.real; + [h getCursorCoord:point]; } static void MwLLGetScreenSizeImpl(MwLL handle, MwRect* rect) { - [handle->cocoa.real getScreenSize:rect]; + MilskoCocoa* h = handle->cocoa.real; + [h getScreenSize:rect]; } static void MwLLBeginStateChangeImpl(MwLL handle) {