[vlc-devel] commit: macosx: added another option to disable media key support specifically for background usage ( Felix Paul Kühne )
git version control
git at videolan.org
Sat Jul 25 16:56:57 CEST 2009
vlc | branch: 1.0-bugfix | Felix Paul Kühne <fkuehne at videolan.org> | Sat Jul 25 16:56:37 2009 +0200| [eb241138f52e7fbf1e83b07791bad007e2c2f3c6] | committer: Felix Paul Kühne
macosx: added another option to disable media key support specifically for background usage
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=eb241138f52e7fbf1e83b07791bad007e2c2f3c6
---
.../English.lproj/Preferences.nib/classes.nib | 1 +
.../English.lproj/Preferences.nib/info.nib | 2 +-
.../English.lproj/Preferences.nib/keyedobjects.nib | Bin 94466 -> 95034 bytes
modules/gui/macosx/intf.h | 2 ++
modules/gui/macosx/intf.m | 18 +++++++++++++++---
modules/gui/macosx/macosx.m | 10 ++++++++--
modules/gui/macosx/simple_prefs.h | 1 +
modules/gui/macosx/simple_prefs.m | 6 ++++++
8 files changed, 34 insertions(+), 6 deletions(-)
diff --git a/extras/package/macosx/Resources/English.lproj/Preferences.nib/classes.nib b/extras/package/macosx/Resources/English.lproj/Preferences.nib/classes.nib
index 5d96246..7cd056e 100644
--- a/extras/package/macosx/Resources/English.lproj/Preferences.nib/classes.nib
+++ b/extras/package/macosx/Resources/English.lproj/Preferences.nib/classes.nib
@@ -123,6 +123,7 @@
"o_intf_fspanel_ckb" = id;
"o_intf_lang_pop" = id;
"o_intf_lang_txt" = id;
+ "o_intf_mediakeys_bg_ckb" = id;
"o_intf_mediakeys_ckb" = id;
"o_intf_network_box" = id;
"o_intf_view" = id;
diff --git a/extras/package/macosx/Resources/English.lproj/Preferences.nib/info.nib b/extras/package/macosx/Resources/English.lproj/Preferences.nib/info.nib
index e79a4ca..ce13663 100644
--- a/extras/package/macosx/Resources/English.lproj/Preferences.nib/info.nib
+++ b/extras/package/macosx/Resources/English.lproj/Preferences.nib/info.nib
@@ -7,7 +7,7 @@
<key>IBEditorPositions</key>
<dict>
<key>2311</key>
- <string>345 378 590 293 0 0 1280 778 </string>
+ <string>345 356 590 315 0 0 1280 778 </string>
<key>2330</key>
<string>345 222 590 502 0 0 1280 778 </string>
<key>2440</key>
diff --git a/extras/package/macosx/Resources/English.lproj/Preferences.nib/keyedobjects.nib b/extras/package/macosx/Resources/English.lproj/Preferences.nib/keyedobjects.nib
index a9250e0..add5018 100644
Binary files a/extras/package/macosx/Resources/English.lproj/Preferences.nib/keyedobjects.nib and b/extras/package/macosx/Resources/English.lproj/Preferences.nib/keyedobjects.nib differ
diff --git a/modules/gui/macosx/intf.h b/modules/gui/macosx/intf.h
index 8d18277..826dbe1 100644
--- a/modules/gui/macosx/intf.h
+++ b/modules/gui/macosx/intf.h
@@ -426,6 +426,8 @@ struct intf_sys_t
{
BOOL b_justJumped;
BOOL b_mediaKeySupport;
+ BOOL b_activeInBackground;
+ BOOL b_active;
}
- (void)coreChangedMediaKeySupportSetting: (NSNotification *)o_notification;
diff --git a/modules/gui/macosx/intf.m b/modules/gui/macosx/intf.m
index de15b02..2245374 100644
--- a/modules/gui/macosx/intf.m
+++ b/modules/gui/macosx/intf.m
@@ -2825,8 +2825,11 @@ end:
- (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(appGotActiveOrInactive:) name: @"NSApplicationDidBecomeActiveNotification" object: nil];
+ [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(appGotActiveOrInactive:) name: @"NSApplicationWillResignActiveNotification" object: nil];
}
- (void)dealloc
@@ -2835,15 +2838,24 @@ end:
[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
{
- 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
{
- if( b_mediaKeySupport )
+ if( b_active )
{
if( [event type] == NSSystemDefined && [event subtype] == 8 )
{
diff --git a/modules/gui/macosx/macosx.m b/modules/gui/macosx/macosx.m
index 3f6ce62..e9556ad 100644
--- a/modules/gui/macosx/macosx.m
+++ b/modules/gui/macosx/macosx.m
@@ -87,13 +87,17 @@ void CloseVideoGL ( vlc_object_t * );
#define EQ_KEEP_LONGTEXT N_("By default, VLC keeps the last equalizer settings before " \
"termination. This feature can be disabled here.")
-#define USE_APPLE_REMOTE_TEXT N_("Allow playback control with the Apple Remote")
+#define USE_APPLE_REMOTE_TEXT N_("Control playback with the Apple Remote")
#define USE_APPLE_REMOTE_LONGTEXT N_("By default, VLC can be remotely controlled with the Apple Remote.")
-#define USE_MEDIAKEYS_TEXT N_("Allow playback control with the media keys")
+#define USE_MEDIAKEYS_TEXT N_("Control playback with media keys")
#define USE_MEDIAKEYS_LONGTEXT N_("By default, VLC can be controlled using the media keys on modern Apple " \
"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 ()
set_description( N_("Mac OS X interface") )
set_capability( "interface", 200 )
@@ -112,6 +116,8 @@ vlc_module_begin ()
false )
add_bool( "macosx-mediakeys", 1, NULL, USE_MEDIAKEYS_TEXT, USE_MEDIAKEYS_LONGTEXT,
false )
+ add_bool( "macosx-mediakeys-background", 1, NULL, USE_MEDIAKEYS_BACKGROUND_TEXT, USE_MEDIAKEYS_BACKGROUND_LONGTEXT,
+ false )
add_submodule ()
set_description( "Mac OS X OpenGL" )
diff --git a/modules/gui/macosx/simple_prefs.h b/modules/gui/macosx/simple_prefs.h
index d7d0f0a..936a4cf 100644
--- a/modules/gui/macosx/simple_prefs.h
+++ b/modules/gui/macosx/simple_prefs.h
@@ -91,6 +91,7 @@
IBOutlet id o_intf_fspanel_ckb;
IBOutlet id o_intf_appleremote_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_txt;
IBOutlet id o_intf_network_box;
diff --git a/modules/gui/macosx/simple_prefs.m b/modules/gui/macosx/simple_prefs.m
index eb7e990..4f89e34 100644
--- a/modules/gui/macosx/simple_prefs.m
+++ b/modules/gui/macosx/simple_prefs.m
@@ -265,6 +265,7 @@ create_toolbar_item( NSString * o_itemIdent, NSString * o_name, NSString * o_des
[o_intf_network_box setTitle: _NS("Privacy / Network Interaction")];
[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_bg_ckb setTitle: _NS("...when VLC is in background")];
/* Subtitles and OSD */
[o_osd_encoding_txt setStringValue: _NS("Default Encoding")];
@@ -451,6 +452,8 @@ static inline char * __config_GetLabel( vlc_object_t *p_this, const char *psz_na
[self setupButton: o_intf_embedded_ckb forBoolValue: "embedded-video"];
[self setupButton: o_intf_appleremote_ckb forBoolValue: "macosx-appleremote"];
[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 *
@@ -779,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, "macosx-appleremote", [o_intf_appleremote_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 */
if( [o_intf_appleremote_ckb state] == YES )
@@ -1079,6 +1083,8 @@ static inline void save_module_list( intf_thread_t * p_intf, id object, const ch
- (IBAction)interfaceSettingChanged:(id)sender
{
+ if( sender == o_intf_mediakeys_ckb )
+ [o_intf_mediakeys_bg_ckb setEnabled: [o_intf_mediakeys_ckb state]];
b_intfSettingChanged = YES;
}
More information about the vlc-devel
mailing list