From 2b8b17402ed59815019b309051b277ba4de82f3b Mon Sep 17 00:00:00 2001 From: Akemi Date: Thu, 15 Dec 2016 23:06:04 +0100 Subject: [PATCH] cocoa: cosmetic fixes --- osdep/macosx_application.m | 3 ++- osdep/macosx_events.m | 14 +++++++++----- video/out/cocoa/events_view.m | 23 ++++++++++++++--------- video/out/cocoa/video_view.m | 3 ++- video/out/cocoa/window.m | 6 ++++-- video/out/cocoa_common.m | 15 ++++++++++----- waftools/fragments/cocoa.m | 3 ++- 7 files changed, 43 insertions(+), 24 deletions(-) diff --git a/osdep/macosx_application.m b/osdep/macosx_application.m index 8808caa0a4..d31269279e 100644 --- a/osdep/macosx_application.m +++ b/osdep/macosx_application.m @@ -206,7 +206,8 @@ static void terminate_cocoa_application(void) return [item autorelease]; } -- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)theApp { +- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)theApp +{ return NSTerminateNow; } diff --git a/osdep/macosx_events.m b/osdep/macosx_events.m index c493c58c96..494c9aa88c 100644 --- a/osdep/macosx_events.m +++ b/osdep/macosx_events.m @@ -142,7 +142,8 @@ static int mk_flags(NSEvent *event) return ([event data1] & 0x0000FFFF); } -static int mk_down(NSEvent *event) { +static int mk_down(NSEvent *event) +{ return (((mk_flags(event) & 0xFF00) >> 8)) == 0xA; } @@ -178,11 +179,13 @@ static CGEventRef tap_event_callback(CGEventTapProxy proxy, CGEventType type, } } -void cocoa_init_media_keys(void) { +void cocoa_init_media_keys(void) +{ [[EventsResponder sharedInstance] startMediaKeys]; } -void cocoa_uninit_media_keys(void) { +void cocoa_uninit_media_keys(void) +{ [[EventsResponder sharedInstance] stopMediaKeys]; } @@ -446,10 +449,11 @@ void cocoa_set_input_context(struct input_ctx *input_context) NSString *chars; - if ([self useAltGr] && RightAltPressed([event modifierFlags])) + if ([self useAltGr] && RightAltPressed([event modifierFlags])) { chars = [event characters]; - else + } else { chars = [event charactersIgnoringModifiers]; + } struct bstr t = bstr0([chars UTF8String]); int key = convert_key([event keyCode], bstr_decode_utf8(t, &t)); diff --git a/video/out/cocoa/events_view.m b/video/out/cocoa/events_view.m index 53d1da86ff..d377597006 100644 --- a/video/out/cocoa/events_view.m +++ b/video/out/cocoa/events_view.m @@ -39,7 +39,8 @@ @synthesize tracker = _tracker; @synthesize hasMouseDown = _mouse_down; -- (id)initWithFrame:(NSRect)frame { +- (id)initWithFrame:(NSRect)frame +{ self = [super initWithFrame:frame]; if (self) { [self registerForDraggedTypes:@[NSFilenamesPboardType, @@ -96,21 +97,25 @@ { return [self.adapter mouseEnabled]; } -- (BOOL)acceptsFirstResponder { +- (BOOL)acceptsFirstResponder +{ return [self.adapter keyboardEnabled] || [self.adapter mouseEnabled]; } -- (BOOL)becomeFirstResponder { +- (BOOL)becomeFirstResponder +{ return [self.adapter keyboardEnabled] || [self.adapter mouseEnabled]; } - (BOOL)resignFirstResponder { return YES; } -- (void)keyDown:(NSEvent *)event { +- (void)keyDown:(NSEvent *)event +{ [self.adapter putKeyEvent:event]; } -- (void)keyUp:(NSEvent *)event { +- (void)keyUp:(NSEvent *)event +{ [self.adapter putKeyEvent:event]; } @@ -298,10 +303,11 @@ NSPasteboard *pboard = [sender draggingPasteboard]; NSArray *types = [pboard types]; if ([types containsObject:NSFilenamesPboardType] || - [types containsObject:NSURLPboardType]) + [types containsObject:NSURLPboardType]) { return NSDragOperationCopy; - else + } else { return NSDragOperationNone; + } } - (BOOL)performDragOperation:(id )sender @@ -314,8 +320,7 @@ for (NSURL* url in pbitems) { if (url.fileURL) { [ar addObject:[url path]]; - } - else { + } else { [ar addObject:[url absoluteString]]; } } diff --git a/video/out/cocoa/video_view.m b/video/out/cocoa/video_view.m index 786c6ef4da..cb09dc8b9f 100644 --- a/video/out/cocoa/video_view.m +++ b/video/out/cocoa/video_view.m @@ -22,7 +22,8 @@ @implementation MpvVideoView @synthesize adapter = _adapter; -- (id)initWithFrame:(NSRect)frame { +- (id)initWithFrame:(NSRect)frame +{ self = [super initWithFrame:frame]; if (self) { [self setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable]; diff --git a/video/out/cocoa/window.m b/video/out/cocoa/window.m index 6d63263cb4..68e5222a03 100644 --- a/video/out/cocoa/window.m +++ b/video/out/cocoa/window.m @@ -309,7 +309,8 @@ _unfs_content_frame = [self frameRect:_unfs_content_frame forCenteredContentSize:newSize]; } -- (void)tryDequeueSize { +- (void)tryDequeueSize +{ if (_queued_video_size.width <= 0.0 || _queued_video_size.height <= 0.0) return; @@ -330,7 +331,8 @@ } } -- (void)windowDidBecomeMain:(NSNotification *)notification { +- (void)windowDidBecomeMain:(NSNotification *)notification +{ [self tryDequeueSize]; } @end diff --git a/video/out/cocoa_common.m b/video/out/cocoa_common.m index c1a65ef2ee..164663c332 100644 --- a/video/out/cocoa_common.m +++ b/video/out/cocoa_common.m @@ -803,20 +803,24 @@ int vo_cocoa_control(struct vo *vo, int *events, int request, void *arg) @implementation MpvCocoaAdapter @synthesize vout = _video_output; -- (void)performAsyncResize:(NSSize)size { +- (void)performAsyncResize:(NSSize)size +{ struct vo_cocoa_state *s = self.vout->cocoa; vo_cocoa_resize_redraw(self.vout, size.width, size.height); } -- (BOOL)keyboardEnabled { +- (BOOL)keyboardEnabled +{ return !!mp_input_vo_keyboard_enabled(self.vout->input_ctx); } -- (BOOL)mouseEnabled { +- (BOOL)mouseEnabled +{ return !!mp_input_mouse_enabled(self.vout->input_ctx); } -- (void)setNeedsResize { +- (void)setNeedsResize +{ resize_event(self.vout); } @@ -830,7 +834,8 @@ int vo_cocoa_control(struct vo *vo, int *events, int request, void *arg) [self.vout->cocoa->window setMovableByWindowBackground:movable]; } -- (void)signalMouseMovement:(NSPoint)point { +- (void)signalMouseMovement:(NSPoint)point +{ mp_input_set_mouse_pos(self.vout->input_ctx, point.x, point.y); [self recalcMovableByWindowBackground:point]; } diff --git a/waftools/fragments/cocoa.m b/waftools/fragments/cocoa.m index 3c6230401d..91b3aaa585 100644 --- a/waftools/fragments/cocoa.m +++ b/waftools/fragments/cocoa.m @@ -4,7 +4,8 @@ #include "osdep/macosx_compat.h" -int main(int argc, char **argv) { +int main(int argc, char **argv) +{ @autoreleasepool { NSArray *ary = @[@1, @2, @3]; NSLog(@"test subscripting: %@", ary[0]);