some redundant functions that jump through hoops.
Unified · Split
| @@ -117,7 +117,7 @@ static void terminate_cocoa_application(void) · 116 unmodified lines | |||
| 117 | { | 117 | { |
| 118 | if ([self modalWindow] || ![_eventsResponder processKeyEvent:event]) | 118 | if ([self modalWindow] || ![_eventsResponder processKeyEvent:event]) |
| 119 | [super sendEvent:event]; | 119 | [super sendEvent:event]; |
| 120 | [_eventsResponder wakeup]; | 120 | [_eventsResponder.inputHelper wakeup]; |
| 121 | } | 121 | } |
| 122 | 122 | ||
| 123 | - (id)init | 123 | - (id)init |
| @@ -162,7 +162,6 @@ static const char mac_icon[] = · 38 unmodified lines | |||
| 162 | - (NSTouchBar *)makeTouchBar | 162 | - (NSTouchBar *)makeTouchBar |
| 163 | { | 163 | { |
| 164 | TouchBar *tBar = [[TouchBar alloc] init]; | 164 | TouchBar *tBar = [[TouchBar alloc] init]; |
| 165 | [tBar setApp:self]; | ||
| 166 | tBar.delegate = tBar; | 165 | tBar.delegate = tBar; |
| 167 | tBar.customizationIdentifier = customID; | 166 | tBar.customizationIdentifier = customID; |
| 168 | tBar.defaultItemIdentifiers = @[play, previousItem, nextItem, seekBar]; | 167 | tBar.defaultItemIdentifiers = @[play, previousItem, nextItem, seekBar]; |
| @@ -202,17 +201,6 @@ static const char mac_icon[] = · 33 unmodified lines | |||
| 202 | return &vo_sub_opts; | 201 | return &vo_sub_opts; |
| 203 | } | 202 | } |
| 204 | 203 | ||
| 205 | - (void)queueCommand:(char *)cmd | ||
| 206 | { | ||
| 207 | [_eventsResponder queueCommand:cmd]; | ||
| 208 | } | ||
| 209 | |||
| 210 | - (void)stopMPV:(char *)cmd | ||
| 211 | { | ||
| 212 | if (![_eventsResponder queueCommand:cmd]) | ||
| 213 | terminate_cocoa_application(); | ||
| 214 | } | ||
| 215 | |||
| 216 | - (void)applicationWillFinishLaunching:(NSNotification *)notification | 204 | - (void)applicationWillFinishLaunching:(NSNotification *)notification |
| 217 | { | 205 | { |
| 218 | NSAppleEventManager *em = [NSAppleEventManager sharedAppleEventManager]; | 206 | NSAppleEventManager *em = [NSAppleEventManager sharedAppleEventManager]; |
| @@ -225,7 +213,8 @@ static const char mac_icon[] = · 6 unmodified lines | |||
| 225 | - (void)handleQuitEvent:(NSAppleEventDescriptor *)event | 213 | - (void)handleQuitEvent:(NSAppleEventDescriptor *)event |
| 226 | withReplyEvent:(NSAppleEventDescriptor *)replyEvent | 214 | withReplyEvent:(NSAppleEventDescriptor *)replyEvent |
| 227 | { | 215 | { |
| 228 | [self stopMPV:"quit"]; | 216 | if (![_eventsResponder.inputHelper command:@"quit"]) |
| 217 | terminate_cocoa_application(); | ||
| 229 | } | 218 | } |
| 230 | 219 | ||
| 231 | - (void)getUrl:(NSAppleEventDescriptor *)event | 220 | - (void)getUrl:(NSAppleEventDescriptor *)event |
| @@ -240,7 +229,7 @@ static const char mac_icon[] = · 8 unmodified lines | |||
| 240 | range:NSMakeRange(0, [MPV_PROTOCOL length])]; | 229 | range:NSMakeRange(0, [MPV_PROTOCOL length])]; |
| 241 | 230 | ||
| 242 | url = [url stringByRemovingPercentEncoding]; | 231 | url = [url stringByRemovingPercentEncoding]; |
| 243 | [_eventsResponder handleFilesArray:@[url]]; | 232 | [_eventsResponder.inputHelper openWithFiles:@[url]]; |
| 244 | } | 233 | } |
| 245 | 234 | ||
| 246 | - (void)application:(NSApplication *)sender openFiles:(NSArray *)filenames | 235 | - (void)application:(NSApplication *)sender openFiles:(NSArray *)filenames |
| @@ -249,14 +238,10 @@ static const char mac_icon[] = · 2 unmodified lines | |||
| 249 | mpv_shared_app().openCount--; | 238 | mpv_shared_app().openCount--; |
| 250 | return; | 239 | return; |
| 251 | } | 240 | } |
| 252 | [self openFiles:filenames]; | ||
| 253 | } | ||
| 254 | 241 | ||
| 255 | - (void)openFiles:(NSArray *)filenames | ||
| 256 | { | ||
| 257 | SEL cmpsel = @selector(localizedStandardCompare:); | 242 | SEL cmpsel = @selector(localizedStandardCompare:); |
| 258 | NSArray *files = [filenames sortedArrayUsingSelector:cmpsel]; | 243 | NSArray *files = [filenames sortedArrayUsingSelector:cmpsel]; |
| 259 | [_eventsResponder handleFilesArray:files]; | 244 | [_eventsResponder.inputHelper openWithFiles:files]; |
| 260 | } | 245 | } |
| 261 | @end | 246 | @end |
| 262 | 247 | ||
| @@ -357,7 +342,7 @@ int cocoa_main(int argc, char *argv[]) · 94 unmodified lines | |||
| 357 | } | 342 | } |
| 358 | 343 | ||
| 359 | mp_thread_create(&playback_thread_id, playback_thread, &ctx); | 344 | mp_thread_create(&playback_thread_id, playback_thread, &ctx); |
| 360 | [[EventsResponder sharedInstance] waitForInputContext]; | 345 | [[EventsResponder sharedInstance].inputHelper wait]; |
| 361 | cocoa_run_runloop(); | 346 | cocoa_run_runloop(); |
| 362 | 347 | ||
| 363 | // This should never be reached: cocoa_run_runloop blocks until the | 348 | // This should never be reached: cocoa_run_runloop blocks until the |
| @@ -27,9 +27,6 @@ struct mpv_handle; · 26 unmodified lines | |||
| 27 | 27 | ||
| 28 | - (NSImage *)getMPVIcon; | 28 | - (NSImage *)getMPVIcon; |
| 29 | - (void)processEvent:(struct mpv_event *)event; | 29 | - (void)processEvent:(struct mpv_event *)event; |
| 30 | - (void)queueCommand:(char *)cmd; | ||
| 31 | - (void)stopMPV:(char *)cmd; | ||
| 32 | - (void)openFiles:(NSArray *)filenames; | ||
| 33 | - (void)initCocoaCb:(struct mpv_handle *)ctx; | 30 | - (void)initCocoaCb:(struct mpv_handle *)ctx; |
| 34 | + (const struct m_sub_options *)getMacOSConf; | 31 | + (const struct m_sub_options *)getMacOSConf; |
| 35 | + (const struct m_sub_options *)getVoSubConf; | 32 | + (const struct m_sub_options *)getVoSubConf; |
| @@ -24,9 +24,6 @@ · 23 unmodified lines | |||
| 24 | struct input_ctx; | 24 | struct input_ctx; |
| 25 | struct mpv_handle; | 25 | struct mpv_handle; |
| 26 | 26 | ||
| 27 | void cocoa_put_key(int keycode); | ||
| 28 | void cocoa_put_key_with_modifiers(int keycode, int modifiers); | ||
| 29 | |||
| 30 | void cocoa_init_media_keys(void); | 27 | void cocoa_init_media_keys(void); |
| 31 | void cocoa_uninit_media_keys(void); | 28 | void cocoa_uninit_media_keys(void); |
| 32 | 29 | ||
| @@ -129,20 +129,9 @@ void cocoa_uninit_media_keys(void) · 128 unmodified lines | |||
| 129 | [[EventsResponder sharedInstance] stopMediaKeys]; | 129 | [[EventsResponder sharedInstance] stopMediaKeys]; |
| 130 | } | 130 | } |
| 131 | 131 | ||
| 132 | void cocoa_put_key(int keycode) | ||
| 133 | { | ||
| 134 | [[EventsResponder sharedInstance] putKey:keycode]; | ||
| 135 | } | ||
| 136 | |||
| 137 | void cocoa_put_key_with_modifiers(int keycode, int modifiers) | ||
| 138 | { | ||
| 139 | keycode |= [[EventsResponder sharedInstance] mapKeyModifiers:modifiers]; | ||
| 140 | cocoa_put_key(keycode); | ||
| 141 | } | ||
| 142 | |||
| 143 | void cocoa_set_input_context(struct input_ctx *input_context) | 132 | void cocoa_set_input_context(struct input_ctx *input_context) |
| 144 | { | 133 | { |
| 145 | [[EventsResponder sharedInstance] setInputContext:input_context]; | 134 | [[EventsResponder sharedInstance].inputHelper signalWithInput:input_context]; |
| 146 | } | 135 | } |
| 147 | 136 | ||
| 148 | static void wakeup(void *context) | 137 | static void wakeup(void *context) |
| @@ -186,36 +175,6 @@ void cocoa_init_cocoa_cb(void) · 37 unmodified lines | |||
| 186 | return responder; | 175 | return responder; |
| 187 | } | 176 | } |
| 188 | 177 | ||
| 189 | - (void)waitForInputContext | ||
| 190 | { | ||
| 191 | [_inputHelper wait]; | ||
| 192 | } | ||
| 193 | |||
| 194 | - (void)setInputContext:(struct input_ctx *)ctx | ||
| 195 | { | ||
| 196 | [_inputHelper signalWithInput:ctx]; | ||
| 197 | } | ||
| 198 | |||
| 199 | - (void)wakeup | ||
| 200 | { | ||
| 201 | [_inputHelper wakeup]; | ||
| 202 | } | ||
| 203 | |||
| 204 | - (bool)queueCommand:(char *)cmd | ||
| 205 | { | ||
| 206 | return [_inputHelper command:[NSString stringWithUTF8String:cmd]]; | ||
| 207 | } | ||
| 208 | |||
| 209 | - (void)putKey:(int)keycode | ||
| 210 | { | ||
| 211 | [_inputHelper putKey:keycode]; | ||
| 212 | } | ||
| 213 | |||
| 214 | - (BOOL)useAltGr | ||
| 215 | { | ||
| 216 | return [_inputHelper useAltGr]; | ||
| 217 | } | ||
| 218 | |||
| 219 | - (void)setIsApplication:(BOOL)isApplication | 178 | - (void)setIsApplication:(BOOL)isApplication |
| 220 | { | 179 | { |
| 221 | _is_application = isApplication; | 180 | _is_application = isApplication; |
| @@ -304,7 +263,7 @@ void cocoa_init_cocoa_cb(void) · 82 unmodified lines | |||
| 304 | if (cocoaModifiers & NSEventModifierFlagControl) | 263 | if (cocoaModifiers & NSEventModifierFlagControl) |
| 305 | mask |= MP_KEY_MODIFIER_CTRL; | 264 | mask |= MP_KEY_MODIFIER_CTRL; |
| 306 | if (LeftAltPressed(cocoaModifiers) || | 265 | if (LeftAltPressed(cocoaModifiers) || |
| 307 | (RightAltPressed(cocoaModifiers) && ![self useAltGr])) | 266 | (RightAltPressed(cocoaModifiers) && ![_inputHelper useAltGr])) |
| 308 | mask |= MP_KEY_MODIFIER_ALT; | 267 | mask |= MP_KEY_MODIFIER_ALT; |
| 309 | if (cocoaModifiers & NSEventModifierFlagCommand) | 268 | if (cocoaModifiers & NSEventModifierFlagCommand) |
| 310 | mask |= MP_KEY_MODIFIER_META; | 269 | mask |= MP_KEY_MODIFIER_META; |
| @@ -329,9 +288,9 @@ void cocoa_init_cocoa_cb(void) · 18 unmodified lines | |||
| 329 | -(BOOL)handleMPKey:(int)key withMask:(int)mask | 288 | -(BOOL)handleMPKey:(int)key withMask:(int)mask |
| 330 | { | 289 | { |
| 331 | if (key > 0) { | 290 | if (key > 0) { |
| 332 | cocoa_put_key(key | mask); | 291 | [_inputHelper putKey:key | mask modifiers:0]; |
| 333 | if (mask & MP_KEY_STATE_UP) | 292 | if (mask & MP_KEY_STATE_UP) |
| 334 | cocoa_put_key(MP_INPUT_RELEASE_ALL); | 293 | [_inputHelper putKey:MP_INPUT_RELEASE_ALL modifiers:0]; |
| 335 | return YES; | 294 | return YES; |
| 336 | } else { | 295 | } else { |
| 337 | return NO; | 296 | return NO; |
| @@ -344,7 +303,7 @@ void cocoa_init_cocoa_cb(void) · 6 unmodified lines | |||
| 344 | 303 | ||
| 345 | NSString *chars; | 304 | NSString *chars; |
| 346 | 305 | ||
| 347 | if ([self useAltGr] && RightAltPressed([event modifierFlags])) { | 306 | if ([_inputHelper useAltGr] && RightAltPressed([event modifierFlags])) { |
| 348 | chars = [event characters]; | 307 | chars = [event characters]; |
| 349 | } else { | 308 | } else { |
| 350 | chars = [event charactersIgnoringModifiers]; | 309 | chars = [event charactersIgnoringModifiers]; |
| @@ -369,9 +328,4 @@ void cocoa_init_cocoa_cb(void) · 18 unmodified lines | |||
| 369 | return false; | 328 | return false; |
| 370 | } | 329 | } |
| 371 | 330 | ||
| 372 | - (void)handleFilesArray:(NSArray *)files | ||
| 373 | { | ||
| 374 | [_inputHelper openWithFiles:files]; | ||
| 375 | } | ||
| 376 | |||
| 377 | @end | 331 | @end |
| @@ -27,16 +27,8 @@ struct input_ctx; · 26 unmodified lines | |||
| 27 | @interface EventsResponder : NSObject | 27 | @interface EventsResponder : NSObject |
| 28 | 28 | ||
| 29 | + (EventsResponder *)sharedInstance; | 29 | + (EventsResponder *)sharedInstance; |
| 30 | - (void)setInputContext:(struct input_ctx *)ctx; | ||
| 31 | - (void)setIsApplication:(BOOL)isApplication; | 30 | - (void)setIsApplication:(BOOL)isApplication; |
| 32 | 31 | ||
| 33 | /// Blocks until inputContext is present. | ||
| 34 | - (void)waitForInputContext; | ||
| 35 | - (void)wakeup; | ||
| 36 | - (void)putKey:(int)keycode; | ||
| 37 | - (void)handleFilesArray:(NSArray *)files; | ||
| 38 | |||
| 39 | - (bool)queueCommand:(char *)cmd; | ||
| 40 | - (bool)processKeyEvent:(NSEvent *)event; | 32 | - (bool)processKeyEvent:(NSEvent *)event; |
| 41 | 33 | ||
| 42 | - (BOOL)handleMPKey:(int)key withMask:(int)mask; | 34 | - (BOOL)handleMPKey:(int)key withMask:(int)mask; |
| @@ -26,10 +26,10 @@ class InputHelper: NSObject { · 25 unmodified lines | |||
| 26 | self.mpv = mpv | 26 | self.mpv = mpv |
| 27 | } | 27 | } |
| 28 | 28 | ||
| 29 | @objc func putKey(_ key: Int32) { | 29 | @objc func putKey(_ key: Int32, modifiers: NSEvent.ModifierFlags = .init(rawValue: 0)) { |
| 30 | lock.withLock { | 30 | lock.withLock { |
| 31 | guard let input = input else { return } | 31 | guard let input = input else { return } |
| 32 | mp_input_put_key(input, key) | 32 | mp_input_put_key(input, key | mapModifier(modifiers)) |
| 33 | } | 33 | } |
| 34 | } | 34 | } |
| 35 | 35 | ||
| @@ -318,9 +318,7 @@ class MenuBar: NSObject { · 317 unmodified lines | |||
| 318 | 318 | ||
| 319 | @objc func quit(_ menuItem: MenuItem) { | 319 | @objc func quit(_ menuItem: MenuItem) { |
| 320 | guard let menuConfig = menuItem.config else { return } | 320 | guard let menuConfig = menuItem.config else { return } |
| 321 | menuConfig.command.withCString { | 321 | EventsResponder.sharedInstance().inputHelper.command(menuConfig.command) |
| 322 | (NSApp as? Application)?.stopMPV(UnsafeMutablePointer<CChar>(mutating: $0)) | ||
| 323 | } | ||
| 324 | } | 322 | } |
| 325 | 323 | ||
| 326 | @objc func openFiles() { | 324 | @objc func openFiles() { |
| @@ -329,7 +327,7 @@ class MenuBar: NSObject { · 2 unmodified lines | |||
| 329 | panel.canChooseDirectories = true | 327 | panel.canChooseDirectories = true |
| 330 | 328 | ||
| 331 | if panel.runModal() == .OK { | 329 | if panel.runModal() == .OK { |
| 332 | (NSApp as? Application)?.openFiles(panel.urls.map { $0.path }) | 330 | EventsResponder.sharedInstance().inputHelper.open(files: panel.urls.map { $0.path }) |
| 333 | } | 331 | } |
| 334 | } | 332 | } |
| 335 | 333 | ||
| @@ -337,9 +335,7 @@ class MenuBar: NSObject { · 1 unmodified line | |||
| 337 | let panel = NSOpenPanel() | 335 | let panel = NSOpenPanel() |
| 338 | 336 | ||
| 339 | if panel.runModal() == .OK, let url = panel.urls.first { | 337 | if panel.runModal() == .OK, let url = panel.urls.first { |
| 340 | "loadlist \"\(url.path)\"".withCString { | 338 | EventsResponder.sharedInstance().inputHelper.command("loadlist \"\(url.path)\"") |
| 341 | EventsResponder.sharedInstance().queueCommand(UnsafeMutablePointer<CChar>(mutating: $0)) | ||
| 342 | } | ||
| 343 | } | 339 | } |
| 344 | } | 340 | } |
| 345 | 341 | ||
| @@ -359,15 +355,13 @@ class MenuBar: NSObject { · 13 unmodified lines | |||
| 359 | } | 355 | } |
| 360 | 356 | ||
| 361 | if alert.runModal() == .alertFirstButtonReturn && input.stringValue.count > 0 { | 357 | if alert.runModal() == .alertFirstButtonReturn && input.stringValue.count > 0 { |
| 362 | (NSApp as? Application)?.openFiles([input.stringValue]) | 358 | EventsResponder.sharedInstance().inputHelper.open(files: [input.stringValue]) |
| 363 | } | 359 | } |
| 364 | } | 360 | } |
| 365 | 361 | ||
| 366 | @objc func command(_ menuItem: MenuItem) { | 362 | @objc func command(_ menuItem: MenuItem) { |
| 367 | guard let menuConfig = menuItem.config else { return } | 363 | guard let menuConfig = menuItem.config else { return } |
| 368 | menuConfig.command.withCString { | 364 | EventsResponder.sharedInstance().inputHelper.command(menuConfig.command) |
| 369 | EventsResponder.sharedInstance().queueCommand(UnsafeMutablePointer<CChar>(mutating: $0)) | ||
| 370 | } | ||
| 371 | } | 365 | } |
| 372 | 366 | ||
| 373 | @objc func url(_ menuItem: MenuItem) { | 367 | @objc func url(_ menuItem: MenuItem) { |
| @@ -165,11 +165,8 @@ class RemoteCommandCenter: NSObject { · 164 unmodified lines | |||
| 165 | return .commandFailed | 165 | return .commandFailed |
| 166 | } | 166 | } |
| 167 | 167 | ||
| 168 | let success = String(format: "seek %.02f absolute", posEvent.positionTime).withCString { | 168 | let cmd = String(format: "seek %.02f absolute", posEvent.positionTime) |
| 169 | EventsResponder.sharedInstance().queueCommand(UnsafeMutablePointer<Int8>(mutating: $0)) | 169 | return EventsResponder.sharedInstance().inputHelper.command(cmd) ? .success : .commandFailed |
| 170 | } | ||
| 171 | |||
| 172 | return success ? .success : .commandFailed | ||
| 173 | } | 170 | } |
| 174 | 171 | ||
| 175 | @objc func processEvent(_ event: UnsafeMutablePointer<mpv_event>) { | 172 | @objc func processEvent(_ event: UnsafeMutablePointer<mpv_event>) { |
| @@ -16,7 +16,6 @@ · 15 unmodified lines | |||
| 16 | */ | 16 | */ |
| 17 | 17 | ||
| 18 | #import <Cocoa/Cocoa.h> | 18 | #import <Cocoa/Cocoa.h> |
| 19 | #import "osdep/mac/application_objc.h" | ||
| 20 | 19 | ||
| 21 | #define BASE_ID @"io.mpv.touchbar" | 20 | #define BASE_ID @"io.mpv.touchbar" |
| 22 | static NSTouchBarCustomizationIdentifier customID = BASE_ID; | 21 | static NSTouchBarCustomizationIdentifier customID = BASE_ID; |
| @@ -37,7 +36,6 @@ struct mpv_event; · 14 unmodified lines | |||
| 37 | 36 | ||
| 38 | -(void)processEvent:(struct mpv_event *)event; | 37 | -(void)processEvent:(struct mpv_event *)event; |
| 39 | 38 | ||
| 40 | @property(nonatomic, retain) Application *app; | ||
| 41 | @property(nonatomic, retain) NSDictionary *touchbarItems; | 39 | @property(nonatomic, retain) NSDictionary *touchbarItems; |
| 42 | @property(nonatomic, assign) double duration; | 40 | @property(nonatomic, assign) double duration; |
| 43 | @property(nonatomic, assign) double position; | 41 | @property(nonatomic, assign) double position; |
| @@ -17,10 +17,16 @@ · 16 unmodified lines | |||
| 17 | 17 | ||
| 18 | #include "player/client.h" | 18 | #include "player/client.h" |
| 19 | #import "osdep/mac/touchbar.h" | 19 | #import "osdep/mac/touchbar.h" |
| 20 | #import "osdep/mac/events_objc.h" | ||
| 21 | |||
| 22 | #include "config.h" | ||
| 23 | |||
| 24 | #if HAVE_SWIFT | ||
| 25 | #include "osdep/mac/swift.h" | ||
| 26 | #endif | ||
| 20 | 27 | ||
| 21 | @implementation TouchBar | 28 | @implementation TouchBar |
| 22 | 29 | ||
| 23 | @synthesize app = _app; | ||
| 24 | @synthesize touchbarItems = _touchbar_items; | 30 | @synthesize touchbarItems = _touchbar_items; |
| 25 | @synthesize duration = _duration; | 31 | @synthesize duration = _duration; |
| 26 | @synthesize position = _position; | 32 | @synthesize position = _position; |
| @@ -231,7 +237,7 @@ · 204 unmodified lines | |||
| 231 | - (void)buttonAction:(NSButton *)sender | 237 | - (void)buttonAction:(NSButton *)sender |
| 232 | { | 238 | { |
| 233 | NSString *identifier = [self getIdentifierFromView:sender]; | 239 | NSString *identifier = [self getIdentifierFromView:sender]; |
| 234 | [self.app queueCommand:(char *)[self.touchbarItems[identifier][@"cmd"] UTF8String]]; | 240 | [[EventsResponder sharedInstance].inputHelper command:self.touchbarItems[identifier][@"cmd"]]; |
| 235 | } | 241 | } |
| 236 | 242 | ||
| 237 | - (void)seekbarChanged:(NSSlider *)slider | 243 | - (void)seekbarChanged:(NSSlider *)slider |
| @@ -239,7 +245,7 @@ · 1 unmodified line | |||
| 239 | NSString *identifier = [self getIdentifierFromView:slider]; | 245 | NSString *identifier = [self getIdentifierFromView:slider]; |
| 240 | NSString *seek = [NSString stringWithFormat: | 246 | NSString *seek = [NSString stringWithFormat: |
| 241 | self.touchbarItems[identifier][@"cmd"], slider.doubleValue]; | 247 | self.touchbarItems[identifier][@"cmd"], slider.doubleValue]; |
| 242 | [self.app queueCommand:(char *)[seek UTF8String]]; | 248 | [[EventsResponder sharedInstance].inputHelper command:seek]; |
| 243 | } | 249 | } |
| 244 | 250 | ||
| 245 | - (NSString *)formatTime:(int)time | 251 | - (NSString *)formatTime:(int)time |
| @@ -53,7 +53,7 @@ class View: NSView, CALayerDelegate { · 52 unmodified lines | |||
| 53 | addTrackingArea(tracker!) | 53 | addTrackingArea(tracker!) |
| 54 | 54 | ||
| 55 | if containsMouseLocation() { | 55 | if containsMouseLocation() { |
| 56 | cocoa_put_key_with_modifiers(SWIFT_KEY_MOUSE_LEAVE, 0) | 56 | input?.putKey(SWIFT_KEY_MOUSE_LEAVE) |
| 57 | } | 57 | } |
| 58 | } | 58 | } |
| 59 | 59 | ||
| @@ -118,14 +118,14 @@ class View: NSView, CALayerDelegate { · 58 unmodified lines | |||
| 118 | 118 | ||
| 119 | override func mouseEntered(with event: NSEvent) { | 119 | override func mouseEntered(with event: NSEvent) { |
| 120 | if input?.mouseEnabled() ?? true { | 120 | if input?.mouseEnabled() ?? true { |
| 121 | cocoa_put_key_with_modifiers(SWIFT_KEY_MOUSE_ENTER, 0) | 121 | input?.putKey(SWIFT_KEY_MOUSE_ENTER) |
| 122 | } | 122 | } |
| 123 | common.updateCursorVisibility() | 123 | common.updateCursorVisibility() |
| 124 | } | 124 | } |
| 125 | 125 | ||
| 126 | override func mouseExited(with event: NSEvent) { | 126 | override func mouseExited(with event: NSEvent) { |
| 127 | if input?.mouseEnabled() ?? true { | 127 | if input?.mouseEnabled() ?? true { |
| 128 | cocoa_put_key_with_modifiers(SWIFT_KEY_MOUSE_LEAVE, 0) | 128 | input?.putKey(SWIFT_KEY_MOUSE_LEAVE) |
| 129 | } | 129 | } |
| 130 | common.titleBar?.hide() | 130 | common.titleBar?.hide() |
| 131 | common.setCursorVisibility(true) | 131 | common.setCursorVisibility(true) |
| @@ -202,7 +202,7 @@ class View: NSView, CALayerDelegate { · 70 unmodified lines | |||
| 202 | func signalMouseEvent(_ event: NSEvent, _ state: UInt32) { | 202 | func signalMouseEvent(_ event: NSEvent, _ state: UInt32) { |
| 203 | hasMouseDown = state == MP_KEY_STATE_DOWN | 203 | hasMouseDown = state == MP_KEY_STATE_DOWN |
| 204 | let mpkey = getMpvButton(event) | 204 | let mpkey = getMpvButton(event) |
| 205 | cocoa_put_key_with_modifiers((mpkey | Int32(state)), Int32(event.modifierFlags.rawValue)) | 205 | input?.putKey((mpkey | Int32(state)), modifiers: event.modifierFlags) |
| 206 | } | 206 | } |
| 207 | 207 | ||
| 208 | func signalMouseMovement(_ event: NSEvent) { | 208 | func signalMouseMovement(_ event: NSEvent) { |
| @@ -250,7 +250,7 @@ class View: NSView, CALayerDelegate { · 41 unmodified lines | |||
| 250 | mpkey = deltaX > 0 ? SWIFT_WHEEL_LEFT : SWIFT_WHEEL_RIGHT | 250 | mpkey = deltaX > 0 ? SWIFT_WHEEL_LEFT : SWIFT_WHEEL_RIGHT |
| 251 | } | 251 | } |
| 252 | 252 | ||
| 253 | cocoa_put_key_with_modifiers(mpkey, Int32(modifiers.rawValue)) | 253 | input?.putKey(mpkey, modifiers: modifiers) |
| 254 | } | 254 | } |
| 255 | } | 255 | } |
| 256 | 256 | ||
| @@ -556,7 +556,7 @@ class Window: NSWindow, NSWindowDelegate { · 555 unmodified lines | |||
| 556 | } | 556 | } |
| 557 | 557 | ||
| 558 | func windowShouldClose(_ sender: NSWindow) -> Bool { | 558 | func windowShouldClose(_ sender: NSWindow) -> Bool { |
| 559 | cocoa_put_key(MP_KEY_CLOSE_WIN) | 559 | input?.putKey(MP_KEY_CLOSE_WIN) |
| 560 | return false | 560 | return false |
| 561 | } | 561 | } |
| 562 | 562 | ||