]> git.sesse.net Git - vlc/commitdiff
* Patch from Basil Achermann to handle esc and space keyboard events in VLCControl...
authorBenjamin Pracht <bigben@videolan.org>
Sun, 30 Apr 2006 19:26:25 +0000 (19:26 +0000)
committerBenjamin Pracht <bigben@videolan.org>
Sun, 30 Apr 2006 19:26:25 +0000 (19:26 +0000)
* It seems that corrects a bug when the controller was the acrtive window in fullscreen (that shouldn't happen, but well...)
* Best thing to do would be to handle the keypresses from the vout here too, I guess...

THANKS
modules/gui/macosx/controls.h
modules/gui/macosx/controls.m
modules/gui/macosx/misc.m

diff --git a/THANKS b/THANKS
index cd7a0bde471c98d4fa06ee2f0fdb622453603de9..b6e8a94bfc80c8f5542c792e5c3fba9ca0e7525c 100644 (file)
--- a/THANKS
+++ b/THANKS
@@ -21,6 +21,7 @@ Arkadiusz Lipiec <A.Lipiec at elka.pw.edu.pl> - Polish translation
 Arkadiusz Miskiewicz <misiek at pld.ORG.PL> - autoconf and Makefile patches
 Arnaud Gomes-do-Vale <arnaud at carrosse.frmug.org> - autoconf patches
 Arwed v. Merkatz <v.merkatz at gmx dot net> - Gamma correction for adjust filter
+Basil Achermann <vlc at acherma dot com> - Patch to handle esc and space key events from VLCControl (OSX)
 Barak Ori <barakori at gmail dot com> - Bidi fixes
 Benjamin Mironer <bmironer at noos.fr> - Mac OS X fixes
 Benoit Steiner <benny at via.ecp.fr> - MPEG system input, network input
index a56313d66652307e47629366ba3ec398fc9b6153..f7a190cb60b931925888fcc7805d7a6674637472 100644 (file)
@@ -63,6 +63,7 @@
 - (IBAction)volumeSliderUpdated:(id)sender;
 
 - (IBAction)windowAction:(id)sender;
+- (BOOL)keyEvent:(NSEvent *)o_event;
 
 - (void)setupVarMenuItem:(NSMenuItem *)o_mi
                     target:(vlc_object_t *)p_object
index e6c0c9d39151ffc6327dae8bead2a2b06fe39308..1870c19af6d84c09ea50107c84a812d33d0477ba 100644 (file)
@@ -37,6 +37,7 @@
 #include "controls.h"
 #include <vlc_osd.h>
 
+
 /*****************************************************************************
  * VLCControls implementation 
  *****************************************************************************/
     var_Set( p_intf->p_vlc, "key-pressed", val );
 }
 
+/* Small helper method */
+
+-(id) getVoutView
+{
+    id o_window;
+    id o_vout_view = nil;
+    id o_embedded_vout_list = [[VLCMain sharedInstance] getEmbeddedList];
+    NSEnumerator *o_enumerator = [[NSApp orderedWindows] objectEnumerator];
+    while( !o_vout_view && ( o_window = [o_enumerator nextObject] ) )
+    {
+        /* We have an embedded vout */
+        if( [o_embedded_vout_list windowContainsEmbedded: o_window] )
+        {
+            o_vout_view = [o_embedded_vout_list getViewForWindow: o_window];
+        }
+        /* We have a detached vout */
+        else if( [[o_window className] isEqualToString: @"VLCWindow"] )
+        {
+            msg_Dbg( VLCIntf, "detached vout controls.m call getVoutView" );
+            o_vout_view = [o_window getVoutView];
+        }
+    }
+    return o_vout_view;
+}
+
+
 - (IBAction)stop:(id)sender
 {
     vlc_value_t val;
 
 - (IBAction)windowAction:(id)sender
 {
-    id o_window = [NSApp keyWindow];
     NSString *o_title = [sender title];
-    NSArray *o_windows = [NSApp orderedWindows];
-    NSEnumerator *o_enumerator = [o_windows objectEnumerator];
+
     vout_thread_t *p_vout = vlc_object_find( VLCIntf, VLC_OBJECT_VOUT,
                                               FIND_ANYWHERE );
-
     if( p_vout != NULL )
     {
-        id o_embedded_vout_list = [[VLCMain sharedInstance] getEmbeddedList];
-        while ((o_window = [o_enumerator nextObject]))
+        id o_vout_view = [self getVoutView];
+        if( o_vout_view )
         {
-            id o_vout_view = nil;
-            /* We have an embedded vout */
-            if( [o_embedded_vout_list windowContainsEmbedded: o_window] )
+            if( [o_title isEqualToString: _NS("Half Size") ] )
+                [o_vout_view scaleWindowWithFactor: 0.5];
+            else if( [o_title isEqualToString: _NS("Normal Size") ] )
+                [o_vout_view scaleWindowWithFactor: 1.0];
+            else if( [o_title isEqualToString: _NS("Double Size") ] )
+                [o_vout_view scaleWindowWithFactor: 2.0];
+            else if( [o_title isEqualToString: _NS("Float on Top") ] )
+                [o_vout_view toggleFloatOnTop];
+            else if( [o_title isEqualToString: _NS("Fit to Screen") ] )
             {
-                o_vout_view = [o_embedded_vout_list getViewForWindow: o_window];
+                id o_window = [o_vout_view getWindow];
+                if( ![o_window isZoomed] )
+                    [o_window performZoom:self];
             }
-            /* We have a detached Vout */
-            else if( [[o_window className] isEqualToString: @"VLCWindow"] )
+            else if( [o_title isEqualToString: _NS("Snapshot") ] )
             {
-                msg_Dbg( VLCIntf, "detached vout controls.m call getVoutView" );
-                o_vout_view = [o_window getVoutView];
+                [o_vout_view snapshot];
             }
-
-            if( o_vout_view )
+            else
             {
-                if( [o_title isEqualToString: _NS("Half Size") ] )
-                    [o_vout_view scaleWindowWithFactor: 0.5];
-                else if( [o_title isEqualToString: _NS("Normal Size") ] )
-                    [o_vout_view scaleWindowWithFactor: 1.0];
-                else if( [o_title isEqualToString: _NS("Double Size") ] )
-                    [o_vout_view scaleWindowWithFactor: 2.0];
-                else if( [o_title isEqualToString: _NS("Float on Top") ] )
-                    [o_vout_view toggleFloatOnTop];
-                else if( [o_title isEqualToString: _NS("Fit to Screen") ] )
-                {
-                    if( ![o_window isZoomed] )
-                        [o_window performZoom:self];
-                }
-                else if( [o_title isEqualToString: _NS("Snapshot") ] )
-                {
-                    [o_vout_view snapshot];
-                }
-                else
-                {
-                    [o_vout_view toggleFullscreen];
-                }
-                break;
+                [o_vout_view toggleFullscreen];
             }
         }
         vlc_object_release( (vlc_object_t *)p_vout );
 
 }
 
+- (BOOL)keyEvent:(NSEvent *)o_event
+{
+    BOOL eventHandled = NO;
+    unichar key = [[o_event charactersIgnoringModifiers] characterAtIndex: 0];
+
+    if( key )
+    {
+        vout_thread_t *p_vout = vlc_object_find( VLCIntf, VLC_OBJECT_VOUT,
+                                              FIND_ANYWHERE );
+        if( p_vout != NULL )
+        {
+            /* Escape */
+            if( key == (unichar) 0x1b )
+            {
+                id o_vout_view = [self getVoutView];
+                if( o_vout_view && [o_vout_view isFullscreen] )
+                {
+                    [o_vout_view toggleFullscreen];
+                    eventHandled = YES;
+                }
+            }
+            else if( key == ' ' )
+            {
+                [self play:self];
+                eventHandled = YES;
+            }
+            vlc_object_release( (vlc_object_t *)p_vout );
+        }
+    }
+    return eventHandled;
+}
+
 - (void)setupVarMenuItem:(NSMenuItem *)o_mi
                     target:(vlc_object_t *)p_object
                     var:(const char *)psz_variable
             [o_mi setState: val.b_bool];
             bEnabled = TRUE;
         }
-               [o_main setupMenus]; /* Make sure video menu is up to date */
+        [o_main setupMenus]; /* Make sure video menu is up to date */
     }
 
     vlc_mutex_unlock( &p_playlist->object_lock );
index fd25b6d7863cbd2d54063200f3a76a189465c17f..89cb25ed2cee28fbe29b229b6aab0af6c4386b74 100644 (file)
@@ -26,6 +26,7 @@
 #include "intf.h"                                          /* VLCApplication */
 #include "misc.h"
 #include "playlist.h"
+#include "controls.h"
 
 /*****************************************************************************
  * VLCControllerWindow
@@ -46,7 +47,8 @@
 
 - (BOOL)performKeyEquivalent:(NSEvent *)o_event
 {
-    return [[VLCMain sharedInstance] hasDefinedShortcutKey:o_event];
+    return [[VLCMain sharedInstance] hasDefinedShortcutKey:o_event] ||
+           [(VLCControls *)[[VLCMain sharedInstance] getControls] keyEvent:o_event];
 }
 
 @end