Browse Source

actions: replace libvlc->p_hotkeys

Use vlc_actions_get_key_names instead

Signed-off-by: Hugo Beauzée-Luyssen <hugo@beauzee.fr>
pull/56/head
Thomas Guillem 9 years ago
committed by Hugo Beauzée-Luyssen
parent
commit
c46cbfef3a
  1. 11
      include/vlc_actions.h
  2. 5
      include/vlc_main.h
  3. 18
      modules/control/globalhotkeys/win32.c
  4. 9
      modules/control/globalhotkeys/xcb.c
  5. 1
      modules/gui/macosx/VLCSimplePrefsController.m
  6. 1
      src/libvlccore.sym
  7. 22
      src/misc/actions.c

11
include/vlc_actions.h

@ -254,9 +254,12 @@ typedef enum vlc_action_id {
VLC_API vlc_action_id_t VLC_API vlc_action_id_t
vlc_actions_get_id(const char *psz_key_name); vlc_actions_get_id(const char *psz_key_name);
struct hotkey /**
{ * Get a list a key names
const char *psz_action; * \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 #endif

5
include/vlc_main.h

@ -26,8 +26,6 @@
* This file defines libvlc_int_t internal libvlc instance * This file defines libvlc_int_t internal libvlc instance
*/ */
struct hotkey;
/***************************************************************************** /*****************************************************************************
* libvlc_internal_instance_t * libvlc_internal_instance_t
***************************************************************************** *****************************************************************************
@ -36,8 +34,5 @@ struct hotkey;
struct libvlc_int_t struct libvlc_int_t
{ {
VLC_COMMON_MEMBERS VLC_COMMON_MEMBERS
/* Structure storing the action name / key associations */
const struct hotkey *p_hotkeys;
}; };

18
modules/control/globalhotkeys/win32.c

@ -167,12 +167,11 @@ static void *Thread( void *p_data )
(LONG_PTR)p_intf ); (LONG_PTR)p_intf );
/* Registering of Hotkeys */ /* Registering of Hotkeys */
for( const struct hotkey *p_hotkey = p_intf->obj.libvlc->p_hotkeys; for( const char* const* ppsz_keys = vlc_actions_get_key_names( p_intf );
p_hotkey->psz_action != NULL; *ppsz_keys != NULL; ppsz_keys++ )
p_hotkey++ )
{ {
char varname[12 + strlen( p_hotkey->psz_action )]; char varname[12 + strlen( *ppsz_keys )];
sprintf( varname, "global-key-%s", p_hotkey->psz_action ); sprintf( varname, "global-key-%s", *ppsz_keys );
char *key = var_InheritString( p_intf, varname ); char *key = var_InheritString( p_intf, varname );
if( key == NULL ) if( key == NULL )
@ -254,7 +253,7 @@ static void *Thread( void *p_data )
#undef HANDLE #undef HANDLE
#undef HANDLE2 #undef HANDLE2
ATOM atom = GlobalAddAtomA( p_hotkey->psz_action ); ATOM atom = GlobalAddAtomA( *ppsz_keys );
if( !atom ) continue; if( !atom ) continue;
if( !RegisterHotKey( p_sys->hotkeyWindow, atom, i_keyMod, i_vk ) ) if( !RegisterHotKey( p_sys->hotkeyWindow, atom, i_keyMod, i_vk ) )
@ -266,11 +265,10 @@ static void *Thread( void *p_data )
DispatchMessage( &message ); DispatchMessage( &message );
/* Unregistering of Hotkeys */ /* Unregistering of Hotkeys */
for( const struct hotkey *p_hotkey = p_intf->obj.libvlc->p_hotkeys; for( const char* const* ppsz_keys = vlc_actions_get_key_names( p_intf );
p_hotkey->psz_action != NULL; *ppsz_keys != NULL; ppsz_keys++ )
p_hotkey++ )
{ {
ATOM atom = GlobalFindAtomA( p_hotkey->psz_action ); ATOM atom = GlobalFindAtomA( *ppsz_keys );
if( !atom ) continue; if( !atom ) continue;
if( UnregisterHotKey( p_sys->hotkeyWindow, atom ) ) if( UnregisterHotKey( p_sys->hotkeyWindow, atom ) )

9
modules/control/globalhotkeys/xcb.c

@ -290,12 +290,11 @@ static bool Mapping( intf_thread_t *p_intf )
p_sys->p_map = NULL; p_sys->p_map = NULL;
/* Registering of Hotkeys */ /* Registering of Hotkeys */
for( const struct hotkey *p_hotkey = p_intf->obj.libvlc->p_hotkeys; for( const char* const* ppsz_keys = vlc_actions_get_key_names( p_intf );
p_hotkey->psz_action != NULL; *ppsz_keys != NULL; ppsz_keys++ )
p_hotkey++ )
{ {
char varname[12 + strlen( p_hotkey->psz_action )]; char varname[12 + strlen( *ppsz_keys )];
sprintf( varname, "global-key-%s", p_hotkey->psz_action ); sprintf( varname, "global-key-%s", *ppsz_keys );
char *key = var_InheritString( p_intf, varname ); char *key = var_InheritString( p_intf, varname );
if( key == NULL ) if( key == NULL )

1
modules/gui/macosx/VLCSimplePrefsController.m

@ -705,7 +705,6 @@ static inline const char * __config_GetLabel(vlc_object_t *p_this, const char *p
/******************** /********************
* hotkeys settings * * hotkeys settings *
********************/ ********************/
const struct hotkey *p_hotkeys = p_intf->obj.libvlc->p_hotkeys;
_hotkeySettings = [[NSMutableArray alloc] init]; _hotkeySettings = [[NSMutableArray alloc] init];
NSMutableArray *tempArray_desc = [[NSMutableArray alloc] init]; NSMutableArray *tempArray_desc = [[NSMutableArray alloc] init];
NSMutableArray *tempArray_names = [[NSMutableArray alloc] init]; NSMutableArray *tempArray_names = [[NSMutableArray alloc] init];

1
src/libvlccore.sym

@ -511,6 +511,7 @@ video_format_IsSimilar
video_format_Setup video_format_Setup
video_format_Print video_format_Print
vlc_actions_get_id vlc_actions_get_id
vlc_actions_get_key_names
vlc_b64_decode vlc_b64_decode
vlc_b64_decode_binary vlc_b64_decode_binary
vlc_b64_decode_binary_to_buffer vlc_b64_decode_binary_to_buffer

22
src/misc/actions.c

@ -395,7 +395,7 @@ struct vlc_actions_t
{ {
void *map; /* Key map */ void *map; /* Key map */
void *global_map; /* Grabbed/global 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, 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); assert(libvlc != NULL);
vlc_object_t *obj = VLC_OBJECT(libvlc); vlc_object_t *obj = VLC_OBJECT(libvlc);
struct hotkey *keys; vlc_actions_t *as = malloc (sizeof (*as) + (1 + ACTIONS_COUNT)
vlc_actions_t *as = malloc (sizeof (*as) + ACTIONS_COUNT * sizeof (*keys)); * sizeof (*as->ppsz_keys));
if (unlikely(as == NULL)) if (unlikely(as == NULL))
return VLC_ENOMEM; return VLC_ENOMEM;
as->map = NULL; as->map = NULL;
as->global_map = NULL; as->global_map = NULL;
keys = as->keys;
var_Create (obj, "key-pressed", VLC_VAR_INTEGER); var_Create (obj, "key-pressed", VLC_VAR_INTEGER);
var_Create (obj, "global-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 (); abort ();
} }
#endif #endif
keys->psz_action = s_names2actions[i].psz; as->ppsz_keys[i] = s_names2actions[i].psz;
keys++;
char name[12 + MAXACTION]; 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->map, name + 7, s_names2actions[i].id);
init_action (obj, &as->global_map, name, 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 */ /* Initialize mouse wheel events */
add_wheel_mapping (&as->map, KEY_MOUSEWHEELRIGHT, KEY_MOUSEWHEELLEFT, 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")); var_InheritInteger (obj, "hotkeys-y-wheel-mode"));
libvlc_priv(libvlc)->actions = as; libvlc_priv(libvlc)->actions = as;
libvlc->p_hotkeys = as->keys;
var_AddCallback (obj, "key-pressed", vlc_key_to_action, &as->map); var_AddCallback (obj, "key-pressed", vlc_key_to_action, &as->map);
var_AddCallback (obj, "global-key-pressed", vlc_key_to_action, var_AddCallback (obj, "global-key-pressed", vlc_key_to_action,
&as->global_map); &as->global_map);
@ -571,7 +568,6 @@ void libvlc_InternalActionsClean (libvlc_int_t *libvlc)
tdestroy (as->map, free); tdestroy (as->map, free);
free (as); free (as);
libvlc_priv(libvlc)->actions = NULL; 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); act = bsearch(name, s_names2actions, ACTIONS_COUNT, sizeof(*act), actcmp);
return (act != NULL) ? act->id : ACTIONID_NONE; 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;
}

Loading…
Cancel
Save