diff --git a/configure b/configure index 0c17663..5551d4c 100755 --- a/configure +++ b/configure @@ -66,6 +66,7 @@ my %features = ( "shared" => "build shared library", "static" => "build static library", "wayland" => "enable wayland backend", + "gnustep" => "use gnustep", ); my @features_keys = ( "1classic-theme", "1stb-image", @@ -73,9 +74,16 @@ my @features_keys = ( "1opengl", "2xrender", "1vulkan", "2vulkan-string-helper", "1shared", "1static", - "1wayland", + "1wayland", "1gnustep", ); +if($target eq "Linux") { + param_set("x11", 1); + if(!param_get("tiny")){ + param_set("wayland", 1); + } +} + foreach my $l (@ARGV) { if ($l =~ /^--with-([^=]+)=(.+)$/) { param_set($1, $2); @@ -138,12 +146,7 @@ foreach my $l (@ARGV) { } } -if($target eq "Linux") { - param_set("x11", 1); - if(!param_get("tiny")){ - param_set("wayland", 1); - } -} + 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 89e5f58..d31e590 100644 --- a/include/Mw/LowLevel/Cocoa.h +++ b/include/Mw/LowLevel/Cocoa.h @@ -15,12 +15,6 @@ #import #import -#ifdef __APPLE__ -#import -#else -#import -#endif - @interface MilskoCocoaApplication : NSApplication { MwBool doPending; } @@ -29,9 +23,9 @@ // Note: implements NSApplicationDelegate @interface MilskoCocoaApplicationDelegate : NSObject { - MilskoCocoaApplication* appl; + NSApplication* appl; } -- (MilskoCocoaApplicationDelegate*)initWithAppl:(MilskoCocoaApplication*)appl; +- (MilskoCocoaApplicationDelegate*)initWithAppl:(NSApplication*)appl; @end @interface MilskoCocoaWindow : NSWindow { @@ -40,7 +34,7 @@ // Note: implements NSWindowDelegate @interface MilskoCocoaWindowDelegate : NSObject { - MilskoCocoaWindow* w; + NSWindow* w; } - (MilskoCocoaWindowDelegate*)initWithWin:(MilskoCocoaWindow*)win; @end @@ -89,8 +83,6 @@ NSBitmapImageRep* rep; NSGraphicsContext* context; MwBool valid; - CGColorSpaceRef space; - CGDataProviderRef provider; NSRect givenRect; float x; float y; @@ -111,16 +103,16 @@ @end @interface MilskoCocoa : NSObject { - MilskoCocoaApplication* application; - MwBool _forceRender; - MwBool _eventsPending; - MilskoCocoaWindow* window; - NSRect rect; - MilskoCocoaView* view; - MwLL parent; - MilskoFakePointer* handle; - unsigned int strHash; - NSEvent* lastEvent; + NSApplication* application; + MwBool _forceRender; + MwBool _eventsPending; + MilskoCocoaWindow* window; + NSRect rect; + MilskoCocoaView* view; + MwLL parent; + MilskoFakePointer* handle; + unsigned int strHash; + NSEvent* lastEvent; MilskoCocoaPixmap* cursorPixmap; NSCursor* cursor; diff --git a/pl/rules.pl b/pl/rules.pl index bf18575..000a6fe 100644 --- a/pl/rules.pl +++ b/pl/rules.pl @@ -52,10 +52,14 @@ if (grep(/^wayland$/, @backends)) { $gl_libs = "-lGL -lGLU"; } -if (grep(/^cocoa$/, @backends)) { +if (grep(/^cocoa$/, @backends) || param_get("gnustep")) { add_cflags("-DUSE_COCOA"); new_object("src/backend/cocoa.m"); + if(param_get("gnustep")){ + add_ldflags("-lobjc -lgnustep-base -lm -lgnustep-gui"); + } + if (param_get("opengl")) { new_object("src/widget/opengl_cocoa.m"); } diff --git a/pl/utils.pl b/pl/utils.pl index 9472123..70c0b51 100644 --- a/pl/utils.pl +++ b/pl/utils.pl @@ -55,7 +55,6 @@ sub new_object { my @l = glob($_[0]); foreach my $e (@l) { $e =~ s/\.(c|m)$/$object_suffix/; - print($e."\n"); push(@library_targets, $e); } } diff --git a/src/backend/cocoa.m b/src/backend/cocoa.m index 6961a96..7b28172 100644 --- a/src/backend/cocoa.m +++ b/src/backend/cocoa.m @@ -325,7 +325,7 @@ static void recursive_dispatch_key_released(MwLL handle, int* k) { if(!parent) { frame = rectFlip(frame); - [self->window setFrame:frame display:TRUE animate:TRUE]; + [self->window setFrame:frame display:MwTRUE animate:MwTRUE]; } else { frame = localRectFlip(frame, parent->cocoa.real->view); [self->view setBounds:frame]; @@ -367,6 +367,7 @@ static void recursive_dispatch_key_released(MwLL handle, int* k) { } [self sendClipboardEvent]; +#ifdef __APPLE__ if(self->pointerLocked && [self->window isMainWindow] && self->lastEvent) { struct CGPoint pos; pos.x = [window frame].origin.x + [window frame].size.width / 2; @@ -374,6 +375,7 @@ static void recursive_dispatch_key_released(MwLL handle, int* k) { CGWarpMouseCursorPosition(pos); } +#endif [self->application updateWindows]; }; @@ -617,13 +619,12 @@ static void recursive_dispatch_key_released(MwLL handle, int* k) { @implementation MilskoCocoaView - (id)initWithFrame:(NSRect)frame { - givenRect = frame; - x = frame.origin.x; - y = frame.origin.y; - width = frame.size.width; - height = frame.size.height; - self = [super initWithFrame:frame]; - self->space = CGColorSpaceCreateDeviceRGB(); + givenRect = frame; + x = frame.origin.x; + y = frame.origin.y; + width = frame.size.width; + height = frame.size.height; + self = [super initWithFrame:frame]; if(width == 0 || height == 0) { self->rep = NULL; @@ -701,7 +702,6 @@ static void recursive_dispatch_key_released(MwLL handle, int* k) { } - (void)destroy { - CGColorSpaceRelease(self->space); [self->rep release]; [self->context release]; } diff --git a/src/backend/x11.c b/src/backend/x11.c index 4068186..ad97d68 100644 --- a/src/backend/x11.c +++ b/src/backend/x11.c @@ -1280,8 +1280,7 @@ static int MwLLX11CallInitImpl(void) { if(getenv("MILSKO_BACKEND")) { loadX11 |= (strcmp(getenv("MILSKO_BACKEND"), "x11") == 0); - } - if(getenv("DISPLAY")) { + } else if(getenv("DISPLAY")) { loadX11 |= (getenv("DISPLAY") != NULL); }