mirror of https://github.com/mpv-player/mpv
mac: cleanup swift bridge header imports and unify them
This commit is contained in:
parent
7c86074a15
commit
ba45f2004f
|
@ -17,8 +17,6 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "input/input.h"
|
||||
|
||||
enum {
|
||||
FRAME_VISIBLE = 0,
|
||||
FRAME_WHOLE,
|
||||
|
|
|
@ -75,6 +75,11 @@ NSData *app_bridge_icon(void)
|
|||
return [NSData dataWithBytesNoCopy:(void *)app_icon length:sizeof(app_icon) - 1 freeWhenDone:NO];
|
||||
}
|
||||
|
||||
void app_bridge_tarray_append(void *t, char ***a, int *i, char *s)
|
||||
{
|
||||
MP_TARRAY_APPEND(t, *a, *i, s);
|
||||
}
|
||||
|
||||
const struct m_sub_options *app_bridge_mac_conf(void)
|
||||
{
|
||||
return &macos_conf;
|
||||
|
|
|
@ -15,10 +15,41 @@
|
|||
* License along with mpv. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import <QuartzCore/QuartzCore.h>
|
||||
|
||||
#include "player/client.h"
|
||||
#include "video/out/libmpv.h"
|
||||
#include "libmpv/render_gl.h"
|
||||
|
||||
#include "options/m_config.h"
|
||||
#include "player/core.h"
|
||||
#include "input/input.h"
|
||||
#include "input/event.h"
|
||||
#include "input/keycodes.h"
|
||||
#include "video/out/win_state.h"
|
||||
|
||||
#include "osdep/mac/app_bridge.h"
|
||||
#include "osdep/mac/application_objc.h"
|
||||
|
||||
// complex macros won't get imported to swift so we have to reassign them
|
||||
static int SWIFT_MBTN_LEFT = MP_MBTN_LEFT;
|
||||
static int SWIFT_MBTN_MID = MP_MBTN_MID;
|
||||
static int SWIFT_MBTN_RIGHT = MP_MBTN_RIGHT;
|
||||
static int SWIFT_WHEEL_UP = MP_WHEEL_UP;
|
||||
static int SWIFT_WHEEL_DOWN = MP_WHEEL_DOWN;
|
||||
static int SWIFT_WHEEL_LEFT = MP_WHEEL_LEFT;
|
||||
static int SWIFT_WHEEL_RIGHT = MP_WHEEL_RIGHT;
|
||||
static int SWIFT_MBTN_BACK = MP_MBTN_BACK;
|
||||
static int SWIFT_MBTN_FORWARD = MP_MBTN_FORWARD;
|
||||
static int SWIFT_MBTN9 = MP_MBTN9;
|
||||
|
||||
static int SWIFT_KEY_MOUSE_LEAVE = MP_KEY_MOUSE_LEAVE;
|
||||
static int SWIFT_KEY_MOUSE_ENTER = MP_KEY_MOUSE_ENTER;
|
||||
|
||||
static const char *swift_mpv_version = mpv_version;
|
||||
static const char *swift_mpv_copyright = mpv_copyright;
|
||||
|
||||
NSData *app_bridge_icon(void);
|
||||
void app_bridge_tarray_append(void *t, char ***a, int *i, char *s);
|
||||
const struct m_sub_options *app_bridge_mac_conf(void);
|
||||
const struct m_sub_options *app_bridge_vo_conf(void);
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
* License along with mpv. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import Cocoa
|
||||
|
||||
class AppHub: NSObject {
|
||||
@objc static let shared = AppHub()
|
||||
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
* License along with mpv. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import Cocoa
|
||||
|
||||
protocol EventSubscriber: AnyObject {
|
||||
var uid: Int { get }
|
||||
func handle(event: EventHelper.Event)
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
* License along with mpv. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import Cocoa
|
||||
import Carbon.HIToolbox
|
||||
|
||||
class InputHelper: NSObject {
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
* License along with mpv. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import Cocoa
|
||||
|
||||
extension MenuBar {
|
||||
class MenuItem: NSMenuItem {
|
||||
var config: Config?
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# custom swift targets
|
||||
bridge = join_paths(source_root, 'osdep/mac/swift_bridge.h')
|
||||
bridge = join_paths(source_root, 'osdep/mac/app_bridge_objc.h')
|
||||
header = join_paths(build_root, 'osdep/mac/swift.h')
|
||||
module = join_paths(build_root, 'osdep/mac/swift.swiftmodule')
|
||||
target = join_paths(build_root, 'osdep/mac/swift.o')
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
* License along with mpv. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import Cocoa
|
||||
import MediaPlayer
|
||||
|
||||
extension RemoteCommandCenter {
|
||||
|
|
|
@ -1,61 +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 Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with mpv. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// including frameworks here again doesn't make sense, but otherwise the swift
|
||||
// compiler doesn't include the needed headers in our generated header file
|
||||
#import <IOKit/pwr_mgt/IOPMLib.h>
|
||||
#import <QuartzCore/QuartzCore.h>
|
||||
|
||||
#include "player/client.h"
|
||||
#include "video/out/libmpv.h"
|
||||
#include "libmpv/render_gl.h"
|
||||
|
||||
#include "options/m_config.h"
|
||||
#include "player/core.h"
|
||||
#include "input/input.h"
|
||||
#include "input/event.h"
|
||||
#include "input/keycodes.h"
|
||||
#include "video/out/win_state.h"
|
||||
|
||||
#include "osdep/mac/app_bridge_objc.h"
|
||||
#include "osdep/mac/application_objc.h"
|
||||
|
||||
// complex macros won't get imported to Swift so we have to reassign them
|
||||
static int SWIFT_MBTN_LEFT = MP_MBTN_LEFT;
|
||||
static int SWIFT_MBTN_MID = MP_MBTN_MID;
|
||||
static int SWIFT_MBTN_RIGHT = MP_MBTN_RIGHT;
|
||||
static int SWIFT_WHEEL_UP = MP_WHEEL_UP;
|
||||
static int SWIFT_WHEEL_DOWN = MP_WHEEL_DOWN;
|
||||
static int SWIFT_WHEEL_LEFT = MP_WHEEL_LEFT;
|
||||
static int SWIFT_WHEEL_RIGHT = MP_WHEEL_RIGHT;
|
||||
static int SWIFT_MBTN_BACK = MP_MBTN_BACK;
|
||||
static int SWIFT_MBTN_FORWARD = MP_MBTN_FORWARD;
|
||||
static int SWIFT_MBTN9 = MP_MBTN9;
|
||||
|
||||
static int SWIFT_KEY_MOUSE_LEAVE = MP_KEY_MOUSE_LEAVE;
|
||||
static int SWIFT_KEY_MOUSE_ENTER = MP_KEY_MOUSE_ENTER;
|
||||
|
||||
static const char *swift_mpv_version = mpv_version;
|
||||
static const char *swift_mpv_copyright = mpv_copyright;
|
||||
|
||||
// only used from Swift files and therefore seen as unused by the c compiler
|
||||
static void SWIFT_TARRAY_STRING_APPEND(void *t, char ***a, int *i, char *s) __attribute__ ((unused));
|
||||
|
||||
static void SWIFT_TARRAY_STRING_APPEND(void *t, char ***a, int *i, char *s)
|
||||
{
|
||||
MP_TARRAY_APPEND(t, *a, *i, s);
|
||||
}
|
|
@ -15,6 +15,8 @@
|
|||
* License along with mpv. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import Cocoa
|
||||
|
||||
extension NSTouchBar.CustomizationIdentifier {
|
||||
public static let customId: NSTouchBar.CustomizationIdentifier = "io.mpv.touchbar"
|
||||
}
|
||||
|
|
|
@ -626,8 +626,8 @@ class Common: NSObject {
|
|||
var count: Int32 = 0
|
||||
let displayName = getCurrentScreen()?.localizedName ?? "Unknown"
|
||||
|
||||
SWIFT_TARRAY_STRING_APPEND(nil, &array, &count, ta_xstrdup(nil, displayName))
|
||||
SWIFT_TARRAY_STRING_APPEND(nil, &array, &count, nil)
|
||||
app_bridge_tarray_append(nil, &array, &count, ta_xstrdup(nil, displayName))
|
||||
app_bridge_tarray_append(nil, &array, &count, nil)
|
||||
dnames.pointee = array
|
||||
return VO_TRUE
|
||||
case VOCTRL_GET_DISPLAY_RES:
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
*/
|
||||
|
||||
import Cocoa
|
||||
import QuartzCore
|
||||
|
||||
class MetalLayer: CAMetalLayer {
|
||||
unowned var common: MacCommon
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
* License along with mpv. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#import <QuartzCore/QuartzCore.h>
|
||||
|
||||
#include "video/out/gpu/context.h"
|
||||
#include "osdep/mac/swift.h"
|
||||
|
||||
|
|
Loading…
Reference in New Issue