]> git.sesse.net Git - vlc/blobdiff - modules/gui/macosx/vout.m
macosx: Save a reference to the view in the voutgl.
[vlc] / modules / gui / macosx / vout.m
index 94114dfebb6d52b68eb7c37c9395b3a45780d86b..3d309fce246b5f87a85d4fefff8ff837cb45933c 100644 (file)
@@ -145,7 +145,7 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
 
 - (id)initWithFrame: (NSRect)frameRect
 {
-    [super initWithFrame: frameRect];
+    self = [super initWithFrame: frameRect];
     p_vout = NULL;
     o_view = nil;
     s_frame = &frameRect;
@@ -480,7 +480,7 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
     if( i_pressed_modifiers & NSCommandKeyMask )
         val.i_int |= KEY_MODIFIER_COMMAND;
 
-    key = [[o_event charactersIgnoringModifiers] characterAtIndex: 0];
+    key = [[[o_event charactersIgnoringModifiers] lowercaseString] characterAtIndex: 0];
 
     if( key )
     {
@@ -492,22 +492,18 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
                  [self toggleFullscreen];
              }
         }
-        else if ( key == ' ' )
+        else if ( p_vout )
         {
-            vlc_value_t val;
-            val.i_int = config_GetInt( p_vout, "key-play-pause" );
-            var_Set( p_vout->p_libvlc, "key-pressed", val );
-        }
-        else
-        {
-            val.i_int |= CocoaKeyToVLC( key );
+            if( key == ' ')
+                val.i_int = config_GetInt( p_vout, "key-play-pause" );
+            else
+                val.i_int |= (int)CocoaKeyToVLC( key );
             var_Set( p_vout->p_libvlc, "key-pressed", val );
         }
+        else NSLog( @"Could not send keyevent to VLC core" );
     }
     else
-    {
         [super keyDown: o_event];
-    }
 }
 
 - (void)mouseDown:(NSEvent *)o_event
@@ -857,13 +853,18 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
 
 - (void)manage
 {
+    /* Dooh, why do we spend processor time doing this kind of stuff? */
     [super manage];
     unsigned int i_mouse_hide_timeout =
-        var_GetInteger(p_vout, "mouse-hide-timeout") * 1000;
+        var_CreateGetInteger(p_vout, "mouse-hide-timeout") * 1000;
+
+    if( i_mouse_hide_timeout < 100000 )
+        i_mouse_hide_timeout = 100000;
     if( p_vout->b_fullscreen )
     {
         if( mdate() - i_time_mouse_last_moved > i_mouse_hide_timeout )
         {
+            i_time_mouse_last_moved = mdate();
             [self hideMouse: YES];
         }
     }
@@ -876,15 +877,15 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
 
 - (void)enterFullscreen
 {
-    [super enterFullscreen];
     [o_window performSelectorOnMainThread: @selector(enterFullscreen) withObject: NULL waitUntilDone: NO];
+    [super enterFullscreen];
 
 }
 
 - (void)leaveFullscreen
 {
-    [super leaveFullscreen];
     [o_window performSelectorOnMainThread: @selector(leaveFullscreen) withObject: NULL waitUntilDone: NO];
+    [super leaveFullscreen];
 }
 
 
@@ -939,7 +940,7 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
 
         [o_window setAcceptsMouseMovedEvents: TRUE];
 
-        if( var_GetBool( p_real_vout, "video-on-top" ) )
+        if( var_CreateGetBool( p_real_vout, "video-on-top" ) )
         {
             [o_window setLevel: NSStatusWindowLevel];
         }
@@ -1059,6 +1060,8 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
         /* We'll catch mouse events */
         [self makeFirstResponder: o_view];
         [self setCanBecomeKeyWindow: YES];
+        [self setAcceptsMouseMovedEvents: YES];
+        [self setIgnoresMouseEvents: NO];
 
         if( var_CreateGetBool( p_vout, "macosx-background" ) )
         {
@@ -1107,29 +1110,22 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
     screen = [NSScreen screenWithDisplayID: (CGDirectDisplayID)i_device];
     if( !screen ) screen = [self screen];
 
-    if( b_black && [[NSScreen screens] count] > 1)
-    {
-        CGDisplayFadeReservationToken token;
-        CGAcquireDisplayFadeReservation(kCGMaxDisplayReservationInterval, &token);
-        CGDisplayFade( token, 0.2 , kCGDisplayBlendNormal, kCGDisplayBlendSolidColor, 0, 0, 0, YES );
-
+    if( b_black )
         [screen blackoutOtherScreens];
 
-        CGDisplayFade( token, 0.1 , kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0, 0, 0, NO );
-        CGReleaseDisplayFadeReservation( token);
-    }
-
     [self setMovableByWindowBackground: NO];
 
-    /* tell the fspanel to move itself to front next time it's triggered */
-    [[[[VLCMain sharedInstance] getControls] getFSPanel] setVoutWasUpdated: i_device];
-    [[[[VLCMain sharedInstance] getControls] getFSPanel] setActive: nil];
-
     if( [screen isMainScreen] )
         SetSystemUIMode( kUIModeAllHidden, kUIOptionAutoShowMenuBar);
 
     initialFrame = [self frame];
     [self setFrame:[screen frame] display:YES animate:YES];
+    [self setLevel:NSNormalWindowLevel];
+
+    /* tell the fspanel to move itself to front next time it's triggered */
+    [[[[VLCMain sharedInstance] getControls] getFSPanel] setVoutWasUpdated: i_device];
+    [[[[VLCMain sharedInstance] getControls] getFSPanel] setActive: nil];
+
     fullscreen = YES;
 }
 
@@ -1144,6 +1140,8 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
     SetSystemUIMode( kUIModeNormal, kUIOptionAutoShowMenuBar);
     [self setFrame:initialFrame display:YES animate:YES];
     [self setMovableByWindowBackground: YES];
+    if( var_GetBool( p_vout, "video-on-top" ) )
+        [self setLevel: NSStatusWindowLevel];
 }
 
 - (id)getVoutView // FIXME Naming scheme!