mirror of
https://github.com/mpv-player/mpv
synced 2025-03-21 18:57:35 +00:00
mac/events: remove redundant functions and optimise input helper usage
some redundant functions that jump through hoops.
This commit is contained in:
parent
055e9cd93e
commit
18fb71498b
@ -117,7 +117,7 @@ static void terminate_cocoa_application(void)
|
|||||||
{
|
{
|
||||||
if ([self modalWindow] || ![_eventsResponder processKeyEvent:event])
|
if ([self modalWindow] || ![_eventsResponder processKeyEvent:event])
|
||||||
[super sendEvent:event];
|
[super sendEvent:event];
|
||||||
[_eventsResponder wakeup];
|
[_eventsResponder.inputHelper wakeup];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id)init
|
- (id)init
|
||||||
@ -162,7 +162,6 @@ static const char mac_icon[] =
|
|||||||
- (NSTouchBar *)makeTouchBar
|
- (NSTouchBar *)makeTouchBar
|
||||||
{
|
{
|
||||||
TouchBar *tBar = [[TouchBar alloc] init];
|
TouchBar *tBar = [[TouchBar alloc] init];
|
||||||
[tBar setApp:self];
|
|
||||||
tBar.delegate = tBar;
|
tBar.delegate = tBar;
|
||||||
tBar.customizationIdentifier = customID;
|
tBar.customizationIdentifier = customID;
|
||||||
tBar.defaultItemIdentifiers = @[play, previousItem, nextItem, seekBar];
|
tBar.defaultItemIdentifiers = @[play, previousItem, nextItem, seekBar];
|
||||||
@ -202,17 +201,6 @@ static const char mac_icon[] =
|
|||||||
return &vo_sub_opts;
|
return &vo_sub_opts;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)queueCommand:(char *)cmd
|
|
||||||
{
|
|
||||||
[_eventsResponder queueCommand:cmd];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)stopMPV:(char *)cmd
|
|
||||||
{
|
|
||||||
if (![_eventsResponder queueCommand:cmd])
|
|
||||||
terminate_cocoa_application();
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)applicationWillFinishLaunching:(NSNotification *)notification
|
- (void)applicationWillFinishLaunching:(NSNotification *)notification
|
||||||
{
|
{
|
||||||
NSAppleEventManager *em = [NSAppleEventManager sharedAppleEventManager];
|
NSAppleEventManager *em = [NSAppleEventManager sharedAppleEventManager];
|
||||||
@ -225,7 +213,8 @@ static const char mac_icon[] =
|
|||||||
- (void)handleQuitEvent:(NSAppleEventDescriptor *)event
|
- (void)handleQuitEvent:(NSAppleEventDescriptor *)event
|
||||||
withReplyEvent:(NSAppleEventDescriptor *)replyEvent
|
withReplyEvent:(NSAppleEventDescriptor *)replyEvent
|
||||||
{
|
{
|
||||||
[self stopMPV:"quit"];
|
if (![_eventsResponder.inputHelper command:@"quit"])
|
||||||
|
terminate_cocoa_application();
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)getUrl:(NSAppleEventDescriptor *)event
|
- (void)getUrl:(NSAppleEventDescriptor *)event
|
||||||
@ -240,7 +229,7 @@ static const char mac_icon[] =
|
|||||||
range:NSMakeRange(0, [MPV_PROTOCOL length])];
|
range:NSMakeRange(0, [MPV_PROTOCOL length])];
|
||||||
|
|
||||||
url = [url stringByRemovingPercentEncoding];
|
url = [url stringByRemovingPercentEncoding];
|
||||||
[_eventsResponder handleFilesArray:@[url]];
|
[_eventsResponder.inputHelper openWithFiles:@[url]];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)application:(NSApplication *)sender openFiles:(NSArray *)filenames
|
- (void)application:(NSApplication *)sender openFiles:(NSArray *)filenames
|
||||||
@ -249,14 +238,10 @@ static const char mac_icon[] =
|
|||||||
mpv_shared_app().openCount--;
|
mpv_shared_app().openCount--;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
[self openFiles:filenames];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)openFiles:(NSArray *)filenames
|
|
||||||
{
|
|
||||||
SEL cmpsel = @selector(localizedStandardCompare:);
|
SEL cmpsel = @selector(localizedStandardCompare:);
|
||||||
NSArray *files = [filenames sortedArrayUsingSelector:cmpsel];
|
NSArray *files = [filenames sortedArrayUsingSelector:cmpsel];
|
||||||
[_eventsResponder handleFilesArray:files];
|
[_eventsResponder.inputHelper openWithFiles:files];
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@ -357,7 +342,7 @@ int cocoa_main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
mp_thread_create(&playback_thread_id, playback_thread, &ctx);
|
mp_thread_create(&playback_thread_id, playback_thread, &ctx);
|
||||||
[[EventsResponder sharedInstance] waitForInputContext];
|
[[EventsResponder sharedInstance].inputHelper wait];
|
||||||
cocoa_run_runloop();
|
cocoa_run_runloop();
|
||||||
|
|
||||||
// This should never be reached: cocoa_run_runloop blocks until the
|
// This should never be reached: cocoa_run_runloop blocks until the
|
||||||
|
@ -27,9 +27,6 @@ struct mpv_handle;
|
|||||||
|
|
||||||
- (NSImage *)getMPVIcon;
|
- (NSImage *)getMPVIcon;
|
||||||
- (void)processEvent:(struct mpv_event *)event;
|
- (void)processEvent:(struct mpv_event *)event;
|
||||||
- (void)queueCommand:(char *)cmd;
|
|
||||||
- (void)stopMPV:(char *)cmd;
|
|
||||||
- (void)openFiles:(NSArray *)filenames;
|
|
||||||
- (void)initCocoaCb:(struct mpv_handle *)ctx;
|
- (void)initCocoaCb:(struct mpv_handle *)ctx;
|
||||||
+ (const struct m_sub_options *)getMacOSConf;
|
+ (const struct m_sub_options *)getMacOSConf;
|
||||||
+ (const struct m_sub_options *)getVoSubConf;
|
+ (const struct m_sub_options *)getVoSubConf;
|
||||||
|
@ -24,9 +24,6 @@
|
|||||||
struct input_ctx;
|
struct input_ctx;
|
||||||
struct mpv_handle;
|
struct mpv_handle;
|
||||||
|
|
||||||
void cocoa_put_key(int keycode);
|
|
||||||
void cocoa_put_key_with_modifiers(int keycode, int modifiers);
|
|
||||||
|
|
||||||
void cocoa_init_media_keys(void);
|
void cocoa_init_media_keys(void);
|
||||||
void cocoa_uninit_media_keys(void);
|
void cocoa_uninit_media_keys(void);
|
||||||
|
|
||||||
|
@ -129,20 +129,9 @@ void cocoa_uninit_media_keys(void)
|
|||||||
[[EventsResponder sharedInstance] stopMediaKeys];
|
[[EventsResponder sharedInstance] stopMediaKeys];
|
||||||
}
|
}
|
||||||
|
|
||||||
void cocoa_put_key(int keycode)
|
|
||||||
{
|
|
||||||
[[EventsResponder sharedInstance] putKey:keycode];
|
|
||||||
}
|
|
||||||
|
|
||||||
void cocoa_put_key_with_modifiers(int keycode, int modifiers)
|
|
||||||
{
|
|
||||||
keycode |= [[EventsResponder sharedInstance] mapKeyModifiers:modifiers];
|
|
||||||
cocoa_put_key(keycode);
|
|
||||||
}
|
|
||||||
|
|
||||||
void cocoa_set_input_context(struct input_ctx *input_context)
|
void cocoa_set_input_context(struct input_ctx *input_context)
|
||||||
{
|
{
|
||||||
[[EventsResponder sharedInstance] setInputContext:input_context];
|
[[EventsResponder sharedInstance].inputHelper signalWithInput:input_context];
|
||||||
}
|
}
|
||||||
|
|
||||||
static void wakeup(void *context)
|
static void wakeup(void *context)
|
||||||
@ -186,36 +175,6 @@ void cocoa_init_cocoa_cb(void)
|
|||||||
return responder;
|
return responder;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)waitForInputContext
|
|
||||||
{
|
|
||||||
[_inputHelper wait];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)setInputContext:(struct input_ctx *)ctx
|
|
||||||
{
|
|
||||||
[_inputHelper signalWithInput:ctx];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)wakeup
|
|
||||||
{
|
|
||||||
[_inputHelper wakeup];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (bool)queueCommand:(char *)cmd
|
|
||||||
{
|
|
||||||
return [_inputHelper command:[NSString stringWithUTF8String:cmd]];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)putKey:(int)keycode
|
|
||||||
{
|
|
||||||
[_inputHelper putKey:keycode];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (BOOL)useAltGr
|
|
||||||
{
|
|
||||||
return [_inputHelper useAltGr];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)setIsApplication:(BOOL)isApplication
|
- (void)setIsApplication:(BOOL)isApplication
|
||||||
{
|
{
|
||||||
_is_application = isApplication;
|
_is_application = isApplication;
|
||||||
@ -304,7 +263,7 @@ void cocoa_init_cocoa_cb(void)
|
|||||||
if (cocoaModifiers & NSEventModifierFlagControl)
|
if (cocoaModifiers & NSEventModifierFlagControl)
|
||||||
mask |= MP_KEY_MODIFIER_CTRL;
|
mask |= MP_KEY_MODIFIER_CTRL;
|
||||||
if (LeftAltPressed(cocoaModifiers) ||
|
if (LeftAltPressed(cocoaModifiers) ||
|
||||||
(RightAltPressed(cocoaModifiers) && ![self useAltGr]))
|
(RightAltPressed(cocoaModifiers) && ![_inputHelper useAltGr]))
|
||||||
mask |= MP_KEY_MODIFIER_ALT;
|
mask |= MP_KEY_MODIFIER_ALT;
|
||||||
if (cocoaModifiers & NSEventModifierFlagCommand)
|
if (cocoaModifiers & NSEventModifierFlagCommand)
|
||||||
mask |= MP_KEY_MODIFIER_META;
|
mask |= MP_KEY_MODIFIER_META;
|
||||||
@ -329,9 +288,9 @@ void cocoa_init_cocoa_cb(void)
|
|||||||
-(BOOL)handleMPKey:(int)key withMask:(int)mask
|
-(BOOL)handleMPKey:(int)key withMask:(int)mask
|
||||||
{
|
{
|
||||||
if (key > 0) {
|
if (key > 0) {
|
||||||
cocoa_put_key(key | mask);
|
[_inputHelper putKey:key | mask modifiers:0];
|
||||||
if (mask & MP_KEY_STATE_UP)
|
if (mask & MP_KEY_STATE_UP)
|
||||||
cocoa_put_key(MP_INPUT_RELEASE_ALL);
|
[_inputHelper putKey:MP_INPUT_RELEASE_ALL modifiers:0];
|
||||||
return YES;
|
return YES;
|
||||||
} else {
|
} else {
|
||||||
return NO;
|
return NO;
|
||||||
@ -344,7 +303,7 @@ void cocoa_init_cocoa_cb(void)
|
|||||||
|
|
||||||
NSString *chars;
|
NSString *chars;
|
||||||
|
|
||||||
if ([self useAltGr] && RightAltPressed([event modifierFlags])) {
|
if ([_inputHelper useAltGr] && RightAltPressed([event modifierFlags])) {
|
||||||
chars = [event characters];
|
chars = [event characters];
|
||||||
} else {
|
} else {
|
||||||
chars = [event charactersIgnoringModifiers];
|
chars = [event charactersIgnoringModifiers];
|
||||||
@ -369,9 +328,4 @@ void cocoa_init_cocoa_cb(void)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)handleFilesArray:(NSArray *)files
|
|
||||||
{
|
|
||||||
[_inputHelper openWithFiles:files];
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -27,16 +27,8 @@ struct input_ctx;
|
|||||||
@interface EventsResponder : NSObject
|
@interface EventsResponder : NSObject
|
||||||
|
|
||||||
+ (EventsResponder *)sharedInstance;
|
+ (EventsResponder *)sharedInstance;
|
||||||
- (void)setInputContext:(struct input_ctx *)ctx;
|
|
||||||
- (void)setIsApplication:(BOOL)isApplication;
|
- (void)setIsApplication:(BOOL)isApplication;
|
||||||
|
|
||||||
/// Blocks until inputContext is present.
|
|
||||||
- (void)waitForInputContext;
|
|
||||||
- (void)wakeup;
|
|
||||||
- (void)putKey:(int)keycode;
|
|
||||||
- (void)handleFilesArray:(NSArray *)files;
|
|
||||||
|
|
||||||
- (bool)queueCommand:(char *)cmd;
|
|
||||||
- (bool)processKeyEvent:(NSEvent *)event;
|
- (bool)processKeyEvent:(NSEvent *)event;
|
||||||
|
|
||||||
- (BOOL)handleMPKey:(int)key withMask:(int)mask;
|
- (BOOL)handleMPKey:(int)key withMask:(int)mask;
|
||||||
|
@ -26,10 +26,10 @@ class InputHelper: NSObject {
|
|||||||
self.mpv = mpv
|
self.mpv = mpv
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc func putKey(_ key: Int32) {
|
@objc func putKey(_ key: Int32, modifiers: NSEvent.ModifierFlags = .init(rawValue: 0)) {
|
||||||
lock.withLock {
|
lock.withLock {
|
||||||
guard let input = input else { return }
|
guard let input = input else { return }
|
||||||
mp_input_put_key(input, key)
|
mp_input_put_key(input, key | mapModifier(modifiers))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -318,9 +318,7 @@ class MenuBar: NSObject {
|
|||||||
|
|
||||||
@objc func quit(_ menuItem: MenuItem) {
|
@objc func quit(_ menuItem: MenuItem) {
|
||||||
guard let menuConfig = menuItem.config else { return }
|
guard let menuConfig = menuItem.config else { return }
|
||||||
menuConfig.command.withCString {
|
EventsResponder.sharedInstance().inputHelper.command(menuConfig.command)
|
||||||
(NSApp as? Application)?.stopMPV(UnsafeMutablePointer<CChar>(mutating: $0))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc func openFiles() {
|
@objc func openFiles() {
|
||||||
@ -329,7 +327,7 @@ class MenuBar: NSObject {
|
|||||||
panel.canChooseDirectories = true
|
panel.canChooseDirectories = true
|
||||||
|
|
||||||
if panel.runModal() == .OK {
|
if panel.runModal() == .OK {
|
||||||
(NSApp as? Application)?.openFiles(panel.urls.map { $0.path })
|
EventsResponder.sharedInstance().inputHelper.open(files: panel.urls.map { $0.path })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -337,9 +335,7 @@ class MenuBar: NSObject {
|
|||||||
let panel = NSOpenPanel()
|
let panel = NSOpenPanel()
|
||||||
|
|
||||||
if panel.runModal() == .OK, let url = panel.urls.first {
|
if panel.runModal() == .OK, let url = panel.urls.first {
|
||||||
"loadlist \"\(url.path)\"".withCString {
|
EventsResponder.sharedInstance().inputHelper.command("loadlist \"\(url.path)\"")
|
||||||
EventsResponder.sharedInstance().queueCommand(UnsafeMutablePointer<CChar>(mutating: $0))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -359,15 +355,13 @@ class MenuBar: NSObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if alert.runModal() == .alertFirstButtonReturn && input.stringValue.count > 0 {
|
if alert.runModal() == .alertFirstButtonReturn && input.stringValue.count > 0 {
|
||||||
(NSApp as? Application)?.openFiles([input.stringValue])
|
EventsResponder.sharedInstance().inputHelper.open(files: [input.stringValue])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc func command(_ menuItem: MenuItem) {
|
@objc func command(_ menuItem: MenuItem) {
|
||||||
guard let menuConfig = menuItem.config else { return }
|
guard let menuConfig = menuItem.config else { return }
|
||||||
menuConfig.command.withCString {
|
EventsResponder.sharedInstance().inputHelper.command(menuConfig.command)
|
||||||
EventsResponder.sharedInstance().queueCommand(UnsafeMutablePointer<CChar>(mutating: $0))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc func url(_ menuItem: MenuItem) {
|
@objc func url(_ menuItem: MenuItem) {
|
||||||
|
@ -165,11 +165,8 @@ class RemoteCommandCenter: NSObject {
|
|||||||
return .commandFailed
|
return .commandFailed
|
||||||
}
|
}
|
||||||
|
|
||||||
let success = String(format: "seek %.02f absolute", posEvent.positionTime).withCString {
|
let cmd = String(format: "seek %.02f absolute", posEvent.positionTime)
|
||||||
EventsResponder.sharedInstance().queueCommand(UnsafeMutablePointer<Int8>(mutating: $0))
|
return EventsResponder.sharedInstance().inputHelper.command(cmd) ? .success : .commandFailed
|
||||||
}
|
|
||||||
|
|
||||||
return success ? .success : .commandFailed
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc func processEvent(_ event: UnsafeMutablePointer<mpv_event>) {
|
@objc func processEvent(_ event: UnsafeMutablePointer<mpv_event>) {
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#import <Cocoa/Cocoa.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
#import "osdep/mac/application_objc.h"
|
|
||||||
|
|
||||||
#define BASE_ID @"io.mpv.touchbar"
|
#define BASE_ID @"io.mpv.touchbar"
|
||||||
static NSTouchBarCustomizationIdentifier customID = BASE_ID;
|
static NSTouchBarCustomizationIdentifier customID = BASE_ID;
|
||||||
@ -37,7 +36,6 @@ struct mpv_event;
|
|||||||
|
|
||||||
-(void)processEvent:(struct mpv_event *)event;
|
-(void)processEvent:(struct mpv_event *)event;
|
||||||
|
|
||||||
@property(nonatomic, retain) Application *app;
|
|
||||||
@property(nonatomic, retain) NSDictionary *touchbarItems;
|
@property(nonatomic, retain) NSDictionary *touchbarItems;
|
||||||
@property(nonatomic, assign) double duration;
|
@property(nonatomic, assign) double duration;
|
||||||
@property(nonatomic, assign) double position;
|
@property(nonatomic, assign) double position;
|
||||||
|
@ -17,10 +17,16 @@
|
|||||||
|
|
||||||
#include "player/client.h"
|
#include "player/client.h"
|
||||||
#import "osdep/mac/touchbar.h"
|
#import "osdep/mac/touchbar.h"
|
||||||
|
#import "osdep/mac/events_objc.h"
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#if HAVE_SWIFT
|
||||||
|
#include "osdep/mac/swift.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
@implementation TouchBar
|
@implementation TouchBar
|
||||||
|
|
||||||
@synthesize app = _app;
|
|
||||||
@synthesize touchbarItems = _touchbar_items;
|
@synthesize touchbarItems = _touchbar_items;
|
||||||
@synthesize duration = _duration;
|
@synthesize duration = _duration;
|
||||||
@synthesize position = _position;
|
@synthesize position = _position;
|
||||||
@ -231,7 +237,7 @@
|
|||||||
- (void)buttonAction:(NSButton *)sender
|
- (void)buttonAction:(NSButton *)sender
|
||||||
{
|
{
|
||||||
NSString *identifier = [self getIdentifierFromView:sender];
|
NSString *identifier = [self getIdentifierFromView:sender];
|
||||||
[self.app queueCommand:(char *)[self.touchbarItems[identifier][@"cmd"] UTF8String]];
|
[[EventsResponder sharedInstance].inputHelper command:self.touchbarItems[identifier][@"cmd"]];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)seekbarChanged:(NSSlider *)slider
|
- (void)seekbarChanged:(NSSlider *)slider
|
||||||
@ -239,7 +245,7 @@
|
|||||||
NSString *identifier = [self getIdentifierFromView:slider];
|
NSString *identifier = [self getIdentifierFromView:slider];
|
||||||
NSString *seek = [NSString stringWithFormat:
|
NSString *seek = [NSString stringWithFormat:
|
||||||
self.touchbarItems[identifier][@"cmd"], slider.doubleValue];
|
self.touchbarItems[identifier][@"cmd"], slider.doubleValue];
|
||||||
[self.app queueCommand:(char *)[seek UTF8String]];
|
[[EventsResponder sharedInstance].inputHelper command:seek];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString *)formatTime:(int)time
|
- (NSString *)formatTime:(int)time
|
||||||
|
@ -53,7 +53,7 @@ class View: NSView, CALayerDelegate {
|
|||||||
addTrackingArea(tracker!)
|
addTrackingArea(tracker!)
|
||||||
|
|
||||||
if containsMouseLocation() {
|
if containsMouseLocation() {
|
||||||
cocoa_put_key_with_modifiers(SWIFT_KEY_MOUSE_LEAVE, 0)
|
input?.putKey(SWIFT_KEY_MOUSE_LEAVE)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,14 +118,14 @@ class View: NSView, CALayerDelegate {
|
|||||||
|
|
||||||
override func mouseEntered(with event: NSEvent) {
|
override func mouseEntered(with event: NSEvent) {
|
||||||
if input?.mouseEnabled() ?? true {
|
if input?.mouseEnabled() ?? true {
|
||||||
cocoa_put_key_with_modifiers(SWIFT_KEY_MOUSE_ENTER, 0)
|
input?.putKey(SWIFT_KEY_MOUSE_ENTER)
|
||||||
}
|
}
|
||||||
common.updateCursorVisibility()
|
common.updateCursorVisibility()
|
||||||
}
|
}
|
||||||
|
|
||||||
override func mouseExited(with event: NSEvent) {
|
override func mouseExited(with event: NSEvent) {
|
||||||
if input?.mouseEnabled() ?? true {
|
if input?.mouseEnabled() ?? true {
|
||||||
cocoa_put_key_with_modifiers(SWIFT_KEY_MOUSE_LEAVE, 0)
|
input?.putKey(SWIFT_KEY_MOUSE_LEAVE)
|
||||||
}
|
}
|
||||||
common.titleBar?.hide()
|
common.titleBar?.hide()
|
||||||
common.setCursorVisibility(true)
|
common.setCursorVisibility(true)
|
||||||
@ -202,7 +202,7 @@ class View: NSView, CALayerDelegate {
|
|||||||
func signalMouseEvent(_ event: NSEvent, _ state: UInt32) {
|
func signalMouseEvent(_ event: NSEvent, _ state: UInt32) {
|
||||||
hasMouseDown = state == MP_KEY_STATE_DOWN
|
hasMouseDown = state == MP_KEY_STATE_DOWN
|
||||||
let mpkey = getMpvButton(event)
|
let mpkey = getMpvButton(event)
|
||||||
cocoa_put_key_with_modifiers((mpkey | Int32(state)), Int32(event.modifierFlags.rawValue))
|
input?.putKey((mpkey | Int32(state)), modifiers: event.modifierFlags)
|
||||||
}
|
}
|
||||||
|
|
||||||
func signalMouseMovement(_ event: NSEvent) {
|
func signalMouseMovement(_ event: NSEvent) {
|
||||||
@ -250,7 +250,7 @@ class View: NSView, CALayerDelegate {
|
|||||||
mpkey = deltaX > 0 ? SWIFT_WHEEL_LEFT : SWIFT_WHEEL_RIGHT
|
mpkey = deltaX > 0 ? SWIFT_WHEEL_LEFT : SWIFT_WHEEL_RIGHT
|
||||||
}
|
}
|
||||||
|
|
||||||
cocoa_put_key_with_modifiers(mpkey, Int32(modifiers.rawValue))
|
input?.putKey(mpkey, modifiers: modifiers)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -556,7 +556,7 @@ class Window: NSWindow, NSWindowDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func windowShouldClose(_ sender: NSWindow) -> Bool {
|
func windowShouldClose(_ sender: NSWindow) -> Bool {
|
||||||
cocoa_put_key(MP_KEY_CLOSE_WIN)
|
input?.putKey(MP_KEY_CLOSE_WIN)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user