From a71096711542833ac1ecdf96369738560884f157 Mon Sep 17 00:00:00 2001 From: IoIxD Date: Wed, 14 Jan 2026 13:47:49 -0700 Subject: [PATCH] cocoa: move interfaces to header (guarded by ifdef __OBJC__) --- include/Mw/LowLevel/Cocoa.h | 61 +++++++++++++++++++++++++++++++++++-- src/backend/cocoa.m | 51 ------------------------------- 2 files changed, 59 insertions(+), 53 deletions(-) diff --git a/include/Mw/LowLevel/Cocoa.h b/include/Mw/LowLevel/Cocoa.h index 06afe78..868d6ad 100644 --- a/include/Mw/LowLevel/Cocoa.h +++ b/include/Mw/LowLevel/Cocoa.h @@ -10,11 +10,67 @@ #include #include +#ifdef __OBJC__ +@interface MilskoCocoaPixmap : NSObject { + NSImage* image; +} ++ (MilskoCocoaPixmap*)newWithWidth:(int)width height:(int)height; +- (void)updateWithData:(void*)data; +- (void)destroy; +@end +@interface MilskoCocoa : NSObject { + NSApplication* application; + NSWindow* window; + NSRect rect; +} + ++ (MilskoCocoa*)newWithParent:(MwLL)parent + x:(int)x + y:(int)y + width:(int)width + height:(int)height; +- (void)polygonWithPoints:(MwPoint*)points + points_count:(int)points_count + color:(MwLLColor)color; +- (void)lineWithPoints:(MwPoint*)points color:(MwLLColor)color; +- (void)getX:(int*)x Y:(int*)y W:(unsigned int*)w H:(unsigned int*)h; +- (void)setX:(int)x Y:(int)y; +- (void)setW:(int)w H:(int)h; +- (int)pending; +- (void)getNextEvent; +- (void)setTitle:(const char*)title; +- (void)drawPixmap:(MwLLPixmap)pixmap rect:(MwRect*)rect; +- (void)setIcon:(MwLLPixmap)pixmap; +- (void)forceRender; +- (void)setCursor:(MwCursor*)image mask:(MwCursor*)mask; +- (void)detachWithPoint:(MwPoint*)point; +- (void)show:(int)show; +- (void)makePopupWithParent:(MwLL)parent; +- (void)setSizeHintsWithMinX:(int)minx + MinY:(int)miny + MaxX:(int)maxx + MaxY:(int)maxy; +- (void)makeBorderless:(int)toggle; +- (void)focus; +- (void)grabPointer:(int)toggle; +- (void)setClipboard:(const char*)text; +- (void)makeToolWindow; +- (void)getCursorCoord:(MwPoint*)point; +- (void)getScreenSize:(MwRect*)rect; +- (void)destroy; + +@end +#define OBJC(x) x +#else +#define OBJC(x) void* +#endif + MWDECL int MwLLCocoaCallInit(void); struct _MwLLCocoa { struct _MwLLCommon common; - void* real; + OBJC(MilskoCocoa*) + real; }; struct _MwLLCocoaColor { @@ -23,7 +79,8 @@ struct _MwLLCocoaColor { struct _MwLLCocoaPixmap { struct _MwLLCommonPixmap common; - void* real; + OBJC(MilskoCocoaPixmap*) + real; }; #endif diff --git a/src/backend/cocoa.m b/src/backend/cocoa.m index 6d118f3..b5ccd40 100644 --- a/src/backend/cocoa.m +++ b/src/backend/cocoa.m @@ -12,14 +12,6 @@ #include "../../external/stb_ds.h" -@interface MilskoCocoaPixmap : NSObject { - NSImage* image; -} -+ (MilskoCocoaPixmap*)newWithWidth:(int)width height:(int)height; -- (void)updateWithData:(void*)data; -- (void)destroy; -@end - @implementation MilskoCocoaPixmap + (MilskoCocoaPixmap*)newWithWidth:(int)width height:(int)height { @@ -40,49 +32,6 @@ } @end -@interface MilskoCocoa : NSObject { - NSApplication* application; - NSWindow* window; - NSRect rect; -} - -+ (MilskoCocoa*)newWithParent:(MwLL)parent - x:(int)x - y:(int)y - width:(int)width - height:(int)height; -- (void)polygonWithPoints:(MwPoint*)points - points_count:(int)points_count - color:(MwLLColor)color; -- (void)lineWithPoints:(MwPoint*)points color:(MwLLColor)color; -- (void)getX:(int*)x Y:(int*)y W:(unsigned int*)w H:(unsigned int*)h; -- (void)setX:(int)x Y:(int)y; -- (void)setW:(int)w H:(int)h; -- (int)pending; -- (void)getNextEvent; -- (void)setTitle:(const char*)title; -- (void)drawPixmap:(MwLLPixmap)pixmap rect:(MwRect*)rect; -- (void)setIcon:(MwLLPixmap)pixmap; -- (void)forceRender; -- (void)setCursor:(MwCursor*)image mask:(MwCursor*)mask; -- (void)detachWithPoint:(MwPoint*)point; -- (void)show:(int)show; -- (void)makePopupWithParent:(MwLL)parent; -- (void)setSizeHintsWithMinX:(int)minx - MinY:(int)miny - MaxX:(int)maxx - MaxY:(int)maxy; -- (void)makeBorderless:(int)toggle; -- (void)focus; -- (void)grabPointer:(int)toggle; -- (void)setClipboard:(const char*)text; -- (void)makeToolWindow; -- (void)getCursorCoord:(MwPoint*)point; -- (void)getScreenSize:(MwRect*)rect; -- (void)destroy; - -@end - @implementation MilskoCocoa + (MilskoCocoa*)newWithParent:(MwLL)parent