summaryrefslogtreecommitdiffstats
path: root/video/out
diff options
context:
space:
mode:
authorStefano Pigozzi <stefano.pigozzi@gmail.com>2014-10-12 00:14:21 +0200
committerStefano Pigozzi <stefano.pigozzi@gmail.com>2014-10-12 00:19:44 +0200
commit8b6b84f36b00f06e6879db9c3bc9d171afa57cd7 (patch)
tree20b3fbede8d55fc1da9e1983281c0abd79323b35 /video/out
parentb9077214cf63f6103deed12c3047388f5dbb3fc4 (diff)
downloadmpv-8b6b84f36b00f06e6879db9c3bc9d171afa57cd7.tar.bz2
mpv-8b6b84f36b00f06e6879db9c3bc9d171afa57cd7.tar.xz
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.
Diffstat (limited to 'video/out')
-rw-r--r--video/out/cocoa/additions.h27
-rw-r--r--video/out/cocoa/additions.m54
-rw-r--r--video/out/cocoa/events_view.m42
-rw-r--r--video/out/cocoa/window.m2
4 files changed, 37 insertions, 88 deletions
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 <http://www.gnu.org/licenses/>.
- */
-
-#import <Cocoa/Cocoa.h>
-
-@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 <http://www.gnu.org/licenses/>.
- */
-
-#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"