Compare commits

..

No commits in common. "efcc176c0428a2fd8ce2a3f87ef5bb9ce4feabbf" and "31cc8e5a0d2660503cb1a98f6e0b0714d061f72a" have entirely different histories.

View file

@ -1,7 +1,5 @@
#ifndef USE_COCOA #ifndef USE_COCOA
#define USE_COCOA #define USE_COCOA
#include <Foundation/NSGeometry.h>
#include <Foundation/NSObjCRuntime.h>
#endif #endif
#import <AppKit/AppKit.h> #import <AppKit/AppKit.h>
@ -43,7 +41,6 @@
@interface MilskoCocoa : NSObject { @interface MilskoCocoa : NSObject {
NSApplication *application; NSApplication *application;
NSWindow *window; NSWindow *window;
NSRect rect;
} }
+ (MilskoCocoa *)newWithParent:(MwLL)parent + (MilskoCocoa *)newWithParent:(MwLL)parent
@ -103,20 +100,22 @@
} }
c->application = [NSApplication sharedApplication]; c->application = [NSApplication sharedApplication];
c->rect = NSMakeRect(x, y, width, height); NSRect rect = NSMakeRect(x, y, width, height);
c->window = [[NSWindow alloc] c->window = [[[NSWindow alloc]
initWithContentRect:c->rect initWithContentRect:rect
styleMask:parent == NULL styleMask:parent == NULL
? (NSTitledWindowMask | NSClosableWindowMask | ? (NSTitledWindowMask | NSClosableWindowMask |
NSMiniaturizableWindowMask | NSMiniaturizableWindowMask |
NSResizableWindowMask) NSResizableWindowMask)
: NSBorderlessWindowMask : NSBorderlessWindowMask
backing:NSBackingStoreBuffered backing:NSBackingStoreBuffered
defer:NO]; defer:NO] autorelease];
[c->window makeKeyAndOrderFront:c->application]; [c->window makeKeyAndOrderFront:c->application];
if (parent != NULL) { if (parent != NULL) {
[c->window setBackgroundColor:[NSColor blueColor]];
MilskoCocoa *p = parent->cocoa.real; MilskoCocoa *p = parent->cocoa.real;
[p->window addChildWindow:c->window ordered:NSWindowAbove]; [p->window addChildWindow:c->window ordered:NSWindowAbove];
} }
@ -141,16 +140,13 @@
NSPoint p; NSPoint p;
p.x = x; p.x = x;
p.y = y; p.y = y;
NSRect frame = [self->window frame]; [self->window setFrameTopLeftPoint:p];
frame.origin.x = x;
frame.origin.y = y;
[self->window setFrame: frame display: YES animate: true];
}; };
- (void)setW:(int)w H:(int)h { - (void)setW:(int)w H:(int)h {
NSRect frame = [self->window frame]; NSSize s;
frame.size.width = w; s.width = w;
frame.size.height = h; s.height = h;
[self->window setFrame: frame display: YES animate: true]; [self->window setFrameSize:s];
}; };
- (int)pending { - (int)pending {
return 1; return 1;
@ -193,7 +189,7 @@
MaxY:(int)maxy { MaxY:(int)maxy {
}; };
- (void)makeBorderless:(int)toggle { - (void)makeBorderless:(int)toggle {
uint32_t mask = [self->window styleMask]; NSWindowStyleMask mask = self->window.styleMask;
if (mask & NSBorderlessWindowMask) { if (mask & NSBorderlessWindowMask) {
mask ^= NSBorderlessWindowMask; mask ^= NSBorderlessWindowMask;
mask |= NSTitledWindowMask; mask |= NSTitledWindowMask;
@ -201,10 +197,7 @@
mask |= NSBorderlessWindowMask; mask |= NSBorderlessWindowMask;
mask ^= NSTitledWindowMask; mask ^= NSTitledWindowMask;
} }
[self->window initWithContentRect:self->rect [self->window setStyleMask:mask];
styleMask:mask
backing:NSBackingStoreBuffered
defer:NO];
}; };
- (void)focus { - (void)focus {
[self->window makeMainWindow]; [self->window makeMainWindow];
@ -224,12 +217,12 @@
point->x = p.x; point->x = p.x;
point->y = p.y; point->y = p.y;
}; };
- (void)getScreenSize:(MwRect *)_rect { - (void)getScreenSize:(MwRect *)rect {
NSScreen *screen = [self->window screen]; NSScreen *screen = [self->window screen];
_rect->x = [screen frame].origin.x; rect->x = screen.frame.origin.x;
_rect->y = [screen frame].origin.y; rect->y = screen.frame.origin.y;
_rect->width = [screen frame].size.width; rect->width = screen.frame.size.width;
_rect->height = [screen frame].size.height; rect->height = screen.frame.size.height;
}; };
- (void)destroy { - (void)destroy {
[self->window dealloc]; [self->window dealloc];