Commit c46cbfef authored by Thomas Guillem's avatar Thomas Guillem Committed by Hugo Beauzée-Luyssen

actions: replace libvlc->p_hotkeys

Use vlc_actions_get_key_names instead
Signed-off-by: default avatarHugo Beauzée-Luyssen <hugo@beauzee.fr>
parent 32fb07be
......@@ -254,9 +254,12 @@ typedef enum vlc_action_id {
VLC_API vlc_action_id_t
vlc_actions_get_id(const char *psz_key_name);
struct hotkey
{
const char *psz_action;
};
/**
* Get a list a key names
* \return A NULL terminated list of const char *
*/
VLC_API const char* const*
vlc_actions_get_key_names(vlc_object_t *p_obj);
#define vlc_actions_get_key_names(x) vlc_actions_get_key_names(VLC_OBJECT(x))
#endif
......@@ -26,8 +26,6 @@
* This file defines libvlc_int_t internal libvlc instance
*/
struct hotkey;
/*****************************************************************************
* libvlc_internal_instance_t
*****************************************************************************
......@@ -36,8 +34,5 @@ struct hotkey;
struct libvlc_int_t
{
VLC_COMMON_MEMBERS
/* Structure storing the action name / key associations */
const struct hotkey *p_hotkeys;
};
......@@ -167,12 +167,11 @@ static void *Thread( void *p_data )
(LONG_PTR)p_intf );
/* Registering of Hotkeys */
for( const struct hotkey *p_hotkey = p_intf->obj.libvlc->p_hotkeys;
p_hotkey->psz_action != NULL;
p_hotkey++ )
for( const char* const* ppsz_keys = vlc_actions_get_key_names( p_intf );
*ppsz_keys != NULL; ppsz_keys++ )
{
char varname[12 + strlen( p_hotkey->psz_action )];
sprintf( varname, "global-key-%s", p_hotkey->psz_action );
char varname[12 + strlen( *ppsz_keys )];
sprintf( varname, "global-key-%s", *ppsz_keys );
char *key = var_InheritString( p_intf, varname );
if( key == NULL )
......@@ -254,7 +253,7 @@ static void *Thread( void *p_data )
#undef HANDLE
#undef HANDLE2
ATOM atom = GlobalAddAtomA( p_hotkey->psz_action );
ATOM atom = GlobalAddAtomA( *ppsz_keys );
if( !atom ) continue;
if( !RegisterHotKey( p_sys->hotkeyWindow, atom, i_keyMod, i_vk ) )
......@@ -266,11 +265,10 @@ static void *Thread( void *p_data )
DispatchMessage( &message );
/* Unregistering of Hotkeys */
for( const struct hotkey *p_hotkey = p_intf->obj.libvlc->p_hotkeys;
p_hotkey->psz_action != NULL;
p_hotkey++ )
for( const char* const* ppsz_keys = vlc_actions_get_key_names( p_intf );
*ppsz_keys != NULL; ppsz_keys++ )
{
ATOM atom = GlobalFindAtomA( p_hotkey->psz_action );
ATOM atom = GlobalFindAtomA( *ppsz_keys );
if( !atom ) continue;
if( UnregisterHotKey( p_sys->hotkeyWindow, atom ) )
......
......@@ -290,12 +290,11 @@ static bool Mapping( intf_thread_t *p_intf )
p_sys->p_map = NULL;
/* Registering of Hotkeys */
for( const struct hotkey *p_hotkey = p_intf->obj.libvlc->p_hotkeys;
p_hotkey->psz_action != NULL;
p_hotkey++ )
for( const char* const* ppsz_keys = vlc_actions_get_key_names( p_intf );
*ppsz_keys != NULL; ppsz_keys++ )
{
char varname[12 + strlen( p_hotkey->psz_action )];
sprintf( varname, "global-key-%s", p_hotkey->psz_action );
char varname[12 + strlen( *ppsz_keys )];
sprintf( varname, "global-key-%s", *ppsz_keys );
char *key = var_InheritString( p_intf, varname );
if( key == NULL )
......
......@@ -705,7 +705,6 @@ static inline const char * __config_GetLabel(vlc_object_t *p_this, const char *p
/********************
* hotkeys settings *
********************/
const struct hotkey *p_hotkeys = p_intf->obj.libvlc->p_hotkeys;
_hotkeySettings = [[NSMutableArray alloc] init];
NSMutableArray *tempArray_desc = [[NSMutableArray alloc] init];
NSMutableArray *tempArray_names = [[NSMutableArray alloc] init];
......
......@@ -511,6 +511,7 @@ video_format_IsSimilar
video_format_Setup
video_format_Print
vlc_actions_get_id
vlc_actions_get_key_names
vlc_b64_decode
vlc_b64_decode_binary
vlc_b64_decode_binary_to_buffer
......
......@@ -395,7 +395,7 @@ struct vlc_actions_t
{
void *map; /* Key map */
void *global_map; /* Grabbed/global key map */
struct hotkey keys[1];
const char *ppsz_keys[];
};
static int vlc_key_to_action (vlc_object_t *obj, const char *varname,
......@@ -502,14 +502,13 @@ int libvlc_InternalActionsInit (libvlc_int_t *libvlc)
assert(libvlc != NULL);
vlc_object_t *obj = VLC_OBJECT(libvlc);
struct hotkey *keys;
vlc_actions_t *as = malloc (sizeof (*as) + ACTIONS_COUNT * sizeof (*keys));
vlc_actions_t *as = malloc (sizeof (*as) + (1 + ACTIONS_COUNT)
* sizeof (*as->ppsz_keys));
if (unlikely(as == NULL))
return VLC_ENOMEM;
as->map = NULL;
as->global_map = NULL;
keys = as->keys;
var_Create (obj, "key-pressed", VLC_VAR_INTEGER);
var_Create (obj, "global-key-pressed", VLC_VAR_INTEGER);
......@@ -527,8 +526,7 @@ int libvlc_InternalActionsInit (libvlc_int_t *libvlc)
abort ();
}
#endif
keys->psz_action = s_names2actions[i].psz;
keys++;
as->ppsz_keys[i] = s_names2actions[i].psz;
char name[12 + MAXACTION];
......@@ -536,7 +534,7 @@ int libvlc_InternalActionsInit (libvlc_int_t *libvlc)
init_action (obj, &as->map, name + 7, s_names2actions[i].id);
init_action (obj, &as->global_map, name, s_names2actions[i].id);
}
keys->psz_action = NULL;
as->ppsz_keys[ACTIONS_COUNT] = NULL;
/* Initialize mouse wheel events */
add_wheel_mapping (&as->map, KEY_MOUSEWHEELRIGHT, KEY_MOUSEWHEELLEFT,
......@@ -545,7 +543,6 @@ int libvlc_InternalActionsInit (libvlc_int_t *libvlc)
var_InheritInteger (obj, "hotkeys-y-wheel-mode"));
libvlc_priv(libvlc)->actions = as;
libvlc->p_hotkeys = as->keys;
var_AddCallback (obj, "key-pressed", vlc_key_to_action, &as->map);
var_AddCallback (obj, "global-key-pressed", vlc_key_to_action,
&as->global_map);
......@@ -571,7 +568,6 @@ void libvlc_InternalActionsClean (libvlc_int_t *libvlc)
tdestroy (as->map, free);
free (as);
libvlc_priv(libvlc)->actions = NULL;
libvlc->p_hotkeys = NULL;
}
......@@ -597,3 +593,11 @@ vlc_actions_get_id (const char *name)
act = bsearch(name, s_names2actions, ACTIONS_COUNT, sizeof(*act), actcmp);
return (act != NULL) ? act->id : ACTIONID_NONE;
}
#undef vlc_actions_get_key_names
const char* const*
vlc_actions_get_key_names(vlc_object_t *p_obj)
{
vlc_actions_t *as = libvlc_priv(p_obj->obj.libvlc)->actions;
return as->ppsz_keys;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment