Commit 5879ef30 authored by Felix Paul Kühne's avatar Felix Paul Kühne

macosx: forward-port recent preferences and media keys enhancements

This includes [eb241138f52e7fbf1e83b07791bad007e2c2f3c6], [fb5108db888105b7fd07f89aaee5eb979ec8be15], [b8d90e93024e3e3f816f6a37d4c8933cdbbc8592], [acb8baa1e5e0d490353d92bbc1cf5902a3bdd792]. Regrettably, these weren't cherry-pickable.
parent 97db61fd
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -431,6 +431,8 @@ struct intf_sys_t ...@@ -431,6 +431,8 @@ struct intf_sys_t
{ {
BOOL b_justJumped; BOOL b_justJumped;
BOOL b_mediaKeySupport; BOOL b_mediaKeySupport;
BOOL b_activeInBackground;
BOOL b_active;
} }
- (void)coreChangedMediaKeySupportSetting: (NSNotification *)o_notification; - (void)coreChangedMediaKeySupportSetting: (NSNotification *)o_notification;
......
...@@ -2862,8 +2862,11 @@ end: ...@@ -2862,8 +2862,11 @@ end:
- (void)awakeFromNib - (void)awakeFromNib
{ {
b_mediaKeySupport = config_GetInt( VLCIntf, "macosx-mediakeys" ); b_active = b_mediaKeySupport = config_GetInt( VLCIntf, "macosx-mediakeys" );
b_activeInBackground = config_GetInt( VLCIntf, "macosx-mediakeys-background" );
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(coreChangedMediaKeySupportSetting:) name: @"VLCMediaKeySupportSettingChanged" object: nil]; [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(coreChangedMediaKeySupportSetting:) name: @"VLCMediaKeySupportSettingChanged" object: nil];
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(appGotActiveOrInactive:) name: @"NSApplicationDidBecomeActiveNotification" object: nil];
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(appGotActiveOrInactive:) name: @"NSApplicationWillResignActiveNotification" object: nil];
} }
- (void)dealloc - (void)dealloc
...@@ -2872,14 +2875,24 @@ end: ...@@ -2872,14 +2875,24 @@ end:
[super dealloc]; [super dealloc];
} }
- (void)appGotActiveOrInactive: (NSNotification *)o_notification
{
if(( [[o_notification name] isEqualToString: @"NSApplicationWillResignActiveNotification"] && !b_activeInBackground ) || !b_mediaKeySupport)
b_active = NO;
else
b_active = YES;
}
- (void)coreChangedMediaKeySupportSetting: (NSNotification *)o_notification - (void)coreChangedMediaKeySupportSetting: (NSNotification *)o_notification
{ {
b_mediaKeySupport = config_GetInt( VLCIntf, "macosx-mediakeys" ); b_active = b_mediaKeySupport = config_GetInt( VLCIntf, "macosx-mediakeys" );
b_activeInBackground = config_GetInt( VLCIntf, "macosx-mediakeys-background" );
} }
- (void)sendEvent: (NSEvent*)event - (void)sendEvent: (NSEvent*)event
{ {
if( b_mediaKeySupport ) if( b_active )
{ {
if( [event type] == NSSystemDefined && [event subtype] == 8 ) if( [event type] == NSSystemDefined && [event subtype] == 8 )
{ {
......
...@@ -95,6 +95,10 @@ void CloseVideoGL ( vlc_object_t * ); ...@@ -95,6 +95,10 @@ void CloseVideoGL ( vlc_object_t * );
#define USE_MEDIAKEYS_LONGTEXT N_("By default, VLC can be controlled using the media keys on modern Apple " \ #define USE_MEDIAKEYS_LONGTEXT N_("By default, VLC can be controlled using the media keys on modern Apple " \
"keyboards.") "keyboards.")
#define USE_MEDIAKEYS_BACKGROUND_TEXT N_("Use media key control when VLC is in background")
#define USE_MEDIAKEYS_BACKGROUND_LONGTEXT N_("By default, VLC will accept media key events also when being " \
"in background.")
vlc_module_begin () vlc_module_begin ()
set_description( N_("Mac OS X interface") ) set_description( N_("Mac OS X interface") )
set_capability( "interface", 200 ) set_capability( "interface", 200 )
...@@ -113,6 +117,8 @@ vlc_module_begin () ...@@ -113,6 +117,8 @@ vlc_module_begin ()
false ) false )
add_bool( "macosx-mediakeys", 1, NULL, USE_MEDIAKEYS_TEXT, USE_MEDIAKEYS_LONGTEXT, add_bool( "macosx-mediakeys", 1, NULL, USE_MEDIAKEYS_TEXT, USE_MEDIAKEYS_LONGTEXT,
false ) false )
add_bool( "macosx-mediakeys-background", 1, NULL, USE_MEDIAKEYS_BACKGROUND_TEXT, USE_MEDIAKEYS_BACKGROUND_LONGTEXT,
false )
add_submodule () add_submodule ()
set_description( "Mac OS X OpenGL" ) set_description( "Mac OS X OpenGL" )
......
...@@ -91,6 +91,7 @@ ...@@ -91,6 +91,7 @@
IBOutlet id o_intf_fspanel_ckb; IBOutlet id o_intf_fspanel_ckb;
IBOutlet id o_intf_appleremote_ckb; IBOutlet id o_intf_appleremote_ckb;
IBOutlet id o_intf_mediakeys_ckb; IBOutlet id o_intf_mediakeys_ckb;
IBOutlet id o_intf_mediakeys_bg_ckb;
IBOutlet id o_intf_lang_pop; IBOutlet id o_intf_lang_pop;
IBOutlet id o_intf_lang_txt; IBOutlet id o_intf_lang_txt;
IBOutlet id o_intf_network_box; IBOutlet id o_intf_network_box;
......
...@@ -266,6 +266,7 @@ create_toolbar_item( NSString * o_itemIdent, NSString * o_name, NSString * o_des ...@@ -266,6 +266,7 @@ create_toolbar_item( NSString * o_itemIdent, NSString * o_name, NSString * o_des
[o_intf_network_box setTitle: _NS("Privacy / Network Interaction")]; [o_intf_network_box setTitle: _NS("Privacy / Network Interaction")];
[o_intf_appleremote_ckb setTitle: _NS("Control playback with the Apple Remote")]; [o_intf_appleremote_ckb setTitle: _NS("Control playback with the Apple Remote")];
[o_intf_mediakeys_ckb setTitle: _NS("Control playback with media keys")]; [o_intf_mediakeys_ckb setTitle: _NS("Control playback with media keys")];
[o_intf_mediakeys_bg_ckb setTitle: _NS("...when VLC is in background")];
/* Subtitles and OSD */ /* Subtitles and OSD */
[o_osd_encoding_txt setStringValue: _NS("Default Encoding")]; [o_osd_encoding_txt setStringValue: _NS("Default Encoding")];
...@@ -304,6 +305,31 @@ create_toolbar_item( NSString * o_itemIdent, NSString * o_name, NSString * o_des ...@@ -304,6 +305,31 @@ create_toolbar_item( NSString * o_itemIdent, NSString * o_name, NSString * o_des
[o_sprefs_win setTitle: _NS("Preferences")]; [o_sprefs_win setTitle: _NS("Preferences")];
} }
/* TODO: move this part to core */
#define config_GetLabel(a,b) __config_GetLabel(VLC_OBJECT(a),b)
static inline char * __config_GetLabel( vlc_object_t *p_this, const char *psz_name )
{
module_config_t *p_config;
p_config = config_FindConfig( p_this, psz_name );
/* sanity checks */
if( !p_config )
{
msg_Err( p_this, "option %s does not exist", psz_name );
return NULL;
}
if ( p_config->psz_longtext )
return p_config->psz_longtext;
else if( p_config->psz_text )
return p_config->psz_text;
else
msg_Warn( p_this, "option %s does not include any help" );
return NULL;
}
- (void)setupButton: (NSPopUpButton *)object forStringList: (const char *)name - (void)setupButton: (NSPopUpButton *)object forStringList: (const char *)name
{ {
module_config_t *p_item; module_config_t *p_item;
...@@ -393,10 +419,17 @@ create_toolbar_item( NSString * o_itemIdent, NSString * o_name, NSString * o_des ...@@ -393,10 +419,17 @@ create_toolbar_item( NSString * o_itemIdent, NSString * o_name, NSString * o_des
[object setToolTip: _NS(p_item->psz_longtext)]; [object setToolTip: _NS(p_item->psz_longtext)];
} }
- (void)setupButton: (NSButton *)object forBoolValue: (const char *)name
{
[object setState: config_GetInt( p_intf, name )];
[object setToolTip: [NSString stringWithUTF8String: config_GetLabel( p_intf, name )]];
}
- (void)setupField:(NSTextField *)o_object forOption:(const char *)psz_option - (void)setupField:(NSTextField *)o_object forOption:(const char *)psz_option
{ {
char *psz_tmp = config_GetPsz( p_intf, psz_option ); char *psz_tmp = config_GetPsz( p_intf, psz_option );
[o_object setStringValue: [NSString stringWithUTF8String: psz_tmp ?: ""]]; [o_object setStringValue: [NSString stringWithUTF8String: psz_tmp ?: ""]];
[o_object setToolTip: [NSString stringWithUTF8String: config_GetLabel( p_intf, psz_option )]];
free( psz_tmp ); free( psz_tmp );
} }
...@@ -415,25 +448,29 @@ create_toolbar_item( NSString * o_itemIdent, NSString * o_name, NSString * o_des ...@@ -415,25 +448,29 @@ create_toolbar_item( NSString * o_itemIdent, NSString * o_name, NSString * o_des
[self setupButton: o_intf_lang_pop forStringList: "language"]; [self setupButton: o_intf_lang_pop forStringList: "language"];
[self setupButton: o_intf_art_pop forIntList: "album-art"]; [self setupButton: o_intf_art_pop forIntList: "album-art"];
[o_intf_fspanel_ckb setState: config_GetInt( p_intf, "macosx-fspanel" )]; [self setupButton: o_intf_fspanel_ckb forBoolValue: "macosx-fspanel"];
[o_intf_embedded_ckb setState: config_GetInt( p_intf, "embedded-video" )]; [self setupButton: o_intf_embedded_ckb forBoolValue: "embedded-video"];
[o_intf_appleremote_ckb setState: config_GetInt( p_intf, "macosx-appleremote" )]; [self setupButton: o_intf_appleremote_ckb forBoolValue: "macosx-appleremote"];
[o_intf_mediakeys_ckb setState: config_GetInt( p_intf, "macosx-mediakeys" )]; [self setupButton: o_intf_mediakeys_ckb forBoolValue: "macosx-mediakeys"];
[self setupButton: o_intf_mediakeys_bg_ckb forBoolValue: "macosx-mediakeys-background"];
[o_intf_mediakeys_bg_ckb setEnabled: [o_intf_mediakeys_ckb state]];
/****************** /******************
* audio settings * * audio settings *
******************/ ******************/
[o_audio_enable_ckb setState: config_GetInt( p_intf, "audio" )]; [self setupButton: o_audio_enable_ckb forBoolValue: "audio"];
i = (config_GetInt( p_intf, "volume" ) * 0.390625); i = (config_GetInt( p_intf, "volume" ) * 0.390625);
[o_audio_vol_fld setToolTip: [NSString stringWithUTF8String: config_GetLabel( p_intf, "volume")]];
[o_audio_vol_fld setIntValue: i]; [o_audio_vol_fld setIntValue: i];
[o_audio_vol_sld setToolTip: [o_audio_vol_fld toolTip]];
[o_audio_vol_sld setIntValue: i]; [o_audio_vol_sld setIntValue: i];
[o_audio_spdif_ckb setState: config_GetInt( p_intf, "spdif" )]; [self setupButton: o_audio_spdif_ckb forBoolValue: "spdif"];
[self setupButton: o_audio_dolby_pop forIntList: "force-dolby-surround"]; [self setupButton: o_audio_dolby_pop forIntList: "force-dolby-surround"];
[self setupField: o_audio_lang_fld forOption: "audio-language"]; [self setupField: o_audio_lang_fld forOption: "audio-language"];
[o_audio_headphone_ckb setState: config_GetInt( p_intf, "headphone-dolby" )]; [self setupButton: o_audio_headphone_ckb forBoolValue: "headphone-dolby"];
psz_tmp = config_GetPsz( p_intf, "audio-filter" ); psz_tmp = config_GetPsz( p_intf, "audio-filter" );
if( psz_tmp ) if( psz_tmp )
...@@ -444,6 +481,7 @@ create_toolbar_item( NSString * o_itemIdent, NSString * o_name, NSString * o_des ...@@ -444,6 +481,7 @@ create_toolbar_item( NSString * o_itemIdent, NSString * o_name, NSString * o_des
free( psz_tmp ); free( psz_tmp );
} }
[o_audio_norm_fld setFloatValue: config_GetFloat( p_intf, "norm-max-level" )]; [o_audio_norm_fld setFloatValue: config_GetFloat( p_intf, "norm-max-level" )];
[o_audio_norm_fld setToolTip: [NSString stringWithUTF8String: config_GetLabel( p_intf, "norm-max-level")]];
[self setupButton: o_audio_visual_pop forModuleList: "audio-visual"]; [self setupButton: o_audio_visual_pop forModuleList: "audio-visual"];
...@@ -472,11 +510,11 @@ create_toolbar_item( NSString * o_itemIdent, NSString * o_name, NSString * o_des ...@@ -472,11 +510,11 @@ create_toolbar_item( NSString * o_itemIdent, NSString * o_name, NSString * o_des
/****************** /******************
* video settings * * video settings *
******************/ ******************/
[o_video_enable_ckb setState: config_GetInt( p_intf, "video" )]; [self setupButton: o_video_enable_ckb forBoolValue: "video"];
[o_video_fullscreen_ckb setState: config_GetInt( p_intf, "fullscreen" )]; [self setupButton: o_video_fullscreen_ckb forBoolValue: "fullscreen"];
[o_video_onTop_ckb setState: config_GetInt( p_intf, "video-on-top" )]; [self setupButton: o_video_onTop_ckb forBoolValue: "video-on-top"];
[o_video_skipFrames_ckb setState: config_GetInt( p_intf, "skip-frames" )]; [self setupButton: o_video_skipFrames_ckb forBoolValue: "skip-frames"];
[o_video_black_ckb setState: config_GetInt( p_intf, "macosx-black" )]; [self setupButton: o_video_black_ckb forBoolValue: "macosx-black"];
[self setupButton: o_video_output_pop forModuleList: "vout"]; [self setupButton: o_video_output_pop forModuleList: "vout"];
...@@ -497,22 +535,24 @@ create_toolbar_item( NSString * o_itemIdent, NSString * o_name, NSString * o_des ...@@ -497,22 +535,24 @@ create_toolbar_item( NSString * o_itemIdent, NSString * o_name, NSString * o_des
[o_video_device_pop selectItemAtIndex: 0]; [o_video_device_pop selectItemAtIndex: 0];
[o_video_device_pop selectItemWithTag: config_GetInt( p_intf, "macosx-vdev" )]; [o_video_device_pop selectItemWithTag: config_GetInt( p_intf, "macosx-vdev" )];
[self setupField:o_video_snap_folder_fld forOption:"snapshot-path"]; [self setupField: o_video_snap_folder_fld forOption:"snapshot-path"];
[self setupField:o_video_snap_prefix_fld forOption:"snapshot-prefix"]; [self setupField: o_video_snap_prefix_fld forOption:"snapshot-prefix"];
[o_video_snap_seqnum_ckb setState: config_GetInt( p_intf, "snapshot-sequential" )]; [self setupButton: o_video_snap_seqnum_ckb forBoolValue: "snapshot-sequential"];
[self setupButton: o_video_snap_format_pop forStringList: "snapshot-format"]; [self setupButton: o_video_snap_format_pop forStringList: "snapshot-format"];
/*************************** /***************************
* input & codecs settings * * input & codecs settings *
***************************/ ***************************/
[o_input_serverport_fld setIntValue: config_GetInt( p_intf, "server-port" )]; [o_input_serverport_fld setIntValue: config_GetInt( p_intf, "server-port")];
[self setupField:o_input_httpproxy_fld forOption:"http-proxy"]; [o_input_serverport_fld setToolTip: [NSString stringWithUTF8String: config_GetLabel( p_intf, "server-port")]];
[self setupField:o_input_httpproxypwd_sfld forOption:"http-proxy-pwd"]; [self setupField: o_input_httpproxy_fld forOption:"http-proxy"];
[o_input_postproc_fld setIntValue: config_GetInt( p_intf, "postproc-q" )]; [self setupField: o_input_httpproxypwd_sfld forOption:"http-proxy-pwd"];
[o_input_postproc_fld setIntValue: config_GetInt( p_intf, "postproc-q")];
[o_input_postproc_fld setToolTip: [NSString stringWithUTF8String: config_GetLabel( p_intf, "postproc-q")]];
[self setupButton: o_input_avi_pop forIntList: "avi-index"]; [self setupButton: o_input_avi_pop forIntList: "avi-index"];
[o_input_rtsp_ckb setState: config_GetInt( p_intf, "rtsp-tcp" )]; [self setupButton: o_input_rtsp_ckb forBoolValue: "rtsp-tcp"];
[self setupButton: o_input_skipLoop_pop forIntList: "ffmpeg-skiploopfilter"]; [self setupButton: o_input_skipLoop_pop forIntList: "ffmpeg-skiploopfilter"];
[o_input_cachelevel_pop removeAllItems]; [o_input_cachelevel_pop removeAllItems];
...@@ -568,7 +608,7 @@ create_toolbar_item( NSString * o_itemIdent, NSString * o_name, NSString * o_des ...@@ -568,7 +608,7 @@ create_toolbar_item( NSString * o_itemIdent, NSString * o_name, NSString * o_des
/********************* /*********************
* subtitle settings * * subtitle settings *
*********************/ *********************/
[o_osd_osd_ckb setState: config_GetInt( p_intf, "osd" )]; [self setupButton: o_osd_osd_ckb forBoolValue: "osd"];
[self setupButton: o_osd_encoding_pop forStringList: "subsdec-encoding"]; [self setupButton: o_osd_encoding_pop forStringList: "subsdec-encoding"];
[self setupField: o_osd_lang_fld forOption: "sub-language" ]; [self setupField: o_osd_lang_fld forOption: "sub-language" ];
...@@ -742,6 +782,7 @@ static inline void save_module_list( intf_thread_t * p_intf, id object, const ch ...@@ -742,6 +782,7 @@ static inline void save_module_list( intf_thread_t * p_intf, id object, const ch
config_PutInt( p_intf, "embedded-video", [o_intf_embedded_ckb state] ); config_PutInt( p_intf, "embedded-video", [o_intf_embedded_ckb state] );
config_PutInt( p_intf, "macosx-appleremote", [o_intf_appleremote_ckb state] ); config_PutInt( p_intf, "macosx-appleremote", [o_intf_appleremote_ckb state] );
config_PutInt( p_intf, "macosx-mediakeys", [o_intf_mediakeys_ckb state] ); config_PutInt( p_intf, "macosx-mediakeys", [o_intf_mediakeys_ckb state] );
config_PutInt( p_intf, "macosx-mediakeys-background", [o_intf_mediakeys_bg_ckb state] );
/* activate stuff without restart */ /* activate stuff without restart */
if( [o_intf_appleremote_ckb state] == YES ) if( [o_intf_appleremote_ckb state] == YES )
...@@ -948,7 +989,9 @@ static inline void save_module_list( intf_thread_t * p_intf, id object, const ch ...@@ -948,7 +989,9 @@ static inline void save_module_list( intf_thread_t * p_intf, id object, const ch
config_PutInt( p_intf, "osd", [o_osd_osd_ckb state] ); config_PutInt( p_intf, "osd", [o_osd_osd_ckb state] );
if( [o_osd_encoding_pop indexOfSelectedItem] >= 0 ) if( [o_osd_encoding_pop indexOfSelectedItem] >= 0 )
config_PutPsz( p_intf, "subsdec-encoding", [[[o_osd_encoding_pop selectedItem] title] UTF8String] ); SaveStringList( o_osd_encoding_pop, "subsdec-encoding" );
else
config_PutPsz( p_intf, "subsdec-encoding", "" );
config_PutPsz( p_intf, "sub-language", [[o_osd_lang_fld stringValue] UTF8String] ); config_PutPsz( p_intf, "sub-language", [[o_osd_lang_fld stringValue] UTF8String] );
...@@ -1042,6 +1085,8 @@ static inline void save_module_list( intf_thread_t * p_intf, id object, const ch ...@@ -1042,6 +1085,8 @@ static inline void save_module_list( intf_thread_t * p_intf, id object, const ch
- (IBAction)interfaceSettingChanged:(id)sender - (IBAction)interfaceSettingChanged:(id)sender
{ {
if( sender == o_intf_mediakeys_ckb )
[o_intf_mediakeys_bg_ckb setEnabled: [o_intf_mediakeys_ckb state]];
b_intfSettingChanged = YES; b_intfSettingChanged = YES;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment