[vlc-devel] Proposal for a new hotkeys design (one more)

brezhoneg1 brezhoneg1 at yahoo.fr
Fri Nov 7 22:51:29 CET 2008

>On Wed, Nov 05, 2008, brezhoneg1 wrote:
>> 2- We think globally
>> --------------------
>> We decide to collect all key-pressed from all entities within an
>> instance into a single processing thread. This is today's situation.
>> This is okay. The only thing is to that key-pressed variable must be
>> changed to a {key-pressed + p_origin_object} variable (see previous
>> email). WE MUST NOT forget the origin of key-pressed.
> On Fri Nov 7 12:46:42 CET 2008 fenrir wrote:
> I think it could be simpler for the time being.
> Btw, for this solution you do not need to modify vlc_variable_t.
>You can use a pointer to a local structure as long as everyone
>a callback on "key-pressed" do not store the pointer.
> Something like that can work:
>SetKey( vlc_object_t *p_obj, int i_key )
>    vlc_key_t k;
>    vlc_variable_t v;
>    k.i_key = i_key;
>    k.p_origin = p_obj;
>    v.p_address = &k
>    var_Set( p_obj->p_libvlc, "key-pressed", &v );
>KeyCallback( ..., vlc_variable_t newval, void *p_user )
>   user_t *p_sys = p_data;
>   const vlc_key_t *p_key = newval.p_address;
>  /* Here you can use p_key->i_key and p_key->p_origin */
>  fprintf( stderr, "%d %p", p_key->i_key, p_key->p_origin );
>  /* You cannot store p_key directly AND you have to vlc_object_hold
>      if you need it (and then you will have to release it later) */
>  user_lock( p_sys );
>  user_push_key( p_sys, p_key->i_key, vlc_object_hold( p_key->p_origin
) );
>  user_unlock( p_sys );

Yes, this is another way of passing (key, p_origin).
btw, vlc_key_t seems already used for something else (see vlc_keys.h).
Another name has to be chosen.

Also, the hotkeys module processes key-action, not key-pressed (except
for 4 special cases).
This whole (key-pressed, p_origin) is being designed mainly for hotkeys
module. So hotkeys module has to let go of key-action and
enqueue/dequeue the new (key-pressed, p_origin) directly. (Key-action
can be computed at the last moment, anyway)

That's why I really think it a fifty/fifty matter. Either locally or
globally, some work has to be done and the 24 or so var_set ( ..,
key-pressed, ...) + 3 var_AddCallback( ... key-pressed, ...) have to be
updated accordingly. 

-> Globally : everything has to be updated at the same time because the
hotkeys module won't work as before.

-> Locally  (patch I wrote some time ago) : the hotkeys module remains
unchanged. It is just duplicated. Therefore, it is not required to
change the 24+3 calls to key-pressed at the same time. Those who don't
update still work as before. Those who update get better servicing.
(only X11 key-pressed was implemented in the patch)


More information about the vlc-devel mailing list