diff --git a/configure b/configure index 5551d4c..5d98108 100755 --- a/configure +++ b/configure @@ -146,8 +146,6 @@ foreach my $l (@ARGV) { } } - - if (-f "./pl/ostype/${target}.pl") { require("./pl/ostype/${target}.pl"); } diff --git a/include/Mw/LowLevel/Cocoa.h b/include/Mw/LowLevel/Cocoa.h index d31e590..ff70295 100644 --- a/include/Mw/LowLevel/Cocoa.h +++ b/include/Mw/LowLevel/Cocoa.h @@ -23,9 +23,9 @@ // Note: implements NSApplicationDelegate @interface MilskoCocoaApplicationDelegate : NSObject { - NSApplication* appl; + MilskoCocoaApplication* appl; } -- (MilskoCocoaApplicationDelegate*)initWithAppl:(NSApplication*)appl; +- (MilskoCocoaApplicationDelegate*)initWithAppl:(MilskoCocoaApplication*)appl; @end @interface MilskoCocoaWindow : NSWindow { @@ -36,7 +36,7 @@ @interface MilskoCocoaWindowDelegate : NSObject { NSWindow* w; } -- (MilskoCocoaWindowDelegate*)initWithWin:(MilskoCocoaWindow*)win; +- (MilskoCocoaWindowDelegate*)initWithWin:(NSWindow*)win; @end /* @@ -103,16 +103,16 @@ @end @interface MilskoCocoa : NSObject { - NSApplication* application; - MwBool _forceRender; - MwBool _eventsPending; - MilskoCocoaWindow* window; - NSRect rect; - MilskoCocoaView* view; - MwLL parent; - MilskoFakePointer* handle; - unsigned int strHash; - NSEvent* lastEvent; + MilskoCocoaApplication* application; + MwBool _forceRender; + MwBool _eventsPending; + NSWindow* window; + NSRect rect; + MilskoCocoaView* view; + MwLL parent; + MilskoFakePointer* handle; + unsigned int strHash; + NSEvent* lastEvent; MilskoCocoaPixmap* cursorPixmap; NSCursor* cursor; @@ -163,14 +163,13 @@ - (MwLL)getParent; - (NSView*)getView; -- (MilskoCocoaWindow*)getWindow; +- (NSWindow*)getWindow; - (void)nudge; - (void)pushCursor; - (void)popCursor; - (MilskoFakePointer*)getHandle; -+ (void)eventCanceller:(MilskoCocoa*)this; @end #define OBJC(x) x diff --git a/pl/rules.pl b/pl/rules.pl index 3d1f2c0..6c23006 100644 --- a/pl/rules.pl +++ b/pl/rules.pl @@ -57,9 +57,10 @@ if (grep(/^cocoa$/, @backends) || param_get("gnustep")) { new_object("src/backend/cocoa.m"); if(param_get("gnustep")){ - add_incdir2("-I/usr/GNUstep/System/Library/Headers"); - add_libdir("-L/usr/GNUstep/System/Library/Libraries"); - add_ldflags("-fblocks -lobjc -lgnustep-base -lm -lgnustep-gui"); + add_incdir("-I".`gnustep-config --variable=GNUSTEP_SYSTEM_HEADERS`); + add_libdir("-L".`gnustep-config --variable=GNUSTEP_SYSTEM_LIBRARIES`); + add_cflags("-fobjc-runtime=gnustep-2.0 -fblocks"); + add_ldflags("-lobjc -lgnustep-base -lm -lgnustep-gui"); } if (param_get("opengl")) { diff --git a/src/backend/cocoa.m b/src/backend/cocoa.m index 1048f82..adf8f74 100644 --- a/src/backend/cocoa.m +++ b/src/backend/cocoa.m @@ -136,8 +136,9 @@ static void recursive_dispatch_key_released(MwLL handle, int* k) { handle:(MwLL)r { MilskoCocoa* c = [MilskoCocoa alloc]; NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; - [c retain]; + c->application = (MilskoCocoaApplication*)[MilskoCocoaApplication sharedApplication]; + [c->application retain]; /* * MacOS doesn't really have a "default" window position, you're actually @@ -151,11 +152,10 @@ static void recursive_dispatch_key_released(MwLL handle, int* k) { y = r ? ([[NSScreen mainScreen] frame].size.height / 2.) - (height / 2.) : 0; } - c->application = NSApp; - c->rect = NSMakeRect(x, y, width, height); + c->rect = NSMakeRect(x, y, width, height); if(parent == NULL) { - c->window = [[MilskoCocoaWindow alloc] + c->window = [[NSWindow alloc] initWithContentRect:rectFlip(c->rect) styleMask:(NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | @@ -183,6 +183,7 @@ static void recursive_dispatch_key_released(MwLL handle, int* k) { [c->application retain]; [c->view addTrackingRect:c->rect owner:c->view userData:NULL assumeInside:MwFALSE]; + c->modalSession = [c->application beginModalSessionForWindow:c->window]; } else { MilskoCocoa* p = parent->cocoa.real; @@ -197,6 +198,8 @@ static void recursive_dispatch_key_released(MwLL handle, int* k) { [c->view addTrackingRect:c->rect owner:c->view userData:NULL assumeInside:MwFALSE]; [p->view addSubview:c->view]; + + c->modalSession = p->modalSession; } [c->window setAcceptsMouseMovedEvents:MwTRUE]; @@ -205,8 +208,7 @@ static void recursive_dispatch_key_released(MwLL handle, int* k) { [c->handle setPointer:r]; [c->view addSubview:c->handle]; - c->modalSession = [c->application beginModalSessionForWindow:c->window]; - c->parent = parent; + c->parent = parent; c->_forceRender = MwTRUE; c->strHash = 0; @@ -350,7 +352,7 @@ static void recursive_dispatch_key_released(MwLL handle, int* k) { - (int)pending { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; MwBool isPending = [self->application pending]; - [NSApp runModalSession:self->modalSession]; + [self->application runModalSession:self->modalSession]; [pool release]; return _forceRender || _eventsPending || isPending; }; @@ -954,7 +956,7 @@ static void recursive_dispatch_key_released(MwLL handle, int* k) { @end @implementation MilskoCocoaApplicationDelegate -- (MilskoCocoaApplicationDelegate*)initWithAppl:(NSApplication*)_appl { +- (MilskoCocoaApplicationDelegate*)initWithAppl:(MilskoCocoaApplication*)_appl { self->appl = _appl; return self; } @@ -1001,10 +1003,9 @@ static void recursive_dispatch_key_released(MwLL handle, int* k) { // This will close/terminate the application when the main window is closed. - (void)windowWillClose:(NSNotification*)notification { (void)notification; - // MilskoCocoa *window = notification.object; - // MwLL handle = [window getHandle].pointer; - // MwLLDispatch(handle, close, NULL); - [NSApp terminate:nil]; + MilskoCocoa* window = notification.object; + MwLL handle = [window getHandle].pointer; + MwLLDispatch(handle, close, NULL); } - (MilskoCocoaWindowDelegate*)initWithWin:(NSWindow*)win { @@ -1235,7 +1236,9 @@ static void MwLLEndStateChangeImpl(MwLL handle) { } static int MwLLCocoaCallInitImpl(void) { - [NSApplication sharedApplication]; + printf("Using GNUStep Backend\n"); + + [MilskoCocoaApplication sharedApplication]; return 0; }