mac fixed
All checks were successful
pyrite-dev/milsko/pipeline/head This commit looks good

This commit is contained in:
IoI_xD 2026-04-21 12:12:08 -07:00
commit 79e1774cb8
2 changed files with 61 additions and 19 deletions

View file

@ -123,6 +123,7 @@ typedef struct {
MilskoCocoaApplication* application; MilskoCocoaApplication* application;
MwBool _forceRender; MwBool _forceRender;
MwBool _eventsPending; MwBool _eventsPending;
MwBool isClosing;
NSWindow* window; NSWindow* window;
NSRect rect; NSRect rect;
MilskoCocoaView* view; MilskoCocoaView* view;

View file

@ -131,6 +131,8 @@ static void recursive_dispatch_key_released(MwLL handle, int* k) {
[nscolor setFill]; [nscolor setFill];
for(n = 0; n < cmd.poly.points_count; n++) { for(n = 0; n < cmd.poly.points_count; n++) {
NSPoint p = localPointFlip(NSMakePoint(cmd.poly.points[n].x, cmd.poly.points[n].y), self); NSPoint p = localPointFlip(NSMakePoint(cmd.poly.points[n].x, cmd.poly.points[n].y), self);
p.x += [self bounds].origin.x;
p.y += [self bounds].origin.y;
if(n == 0) { if(n == 0) {
[path moveToPoint:p]; [path moveToPoint:p];
} else { } else {
@ -157,6 +159,8 @@ static void recursive_dispatch_key_released(MwLL handle, int* k) {
[nscolor setFill]; [nscolor setFill];
for(n = 0; n < 2; n++) { for(n = 0; n < 2; n++) {
NSPoint p = localPointFlip(NSMakePoint(cmd.lines.points[n].x, cmd.lines.points[n].y), self); NSPoint p = localPointFlip(NSMakePoint(cmd.lines.points[n].x, cmd.lines.points[n].y), self);
p.x += [self bounds].origin.x;
p.y += [self bounds].origin.y;
if(n == 0) { if(n == 0) {
[path moveToPoint:p]; [path moveToPoint:p];
} else { } else {
@ -171,8 +175,11 @@ static void recursive_dispatch_key_released(MwLL handle, int* k) {
} break; } break;
case COCOA_DRAW_COMMAND_PIXMAP: { case COCOA_DRAW_COMMAND_PIXMAP: {
NSRect rect = localRectFlip(NSMakeRect(cmd.pixmap.rect.x, cmd.pixmap.rect.y, cmd.pixmap.rect.width, cmd.pixmap.rect.height), self);
rect.origin.x += [self bounds].origin.x;
rect.origin.y += [self bounds].origin.y;
[cmd.pixmap.pixmap->cocoa.real->image [cmd.pixmap.pixmap->cocoa.real->image
drawInRect:localRectFlip(NSMakeRect(cmd.pixmap.rect.x, cmd.pixmap.rect.y, cmd.pixmap.rect.width, cmd.pixmap.rect.height), self) drawInRect:rect
fromRect:NSZeroRect fromRect:NSZeroRect
operation:NSCompositeSourceOver operation:NSCompositeSourceOver
fraction:1.0]; fraction:1.0];
@ -186,6 +193,10 @@ static void recursive_dispatch_key_released(MwLL handle, int* k) {
[pool release]; [pool release];
} }
- (BOOL)isFlipped {
return NO;
}
- (BOOL)canBecomeKeyView { - (BOOL)canBecomeKeyView {
return YES; return YES;
} }
@ -366,7 +377,6 @@ static void recursive_dispatch_key_released(MwLL handle, int* k) {
mouse.point.x = mousePoint.x; mouse.point.x = mousePoint.x;
mouse.point.y = mousePoint.y; mouse.point.y = mousePoint.y;
MwLLDispatch(this, move, &mouse); MwLLDispatch(this, move, &mouse);
[this->cocoa.real nudge];
[super mouseMoved:ev]; [super mouseMoved:ev];
} }
- (BOOL)mouseDownCanMoveWindow { - (BOOL)mouseDownCanMoveWindow {
@ -382,7 +392,6 @@ static void recursive_dispatch_key_released(MwLL handle, int* k) {
mouse.point.x = mousePoint.x; mouse.point.x = mousePoint.x;
mouse.point.y = mousePoint.y; mouse.point.y = mousePoint.y;
MwLLDispatch(this, down, &mouse); MwLLDispatch(this, down, &mouse);
[this->cocoa.real nudge];
[super mouseDown:ev]; [super mouseDown:ev];
} }
@ -395,7 +404,6 @@ static void recursive_dispatch_key_released(MwLL handle, int* k) {
mouse.point.x = mousePoint.x; mouse.point.x = mousePoint.x;
mouse.point.y = mousePoint.y; mouse.point.y = mousePoint.y;
MwLLDispatch(this, up, &mouse); MwLLDispatch(this, up, &mouse);
[this->cocoa.real nudge];
[super mouseUp:ev]; [super mouseUp:ev];
} }
- (void)rightMouseDown:(NSEvent*)ev { - (void)rightMouseDown:(NSEvent*)ev {
@ -407,7 +415,6 @@ static void recursive_dispatch_key_released(MwLL handle, int* k) {
mouse.point.x = mousePoint.x; mouse.point.x = mousePoint.x;
mouse.point.y = mousePoint.y; mouse.point.y = mousePoint.y;
MwLLDispatch(this, down, &mouse); MwLLDispatch(this, down, &mouse);
[this->cocoa.real nudge];
[super rightMouseDown:ev]; [super rightMouseDown:ev];
} }
@ -420,7 +427,6 @@ static void recursive_dispatch_key_released(MwLL handle, int* k) {
mouse.point.x = mousePoint.x; mouse.point.x = mousePoint.x;
mouse.point.y = mousePoint.y; mouse.point.y = mousePoint.y;
MwLLDispatch(this, up, &mouse); MwLLDispatch(this, up, &mouse);
[this->cocoa.real nudge];
[super rightMouseUp:ev]; [super rightMouseUp:ev];
} }
@ -466,6 +472,7 @@ static void recursive_dispatch_key_released(MwLL handle, int* k) {
MwLL h = [((MilskoFakePointer*)[[[w contentView] subviews] MwLL h = [((MilskoFakePointer*)[[[w contentView] subviews]
objectAtIndex:0]) pointer]; objectAtIndex:0]) pointer];
MwLLDispatch(h, close, NULL); MwLLDispatch(h, close, NULL);
h->cocoa.real->isClosing = MwTRUE;
} }
} }
@ -611,16 +618,35 @@ static void recursive_dispatch_key_released(MwLL handle, int* k) {
} }
- (void)nudge { - (void)nudge {
MwLL p = self->parent; MwLL topmost_parent = [self->handle pointer];
MwWidget h;
while(topmost_parent->cocoa.real->parent) topmost_parent = topmost_parent->cocoa.real->parent;
if(!topmost_parent->cocoa.real->isClosing)
self->_eventsPending = MwTRUE; self->_eventsPending = MwTRUE;
while(p) { [topmost_parent->cocoa.real->view setNeedsDisplay:true];
MwLLDispatch(p, draw, NULL); MwLLDispatch(topmost_parent, draw, NULL);
[p->cocoa.real->view setNeedsDisplay:true];
p = p->cocoa.real->parent; h = (MwWidget)topmost_parent->common.user;
if(h) {
int i;
for(i = 0; i < arrlen(h->children); i++) {
[h->children[i]->lowlevel->cocoa.real->view setNeedsDisplay:true];
MwLLDispatch(h->children[i]->lowlevel, draw, NULL);
} }
} }
// MwLL p = self->parent;
// self->_eventsPending = MwTRUE;
// while(p) {
// MwLLDispatch(p, draw, NULL);
// p = p->cocoa.real->parent;
// }
}
- (void)pushCursor { - (void)pushCursor {
[self->cursor push]; [self->cursor push];
} }
@ -697,7 +723,7 @@ static MwLL MwLLCreateImpl(MwLL parent, int x, int y, int width, int height) {
c->window = p->window; c->window = p->window;
c->view = [[MilskoCocoaView alloc] initWithFrame:rect]; c->view = [[MilskoCocoaView alloc] initWithFrame:rect];
[c->view setFrame:rect]; [c->view setBounds:rect];
[c->view retain]; [c->view retain];
[c->view setChild]; [c->view setChild];
@ -727,6 +753,8 @@ static MwLL MwLLCreateImpl(MwLL parent, int x, int y, int width, int height) {
[pool release]; [pool release];
c->isClosing = MwFALSE;
r->cocoa.real = c; r->cocoa.real = c;
return r; return r;
@ -748,7 +776,7 @@ static void MwLLBeginDrawImpl(MwLL handle) {
static void MwLLEndDrawImpl(MwLL handle) { static void MwLLEndDrawImpl(MwLL handle) {
(void)handle; (void)handle;
[handle->cocoa.real->view displayRect:[handle->cocoa.real->window frame]]; // [handle->cocoa.real->view displayRect:[handle->cocoa.real->window frame]];
} }
static void MwLLPolygonImpl(MwLL handle, MwPoint* points, int points_count, static void MwLLPolygonImpl(MwLL handle, MwPoint* points, int points_count,
@ -763,6 +791,8 @@ static void MwLLPolygonImpl(MwLL handle, MwPoint* points, int points_count,
memcpy(poly.poly.points, points, sizeof(MwPoint) * points_count); memcpy(poly.poly.points, points, sizeof(MwPoint) * points_count);
arrpush(handle->cocoa.real->view->commands, poly); arrpush(handle->cocoa.real->view->commands, poly);
[handle->cocoa.real nudge];
} }
static void MwLLLineImpl(MwLL handle, MwPoint* points, MwLLColor color) { static void MwLLLineImpl(MwLL handle, MwPoint* points, MwLLColor color) {
@ -775,6 +805,8 @@ static void MwLLLineImpl(MwLL handle, MwPoint* points, MwLLColor color) {
memcpy(lines.lines.points, points, sizeof(MwPoint) * 2); memcpy(lines.lines.points, points, sizeof(MwPoint) * 2);
arrpush(handle->cocoa.real->view->commands, lines); arrpush(handle->cocoa.real->view->commands, lines);
[handle->cocoa.real nudge];
} }
static MwLLColor MwLLAllocColorImpl(MwLL handle, int r, int g, int b) { static MwLLColor MwLLAllocColorImpl(MwLL handle, int r, int g, int b) {
@ -828,7 +860,7 @@ static void MwLLSetXYImpl(MwLL handle, int x, int y) {
if(!self->parent) { if(!self->parent) {
frame = rectFlip(frame); frame = rectFlip(frame);
[self->window setFrame:frame display:MwTRUE animate:MwTRUE]; [self->window setFrame:frame display:MwTRUE animate:false];
} else { } else {
frame = localRectFlip(frame, self->parent->cocoa.real->view); frame = localRectFlip(frame, self->parent->cocoa.real->view);
[self->view setFrame:frame]; [self->view setFrame:frame];
@ -838,7 +870,13 @@ static void MwLLSetXYImpl(MwLL handle, int x, int y) {
static void MwLLSetWHImpl(MwLL handle, int w, int h) { static void MwLLSetWHImpl(MwLL handle, int w, int h) {
MilskoCocoa* self = handle->cocoa.real; MilskoCocoa* self = handle->cocoa.real;
NSRect frame = [self->window frame]; NSRect frame;
if(self->parent) {
frame = [self->view frame];
} else {
frame = [self->window frame];
}
frame.size.width = w; frame.size.width = w;
frame.size.height = h; frame.size.height = h;
@ -861,6 +899,7 @@ static int MwLLPendingImpl(MwLL handle) {
MilskoCocoa* self = handle->cocoa.real; MilskoCocoa* self = handle->cocoa.real;
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
MwBool isPending = [self->application pending]; MwBool isPending = [self->application pending];
[self->application runModalSession:self->modalSession]; [self->application runModalSession:self->modalSession];
[pool release]; [pool release];
return self->_forceRender || self->_eventsPending || isPending; return self->_forceRender || self->_eventsPending || isPending;
@ -941,6 +980,8 @@ static void MwLLDrawPixmapImpl(MwLL handle, MwRect* rect, MwLLPixmap pixmap) {
pix.pixmap.pixmap = MwLLCreatePixmap(handle, pixmap->common.raw, pixmap->common.width, pixmap->common.height); pix.pixmap.pixmap = MwLLCreatePixmap(handle, pixmap->common.raw, pixmap->common.width, pixmap->common.height);
arrpush(handle->cocoa.real->view->commands, pix); arrpush(handle->cocoa.real->view->commands, pix);
[handle->cocoa.real nudge];
} }
static void MwLLSetIconImpl(MwLL handle, MwLLPixmap pixmap) { static void MwLLSetIconImpl(MwLL handle, MwLLPixmap pixmap) {