diff options
author | der richter <der.richter@gmx.de> | 2024-03-27 23:22:56 +0100 |
---|---|---|
committer | der richter <der.richter@gmx.de> | 2024-03-29 14:20:40 +0100 |
commit | ba45f2004f568455a1b3f846516dc2614737eff8 (patch) | |
tree | 784e6563bb369ed9aad3ec28c678da1f69a92246 /osdep | |
parent | 7c86074a1574d6e79876ce1dd2fc5000f35a913b (diff) | |
download | mpv-ba45f2004f568455a1b3f846516dc2614737eff8.tar.bz2 mpv-ba45f2004f568455a1b3f846516dc2614737eff8.tar.xz |
mac: cleanup swift bridge header imports and unify them
Diffstat (limited to 'osdep')
-rw-r--r-- | osdep/mac/app_bridge.h | 2 | ||||
-rw-r--r-- | osdep/mac/app_bridge.m | 5 | ||||
-rw-r--r-- | osdep/mac/app_bridge_objc.h | 33 | ||||
-rw-r--r-- | osdep/mac/app_hub.swift | 2 | ||||
-rw-r--r-- | osdep/mac/event_helper.swift | 2 | ||||
-rw-r--r-- | osdep/mac/input_helper.swift | 1 | ||||
-rw-r--r-- | osdep/mac/menu_bar.swift | 2 | ||||
-rw-r--r-- | osdep/mac/meson.build | 2 | ||||
-rw-r--r-- | osdep/mac/remote_command_center.swift | 1 | ||||
-rw-r--r-- | osdep/mac/swift_bridge.h | 61 | ||||
-rw-r--r-- | osdep/mac/touch_bar.swift | 2 |
11 files changed, 48 insertions, 65 deletions
diff --git a/osdep/mac/app_bridge.h b/osdep/mac/app_bridge.h index 72553b409b..27cc2413ea 100644 --- a/osdep/mac/app_bridge.h +++ b/osdep/mac/app_bridge.h @@ -17,8 +17,6 @@ #pragma once -#include "input/input.h" - enum { FRAME_VISIBLE = 0, FRAME_WHOLE, diff --git a/osdep/mac/app_bridge.m b/osdep/mac/app_bridge.m index d0f17465a8..ab8470d9cc 100644 --- a/osdep/mac/app_bridge.m +++ b/osdep/mac/app_bridge.m @@ -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; diff --git a/osdep/mac/app_bridge_objc.h b/osdep/mac/app_bridge_objc.h index 31cf90662b..c34b09736c 100644 --- a/osdep/mac/app_bridge_objc.h +++ b/osdep/mac/app_bridge_objc.h @@ -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); diff --git a/osdep/mac/app_hub.swift b/osdep/mac/app_hub.swift index 22f30dd9b3..6d4b00fa4c 100644 --- a/osdep/mac/app_hub.swift +++ b/osdep/mac/app_hub.swift @@ -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() diff --git a/osdep/mac/event_helper.swift b/osdep/mac/event_helper.swift index 7170136478..277a9aa08d 100644 --- a/osdep/mac/event_helper.swift +++ b/osdep/mac/event_helper.swift @@ -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) diff --git a/osdep/mac/input_helper.swift b/osdep/mac/input_helper.swift index d53bfe779b..52a5404f0a 100644 --- a/osdep/mac/input_helper.swift +++ b/osdep/mac/input_helper.swift @@ -15,6 +15,7 @@ * License along with mpv. If not, see <http://www.gnu.org/licenses/>. */ +import Cocoa import Carbon.HIToolbox class InputHelper: NSObject { diff --git a/osdep/mac/menu_bar.swift b/osdep/mac/menu_bar.swift index cd3be5cb27..8768348db7 100644 --- a/osdep/mac/menu_bar.swift +++ b/osdep/mac/menu_bar.swift @@ -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? diff --git a/osdep/mac/meson.build b/osdep/mac/meson.build index de32eb2a3c..8ddbdbaddf 100644 --- a/osdep/mac/meson.build +++ b/osdep/mac/meson.build @@ -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') diff --git a/osdep/mac/remote_command_center.swift b/osdep/mac/remote_command_center.swift index 4e3244a152..358a0a00dd 100644 --- a/osdep/mac/remote_command_center.swift +++ b/osdep/mac/remote_command_center.swift @@ -15,6 +15,7 @@ * License along with mpv. If not, see <http://www.gnu.org/licenses/>. */ +import Cocoa import MediaPlayer extension RemoteCommandCenter { diff --git a/osdep/mac/swift_bridge.h b/osdep/mac/swift_bridge.h deleted file mode 100644 index fd236bf6a4..0000000000 --- a/osdep/mac/swift_bridge.h +++ /dev/null @@ -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); -} diff --git a/osdep/mac/touch_bar.swift b/osdep/mac/touch_bar.swift index 811ffcafa4..8e64c51b22 100644 --- a/osdep/mac/touch_bar.swift +++ b/osdep/mac/touch_bar.swift @@ -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" } |