Fixed macOS warnings

This commit is contained in:
Daniel Collin 2018-10-19 22:05:15 +02:00
parent 6a92232b75
commit 450502f672
3 changed files with 55 additions and 16 deletions

View file

@ -63,16 +63,16 @@ void* mfb_open(const char* name, int width, int height, uint32_t flags, int scal
s_init = true; s_init = true;
} }
uint32_t styles = NSClosableWindowMask | NSMiniaturizableWindowMask; NSWindowStyleMask styles = NSWindowStyleMaskClosable | NSWindowStyleMaskResizable;
if (flags & WINDOW_BORDERLESS) if (flags & WINDOW_BORDERLESS)
styles |= NSBorderlessWindowMask; styles |= NSWindowStyleMaskBorderless;
if (flags & WINDOW_RESIZE) if (flags & WINDOW_RESIZE)
styles |= NSResizableWindowMask; styles |= NSWindowStyleMaskResizable;
if (flags & WINDOW_TITLE) if (flags & WINDOW_TITLE)
styles |= NSTitledWindowMask; styles |= NSWindowStyleMaskTitled;
NSRect rectangle = NSMakeRect(0, 0, width * scale, (height * scale)); NSRect rectangle = NSMakeRect(0, 0, width * scale, (height * scale));
@ -184,7 +184,7 @@ static void create_standard_menu(void)
[[appMenu addItemWithTitle:@"Hide Others" [[appMenu addItemWithTitle:@"Hide Others"
action:@selector(hideOtherApplications:) action:@selector(hideOtherApplications:)
keyEquivalent:@"h"] keyEquivalent:@"h"]
setKeyEquivalentModifierMask:NSAlternateKeyMask | NSCommandKeyMask]; setKeyEquivalentModifierMask:NSEventModifierFlagOption | NSEventModifierFlagCommand];
[appMenu addItemWithTitle:@"Show All" [appMenu addItemWithTitle:@"Show All"
action:@selector(unhideAllApplications:) action:@selector(unhideAllApplications:)
keyEquivalent:@""]; keyEquivalent:@""];
@ -257,7 +257,7 @@ static int update_events()
do do
{ {
event = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate distantPast] inMode:NSDefaultRunLoopMode dequeue:YES]; event = [NSApp nextEventMatchingMask:NSEventMaskAny untilDate:[NSDate distantPast] inMode:NSDefaultRunLoopMode dequeue:YES];
if (event) { if (event) {
[NSApp sendEvent:event]; [NSApp sendEvent:event];
@ -285,7 +285,7 @@ static int generic_update(OSXWindow* win)
if (win->shared_data) { if (win->shared_data) {
NSPoint p = [win mouseLocationOutsideOfEventStream]; NSPoint p = [win mouseLocationOutsideOfEventStream];
NSRect originalFrame = [win frame]; NSRect originalFrame = [win frame];
NSRect contentRect = [NSWindow contentRectForFrameRect: originalFrame styleMask: NSTitledWindowMask]; NSRect contentRect = [NSWindow contentRectForFrameRect: originalFrame styleMask: NSWindowStyleMaskTitled];
win->shared_data->mouse_x = p.x; win->shared_data->mouse_x = p.x;
win->shared_data->mouse_y = contentRect.size.height - p.y; win->shared_data->mouse_y = contentRect.size.height - p.y;
} }
@ -297,6 +297,7 @@ static int generic_update(OSXWindow* win)
int mfb_update(void* window, void* buffer) int mfb_update(void* window, void* buffer)
{ {
(void)buffer;
OSXWindow* win = (OSXWindow*)window; OSXWindow* win = (OSXWindow*)window;
return generic_update(win); return generic_update(win);
} }
@ -405,7 +406,7 @@ void mfb_remove_menu(void* window, const char* name)
{ {
OSXWindow* win = (OSXWindow*)window; OSXWindow* win = (OSXWindow*)window;
NSString* ns_name = [NSString stringWithUTF8String: name]; //NSString* ns_name = [NSString stringWithUTF8String: name];
NSMenu* main_menu = [NSApp mainMenu]; NSMenu* main_menu = [NSApp mainMenu];
int len = win->menu_data->menu_count; int len = win->menu_data->menu_count;
@ -538,17 +539,17 @@ uint64_t mfb_add_menu_item(
// //
if ((modfier & MENU_KEY_CTRL)) { if ((modfier & MENU_KEY_CTRL)) {
mask |= NSCommandKeyMask; mask |= NSEventModifierFlagCommand;
} }
if ((modfier & MENU_KEY_CTRL) && if ((modfier & MENU_KEY_CTRL) &&
(modfier & MENU_KEY_COMMAND)) { (modfier & MENU_KEY_COMMAND)) {
mask |= NSControlKeyMask; mask |= NSEventModifierFlagControl;
} }
if (modfier & MENU_KEY_SHIFT) { if (modfier & MENU_KEY_SHIFT) {
mask |= NSShiftKeyMask; mask |= NSEventModifierFlagShift;
} }
if (modfier & MENU_KEY_ALT) { if (modfier & MENU_KEY_ALT) {
mask |= NSAlternateKeyMask; mask |= NSEventModifierFlagOption;
} }
switch (key) { switch (key) {
@ -615,6 +616,7 @@ void* mfb_create_menu(const char* name) {
void mfb_destroy_menu(void* menu_item, const char* name) void mfb_destroy_menu(void* menu_item, const char* name)
{ {
(void)name;
NSMenuItem* item = (NSMenuItem*)menu_item; NSMenuItem* item = (NSMenuItem*)menu_item;
NSMenu* main_menu = [NSApp mainMenu]; NSMenu* main_menu = [NSApp mainMenu];
[main_menu removeItem:item]; [main_menu removeItem:item];
@ -632,7 +634,10 @@ void mfb_remove_menu_item(void* parent, uint64_t menu_item) {
uint64_t mfb_add_menu(void* window, void* m) uint64_t mfb_add_menu(void* window, void* m)
{ {
OSXWindow* win = (OSXWindow*)window; (void)m;
(void)window;
//OSXWindow* win = (OSXWindow*)window;
NSMenu* menu = (NSMenu*)m; NSMenu* menu = (NSMenu*)m;
NSMenu* main_menu = [NSApp mainMenu]; NSMenu* main_menu = [NSApp mainMenu];

View file

@ -105,6 +105,7 @@
- (void)windowWillClose:(NSNotification *)notification - (void)windowWillClose:(NSNotification *)notification
{ {
(void)notification;
should_close = true; should_close = true;
} }
@ -112,6 +113,7 @@
- (BOOL)windowShouldClose:(id)sender - (BOOL)windowShouldClose:(id)sender
{ {
(void)sender;
should_close = true; should_close = true;
return TRUE; return TRUE;
} }
@ -152,7 +154,7 @@
if (childContentView) if (childContentView)
[childContentView removeFromSuperview]; [childContentView removeFromSuperview];
NSRect t = [self contentRectForFrameRect:bounds]; //NSRect t = [self contentRectForFrameRect:bounds];
childContentView = aView; childContentView = aView;
[childContentView setFrame:[self contentRectForFrameRect:bounds]]; [childContentView setFrame:[self contentRectForFrameRect:bounds]];

View file

@ -24,7 +24,9 @@
- (void)drawRect:(NSRect)rect - (void)drawRect:(NSRect)rect
{ {
CGContextRef context = [[NSGraphicsContext currentContext] graphicsPort]; (void)rect;
CGContextRef context = [[NSGraphicsContext currentContext] CGContext];
//CGContextRef context = [[NSGraphicsContext currentContext]];
CGColorSpaceRef space = CGColorSpaceCreateDeviceRGB(); CGColorSpaceRef space = CGColorSpaceCreateDeviceRGB();
CGDataProviderRef provider = CGDataProviderCreateWithData(NULL, draw_buffer, width * height * 4, NULL); CGDataProviderRef provider = CGDataProviderCreateWithData(NULL, draw_buffer, width * height * 4, NULL);
@ -42,8 +44,34 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*
- (BOOL)wantsUpdateLayer
{
return TRUE;
}
*/
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*
-(void)updateLayer
{
// Force the graphics context to clear to black so we don't get a flash of
// white until the app is ready to draw. In practice on modern macOS, this
// only gets called for window creation and other extraordinary events.
self.layer.backgroundColor = NSColor.blackColor.CGColor;
ScheduleContextUpdates((SDL_WindowData *) _sdlWindow->driverdata);
SDL_SendWindowEvent(_sdlWindow, SDL_WINDOWEVENT_EXPOSED, 0, 0);
[context scheduleUpdate];
}
*/
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- (void)mouseDown:(NSEvent*)event - (void)mouseDown:(NSEvent*)event
{ {
(void)event;
OSXWindow* window = (OSXWindow*)[self window]; OSXWindow* window = (OSXWindow*)[self window];
window->shared_data->mouse_state[0] = 1; window->shared_data->mouse_state[0] = 1;
} }
@ -52,6 +80,7 @@
- (void)mouseUp:(NSEvent*)event - (void)mouseUp:(NSEvent*)event
{ {
(void)event;
OSXWindow* window = (OSXWindow*)[self window]; OSXWindow* window = (OSXWindow*)[self window];
window->shared_data->mouse_state[0] = 0; window->shared_data->mouse_state[0] = 0;
} }
@ -60,6 +89,7 @@
- (void)rightMouseDown:(NSEvent*)event - (void)rightMouseDown:(NSEvent*)event
{ {
(void)event;
OSXWindow* window = (OSXWindow*)[self window]; OSXWindow* window = (OSXWindow*)[self window];
window->shared_data->mouse_state[2] = 1; window->shared_data->mouse_state[2] = 1;
} }
@ -68,6 +98,7 @@
- (void)rightMouseUp:(NSEvent*)event - (void)rightMouseUp:(NSEvent*)event
{ {
(void)event;
OSXWindow* window = (OSXWindow*)[self window]; OSXWindow* window = (OSXWindow*)[self window];
window->shared_data->mouse_state[2] = 0; window->shared_data->mouse_state[2] = 0;
} }
@ -124,8 +155,9 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- (void)windowResized:(NSNotification *)notification; - (void)windowResized:(NSNotification *)notification
{ {
(void)notification;
NSSize size = [self bounds].size; NSSize size = [self bounds].size;
OSXWindow* window = (OSXWindow*)[self window]; OSXWindow* window = (OSXWindow*)[self window];