]> git.sesse.net Git - vlc/commitdiff
hotkeys: Change subtitle position only if it exists and is enabled.
authorZoran Turalija <zoran.turalija@gmail.com>
Sun, 14 Apr 2013 10:49:03 +0000 (12:49 +0200)
committerJean-Baptiste Kempf <jb@videolan.org>
Mon, 15 Apr 2013 09:28:37 +0000 (11:28 +0200)
In ACTIONID_SUBPOS_UP/DOWN, do not change subtitle position if there
is no subtitle, or if subtitle has been currently disabled.

Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>
modules/control/hotkeys.c

index 01d6f6bf699ff1e22c9b33c9fbb8619c0e011ea3..7069d3d67295ea64272e05310fcc1040e6a9edad 100644 (file)
@@ -970,14 +970,33 @@ static int PutAction( intf_thread_t *p_intf, int i_action )
         case ACTIONID_SUBPOS_DOWN:
         case ACTIONID_SUBPOS_UP:
         {
-            int i_pos;
-            if( i_action == ACTIONID_SUBPOS_DOWN )
-                i_pos = var_DecInteger( p_vout, "sub-margin" );
-            else
-                i_pos = var_IncInteger( p_vout, "sub-margin" );
+            if( p_input )
+            {
+                vlc_value_t val, list, list2;
+                int i_count;
+                var_Get( p_input, "spu-es", &val );
 
-            ClearChannels( p_intf, p_vout );
-            DisplayMessage( p_vout, _( "Subtitle position %d px" ), i_pos );
+                var_Change( p_input, "spu-es", VLC_VAR_GETCHOICES,
+                            &list, &list2 );
+                i_count = list.p_list->i_count;
+                if( i_count < 1 || val.i_int < 0 )
+                {
+                    DisplayMessage( p_vout,
+                                    _("Subtitle position: no active subtitle") );
+                    var_FreeList( &list, &list2 );
+                    break;
+                }
+
+                int i_pos;
+                if( i_action == ACTIONID_SUBPOS_DOWN )
+                    i_pos = var_DecInteger( p_vout, "sub-margin" );
+                else
+                    i_pos = var_IncInteger( p_vout, "sub-margin" );
+
+                ClearChannels( p_intf, p_vout );
+                DisplayMessage( p_vout, _( "Subtitle position %d px" ), i_pos );
+                var_FreeList( &list, &list2 );
+            }
             break;
         }