Skip to content

Commit

Permalink
cocoa: cosmetic fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Akemi committed Dec 16, 2016
1 parent aab9877 commit 2b8b174
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 24 deletions.
3 changes: 2 additions & 1 deletion osdep/macosx_application.m
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,8 @@ - (NSMenuItem *)mainMenuItemWithParent:(NSMenu *)parent
return [item autorelease];
}

- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)theApp {
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)theApp
{
return NSTerminateNow;
}

Expand Down
14 changes: 9 additions & 5 deletions osdep/macosx_events.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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];
}

Expand Down Expand Up @@ -446,10 +449,11 @@ - (NSEvent*)handleKey:(NSEvent *)event

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));
Expand Down
23 changes: 14 additions & 9 deletions video/out/cocoa/events_view.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ @implementation MpvEventsView
@synthesize tracker = _tracker;
@synthesize hasMouseDown = _mouse_down;

- (id)initWithFrame:(NSRect)frame {
- (id)initWithFrame:(NSRect)frame
{
self = [super initWithFrame:frame];
if (self) {
[self registerForDraggedTypes:@[NSFilenamesPboardType,
Expand Down Expand Up @@ -96,21 +97,25 @@ - (BOOL)acceptsFirstMouse:(NSEvent *)theEvent
{
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];
}

Expand Down Expand Up @@ -298,10 +303,11 @@ - (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
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 <NSDraggingInfo>)sender
Expand All @@ -314,8 +320,7 @@ - (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
for (NSURL* url in pbitems) {
if (url.fileURL) {
[ar addObject:[url path]];
}
else {
} else {
[ar addObject:[url absoluteString]];
}
}
Expand Down
3 changes: 2 additions & 1 deletion video/out/cocoa/video_view.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
6 changes: 4 additions & 2 deletions video/out/cocoa/window.m
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,8 @@ - (void)updateWindowFrame:(NSSize)newSize
_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;

Expand All @@ -330,7 +331,8 @@ - (void)queueNewVideoSize:(NSSize)newSize
}
}

- (void)windowDidBecomeMain:(NSNotification *)notification {
- (void)windowDidBecomeMain:(NSNotification *)notification
{
[self tryDequeueSize];
}
@end
15 changes: 10 additions & 5 deletions video/out/cocoa_common.m
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -830,7 +834,8 @@ - (void)recalcMovableByWindowBackground:(NSPoint)p
[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];
}
Expand Down
3 changes: 2 additions & 1 deletion waftools/fragments/cocoa.m
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down

0 comments on commit 2b8b174

Please sign in to comment.