[vlc-commits] macosx: fix the window menu' s close and minimize commands when using the black window style

Felix Paul Kühne git at videolan.org
Sun Jan 8 14:07:02 CET 2012


vlc | branch: master | Felix Paul Kühne <fkuehne at videolan.org> | Sat Jan  7 21:53:38 2012 +0100| [09ad74bd3606a9dc876f1d3647bd74e016d47a7a] | committer: Felix Paul Kühne

macosx: fix the window menu's close and minimize commands when using the black window style

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=09ad74bd3606a9dc876f1d3647bd74e016d47a7a
---

 modules/gui/macosx/CoreInteraction.h |    3 ++-
 modules/gui/macosx/CoreInteraction.m |    7 ++++++-
 modules/gui/macosx/MainWindow.h      |    2 +-
 modules/gui/macosx/MainWindow.m      |   29 +++++++++++++++++++++++++++--
 modules/gui/macosx/intf.m            |   13 ++-----------
 5 files changed, 38 insertions(+), 16 deletions(-)

diff --git a/modules/gui/macosx/CoreInteraction.h b/modules/gui/macosx/CoreInteraction.h
index 085997a..b155586 100644
--- a/modules/gui/macosx/CoreInteraction.h
+++ b/modules/gui/macosx/CoreInteraction.h
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * CoreInteraction.h: MacOS X interface module
  *****************************************************************************
- * Copyright (C) 2011 Felix Paul Kühne
+ * Copyright (C) 2011-2012 Felix Paul Kühne
  * $Id$
  *
  * Authors: Felix Paul Kühne <fkuehne -at- videolan -dot- org>
@@ -32,6 +32,7 @@
 + (VLCCoreInteraction *)sharedInstance;
 
 - (void)play;
+- (void)pause;
 - (void)stop;
 - (void)faster;
 - (void)slower;
diff --git a/modules/gui/macosx/CoreInteraction.m b/modules/gui/macosx/CoreInteraction.m
index 58b46d1..2044c42 100644
--- a/modules/gui/macosx/CoreInteraction.m
+++ b/modules/gui/macosx/CoreInteraction.m
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * CoreInteraction.m: MacOS X interface module
  *****************************************************************************
- * Copyright (C) 2011 Felix Paul Kühne
+ * Copyright (C) 2011-2012 Felix Paul Kühne
  * $Id$
  *
  * Authors: Felix Paul Kühne <fkuehne -at- videolan -dot- org>
@@ -91,6 +91,11 @@ static VLCCoreInteraction *_o_sharedInstance = nil;
     var_SetInteger( VLCIntf->p_libvlc, "key-action", ACTIONID_PLAY_PAUSE );
 }
 
+- (void)pause
+{
+    var_SetInteger( VLCIntf->p_libvlc, "key-action", ACTIONID_PAUSE );
+}
+
 - (void)stop
 {
     var_SetInteger( VLCIntf->p_libvlc, "key-action", ACTIONID_STOP );
diff --git a/modules/gui/macosx/MainWindow.h b/modules/gui/macosx/MainWindow.h
index 51b2f0f..44b2438 100644
--- a/modules/gui/macosx/MainWindow.h
+++ b/modules/gui/macosx/MainWindow.h
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * MainWindow.h: MacOS X interface module
  *****************************************************************************
- * Copyright (C) 2002-2011 VLC authors and VideoLAN
+ * Copyright (C) 2002-2012 VLC authors and VideoLAN
  * $Id$
  *
  * Authors: Felix Paul Kühne <fkuehne -at- videolan -dot- org>
diff --git a/modules/gui/macosx/MainWindow.m b/modules/gui/macosx/MainWindow.m
index 8fdd2f0..5af29ea 100644
--- a/modules/gui/macosx/MainWindow.m
+++ b/modules/gui/macosx/MainWindow.m
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * MainWindow.m: MacOS X interface module
  *****************************************************************************
- * Copyright (C) 2002-2011 VLC authors and VideoLAN
+ * Copyright (C) 2002-2012 VLC authors and VideoLAN
  * $Id$
  *
  * Authors: Felix Paul Kühne <fkuehne -at- videolan -dot- org>
@@ -709,6 +709,15 @@ static VLCMainWindow *_o_sharedInstance = nil;
     return YES;
 }
 
+- (BOOL)validateMenuItem:(NSMenuItem *)menuItem
+{
+	SEL s_menuAction = [menuItem action];
+	if ((s_menuAction == @selector(performClose:)) || (s_menuAction == @selector(performMiniaturize:)) || (s_menuAction == @selector(performZoom:)))
+        return YES;
+
+	return [super validateMenuItem:menuItem];
+}
+
 - (BOOL)isMainWindow
 {
 	return YES;
@@ -723,6 +732,22 @@ static VLCMainWindow *_o_sharedInstance = nil;
     [super setTitle: title];
 }
 
+- (void)performClose:(id)sender
+{
+    if (b_dark_interface)
+        [self orderOut: sender];
+    else
+        [super performClose: sender];
+}
+
+- (void)performMiniaturize:(id)sender
+{
+    if (b_dark_interface)
+        [self miniaturize: sender];
+    else
+        [super performMiniaturize: sender];
+}
+
 - (void)performZoom:(id)sender
 {
     if (b_dark_interface)
@@ -1210,7 +1235,7 @@ static VLCMainWindow *_o_sharedInstance = nil;
 
 - (void)someWindowWillClose:(NSNotification *)notification
 {
-    if([notification object] == o_nonembedded_window)
+    if([notification object] == o_nonembedded_window || [notification object] == self)
         [[VLCCoreInteraction sharedInstance] stop];
 }
 
diff --git a/modules/gui/macosx/intf.m b/modules/gui/macosx/intf.m
index 389260b..0d24c16 100644
--- a/modules/gui/macosx/intf.m
+++ b/modules/gui/macosx/intf.m
@@ -783,7 +783,7 @@ static VLCMain *_o_sharedMainInstance = nil;
 {
     [NSApp activateIgnoringOtherApps:YES];
     [o_remote stopListening: self];
-    var_SetInteger( p_intf->p_libvlc, "key-action", ACTIONID_STOP );
+    [[VLCCoreInteraction sharedInstance] stop];
 }
 
 #pragma mark -
@@ -853,16 +853,7 @@ static VLCMain *_o_sharedMainInstance = nil;
 /* Triggered when the computer goes to sleep */
 - (void)computerWillSleep: (NSNotification *)notification
 {
-    input_thread_t * p_input;
-
-    p_input = pl_CurrentInput( p_intf );
-    if( p_input )
-    {
-        int state = var_GetInteger( p_input, "state" );
-        if( state == PLAYING_S )
-            var_SetInteger( p_intf->p_libvlc, "key-action", ACTIONID_PLAY_PAUSE );
-        vlc_object_release( p_input );
-    }
+    [[VLCCoreInteraction sharedInstance] pause];
 }
 
 #pragma mark -



More information about the vlc-commits mailing list