cocoa: cosmetic fixes

This commit is contained in:
Akemi 2016-12-15 23:06:04 +01:00
parent aab98776f6
commit 2b8b17402e
7 changed files with 43 additions and 24 deletions

View File

@ -206,7 +206,8 @@ static void terminate_cocoa_application(void)
return [item autorelease];
}
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)theApp {
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)theApp
{
return NSTerminateNow;
}

View File

@ -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));

View File

@ -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 <NSDraggingInfo>)sender
@ -314,8 +320,7 @@
for (NSURL* url in pbitems) {
if (url.fileURL) {
[ar addObject:[url path]];
}
else {
} else {
[ar addObject:[url absoluteString]];
}
}

View File

@ -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];

View File

@ -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

View File

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

View File

@ -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]);