Commit 896ea693 authored by Gildas Bazin's avatar Gildas Bazin

* modules/video_output/x11/xcommon.c: hotkeys handling cleanup and support for ctrl/alt/shift modifiers.
* modules/gui/wxwindows/preferences_widgets.cpp: correctly select the active hotkey (needed on win32).
parent 3b9cfe30
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* preferences_widgets.cpp : wxWindows plugin for vlc * preferences_widgets.cpp : wxWindows plugin for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2000-2001 VideoLAN * Copyright (C) 2000-2001 VideoLAN
* $Id: preferences_widgets.cpp,v 1.5 2003/10/21 12:30:40 hartman Exp $ * $Id: preferences_widgets.cpp,v 1.6 2003/10/28 21:59:13 gbazin Exp $
* *
* Authors: Gildas Bazin <gbazin@netcourrier.com> * Authors: Gildas Bazin <gbazin@netcourrier.com>
* Sigmund Augdal <sigmunau@idi.ntnu.no> * Sigmund Augdal <sigmunau@idi.ntnu.no>
...@@ -153,11 +153,13 @@ KeyConfigControl::KeyConfigControl( module_config_t *p_item, wxWindow *parent ) ...@@ -153,11 +153,13 @@ KeyConfigControl::KeyConfigControl( module_config_t *p_item, wxWindow *parent )
/* HPReg says casting the int to void * is fine */ /* HPReg says casting the int to void * is fine */
combo->Append( wxU(_(keys[i].psz_key_string)), combo->Append( wxU(_(keys[i].psz_key_string)),
(void*)keys[i].i_key_code ); (void*)keys[i].i_key_code );
if( keys[i].i_key_code == ( p_item->i_value & ~KEY_MODIFIER ) ) if( keys[i].i_key_code == ( ((unsigned int)p_item->i_value) & ~KEY_MODIFIER ) )
{ {
combo->SetSelection( i ); combo->SetSelection( i );
combo->SetValue( wxU(_(keys[i].psz_key_string)) );
} }
} }
sizer->Add( label, 2, wxALIGN_CENTER_VERTICAL | wxALL | wxEXPAND, 5 ); sizer->Add( label, 2, wxALIGN_CENTER_VERTICAL | wxALL | wxEXPAND, 5 );
sizer->Add( alt, 1, wxALIGN_CENTER_VERTICAL | wxALL | wxEXPAND, 5 ); sizer->Add( alt, 1, wxALIGN_CENTER_VERTICAL | wxALL | wxEXPAND, 5 );
sizer->Add( ctrl, 1, wxALIGN_CENTER_VERTICAL | wxALL | wxEXPAND, 5 ); sizer->Add( ctrl, 1, wxALIGN_CENTER_VERTICAL | wxALL | wxEXPAND, 5 );
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* xcommon.c: Functions common to the X11 and XVideo plugins * xcommon.c: Functions common to the X11 and XVideo plugins
***************************************************************************** *****************************************************************************
* Copyright (C) 1998-2001 VideoLAN * Copyright (C) 1998-2001 VideoLAN
* $Id: xcommon.c,v 1.36 2003/10/26 23:03:47 sigmunau Exp $ * $Id: xcommon.c,v 1.37 2003/10/28 21:59:12 gbazin Exp $
* *
* Authors: Vincent Seguin <seguin@via.ecp.fr> * Authors: Vincent Seguin <seguin@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org> * Samuel Hocevar <sam@zoy.org>
...@@ -120,6 +120,8 @@ static void SetPalette ( vout_thread_t *, ...@@ -120,6 +120,8 @@ static void SetPalette ( vout_thread_t *,
static void TestNetWMSupport( vout_thread_t * ); static void TestNetWMSupport( vout_thread_t * );
static int ConvertKey( int );
/***************************************************************************** /*****************************************************************************
* Activate: allocate X11 video thread output method * Activate: allocate X11 video thread output method
***************************************************************************** *****************************************************************************
...@@ -485,8 +487,6 @@ static void DisplayVideo( vout_thread_t *p_vout, picture_t *p_pic ) ...@@ -485,8 +487,6 @@ static void DisplayVideo( vout_thread_t *p_vout, picture_t *p_pic )
static int ManageVideo( vout_thread_t *p_vout ) static int ManageVideo( vout_thread_t *p_vout )
{ {
XEvent xevent; /* X11 event */ XEvent xevent; /* X11 event */
char i_key; /* ISO Latin-1 key */
KeySym x_key_symbol;
vlc_value_t val; vlc_value_t val;
/* Handle X11 events: ConfigureNotify events are parsed to know if the /* Handle X11 events: ConfigureNotify events are parsed to know if the
...@@ -518,117 +518,45 @@ static int ManageVideo( vout_thread_t *p_vout ) ...@@ -518,117 +518,45 @@ static int ManageVideo( vout_thread_t *p_vout )
/* Keyboard event */ /* Keyboard event */
else if( xevent.type == KeyPress ) else if( xevent.type == KeyPress )
{ {
vlc_value_t val; unsigned int state = xevent.xkey.state;
val.i_int = 0; KeySym x_key_symbol;
char i_key; /* ISO Latin-1 key */
/* We may have keys like F1 trough F12, ESC ... */ /* We may have keys like F1 trough F12, ESC ... */
x_key_symbol = XKeycodeToKeysym( p_vout->p_sys->p_display, x_key_symbol = XKeycodeToKeysym( p_vout->p_sys->p_display,
xevent.xkey.keycode, 0 ); xevent.xkey.keycode, 0 );
switch( (int)x_key_symbol ) val.i_int = ConvertKey( (int)x_key_symbol );
{
case XK_F1:
val.i_int = KEY_F1;
break;
case XK_F2:
val.i_int = KEY_F2;
break;
case XK_F3:
val.i_int = KEY_F3;
break;
case XK_F4:
val.i_int = KEY_F4;
break;
case XK_F5:
val.i_int = KEY_F5;
break;
case XK_F6:
val.i_int = KEY_F6;
break;
case XK_F7:
val.i_int = KEY_F7;
break;
case XK_F8:
val.i_int = KEY_F8;
break;
case XK_F9:
val.i_int = KEY_F9;
break;
case XK_F10:
val.i_int = KEY_F10;
break;
case XK_F11:
val.i_int = KEY_F11;
break;
case XK_F12:
val.i_int = KEY_F12;
break;
case XK_Return: xevent.xkey.state &= ~ShiftMask;
case XK_KP_Enter: xevent.xkey.state &= ~ControlMask;
val.i_int = KEY_ENTER; xevent.xkey.state &= ~Mod1Mask;
break;
case XK_Escape:
val.i_int = KEY_ESC;
break;
case XK_Menu:
val.i_int = KEY_MENU;
break;
case XK_Left:
val.i_int = KEY_LEFT;
break;
case XK_Right:
val.i_int = KEY_RIGHT;
break;
case XK_Up:
val.i_int = KEY_UP;
break;
case XK_Down:
val.i_int = KEY_DOWN;
break;
case XK_Home:
val.i_int = KEY_HOME;
break;
case XK_End:
val.i_int = KEY_END;
break;
case XK_Page_Up:
val.i_int = KEY_PAGEUP;
break;
case XK_Page_Down:
val.i_int = KEY_PAGEDOWN;
break;
case XK_space:
val.i_int = KEY_SPACE;
break;
default: if( !val.i_int &&
XLookupString( &xevent.xkey, &i_key, 1, NULL, NULL ) )
{
/* "Normal Keys" /* "Normal Keys"
* The reason why I use this instead of XK_0 is that * The reason why I use this instead of XK_0 is that
* with XLookupString, we don't have to care about * with XLookupString, we don't have to care about
* keymaps. */ * keymaps. */
if( XLookupString( &xevent.xkey, &i_key, 1, NULL, NULL ) )
{
/* FIXME: handle stuff here */
val.i_int = i_key; val.i_int = i_key;
} }
break;
} if( val.i_int )
if ( val.i_int )
{ {
if ( xevent.xkey.state & ShiftMask ) if( state & ShiftMask )
{ {
val.i_int |= KEY_MODIFIER_SHIFT; val.i_int |= KEY_MODIFIER_SHIFT;
} }
if ( xevent.xkey.state & ControlMask ) if( state & ControlMask )
{ {
msg_Dbg( p_vout, "control pressed, key value is %x", val.i_int );
val.i_int |= KEY_MODIFIER_CTRL; val.i_int |= KEY_MODIFIER_CTRL;
} }
if ( xevent.xkey.state & Mod1Mask ) if( state & Mod1Mask )
{ {
val.i_int |= KEY_MODIFIER_ALT; val.i_int |= KEY_MODIFIER_ALT;
} }
if ( val.i_int == config_GetInt( p_vout, "fullscreen-key" ) )
if( val.i_int == config_GetInt( p_vout, "fullscreen-key" ) )
{ {
p_vout->i_changes |= VOUT_FULLSCREEN_CHANGE; p_vout->i_changes |= VOUT_FULLSCREEN_CHANGE;
} }
...@@ -2214,3 +2142,51 @@ static void TestNetWMSupport( vout_thread_t *p_vout ) ...@@ -2214,3 +2142,51 @@ static void TestNetWMSupport( vout_thread_t *p_vout )
XFree( p_args ); XFree( p_args );
} }
/*****************************************************************************
* Key events handling
*****************************************************************************/
static struct
{
int i_x11key;
int i_vlckey;
} x11keys_to_vlckeys[] =
{
{ XK_F1, KEY_F1 }, { XK_F2, KEY_F2 }, { XK_F3, KEY_F3 }, { XK_F4, KEY_F4 },
{ XK_F5, KEY_F5 }, { XK_F6, KEY_F6 }, { XK_F7, KEY_F7 }, { XK_F8, KEY_F8 },
{ XK_F9, KEY_F9 }, { XK_F10, KEY_F10 }, { XK_F11, KEY_F11 },
{ XK_F12, KEY_F12 },
{ XK_Return, KEY_ENTER },
{ XK_KP_Enter, KEY_ENTER },
{ XK_space, KEY_SPACE },
{ XK_Escape, KEY_ESC },
{ XK_Menu, KEY_MENU },
{ XK_Left, KEY_LEFT },
{ XK_Right, KEY_RIGHT },
{ XK_Up, KEY_UP },
{ XK_Down, KEY_DOWN },
{ XK_Home, KEY_HOME },
{ XK_End, KEY_END },
{ XK_Page_Up, KEY_PAGEUP },
{ XK_Page_Down, KEY_PAGEDOWN },
{ 0, 0 }
};
static int ConvertKey( int i_key )
{
int i;
for( i = 0; x11keys_to_vlckeys[i].i_x11key != 0; i++ )
{
if( x11keys_to_vlckeys[i].i_x11key == i_key )
{
return x11keys_to_vlckeys[i].i_vlckey;
}
}
return 0;
}
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