Commit 8bc1b7ed authored by Olivier Teulière's avatar Olivier Teulière

* include/vlc_keys.h: mouse wheel events now considered as hotkeys

 * modules/video_output/directx/events.c: mouse wheel support
 * modules/gui/skins2/src/generic_window.cpp: mouse wheel events are
   treated as hotkeys, but only if they are not intercepted by a control
   (such as a slider)
parent a3a165ed
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* hotkeys.h: keycode defines * hotkeys.h: keycode defines
***************************************************************************** *****************************************************************************
* Copyright (C) 2003 VideoLAN * Copyright (C) 2003 VideoLAN
* $Id: vlc_keys.h,v 1.13 2004/01/25 18:17:08 zorglub Exp $ * $Id$
* *
* Authors: Sigmund Augdal <sigmunau@idi.ntnu.no> * Authors: Sigmund Augdal <sigmunau@idi.ntnu.no>
* *
...@@ -55,6 +55,8 @@ ...@@ -55,6 +55,8 @@
#define KEY_PAGEDOWN 0x00180000 #define KEY_PAGEDOWN 0x00180000
#define KEY_TAB 0x00190000 #define KEY_TAB 0x00190000
#define KEY_BACKSPACE 0x001A0000 #define KEY_BACKSPACE 0x001A0000
#define KEY_MOUSEWHEELUP 0x001B0000
#define KEY_MOUSEWHEELDOWN 0x001C0000
#define KEY_ASCII 0x0000007F #define KEY_ASCII 0x0000007F
#define KEY_UNSET 0 #define KEY_UNSET 0
...@@ -105,6 +107,8 @@ static const struct key_descriptor_s vlc_keys[] = ...@@ -105,6 +107,8 @@ static const struct key_descriptor_s vlc_keys[] =
{ "Page Down", KEY_PAGEDOWN }, { "Page Down", KEY_PAGEDOWN },
{ "Tab", KEY_TAB }, { "Tab", KEY_TAB },
{ "Backspace", KEY_BACKSPACE }, { "Backspace", KEY_BACKSPACE },
{ "Mouse Wheel Up", KEY_MOUSEWHEELUP },
{ "Mouse Wheel Down", KEY_MOUSEWHEELDOWN },
{ "a", 'a' }, { "a", 'a' },
{ "b", 'b' }, { "b", 'b' },
{ "c", 'c' }, { "c", 'c' },
......
...@@ -53,7 +53,8 @@ GenericWindow::GenericWindow( intf_thread_t *pIntf, int left, int top, ...@@ -53,7 +53,8 @@ GenericWindow::GenericWindow( intf_thread_t *pIntf, int left, int top,
SkinObject( pIntf ), m_rWindowManager( rWindowManager ), SkinObject( pIntf ), m_rWindowManager( rWindowManager ),
m_left( left ), m_top( top ), m_width( 0 ), m_height( 0 ), m_left( left ), m_top( top ), m_width( 0 ), m_height( 0 ),
m_pActiveLayout( NULL ), m_pLastHitControl( NULL ), m_pActiveLayout( NULL ), m_pLastHitControl( NULL ),
m_pCapturingControl( NULL ), m_pFocusControl( NULL ), m_varVisible( pIntf ) m_pCapturingControl( NULL ), m_pFocusControl( NULL ), m_varVisible( pIntf ),
m_currModifier( 0 )
{ {
// Register as a moving window // Register as a moving window
m_rWindowManager.registerWindow( *this ); m_rWindowManager.registerWindow( *this );
...@@ -192,10 +193,11 @@ void GenericWindow::processEvent( EvtKey &rEvtKey ) ...@@ -192,10 +193,11 @@ void GenericWindow::processEvent( EvtKey &rEvtKey )
if( m_pFocusControl ) if( m_pFocusControl )
{ {
m_pFocusControl->handleEvent( rEvtKey ); m_pFocusControl->handleEvent( rEvtKey );
return;
} }
// Only do the action when the key is down // Only do the action when the key is down
else if( rEvtKey.getAsString().find( "key:down") != string::npos ) if( rEvtKey.getAsString().find( "key:down") != string::npos )
{ {
//XXX not to be hardcoded ! //XXX not to be hardcoded !
// Ctrl-S = Change skin // Ctrl-S = Change skin
...@@ -239,6 +241,9 @@ void GenericWindow::processEvent( EvtKey &rEvtKey ) ...@@ -239,6 +241,9 @@ void GenericWindow::processEvent( EvtKey &rEvtKey )
var_Set( getIntf()->p_vlc, "key-pressed", val ); var_Set( getIntf()->p_vlc, "key-pressed", val );
} }
// Always store the modifier, which can be needed for scroll events
m_currModifier = rEvtKey.getMod();
} }
...@@ -258,7 +263,6 @@ void GenericWindow::processEvent( EvtScroll &rEvtScroll ) ...@@ -258,7 +263,6 @@ void GenericWindow::processEvent( EvtScroll &rEvtScroll )
// Get the control hit by the mouse // Get the control hit by the mouse
CtrlGeneric *pNewHitControl = findHitControl( rEvtScroll.getXPos(), CtrlGeneric *pNewHitControl = findHitControl( rEvtScroll.getXPos(),
rEvtScroll.getYPos()); rEvtScroll.getYPos());
setLastHit( pNewHitControl ); setLastHit( pNewHitControl );
// Send a mouse event to the hit control, or to the control // Send a mouse event to the hit control, or to the control
...@@ -273,6 +277,23 @@ void GenericWindow::processEvent( EvtScroll &rEvtScroll ) ...@@ -273,6 +277,23 @@ void GenericWindow::processEvent( EvtScroll &rEvtScroll )
{ {
pActiveControl->handleEvent( rEvtScroll ); pActiveControl->handleEvent( rEvtScroll );
} }
else
{
// Treat the scroll event as a hotkey
vlc_value_t val;
if( rEvtScroll.getDirection() == EvtScroll::kUp )
{
val.i_int = KEY_MOUSEWHEELUP;
}
else
{
val.i_int = KEY_MOUSEWHEELDOWN;
}
// Add the modifiers
val.i_int |= m_currModifier;
var_Set( getIntf()->p_vlc, "key-pressed", val );
}
} }
......
...@@ -140,6 +140,8 @@ class GenericWindow: public SkinObject, public Observer<VarBool> ...@@ -140,6 +140,8 @@ class GenericWindow: public SkinObject, public Observer<VarBool>
list<Anchor*> m_anchorList; list<Anchor*> m_anchorList;
/// Variable for the visibility of the window /// Variable for the visibility of the window
VarBoolImpl m_varVisible; VarBoolImpl m_varVisible;
/// Current key modifier (also used for mouse)
int m_currModifier;
/// Method called when the observed variable is modified /// Method called when the observed variable is modified
virtual void onUpdate( Subject<VarBool> &rVariable ); virtual void onUpdate( Subject<VarBool> &rVariable );
......
...@@ -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-2004 VideoLAN * Copyright (C) 2000-2004 VideoLAN
* $Id: preferences_widgets.cpp,v 1.23 2004/01/29 17:04:01 gbazin Exp $ * $Id$
* *
* Authors: Gildas Bazin <gbazin@netcourrier.com> * Authors: Gildas Bazin <gbazin@netcourrier.com>
* Sigmund Augdal <sigmunau@idi.ntnu.no> * Sigmund Augdal <sigmunau@idi.ntnu.no>
...@@ -187,6 +187,8 @@ static wxString KeysList[] = ...@@ -187,6 +187,8 @@ static wxString KeysList[] =
wxT("Page Down"), wxT("Page Down"),
wxT("Tab"), wxT("Tab"),
wxT("Backspace"), wxT("Backspace"),
wxT("Mouse Wheel Up"),
wxT("Mouse Wheel Down"),
wxT("a"), wxT("a"),
wxT("b"), wxT("b"),
wxT("c"), wxT("c"),
......
...@@ -237,6 +237,34 @@ void DirectXEventThread( event_thread_t *p_event ) ...@@ -237,6 +237,34 @@ void DirectXEventThread( event_thread_t *p_event )
} }
break; break;
case WM_MOUSEWHEEL:
if( GET_WHEEL_DELTA_WPARAM( msg.wParam ) > 0 )
{
val.i_int = KEY_MOUSEWHEELUP;
}
else
{
val.i_int = KEY_MOUSEWHEELDOWN;
}
if( val.i_int )
{
if( GetKeyState(VK_CONTROL) & 0x8000 )
{
val.i_int |= KEY_MODIFIER_CTRL;
}
if( GetKeyState(VK_SHIFT) & 0x8000 )
{
val.i_int |= KEY_MODIFIER_SHIFT;
}
if( GetKeyState(VK_MENU) & 0x8000 )
{
val.i_int |= KEY_MODIFIER_ALT;
}
var_Set( p_event->p_vlc, "key-pressed", val );
}
break;
case WM_VLC_CHANGE_TEXT: case WM_VLC_CHANGE_TEXT:
if( p_event->p_vout->p_sys->b_using_overlay ) if( p_event->p_vout->p_sys->b_using_overlay )
SetWindowText( p_event->p_vout->p_sys->hwnd, SetWindowText( p_event->p_vout->p_sys->hwnd,
......
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