diff --git a/extras/package/macosx/VLC.xcodeproj/project.pbxproj b/extras/package/macosx/VLC.xcodeproj/project.pbxproj index 3912b982e0b5786fd8f20dbb2b6d96c0d50556e3..4e16347b7381953e030be829501833fcdd069b56 100644 --- a/extras/package/macosx/VLC.xcodeproj/project.pbxproj +++ b/extras/package/macosx/VLC.xcodeproj/project.pbxproj @@ -19,7 +19,6 @@ 1C31139F1E508C6900D4DD76 /* VLCMainWindowControlsBar.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D5678EF1D5BA397002698F3 /* VLCMainWindowControlsBar.m */; }; 1C3113A11E508C6900D4DD76 /* VLCConvertAndSaveWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = CC0663351566C34C003A411C /* VLCConvertAndSaveWindowController.m */; }; 1C3113A31E508C6900D4DD76 /* VLCCoreDialogProvider.m in Sources */ = {isa = PBXBuildFile; fileRef = CC4A33210F8CB017000FC4A7 /* VLCCoreDialogProvider.m */; }; - 1C3113A51E508C6900D4DD76 /* VLCCoreInteraction.m in Sources */ = {isa = PBXBuildFile; fileRef = CC448A6113B68A0B009F72E0 /* VLCCoreInteraction.m */; }; 1C3113A71E508C6900D4DD76 /* VLCLogWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D8BB0B418302AC000FAE9B7 /* VLCLogWindowController.m */; }; 1C3113A91E508C6900D4DD76 /* VLCDocumentController.m in Sources */ = {isa = PBXBuildFile; fileRef = 1C39ABBD1DA9AB9B00FE052A /* VLCDocumentController.m */; }; 1C3113AB1E508C6900D4DD76 /* VLCExtensionsDialogProvider.m in Sources */ = {isa = PBXBuildFile; fileRef = 5CCED71114C0D4A90057F8D1 /* VLCExtensionsDialogProvider.m */; }; @@ -559,8 +558,6 @@ CC1941240B9C1F8400635F6B /* QTKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QTKit.framework; path = /System/Library/Frameworks/QTKit.framework; sourceTree = "<absolute>"; }; CC3DC89B0A7CDB9600B53F32 /* ApplicationServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ApplicationServices.framework; path = /System/Library/Frameworks/ApplicationServices.framework; sourceTree = "<absolute>"; }; CC426FD01020D44F00A32659 /* Sparkle.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Sparkle.framework; path = ../../../contrib/Sparkle.framework; sourceTree = SOURCE_ROOT; }; - CC448A6013B68A0B009F72E0 /* VLCCoreInteraction.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VLCCoreInteraction.h; sourceTree = "<group>"; }; - CC448A6113B68A0B009F72E0 /* VLCCoreInteraction.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = VLCCoreInteraction.m; sourceTree = "<group>"; }; CC448A6213B68A0B009F72E0 /* VLCMainWindow.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VLCMainWindow.h; sourceTree = "<group>"; }; CC448A6313B68A0B009F72E0 /* VLCMainWindow.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = VLCMainWindow.m; sourceTree = "<group>"; }; CC461F6C160078340022423C /* VLCTextfieldPanelController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = VLCTextfieldPanelController.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; @@ -850,10 +847,6 @@ 1C1ED50A2204AFA900811EC0 /* coreinteraction */ = { isa = PBXGroup; children = ( - 7D66D4342200BC340040D04A /* VLCClickerManager.h */, - 7D66D4352200BC340040D04A /* VLCClickerManager.m */, - CC448A6013B68A0B009F72E0 /* VLCCoreInteraction.h */, - CC448A6113B68A0B009F72E0 /* VLCCoreInteraction.m */, 7D66D4372200C5B80040D04A /* VLCVideoFilterHelper.h */, 7D66D4382200C5B80040D04A /* VLCVideoFilterHelper.m */, ); @@ -873,6 +866,8 @@ 7DF812F01B555C8E0052293C /* VLCKeyboardBacklightControl.m */, 7DD2F5C32081B73B007EE187 /* VLCRemoteControlService.h */, 7DD2F5C42081B73B007EE187 /* VLCRemoteControlService.m */, + 7D66D4342200BC340040D04A /* VLCClickerManager.h */, + 7D66D4352200BC340040D04A /* VLCClickerManager.m */, ); path = "os-integration"; sourceTree = "<group>"; @@ -1633,7 +1628,6 @@ 1C3113A11E508C6900D4DD76 /* VLCConvertAndSaveWindowController.m in Sources */, 1C3113A31E508C6900D4DD76 /* VLCCoreDialogProvider.m in Sources */, 6B2EFC631F281A0900F3C0EA /* VLCVolumeSliderCell.m in Sources */, - 1C3113A51E508C6900D4DD76 /* VLCCoreInteraction.m in Sources */, 1C3113A71E508C6900D4DD76 /* VLCLogWindowController.m in Sources */, 1C3113A91E508C6900D4DD76 /* VLCDocumentController.m in Sources */, 1C3113AB1E508C6900D4DD76 /* VLCExtensionsDialogProvider.m in Sources */, diff --git a/modules/gui/macosx/Makefile.am b/modules/gui/macosx/Makefile.am index 4aa0319f5730c0ed56bc353a388c02804f642710..a326b6ab3a1760ae414fca8e085699b9866c59fd 100644 --- a/modules/gui/macosx/Makefile.am +++ b/modules/gui/macosx/Makefile.am @@ -26,10 +26,6 @@ libmacosx_plugin_la_LDFLAGS += -Wl,-framework,Sparkle endif libmacosx_plugin_la_SOURCES = \ - gui/macosx/coreinteraction/VLCClickerManager.h \ - gui/macosx/coreinteraction/VLCClickerManager.m \ - gui/macosx/coreinteraction/VLCCoreInteraction.h \ - gui/macosx/coreinteraction/VLCCoreInteraction.m \ gui/macosx/coreinteraction/VLCVideoFilterHelper.h \ gui/macosx/coreinteraction/VLCVideoFilterHelper.m \ gui/macosx/extensions/NSScreen+VLCAdditions.h \ @@ -87,6 +83,8 @@ libmacosx_plugin_la_SOURCES = \ gui/macosx/menus/renderers/VLCRendererMenuController.h \ gui/macosx/menus/renderers/VLCRendererMenuController.m \ gui/macosx/os-integration/Spotify.h \ + gui/macosx/os-integration/VLCClickerManager.h \ + gui/macosx/os-integration/VLCClickerManager.m \ gui/macosx/os-integration/VLCDocumentController.h \ gui/macosx/os-integration/VLCDocumentController.m \ gui/macosx/os-integration/VLCKeyboardBacklightControl.h \ diff --git a/modules/gui/macosx/coreinteraction/VLCCoreInteraction.h b/modules/gui/macosx/coreinteraction/VLCCoreInteraction.h deleted file mode 100644 index 6d96e52ff77f94f1b223fd5b031cf4b4ae3c9cef..0000000000000000000000000000000000000000 --- a/modules/gui/macosx/coreinteraction/VLCCoreInteraction.h +++ /dev/null @@ -1,83 +0,0 @@ -/***************************************************************************** - * CoreInteraction.h: MacOS X interface module - ***************************************************************************** - * Copyright (C) 2011-2019 Felix Paul Kühne - * - * Authors: Felix Paul Kühne <fkuehne -at- videolan -dot- org> - * - * This program 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. - * - * This program 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 this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. - *****************************************************************************/ - -#import <Cocoa/Cocoa.h> - -#include <vlc_common.h> - -@interface VLCCoreInteraction : NSObject - -+ (VLCCoreInteraction *)sharedInstance; -@property (readwrite) int volume; -@property (readonly, nonatomic) float maxVolume; -@property (readwrite) int playbackRate; -@property (nonatomic, readwrite) BOOL aspectRatioIsLocked; -@property (readonly) NSInteger durationOfCurrentPlaylistItem; -@property (readonly) NSURL * URLOfCurrentPlaylistItem; -@property (readonly) NSString * nameOfCurrentPlaylistItem; -@property (nonatomic, readwrite) BOOL mute; - -- (void)play; -- (void)playOrPause; -- (void)pause; -- (void)stop; -- (void)faster; -- (void)slower; -- (void)normalSpeed; -- (void)toggleRecord; -- (int)next; -- (int)previous; -- (void)forwardExtraShort; -- (void)backwardExtraShort; -- (void)forwardShort; -- (void)backwardShort; -- (void)forwardMedium; -- (void)backwardMedium; -- (void)forwardLong; -- (void)backwardLong; -- (void)jumpToTime:(vlc_tick_t)time; - -- (void)repeatOne; -- (void)repeatAll; -- (void)repeatOff; -- (void)shuffle; - -- (void)volumeUp; -- (void)volumeDown; -- (void)toggleMute; -- (void)showPosition; - -- (void)menuFocusActivate; -- (void)moveMenuFocusLeft; -- (void)moveMenuFocusRight; -- (void)moveMenuFocusUp; -- (void)moveMenuFocusDown; - -- (void)addSubtitlesToCurrentInput:(NSArray *)paths; - -- (void)toggleFullscreen; - -- (BOOL)keyEvent:(NSEvent *)o_event; -- (void)updateCurrentlyUsedHotkeys; -- (BOOL)hasDefinedShortcutKey:(NSEvent *)o_event force:(BOOL)b_force; - -@end diff --git a/modules/gui/macosx/coreinteraction/VLCCoreInteraction.m b/modules/gui/macosx/coreinteraction/VLCCoreInteraction.m deleted file mode 100644 index c4297b0b7db0cd3e0029e93a603873c766ea411a..0000000000000000000000000000000000000000 --- a/modules/gui/macosx/coreinteraction/VLCCoreInteraction.m +++ /dev/null @@ -1,542 +0,0 @@ -/***************************************************************************** - * CoreInteraction.m: MacOS X interface module - ***************************************************************************** - * Copyright (C) 2011-2019 Felix Paul Kühne - * - * Authors: Felix Paul Kühne <fkuehne -at- videolan -dot- org> - * - * This program 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. - * - * This program 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 this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. - *****************************************************************************/ - -#import "VLCCoreInteraction.h" - -#import <vlc_url.h> -#import <vlc_modules.h> -#import <vlc_plugin.h> -#import <vlc_actions.h> - -#import "main/VLCMain.h" -#import "coreinteraction/VLCClickerManager.h" -#import "playlist/VLCPlaylistController.h" -#import "playlist/VLCPlayerController.h" -#import "playlist/VLCPlaylistModel.h" -#import "windows/VLCOpenWindowController.h" - -static int BossCallback(vlc_object_t *p_this, const char *psz_var, - vlc_value_t oldval, vlc_value_t new_val, void *param) -{ - @autoreleasepool { - dispatch_async(dispatch_get_main_queue(), ^{ - [[VLCCoreInteraction sharedInstance] pause]; - [[NSApplication sharedApplication] hide:nil]; - }); - - return VLC_SUCCESS; - } -} - -@interface VLCCoreInteraction () -{ - float f_currentPlaybackRate; - - float f_maxVolume; - - NSArray *_usedHotkeys; - - VLCClickerManager *_clickerManager; - VLCPlaylistController *_playlistController; - VLCPlayerController *_playerController; -} -@end - -@implementation VLCCoreInteraction - -#pragma mark - Initialization - -+ (VLCCoreInteraction *)sharedInstance -{ - static VLCCoreInteraction *sharedInstance = nil; - static dispatch_once_t pred; - - dispatch_once(&pred, ^{ - sharedInstance = [VLCCoreInteraction new]; - }); - - return sharedInstance; -} - -- (instancetype)init -{ - self = [super init]; - if (self) { - NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; - [notificationCenter addObserver:self - selector:@selector(applicationWillTerminate:) - name:NSApplicationWillTerminateNotification - object:nil]; - - _clickerManager = [[VLCClickerManager alloc] init]; - _playlistController = [[VLCMain sharedInstance] playlistController]; - _playerController = [_playlistController playerController]; - - intf_thread_t *p_intf = getIntf(); - libvlc_int_t* libvlc = vlc_object_instance(p_intf); - var_AddCallback(libvlc, "intf-boss", BossCallback, (__bridge void *)self); - } - return self; -} - -- (void)applicationWillTerminate:(NSNotification *)notification -{ - // Dealloc is never called because this is a singleton, so we should cleanup manually before termination - intf_thread_t *p_intf = getIntf(); - libvlc_int_t* libvlc = vlc_object_instance(p_intf); - var_DelCallback(libvlc, "intf-boss", BossCallback, (__bridge void *)self); - [[NSNotificationCenter defaultCenter] removeObserver: self]; - _clickerManager = nil; - _usedHotkeys = nil; -} - -#pragma mark - Playback Controls - -- (void)play -{ - [_playlistController startPlaylist]; -} - -- (void)playOrPause -{ - input_item_t *p_input_item = _playlistController.currentlyPlayingInputItem; - - if (p_input_item) { - [_playerController togglePlayPause]; - input_item_Release(p_input_item); - } else { - if (_playlistController.playlistModel.numberOfPlaylistItems == 0) - [[[VLCMain sharedInstance] open] openFileGeneric]; - else - [_playlistController startPlaylist]; - } -} - -- (void)pause -{ - [_playlistController pausePlayback]; -} - -- (void)stop -{ - [_playlistController stopPlayback]; -} - -- (void)faster -{ - [_playerController incrementPlaybackRate]; -} - -- (void)slower -{ - [_playerController decrementPlaybackRate]; -} - -- (void)normalSpeed -{ - _playerController.playbackRate = 1.; -} - -- (void)toggleRecord -{ - [_playerController toggleRecord]; -} - -- (void)setPlaybackRate:(int)i_value -{ - double speed = pow(2, (double)i_value / 17); - if (f_currentPlaybackRate != speed) { - _playerController.playbackRate = speed; - } - f_currentPlaybackRate = speed; -} - -- (int)playbackRate -{ - f_currentPlaybackRate = _playerController.playbackRate; - - double value = 17 * log(f_currentPlaybackRate) / log(2.); - int returnValue = (int) ((value > 0) ? value + .5 : value - .5); - - if (returnValue < -34) - returnValue = -34; - else if (returnValue > 34) - returnValue = 34; - - return returnValue; -} - -- (int)previous -{ - return [_playlistController playPreviousItem]; -} - -- (int)next -{ - return [_playlistController playNextItem]; -} - -- (NSInteger)durationOfCurrentPlaylistItem -{ - return SEC_FROM_VLC_TICK(_playerController.durationOfCurrentMediaItem); -} - -- (NSURL*)URLOfCurrentPlaylistItem -{ - return _playerController.URLOfCurrentMediaItem; -} - -- (NSString*)nameOfCurrentPlaylistItem -{ - return _playerController.nameOfCurrentMediaItem; -} - -- (void)forwardExtraShort -{ - [_playerController jumpForwardExtraShort]; -} - -- (void)backwardExtraShort -{ - [_playerController jumpBackwardExtraShort]; -} - -- (void)forwardShort -{ - [_playerController jumpForwardShort]; -} - -- (void)backwardShort -{ - [_playerController jumpBackwardShort]; -} - -- (void)forwardMedium -{ - [_playerController jumpForwardMedium]; -} - -- (void)backwardMedium -{ - [_playerController jumpBackwardMedium]; -} - -- (void)forwardLong -{ - [_playerController jumpForwardLong]; -} - -- (void)backwardLong -{ - [_playerController jumpBackwardLong]; -} - -- (void)shuffle -{ - BOOL on = NO; - if (_playlistController.playbackOrder == VLC_PLAYLIST_PLAYBACK_ORDER_NORMAL) { - _playlistController.playbackOrder = VLC_PLAYLIST_PLAYBACK_ORDER_RANDOM; - on = YES; - } else { - _playlistController.playbackOrder = VLC_PLAYLIST_PLAYBACK_ORDER_NORMAL; - } - config_PutInt("random", on); - - vout_thread_t *p_vout = [_playerController mainVideoOutputThread]; - if (!p_vout) { - return; - } - if (on) { - [_playerController displayOSDMessage:_NS("Random On")]; - } else { - [_playerController displayOSDMessage:_NS("Random Off")]; - } - - vout_Release(p_vout); -} - -- (void)repeatAll -{ - _playlistController.playbackRepeat = VLC_PLAYLIST_PLAYBACK_REPEAT_ALL; - [_playerController displayOSDMessage:_NS("Repeat All")]; -} - -- (void)repeatOne -{ - _playlistController.playbackRepeat = VLC_PLAYLIST_PLAYBACK_REPEAT_CURRENT; - [_playerController displayOSDMessage:_NS("Repeat One")]; -} - -- (void)repeatOff -{ - _playlistController.playbackRepeat = VLC_PLAYLIST_PLAYBACK_REPEAT_NONE; - [_playerController displayOSDMessage:_NS("Repeat Off")]; -} - -- (void)jumpToTime:(vlc_tick_t)time -{ - [_playerController setTimePrecise:time]; -} - -- (void)volumeUp -{ - [_playerController incrementVolume]; -} - -- (void)volumeDown -{ - [_playerController decrementVolume]; -} - -- (void)toggleMute -{ - [_playerController toggleMute]; -} - -- (BOOL)mute -{ - return _playerController.mute; -} - -- (int)volume -{ - return (int)lroundf(_playerController.volume * AOUT_VOLUME_DEFAULT); -} - -- (void)setVolume: (int)i_value -{ - if (i_value >= self.maxVolume) - i_value = self.maxVolume; - - _playerController.volume = i_value / (float)AOUT_VOLUME_DEFAULT; -} - -- (float)maxVolume -{ - if (f_maxVolume == 0.) { - f_maxVolume = (float)var_InheritInteger(getIntf(), "macosx-max-volume") / 100. * AOUT_VOLUME_DEFAULT; - } - - return f_maxVolume; -} - -- (void)addSubtitlesToCurrentInput:(NSArray *)paths -{ - NSUInteger count = [paths count]; - for (int i = 0; i < count ; i++) { - NSURL *url = [NSURL fileURLWithPath:paths[i]]; - [_playerController addAssociatedMediaToCurrentFromURL:url - ofCategory:SPU_ES - shallSelectTrack:YES - shallDisplayOSD:YES - shallVerifyExtension:NO]; - } -} - -- (void)showPosition -{ - [_playerController displayPosition]; -} - -#pragma mark - video output stuff - -- (void)setAspectRatioIsLocked:(BOOL)b_value -{ - config_PutInt("macosx-lock-aspect-ratio", b_value); -} - -- (BOOL)aspectRatioIsLocked -{ - return config_GetInt("macosx-lock-aspect-ratio"); -} - -- (void)toggleFullscreen -{ - BOOL b_fs = !_playerController.fullscreen; - _playerController.fullscreen = b_fs; - - // FIXME: check whether this is still needed - [[[VLCMain sharedInstance] voutProvider] setFullscreen:b_fs forWindow:nil withAnimation:YES]; -} - -#pragma mark - menu navigation -- (void)menuFocusActivate -{ - [_playerController navigateInInteractiveContent:VLC_PLAYER_NAV_ACTIVATE]; -} - -- (void)moveMenuFocusLeft -{ - [_playerController navigateInInteractiveContent:VLC_PLAYER_NAV_LEFT]; -} - -- (void)moveMenuFocusRight -{ - [_playerController navigateInInteractiveContent:VLC_PLAYER_NAV_RIGHT]; -} - -- (void)moveMenuFocusUp -{ - [_playerController navigateInInteractiveContent:VLC_PLAYER_NAV_UP]; -} - -- (void)moveMenuFocusDown -{ - [_playerController navigateInInteractiveContent:VLC_PLAYER_NAV_DOWN]; -} - -#pragma mark - -#pragma mark Key Shortcuts - -/***************************************************************************** - * hasDefinedShortcutKey: Check to see if the key press is a defined VLC - * shortcut key. If it is, pass it off to VLC for handling and return YES, - * otherwise ignore it and return NO (where it will get handled by Cocoa). - *****************************************************************************/ - -- (BOOL)keyEvent:(NSEvent *)o_event -{ - BOOL eventHandled = NO; - NSString * characters = [o_event charactersIgnoringModifiers]; - if ([characters length] > 0) { - unichar key = [characters characterAtIndex: 0]; - - if (key) { - vout_thread_t *p_vout = [_playerController mainVideoOutputThread]; - if (p_vout != NULL) { - /* Escape */ - if (key == (unichar) 0x1b) { - if (var_GetBool(p_vout, "fullscreen")) { - [self toggleFullscreen]; - eventHandled = YES; - } - } - vout_Release(p_vout); - } - } - } - return eventHandled; -} - -- (BOOL)hasDefinedShortcutKey:(NSEvent *)o_event force:(BOOL)b_force -{ - intf_thread_t *p_intf = getIntf(); - if (!p_intf) - return NO; - - unichar key = 0; - vlc_value_t val; - unsigned int i_pressed_modifiers = 0; - - val.i_int = 0; - i_pressed_modifiers = [o_event modifierFlags]; - - if (i_pressed_modifiers & NSControlKeyMask) - val.i_int |= KEY_MODIFIER_CTRL; - - if (i_pressed_modifiers & NSAlternateKeyMask) - val.i_int |= KEY_MODIFIER_ALT; - - if (i_pressed_modifiers & NSShiftKeyMask) - val.i_int |= KEY_MODIFIER_SHIFT; - - if (i_pressed_modifiers & NSCommandKeyMask) - val.i_int |= KEY_MODIFIER_COMMAND; - - NSString * characters = [o_event charactersIgnoringModifiers]; - if ([characters length] > 0) { - key = [[characters lowercaseString] characterAtIndex: 0]; - - /* handle Lion's default key combo for fullscreen-toggle in addition to our own hotkeys */ - if (key == 'f' && i_pressed_modifiers & NSControlKeyMask && i_pressed_modifiers & NSCommandKeyMask) { - [self toggleFullscreen]; - return YES; - } - - if (!b_force) { - switch(key) { - case NSDeleteCharacter: - case NSDeleteFunctionKey: - case NSDeleteCharFunctionKey: - case NSBackspaceCharacter: - case NSUpArrowFunctionKey: - case NSDownArrowFunctionKey: - case NSEnterCharacter: - case NSCarriageReturnCharacter: - return NO; - } - } - - val.i_int |= CocoaKeyToVLC(key); - - BOOL b_found_key = NO; - NSUInteger numberOfUsedHotkeys = [_usedHotkeys count]; - for (NSUInteger i = 0; i < numberOfUsedHotkeys; i++) { - const char *str = [[_usedHotkeys objectAtIndex:i] UTF8String]; - unsigned int i_keyModifiers = VLCModifiersToCocoa((char *)str); - - if ([[characters lowercaseString] isEqualToString:VLCKeyToString((char *)str)] && - (i_keyModifiers & NSShiftKeyMask) == (i_pressed_modifiers & NSShiftKeyMask) && - (i_keyModifiers & NSControlKeyMask) == (i_pressed_modifiers & NSControlKeyMask) && - (i_keyModifiers & NSAlternateKeyMask) == (i_pressed_modifiers & NSAlternateKeyMask) && - (i_keyModifiers & NSCommandKeyMask) == (i_pressed_modifiers & NSCommandKeyMask)) { - b_found_key = YES; - break; - } - } - - if (b_found_key) { - var_SetInteger(vlc_object_instance(p_intf), "key-pressed", val.i_int); - return YES; - } - } - - return NO; -} - -- (void)updateCurrentlyUsedHotkeys -{ - NSMutableArray *mutArray = [[NSMutableArray alloc] init]; - /* Get the main Module */ - module_t *p_main = module_get_main(); - assert(p_main); - unsigned confsize; - module_config_t *p_config; - - p_config = module_config_get (p_main, &confsize); - - for (size_t i = 0; i < confsize; i++) { - module_config_t *p_item = p_config + i; - - if (CONFIG_ITEM(p_item->i_type) && p_item->psz_name != NULL - && !strncmp(p_item->psz_name , "key-", 4) - && !EMPTY_STR(p_item->psz_text)) { - if (p_item->value.psz) - [mutArray addObject:toNSStr(p_item->value.psz)]; - } - } - module_config_free (p_config); - - _usedHotkeys = [[NSArray alloc] initWithArray:mutArray copyItems:YES]; -} - -@end diff --git a/modules/gui/macosx/extensions/misc.m b/modules/gui/macosx/extensions/misc.m index 149c19b0663d812422ba70e0b4557430423a90ac..616ff944c179992d233e4e865b968a3202d3766f 100644 --- a/modules/gui/macosx/extensions/misc.m +++ b/modules/gui/macosx/extensions/misc.m @@ -26,7 +26,6 @@ #import <vlc_common.h> #import <vlc_actions.h> -#import "coreinteraction/VLCCoreInteraction.h" #import "extensions/NSString+Helpers.h" #import "main/CompatibilityFixes.h" #import "main/VLCMain.h" diff --git a/modules/gui/macosx/main/VLCMain+OldPrefs.m b/modules/gui/macosx/main/VLCMain+OldPrefs.m index 9f57712e5dca1ed215fe10f1904f8dee44a0f08a..356839993ac1dfb505ff2908292c251ef7947efc 100644 --- a/modules/gui/macosx/main/VLCMain+OldPrefs.m +++ b/modules/gui/macosx/main/VLCMain+OldPrefs.m @@ -28,7 +28,6 @@ #import <vlc_interface.h> -#import "coreinteraction/VLCCoreInteraction.h" #import "extensions/NSString+Helpers.h" #import "preferences/VLCSimplePrefsController.h" diff --git a/modules/gui/macosx/main/VLCMain.m b/modules/gui/macosx/main/VLCMain.m index 4f1f66c857dae5c52fb01a7d64ac9d436973a890..86635dfe77cd8446a59dfad4cddd8bad33504a23 100644 --- a/modules/gui/macosx/main/VLCMain.m +++ b/modules/gui/macosx/main/VLCMain.m @@ -42,8 +42,6 @@ #include <vlc_url.h> #include <vlc_variables.h> -#import "coreinteraction/VLCCoreInteraction.h" - #import "library/VLCLibraryWindow.h" #import "main/CompatibilityFixes.h" @@ -52,6 +50,8 @@ #import "menus/VLCMainMenu.h" +#import "os-integration/VLCClickerManager.h" + #import "panels/dialogs/VLCResumeDialogController.h" #import "panels/dialogs/VLCCoreDialogProvider.h" #import "panels/VLCAudioEffectsWindowController.h" @@ -157,6 +157,19 @@ static int ShowController(vlc_object_t *p_this, const char *psz_variable, } } +static int BossCallback(vlc_object_t *p_this, const char *psz_var, + vlc_value_t oldval, vlc_value_t new_val, void *param) +{ + @autoreleasepool { + dispatch_async(dispatch_get_main_queue(), ^{ + [[[VLCMain sharedInstance] playlistController] pausePlayback]; + [[NSApplication sharedApplication] hide:nil]; + }); + + return VLC_SUCCESS; + } +} + #pragma mark - #pragma mark Private @@ -188,6 +201,7 @@ static int ShowController(vlc_object_t *p_this, const char *psz_variable, VLCExtensionsManager *_extensionsManager; VLCInformationWindowController *_currentMediaInfoPanel; VLCLibraryWindowController *_libraryWindowController; + VLCClickerManager *_clickerManager; bool b_intf_terminating; /* Makes sure applicationWillTerminate will be called only once */ } @@ -246,6 +260,7 @@ static VLCMain *sharedInstance = nil; libvlc_int_t *libvlc = vlc_object_instance(p_intf); var_AddCallback(libvlc, "intf-toggle-fscontrol", ShowController, (__bridge void *)self); var_AddCallback(libvlc, "intf-show", ShowController, (__bridge void *)self); + var_AddCallback(libvlc, "intf-boss", BossCallback, (__bridge void *)self); // Load them here already to apply stored profiles _videoEffectsPanel = [[VLCVideoEffectsWindowController alloc] init]; @@ -285,6 +300,8 @@ static VLCMain *sharedInstance = nil; - (void)applicationWillFinishLaunching:(NSNotification *)aNotification { + _clickerManager = [[VLCClickerManager alloc] init]; + #ifdef HAVE_SPARKLE [[SUUpdater sharedUpdater] setDelegate:self]; #endif @@ -297,8 +314,6 @@ static VLCMain *sharedInstance = nil; if (!p_intf) return; - [[VLCCoreInteraction sharedInstance] updateCurrentlyUsedHotkeys]; - [self migrateOldPreferences]; /* Handle sleep notification */ @@ -340,6 +355,7 @@ static VLCMain *sharedInstance = nil; libvlc_int_t *libvlc = vlc_object_instance(p_intf); var_DelCallback(libvlc, "intf-toggle-fscontrol", ShowController, (__bridge void *)self); var_DelCallback(libvlc, "intf-show", ShowController, (__bridge void *)self); + var_DelCallback(libvlc, "intf-boss", BossCallback, (__bridge void *)self); [[NSNotificationCenter defaultCenter] removeObserver: self]; @@ -358,7 +374,7 @@ static VLCMain *sharedInstance = nil; - (void)updater:(SUUpdater *)updater willInstallUpdate:(SUAppcastItem *)update { [NSApp activateIgnoringOtherApps:YES]; - [[VLCCoreInteraction sharedInstance] stop]; + [_playlistController stopPlayback]; } /* don't be enthusiastic about an update if we currently play a video */ @@ -377,7 +393,7 @@ static VLCMain *sharedInstance = nil; /* Triggered when the computer goes to sleep */ - (void)computerWillSleep: (NSNotification *)notification { - [[VLCCoreInteraction sharedInstance] pause]; + [_playlistController pausePlayback]; } #pragma mark - diff --git a/modules/gui/macosx/coreinteraction/VLCClickerManager.h b/modules/gui/macosx/os-integration/VLCClickerManager.h similarity index 100% rename from modules/gui/macosx/coreinteraction/VLCClickerManager.h rename to modules/gui/macosx/os-integration/VLCClickerManager.h diff --git a/modules/gui/macosx/coreinteraction/VLCClickerManager.m b/modules/gui/macosx/os-integration/VLCClickerManager.m similarity index 100% rename from modules/gui/macosx/coreinteraction/VLCClickerManager.m rename to modules/gui/macosx/os-integration/VLCClickerManager.m diff --git a/po/POTFILES.in b/po/POTFILES.in index 46482564a18adbd7d9c13a8b54bf58d25ae6a00e..eb1c31471e96f746a5641dde298208f326131b4b 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -448,10 +448,6 @@ modules/demux/xa.c modules/demux/xiph.h modules/demux/xiph_metadata.c modules/demux/xiph_metadata.h -modules/gui/macosx/coreinteraction/VLCClickerManager.h -modules/gui/macosx/coreinteraction/VLCClickerManager.m -modules/gui/macosx/coreinteraction/VLCCoreInteraction.h -modules/gui/macosx/coreinteraction/VLCCoreInteraction.m modules/gui/macosx/coreinteraction/VLCVideoFilterHelper.h modules/gui/macosx/coreinteraction/VLCVideoFilterHelper.m modules/gui/macosx/extensions/NSScreen+VLCAdditions.h @@ -488,6 +484,8 @@ modules/gui/macosx/menus/renderers/VLCRendererItem.m modules/gui/macosx/menus/renderers/VLCRendererMenuController.h modules/gui/macosx/menus/renderers/VLCRendererMenuController.m modules/gui/macosx/os-integration/Spotify.h +modules/gui/macosx/os-integration/VLCClickerManager.h +modules/gui/macosx/os-integration/VLCClickerManager.m modules/gui/macosx/os-integration/VLCDocumentController.h modules/gui/macosx/os-integration/VLCDocumentController.m modules/gui/macosx/os-integration/VLCKeyboardBacklightControl.h