From 8b6b84f36b00f06e6879db9c3bc9d171afa57cd7 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 12 Oct 2014 00:14:21 +0200 Subject: cocoa: remove usage of Objective-C categories Objective-C categories need special linker flags from the user when statically linking (-ObjC LDFLAG), so make everyone's life simpler and remove them. --- video/out/cocoa/additions.h | 27 ---------------------- video/out/cocoa/additions.m | 54 ------------------------------------------- video/out/cocoa/events_view.m | 42 +++++++++++++++++++++++++++++---- video/out/cocoa/window.m | 2 -- wscript_build.py | 1 - 5 files changed, 37 insertions(+), 89 deletions(-) delete mode 100644 video/out/cocoa/additions.h delete mode 100644 video/out/cocoa/additions.m diff --git a/video/out/cocoa/additions.h b/video/out/cocoa/additions.h deleted file mode 100644 index 8c237c9a40..0000000000 --- a/video/out/cocoa/additions.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * This file is part of mpv. - * - * mpv is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * mpv is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with mpv. If not, see . - */ - -#import - -@interface NSScreen (mpvadditions) -- (BOOL)hasDock; -- (BOOL)hasMenubar; -@end - -@interface NSEvent (mpvadditions) -- (int)mpvButtonNumber; -@end diff --git a/video/out/cocoa/additions.m b/video/out/cocoa/additions.m deleted file mode 100644 index 6f7ea10d1d..0000000000 --- a/video/out/cocoa/additions.m +++ /dev/null @@ -1,54 +0,0 @@ -/* - * This file is part of mpv. - * - * mpv is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * mpv is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with mpv. If not, see . - */ - -#import "additions.h" -#include "osdep/macosx_compat.h" - -@implementation NSScreen (mpvadditions) -- (BOOL)hasDock -{ - NSRect vF = [self visibleFrame]; - NSRect f = [self frame]; - return - // The visible frame's width is smaller: dock is on left or right end - // of this method's receiver. - vF.size.width < f.size.width || - // The visible frame's veritical origin is bigger: dock is - // on the bottom of this method's receiver. - vF.origin.y > f.origin.y; - -} - -- (BOOL)hasMenubar -{ - NSRect vF = [self visibleFrame]; - NSRect f = [self frame]; - return f.size.height + f.origin.y > vF.size.height + vF.origin.y; -} -@end - -@implementation NSEvent (mpvadditions) -- (int)mpvButtonNumber -{ - int buttonNumber = [self buttonNumber]; - switch (buttonNumber) { - case 1: return 2; - case 2: return 1; - default: return buttonNumber; - } -} -@end diff --git a/video/out/cocoa/events_view.m b/video/out/cocoa/events_view.m index 6de24c470c..cbc7223098 100644 --- a/video/out/cocoa/events_view.m +++ b/video/out/cocoa/events_view.m @@ -22,14 +22,15 @@ #include "osdep/macosx_compat.h" #include "video/out/cocoa_common.h" -#import "video/out/cocoa/additions.h" - #include "events_view.h" @interface MpvEventsView() @property(nonatomic, assign) BOOL hasMouseDown; @property(nonatomic, retain) NSTrackingArea *tracker; - (void)signalMousePosition; +- (BOOL)hasDock:(NSScreen*)screen; +- (BOOL)hasMenubar:(NSScreen*)screen; +- (int)mpvButtonNumber:(NSEvent*)event; @end @implementation MpvEventsView @@ -52,14 +53,14 @@ NSApplicationPresentationOptions popts = NSApplicationPresentationDefault; - if ([[self.adapter fsScreen] hasMenubar]) + if ([self hasMenubar:[self.adapter fsScreen]]) // Cocoa raises an exception when autohiding the menubar but // not the dock. They probably got bored while programming the // multi screen support and took some shortcuts (tested on 10.8). popts |= NSApplicationPresentationAutoHideMenuBar | NSApplicationPresentationAutoHideDock; - if ([[self.adapter fsScreen] hasDock]) + if ([self hasDock:[self.adapter fsScreen]]) popts |= NSApplicationPresentationAutoHideDock; NSDictionary *fsopts = @{ @@ -233,7 +234,7 @@ - (void)putMouseEvent:(NSEvent *)event withState:(int)state { self.hasMouseDown = (state == MP_KEY_STATE_DOWN); - int mpkey = (MP_MOUSE_BTN0 + [event mpvButtonNumber]); + int mpkey = (MP_MOUSE_BTN0 + [self mpvButtonNumber:event]); [self.adapter putKey:(mpkey | state) withModifiers:[event modifierFlags]]; } @@ -262,4 +263,35 @@ } return NO; } + +- (BOOL)hasDock:(NSScreen*)screen +{ + NSRect vF = [screen visibleFrame]; + NSRect f = [screen frame]; + return + // The visible frame's width is smaller: dock is on left or right end + // of this method's receiver. + vF.size.width < f.size.width || + // The visible frame's veritical origin is bigger: dock is + // on the bottom of this method's receiver. + vF.origin.y > f.origin.y; + +} + +- (BOOL)hasMenubar:(NSScreen*)screen +{ + NSRect vF = [screen visibleFrame]; + NSRect f = [screen frame]; + return f.size.height + f.origin.y > vF.size.height + vF.origin.y; +} + +- (int)mpvButtonNumber:(NSEvent*)event +{ + int buttonNumber = [event buttonNumber]; + switch (buttonNumber) { + case 1: return 2; + case 2: return 1; + default: return buttonNumber; + } +} @end diff --git a/video/out/cocoa/window.m b/video/out/cocoa/window.m index ece6246f34..8d3b507e27 100644 --- a/video/out/cocoa/window.m +++ b/video/out/cocoa/window.m @@ -21,8 +21,6 @@ #include "osdep/macosx_events.h" #include "osdep/macosx_compat.h" - -#include "video/out/cocoa/additions.h" #include "video/out/cocoa_common.h" #include "window.h" diff --git a/wscript_build.py b/wscript_build.py index c218f101f3..2f2b4afd02 100644 --- a/wscript_build.py +++ b/wscript_build.py @@ -335,7 +335,6 @@ def build(ctx): ( "video/filter/vf_yadif.c" ), ( "video/out/aspect.c" ), ( "video/out/bitmap_packer.c" ), - ( "video/out/cocoa/additions.m", "cocoa" ), ( "video/out/cocoa/video_view.m", "cocoa" ), ( "video/out/cocoa/events_view.m", "cocoa" ), ( "video/out/cocoa/window.m", "cocoa" ), -- cgit v1.2.3