From d6cbb705c1f624e67cd060a833f390a6efd76106 Mon Sep 17 00:00:00 2001 From: Daniel Collin Date: Mon, 4 Jan 2016 21:14:06 +0100 Subject: [PATCH] Mac fixes * Removed resizing of window as that isn't supported * Fixed issue that content view would be too small and top of window wouldn't be visible * Removed some code that isn't needed Bump lib version to 0.2.3 --- Cargo.toml | 2 +- src/native/macosx/MacMiniFB.m | 4 +-- src/native/macosx/OSXWindow.m | 43 ++------------------------ src/native/macosx/OSXWindowFrameView.m | 17 ---------- 4 files changed, 5 insertions(+), 61 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index fd4f9d7..27a85b6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "minifb" -version = "0.2.2" +version = "0.2.3" license = "MIT" authors = ["Daniel Collin "] description = "Cross-platform window setup for bitmap rendering" diff --git a/src/native/macosx/MacMiniFB.m b/src/native/macosx/MacMiniFB.m index c761c42..445137d 100644 --- a/src/native/macosx/MacMiniFB.m +++ b/src/native/macosx/MacMiniFB.m @@ -18,9 +18,9 @@ void* mfb_open(const char* name, int width, int height, int scale) s_init = true; } - unsigned int styles = NSResizableWindowMask | NSClosableWindowMask | NSTitledWindowMask; + unsigned int styles = NSClosableWindowMask | NSTitledWindowMask; + NSRect rectangle = NSMakeRect(0, 0, width * scale, (height * scale)); - NSRect rectangle = NSMakeRect(0, 0, width * scale, height * scale); OSXWindow* window = [[OSXWindow alloc] initWithContentRect:rectangle styleMask:styles backing:NSBackingStoreBuffered defer:NO]; if (!window) diff --git a/src/native/macosx/OSXWindow.m b/src/native/macosx/OSXWindow.m index fb5f196..7f047ca 100644 --- a/src/native/macosx/OSXWindow.m +++ b/src/native/macosx/OSXWindow.m @@ -5,38 +5,6 @@ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -- (id)initWithContentRect:(NSRect)contentRect - styleMask:(NSUInteger)windowStyle - backing:(NSBackingStoreType)bufferingType - defer:(BOOL)deferCreation -{ - self = [super - initWithContentRect:contentRect - styleMask:windowStyle - backing:bufferingType - defer:deferCreation]; - if (self) - { - [self setOpaque:YES]; - [self setBackgroundColor:[NSColor clearColor]]; - - [[NSNotificationCenter defaultCenter] - addObserver:self - selector:@selector(mainWindowChanged:) - name:NSWindowDidBecomeMainNotification - object:self]; - - [[NSNotificationCenter defaultCenter] - addObserver:self - selector:@selector(mainWindowChanged:) - name:NSWindowDidResignMainNotification - object:self]; - } - return self; -} - -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - (void)dealloc { [[NSNotificationCenter defaultCenter] @@ -142,9 +110,7 @@ - (void)setContentView:(NSView *)aView { if ([childContentView isEqualTo:aView]) - { return; - } NSRect bounds = [self frame]; bounds.origin = NSZeroPoint; @@ -163,6 +129,8 @@ if (childContentView) [childContentView removeFromSuperview]; + NSRect t = [self contentRectForFrameRect:bounds]; + childContentView = aView; [childContentView setFrame:[self contentRectForFrameRect:bounds]]; [childContentView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; @@ -200,13 +168,6 @@ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -+ (NSRect)frameRectForContentRect:(NSRect)windowContentRect styleMask:(NSUInteger)windowStyle -{ - return NSInsetRect(windowContentRect, 0, 0); -} - -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - (void)updateSize { OSXWindowFrameView* frameView = [super contentView]; diff --git a/src/native/macosx/OSXWindowFrameView.m b/src/native/macosx/OSXWindowFrameView.m index 09b0b65..b8e590d 100644 --- a/src/native/macosx/OSXWindowFrameView.m +++ b/src/native/macosx/OSXWindowFrameView.m @@ -4,23 +4,6 @@ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -- (NSRect)resizeRect -{ - const CGFloat resizeBoxSize = 16.0; - const CGFloat contentViewPadding = 5.5; - - NSRect contentViewRect = [[self window] contentRectForFrameRect:[[self window] frame]]; - NSRect resizeRect = NSMakeRect( - NSMaxX(contentViewRect) + contentViewPadding, - NSMinY(contentViewRect) - resizeBoxSize - contentViewPadding, - resizeBoxSize, - resizeBoxSize); - - return resizeRect; -} - -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - (void)drawRect:(NSRect)rect { CGContextRef context = [[NSGraphicsContext currentContext] graphicsPort];